Browse Source

removed the 'en' in templates

master
manetta 5 years ago
parent
commit
9017d9ff70
  1. 1
      readings.py
  2. 53
      start.py
  3. 16
      templates/base.html
  4. 5
      templates/colophon.html
  5. 2
      templates/cross-readings.html
  6. 24
      templates/en/index.html
  7. 1
      templates/index.html
  8. 4
      templates/list.html
  9. 2
      templates/manifesto.html
  10. 4
      templates/mapping.html
  11. 23
      templates/results.html

1
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)

53
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('/<lang>/', methods=['GET', 'POST'])
def index_lang(lang):
def index_():
"""
Displays the index page accessible at '/<lang>/'
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('/<lang>/cross-readings', methods=['GET', 'POST'])
def crossreadings(lang):
@APP.route('/cross-readings', methods=['GET', 'POST'])
def crossreadings():
"""
Displays the cross-readings page accessible at '/<lang>/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('/<lang>/colophon', methods=['GET', 'POST'])
def colophon(lang):
@APP.route('/colophon', methods=['GET', 'POST'])
def colophon():
"""
Displays the colophon page accessible at '/<lang>/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('/<lang>/manifesto/<name>', methods=['GET', 'POST'])
def manifesto(lang, name):
@APP.route('/manifesto/<name>', methods=['GET', 'POST'])
def manifesto(name):
"""
Displays the page accessible at '/<lang>/manifesto/<name>'.
Displays the page accessible at 'manifesto/<name>'.
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('/<lang>/mapping/<name>', methods=['GET', 'POST'])
def contrast_mappings_name(lang, name):
@APP.route('/mapping/<name>', methods=['GET', 'POST'])
def contrast_mappings_name(name):
"""
Displays the page accessible at '/<lang>/mappings/<name>'.
Displays the page accessible at 'mappings/<name>'.
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('/<lang>/list/<list_type>/<filename>', methods=['GET', 'POST'])
def render_list_for_document(lang, list_type, filename):
@APP.route('/list/<list_type>/<filename>', 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()

16
templates/en/base.html → templates/base.html

@ -12,11 +12,11 @@
{% for txt in filenames|sort %}
{% set name = txt.replace('.txt','') %}
<li>
<a href="/{{ lang }}/manifesto/{{ name }}">{{ txt.replace('_', ' ') }}</a><br>
<a class="contrast" href="/{{ lang }}/mapping/{{ name }}"></a>
<small><a href="/{{ lang }}/list/tf/{{ name }}">TF</a></small>
<small><a href="/{{ lang }}/list/idf/{{ name }}">IDF</a></small>
<small><a href="/{{ lang }}/list/tfidf/{{ name }}">TF-IDF</a></small>
<a href="/manifesto/{{ name }}">{{ txt.replace('_', ' ') }}</a><br>
<a class="contrast" href="/mapping/{{ name }}"></a>
<small><a href="/list/tf/{{ name }}">TF</a></small>
<small><a href="/list/idf/{{ name }}">IDF</a></small>
<small><a href="/list/tfidf/{{ name }}">TF-IDF</a></small>
</li>
{% endfor %}
<ul>
@ -26,14 +26,14 @@
<div id="wrapper">
<div id="nav">
<div class="page-button">
<a href="/{{ lang }}/cross-readings">cross-readings</a>
<a href="/cross-readings">cross-readings</a>
</div>
<div class="page-button">
<a href="/{{ lang }}/colophon">colophon</a>
<a href="/colophon">colophon</a>
</div>
</div>
<div id="logo">
<a href="/{{ lang }}/">cyber/technofeminist <br>cross-readings</a>
<a href="/">cyber/technofeminist <br>cross-readings</a>
</div>
{% block search %}
<div id="search">

5
templates/en/colophon.html → templates/colophon.html

@ -1,4 +1,4 @@
{% extends "en/base.html" %}
{% extends "base.html" %}
{% block view %}black{% endblock %}
{% block title %}- colophon{% endblock %}
@ -26,9 +26,6 @@
Inke Arns<br>
Marie Lechner<br />
</p>
<!-- <br> -->
<!-- <p>Translation to French:<br /> -->
<!-- Julie Boschat-Thorez</p> -->
<p><br />
Fonts:<br />
Go-Mono<br />

2
templates/en/cross-readings.html → templates/cross-readings.html

@ -1,4 +1,4 @@
{% extends "en/base.html" %}
{% extends "base.html" %}
{% block view %}black{% endblock %}
{% block title %}- cross-readings{% endblock %}

24
templates/en/index.html

@ -1,24 +0,0 @@
{% extends "en/base.html" %}
{% block results %}
{% endblock %}
{% block suggestions %}
<!-- <h1>Cross-reading suggestions (manual selection):</h1>
<div>
{% for word in suggestions %}
<strong class="query"><a href="/{{ lang }}/?q={{word}}">{{ word.strip() }}</a></strong>
{% endfor %}
</div>
<br> -->
<!-- <h1>Cross-reading suggestions:</h1>
<div>
{% for word in mappings %}
<strong class="query"><a href="/{{ lang }}/?q={{ word }}">{{ word.strip() }}</a></strong>
{% endfor %}
</div>
<br>
<p>Read more about <a href="/{{ lang }}/about">cross-readings</a>.</p>
<br>
<br> -->
{% endblock %}

1
templates/index.html

@ -0,0 +1 @@
{% extends "base.html" %}

4
templates/en/list.html → templates/list.html

@ -1,11 +1,11 @@
{% extends "en/base.html" %}
{% extends "base.html" %}
{% block title %} - {{ list_type }}{% endblock %}
{% block content %}
<div id="list">
<h1>{{ list_type }} * {{ filename | prettyfilename }}</h1>
{% for value, word in list | sort(reverse=True) %}
<div><strong><a href="/en/?q={{ word}}">{{ word }}</a></strong> <sup>({{ value }})</sup></div>
<div><strong><a href="/?q={{ word}}">{{ word }}</a></strong> <sup>({{ value }})</sup></div>
{% endfor %}
</div>
{% endblock %}

2
templates/en/manifesto.html → templates/manifesto.html

@ -1,4 +1,4 @@
{% extends "en/base.html" %}
{% extends "base.html" %}
{% block title %}{% endblock %}
{% block search %}

4
templates/en/mapping.html → templates/mapping.html

@ -1,4 +1,4 @@
{% extends "en/base.html" %}
{% extends "base.html" %}
{% block title %}{% endblock %}
{% block search %}
@ -11,7 +11,7 @@
{% for sentence in mappings %}
<p class="sentence">
{% for word, tfidf in sentence %}
<strong class="query" style="font-size:{{ 50 + tfidf }}%;"> <a href="/{{ lang }}/?q={{ word }}">{{ word }}</a> </strong>
<strong class="query" style="font-size:{{ 50 + tfidf }}%;"> <a href="/?q={{ word }}">{{ word }}</a> </strong>
{% endfor %}
</p>
{% endfor %}

23
templates/en/results.html → templates/results.html

@ -1,4 +1,4 @@
{% extends "en/base.html" %}
{% extends "base.html" %}
{% block title %}- {{ query }}{% endblock %}
{% block nav %}
@ -50,7 +50,7 @@
<div id="{{ x }}_{{ loop.index }}" class="result">
<div class="title">
{{ manifesto.name }}
<div><a class="contrast" href="/en/mapping/{{ manifesto.filename }}"></a></div>
<div><a class="contrast" href="/mapping/{{ manifesto.filename }}"></a></div>
</div>
<div class="sentence">{{ sentence }}</div>
</div>
@ -73,7 +73,7 @@
<div id="similars" class="analytics stemmer">
<h2>Similar but not the same to <em>{{ query }}</em>:</h2>
{% for word in analytics.stemmer %}
<strong class="word"><a href="/{{ lang}}/?q={{ word }}">{{ word }}</a></strong>
<strong class="word"><a href="/?q={{ word }}">{{ word }}</a></strong>
{% endfor%}
</div>
<br>
@ -88,7 +88,7 @@
{% if word == query %}
<strong class="word">{{ word }}</strong>
{% else %}
<strong class="word"><a href="/{{ lang}}/?q={{ word }}">{{ word }}</a></strong>
<strong class="word"><a href="/?q={{ word }}">{{ word }}</a></strong>
{% endif%}
{% endif%}
{% endfor%}
@ -100,18 +100,3 @@
</div>
{% endblock %}
{% endif%}
<!-- <div class="cross">
<p class="note">[Note on activating]</p>
<p class="tfidf">
The <em>TF-IDF algorithm</em> is an activator. Activating non-linear threads through a dataset of words.
<br><br>
As a navigator the algorithm is a provider of order, deciding on the importance of the search term for a manifesto.
</p>
<p class="techfem">
The <em>cyber- and technofeminist manifesto</em> are written and published to activate. Declaring intentions, motives or specific views on technology. Their writing styles, different as they are, are often statement-based, short and sometimes militant.
<br><br>
<em>&quot;Nothing should be accepted as fixed, permanent, or 'given' -- neither material conditions nor social forms..&quot;</em> (Xenofeminist manifesto), <br>
<em>&quot;So that is why no revolution should be without her.&quot;</em> (The Manifesto of Futurist Woman)
</p>
</div> -->
Loading…
Cancel
Save