From 573e1f68f7af0c732c95cf0436284fde7bf6135b Mon Sep 17 00:00:00 2001 From: "Sebastian Silva (icarito)" Date: Thu, 29 Mar 2012 03:53:54 -0500 Subject: [PATCH] favorites filter and launch functionality --- app/app.py | 29 +++++++++++++++++++++++------ app/static/css/browser.css | 10 ++++++++++ app/templates/context-grid.html | 15 +++++++++++++++ 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/app/app.py b/app/app.py index 6385fbf..445ae9b 100644 --- a/app/app.py +++ b/app/app.py @@ -53,6 +53,20 @@ def home(): session['toolbar']=False return redirect(url_for('context_grid')) +@app.route('/launch/') +def launch(context): + c=client.Context.find(guid=context) + client.launch(c[0]['guid']) + return redirect(url_for('context_grid')) + +@app.route('/favorites') +def favorites(): + if session.get('favorites-filter'): + session['favorites-filter']=False + else: + session['favorites-filter']=True + return redirect(url_for('context_grid')) + @app.route('/toolbar') def enable_toolbar(): session['toolbar']=True @@ -96,7 +110,7 @@ def stars(context=None): if context and vote: context = context[5:] #remove "stars-" from id c=client.Context.find(guid=context) - c[0].vote = vote + c[0]['vote'] = vote c[0].post() return jsonify(vote=vote) @@ -137,9 +151,12 @@ def context_grid(query=None, page=None): terms = [] if query: terms.append(query) + + if session.get('favorites-filter'): + terms.append('vote=True') full_query = join(terms, " AND ") - + _PAGE_SIZE = 6 r = [] page = int(request.args.get('page', 1)) @@ -211,15 +228,15 @@ if __name__=="__main__": server.data_root.value = 'tmp/db' server.stats_root.value = 'tmp/stats' server.logdir.value = 'tmp/log' - server_pid = restful_document.fork(server.resources()) + server_pid = restful_document.fork(server.resources) - client.api_url.value = \ - 'http://%s:%s' % (server.host.value, server.port.value) + #client.api_url.value = \ + # 'http://%s:%s' % (server.host.value, server.port.value) #client.api_url.value = \ # 'http://api.network.sugarlabs.org:8000' - #client.api_url.value = 'http://18.85.44.120:8000' + client.api_url.value = 'http://18.85.44.120:8000' #client.api_url.value = \ # 'http://localhost:8000' host = '127.0.0.1' #'0.0.0.0' for all diff --git a/app/static/css/browser.css b/app/static/css/browser.css index e391727..0157380 100644 --- a/app/static/css/browser.css +++ b/app/static/css/browser.css @@ -175,6 +175,7 @@ li.grid-item { padding: 3%; float:left; text-align:center; + position:relative; } div.iconbox { @@ -191,8 +192,17 @@ div.iconbox { color: white; background-color: #808080; border-radius: 15px; + z-index: 100; } +.launch-icon { + top:122px; + left:172px; + position:absolute; + background-color: #fff; + border-radius: 15px; + z-index: 110; +} /*** Resource browser (Context view) ***/ diff --git a/app/templates/context-grid.html b/app/templates/context-grid.html index 6622fba..cf58e14 100644 --- a/app/templates/context-grid.html +++ b/app/templates/context-grid.html @@ -3,6 +3,9 @@