diff --git a/app.py b/app.py index eb21540..d67c819 100755 --- a/app.py +++ b/app.py @@ -82,7 +82,11 @@ def current_url(): def init_profile(): g.profiling = [] -@app.route('/user/settings') +@app.before_request +def global_user(): + g.user = wikidata_oauth.get_username() + +@app.route('/settings') def user_settings(): session['no_find_more'] = not session.get('no_find_more') display = {True: 'on', False: 'off'}[not session['no_find_more']] @@ -261,7 +265,7 @@ def oauth_disconnect(): for key in 'owner_key', 'owner_secret', 'username', 'after_login': if key in session: del session[key] - return random_painting() + return redirect(url_for('browse_page')) def create_claim(painting_id, depicts_id, token): painting_qid = f'Q{painting_id}' @@ -438,7 +442,7 @@ def get_other(entity): other_items = build_other_set(entity) return get_labels(other_items) -@app.route("/admin/edits") +@app.route("/edits") def list_edits(): edit_list = Edit.query.order_by(Edit.timestamp.desc()) @@ -640,14 +644,15 @@ def get_image_detail_with_cache(items, cache_name, thumbwidth=None): return detail +def browse_index(): + return render_template('browse_index.html', props=find_more_props) + @app.route('/browse') def browse_page(): params = get_painting_params() if not params: - return render_template('browse_index.html', - props=find_more_props, - username=wikidata_oauth.get_username()) + return browse_index() flat = '_'.join(f'{pid}={qid}' for pid, qid in params) diff --git a/templates/base.html b/templates/base.html index 1d08b1a..faf83ae 100644 --- a/templates/base.html +++ b/templates/base.html @@ -11,8 +11,10 @@ {% block style %}{% endblock %} +{% from "navbar.html" import navbar with context %} + {% block nav %}{{ navbar() }}{% endblock %} {% block content %}{% endblock %} diff --git a/templates/browse_index.html b/templates/browse_index.html index b30996d..9e1007c 100644 --- a/templates/browse_index.html +++ b/templates/browse_index.html @@ -6,16 +6,12 @@

random painting - {% if not username %} + {% if not g.user %} | connect to Wikidata account {% endif %}

- {% if username %} -

username: {{ username }}

- {% endif %} - - {% if not username %} + {% if not g.user %}

This tool must be connected with Wikidata to work.

Connect with Wikidata {% endif %} diff --git a/templates/navbar.html b/templates/navbar.html new file mode 100644 index 0000000..ad065db --- /dev/null +++ b/templates/navbar.html @@ -0,0 +1,44 @@ +{% macro nav_item(name, label) %} +

+{% endmacro %} + +{% macro navbar_inner(name) %} + + Wikidata Art Depiction Explorer + + +{% endmacro %} + +{% macro navbar() %} + +{% endmacro %}