From 5f693fdf84a3f6e7978b0107a5432f16ce62e103 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 14 2016 18:24:20 +0000 Subject: [PATCH 1/4] Adjust the routes so that we support both url with and without a trailing slash --- diff --git a/hubs/app.py b/hubs/app.py index 47099c4..6d3e2e6 100755 --- a/hubs/app.py +++ b/hubs/app.py @@ -100,15 +100,16 @@ def groups(): ) -@app.route('/') @app.route('//') +@app.route('/') def hub(name): hub = get_hub(session, name) return flask.render_template( 'hubs.html', hub=hub, session=session, edit=False) -@app.route('//json') + @app.route('//json/') +@app.route('//json') def hub_json(name): hub = get_hub(session, name) response = flask.jsonify(hub.__json__(session)) @@ -116,16 +117,16 @@ def hub_json(name): return response -@app.route('//edit', methods=['GET']) @app.route('//edit/', methods=['GET']) +@app.route('//edit', methods=['GET']) def hub_edit_get(name): hub = get_hub(session, name) return flask.render_template( 'hubs.html', hub=hub, session=session, edit=True) -@app.route('//edit', methods=['POST']) @app.route('//edit/', methods=['POST']) +@app.route('//edit', methods=['POST']) def hub_edit_post(name): #hub = get_hub(session, name) # TODO -- save things to the db ... and then redirect @@ -134,8 +135,8 @@ def hub_edit_post(name): flask.redirect(flask.url_for('hub', name=name)) -@app.route('//') @app.route('///') +@app.route('//') def widget_render(hub, idx): widget = get_widget(session, hub, idx) return widget.render(session)#, edit=False) @@ -151,8 +152,8 @@ def widget_json(hub, idx): return response -@app.route('///edit', methods=['GET']) @app.route('///edit/', methods=['GET']) +@app.route('///edit', methods=['GET']) def widget_edit_get(hub, idx): widget = get_widget(session, hub, idx) raise NotImplementedError('next step is to get the widgets to render ' @@ -161,8 +162,8 @@ def widget_edit_get(hub, idx): return widget.render(session, edit=True) -@app.route('///edit', methods=['POST']) @app.route('///edit/', methods=['POST']) +@app.route('///edit', methods=['POST']) def widget_edit_post(hub, idx): #widget = get_widget(session, hub, idx) # TODO -- save things to the db ... and then redirect @@ -171,8 +172,8 @@ def widget_edit_post(hub, idx): flask.redirect(flask.url_for('hub', name=hub)) -@app.route('/source/') @app.route('/source//') +@app.route('/source/') def widget_source(name): from hubs.widgets import registry base = '/hubs/' @@ -319,6 +320,7 @@ def hub_subscribe(hub): session.commit() return flask.redirect(flask.url_for('hub', name=hub.name)) + @app.route('/api/hub//unsubscribe', methods=['POST']) @login_required def hub_unsubscribe(hub): @@ -331,6 +333,7 @@ def hub_unsubscribe(hub): session.commit() return flask.redirect(flask.url_for('hub', name=hub.name)) + @app.route('/api/hub//star', methods=['POST']) @login_required def hub_star(hub): @@ -340,6 +343,7 @@ def hub_star(hub): session.commit() return flask.redirect(flask.url_for('hub', name=hub.name)) + @app.route('/api/hub//unstar', methods=['POST']) @login_required def hub_unstar(hub): @@ -352,6 +356,7 @@ def hub_unstar(hub): session.commit() return flask.redirect(flask.url_for('hub', name=hub.name)) + @app.route('/api/hub//join', methods=['POST']) @login_required def hub_join(hub): @@ -361,6 +366,7 @@ def hub_join(hub): session.commit() return flask.redirect(flask.url_for('hub', name=hub.name)) + @app.route('/api/hub//leave', methods=['POST']) @login_required def hub_leave(hub): From d6883063b276e38ae9732f9094c642f8d7b2e2fb Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 14 2016 18:24:20 +0000 Subject: [PATCH 2/4] Adjust indentation in the html --- diff --git a/hubs/templates/groups.html b/hubs/templates/groups.html index a26fd17..230e54a 100644 --- a/hubs/templates/groups.html +++ b/hubs/templates/groups.html @@ -9,12 +9,15 @@
- +
{% if g.auth.logged_in %}