From 9017d9ff704c2759428e258da543ca52a1732cd8 Mon Sep 17 00:00:00 2001 From: manetta Date: Wed, 10 Jul 2019 21:19:51 +0200 Subject: [PATCH] removed the 'en' in templates --- readings.py | 1 - start.py | 53 ++++++++++++-------------- templates/{en => }/base.html | 16 ++++---- templates/{en => }/colophon.html | 5 +-- templates/{en => }/cross-readings.html | 2 +- templates/en/index.html | 24 ------------ templates/index.html | 1 + templates/{en => }/list.html | 4 +- templates/{en => }/manifesto.html | 2 +- templates/{en => }/mapping.html | 4 +- templates/{en => }/results.html | 23 ++--------- 11 files changed, 44 insertions(+), 91 deletions(-) rename templates/{en => }/base.html (80%) rename templates/{en => }/colophon.html (92%) rename templates/{en => }/cross-readings.html (99%) delete mode 100644 templates/en/index.html create mode 100644 templates/index.html rename templates/{en => }/list.html (65%) rename templates/{en => }/manifesto.html (90%) rename templates/{en => }/mapping.html (82%) rename templates/{en => }/results.html (64%) diff --git a/readings.py b/readings.py index e86f9e8..7e5f3ca 100644 --- a/readings.py +++ b/readings.py @@ -157,7 +157,6 @@ def request_results(query): # Transform sentence into an HTML elements html = insert_query_highlight(query, sentence, r, g, b) - html = insert_suggestion_links(query, html) html = Markup(html) results[x]['html'].append(html) diff --git a/start.py b/start.py index 1129202..57ad631 100644 --- a/start.py +++ b/start.py @@ -25,13 +25,9 @@ def get_random(x, y): APP.jinja_env.globals.update(get_random=get_random) @APP.route('/', methods=['GET', 'POST']) -def index(): - return redirect('/en/') - -@APP.route('//', methods=['GET', 'POST']) -def index_lang(lang): +def index_(): """ - Displays the index page accessible at '//' + Displays the index page accessible at '' Which is either the start page (index.html) or a results page (results.html). """ @@ -39,7 +35,6 @@ def index_lang(lang): results = None query = request.args.get('q', '') - suggestions = open('words.txt', 'r').readlines() # Check printer argument if printer.connected == True: @@ -55,58 +50,58 @@ def index_lang(lang): if connection == 'connected': printer.printNow(query, results) - return flask.render_template(lang+'/results.html', query=query, results=results, filenames=filenames, connection=connection, suggestions=suggestions, analytics=analytics, lang=lang) + return flask.render_template('results.html', query=query, results=results, filenames=filenames, connection=connection, analytics=analytics) else: index = readings.load_index() filenames = [manifesto for manifesto, _ in index.items()] mappings_top = open('tfidf.top50.txt', 'r').readlines() - return flask.render_template(lang+'/index.html', filenames=filenames, mappings=mappings_top, lang=lang) + return flask.render_template('index.html', filenames=filenames, mappings=mappings_top) -@APP.route('//cross-readings', methods=['GET', 'POST']) -def crossreadings(lang): +@APP.route('/cross-readings', methods=['GET', 'POST']) +def crossreadings(): """ - Displays the cross-readings page accessible at '//cross-readings'. + Displays the cross-readings page accessible at 'cross-readings'. """ - return flask.render_template(lang+'/cross-readings.html', lang=lang) + return flask.render_template('cross-readings.html') -@APP.route('//colophon', methods=['GET', 'POST']) -def colophon(lang): +@APP.route('/colophon', methods=['GET', 'POST']) +def colophon(): """ - Displays the colophon page accessible at '//colophon'. + Displays the colophon page accessible at 'colophon'. """ - return flask.render_template(lang+'/colophon.html', lang=lang) + return flask.render_template('colophon.html') -@APP.route('//manifesto/', methods=['GET', 'POST']) -def manifesto(lang, name): +@APP.route('/manifesto/', methods=['GET', 'POST']) +def manifesto(name): """ - Displays the page accessible at '//manifesto/'. + Displays the page accessible at 'manifesto/'. It shows the original text of the manifesto in plain text. """ index = readings.load_index() filenames = sorted([manifesto for manifesto, _ in index.items()]) manifesto = open('txt/'+name+'.txt', 'r').readlines() link = manifestos[name] - return flask.render_template(lang+'/manifesto.html', filenames=filenames, name=name, manifesto=manifesto, link=link, lang=lang) + return flask.render_template('manifesto.html', filenames=filenames, name=name, manifesto=manifesto, link=link) -@APP.route('//mapping/', methods=['GET', 'POST']) -def contrast_mappings_name(lang, name): +@APP.route('/mapping/', methods=['GET', 'POST']) +def contrast_mappings_name(name): """ - Displays the page accessible at '//mappings/'. + Displays the page accessible at 'mappings/'. A TF-IDF visualisation is displayed from the specific manifesto, using the TF-IDF values as font-size. """ mappings, filenames = readings.request_mappings(name) - return flask.render_template(lang+'/mapping.html', filenames=filenames, mappings=mappings[name], manifesto=name, lang=lang) + return flask.render_template('mapping.html', filenames=filenames, mappings=mappings[name], manifesto=name) -@APP.route('//list//', methods=['GET', 'POST']) -def render_list_for_document(lang, list_type, filename): +@APP.route('/list//', methods=['GET', 'POST']) +def render_list_for_document(list_type, filename): """ Show list of (TF / IDF / TF-IDF) values of one document. """ index = readings.load_index() filenames = sorted([document for document, _ in index.items()]) values_list = [(value, word) for word, value in index[filename][list_type].items()] - return flask.render_template(lang+'/list.html', filenames=filenames, list=values_list, list_type=list_type, filename=filename, lang=lang) + return flask.render_template('list.html', filenames=filenames, list=values_list, list_type=list_type, filename=filename) @APP.route('/favicon.ico') def favicon(): @@ -115,5 +110,5 @@ def favicon(): if __name__ == '__main__': if not 'index.json' in os.listdir('.'): tfidf.create_index() - # APP.debug=True + APP.debug=True APP.run() \ No newline at end of file diff --git a/templates/en/base.html b/templates/base.html similarity index 80% rename from templates/en/base.html rename to templates/base.html index f1c54a4..6d8dfd1 100644 --- a/templates/en/base.html +++ b/templates/base.html @@ -12,11 +12,11 @@ {% for txt in filenames|sort %} {% set name = txt.replace('.txt','') %}
  • - {{ txt.replace('_', ' ') }}
    - - TF - IDF - TF-IDF + {{ txt.replace('_', ' ') }}
    + + TF + IDF + TF-IDF
  • {% endfor %}
      @@ -26,14 +26,14 @@
      {% block search %} {% endblock %} {% endif%} - -