def view_files(path = '.'): submitted = bottle.request.query.submit access_token_key = bottle.request.get_cookie('access_token_key') access_token = TOKEN_STORE[access_token_key] client = get_client(access_token) context = client.metadata(path) if context['is_dir']: return pystache2.render_file('viewfiles.mustache', context) f, metadata = client.get_file_and_metadata(path) text = f.read() context['text'] = text if submitted: context['submit_message'] = 'Submission successful!' else: context['submit_message'] = '' return pystache2.render_file('read.mustache', context)
def view_files(path='.'): submitted = bottle.request.query.submit access_token_key = bottle.request.get_cookie('access_token_key') access_token = TOKEN_STORE[access_token_key] client = get_client(access_token) context = client.metadata(path) if context['is_dir']: return pystache2.render_file('viewfiles.mustache', context) f, metadata = client.get_file_and_metadata(path) text = f.read() context['text'] = text if submitted: context['submit_message'] = 'Submission successful!' else: context['submit_message'] = '' return pystache2.render_file('read.mustache', context)
def login(): sess = get_session() request_token = sess.obtain_request_token() TOKEN_STORE[request_token.key] = request_token callback = "http://%s/viewfiles" % (bottle.request.headers['host']) url = sess.build_authorize_url(request_token, oauth_callback=callback) prompt = """Click this <a href="%s">login link</a> to go to Dropbox!""" #return prompt % url return pystache2.render_file('home.mustache', {'url': url})
def viewfiles(oauth_token=None, path='.'): request_token_key = request.query.oauth_token if not request_token_key: access_token = TOKEN_STORE[accesstoken] else: sess = get_session() request_token = TOKEN_STORE[request_token_key] access_token = sess.obtain_access_token(request_token) global accesstoken accesstoken = access_token.key TOKEN_STORE[access_token.key] = access_token #print 'Token store 1: ' + str(TOKEN_STORE) #print 'Access token key: ' + str(access_token.key) access_token = TOKEN_STORE[access_token.key] client = get_client(access_token) context = client.metadata(path) if context['is_dir']: return pystache2.render_file('viewfiles.mustache', context) else: f = client.get_file_and_metadata(path)[0].read() metadata = client.get_file_and_metadata(path)[1] return pystache2.render_file('viewsinglefile.mustache', {'content': f, 'rev': metadata['rev'], 'path': path})
def view_files(): access_token_key = bottle.request.get_cookie('access_token_key') access_token = TOKEN_STORE[access_token_key] client = get_client(access_token) context = client.metadata('.') return pystache2.render_file('viewfiles.mustache', context)