diff --git a/clic/web/api.py b/clic/web/api.py index 6590a56..5f817aa 100644 --- a/clic/web/api.py +++ b/clic/web/api.py @@ -52,15 +52,17 @@ def concordances(): def fetchKeywords(args): keyworder = Keywords() args = processArgs(args, 'keywords') - keywords = keyworder.list_keywords(args[0], args[1], args[2], args[3], args[4]) - return {'keywords' : keywords} + keywordlist = keyworder.list_keywords(args[0], args[1], args[2], args[3], args[4]) + return keywordlist + # return {'keywords' : keywords} @cache.cache('clusters') def fetchClusters(args): cluster = Clusters() args = processArgs(args, 'clusters') clusterlist = cluster.list_clusters(args[0], args[1]) - return {'clusters' : clusterlist} + return clusterlist + # return {'clusters' : clusterlist} @cache.cache('concordances') def fetchConcordance(args): diff --git a/clic/web/index.py b/clic/web/index.py index 93f84fc..becec91 100644 --- a/clic/web/index.py +++ b/clic/web/index.py @@ -1,19 +1,44 @@ from __future__ import absolute_import ## help python find modules within clic package (see John H email 09.04.2014) from flask import Flask, render_template, url_for, redirect, request -from clic.web.api import api + +from clic.web.api import api, fetchClusters, fetchKeywords +from clic.chapter_repository import ChapterRepository app = Flask(__name__, static_url_path='') app.register_blueprint(api, url_prefix='/api') -from clic.chapter_repository import ChapterRepository +#TODO delete: +# from flask_debugtoolbar import DebugToolbarExtension +# app.debug = True +# app.config["SECRET_KEY"] = "jadajajada" +# toolbar = DebugToolbarExtension(app) ''' Application routes ''' + +#============================================================================== +# Home, about, docs, 404 +#============================================================================== @app.route('/', methods=['GET']) def index(): return redirect(url_for('concordances')) # current home page. may change +@app.route('/about/', methods=['GET']) +def about(): + return render_template("about.html") + +@app.route('/documentation/', methods=['GET']) +def documentation(): + return render_template("documentation.html") + +@app.errorhandler(404) +def page_not_found(error): + return render_template('page-not-found.html'), 404 + +#============================================================================== +# Concordances +#============================================================================== @app.route('/concordances/', methods=['GET']) def concordances(): if 'terms' in request.args.keys(): # form was submitted @@ -21,6 +46,9 @@ def concordances(): else: return render_template("concordance-form.html") +#============================================================================== +# Keywords +#============================================================================== @app.route('/keywords/', methods=['GET']) def keywords(): if 'testIdxGroup' in request.args.keys(): # form was submitted @@ -31,41 +59,51 @@ def keywords(): testIdxMod = request.args.get('testIdxMod') selectWords = "whole" + args = request.args + keywords_result = fetchKeywords(args) + return render_template("keywords-results.html", IdxGroup=IdxGroup, testCollection=testCollection, testIdxMod=testIdxMod, - selectWords=selectWords) + selectWords=selectWords, + keywords=keywords_result) else: return render_template("keywords-form.html") +#============================================================================== +# Clusters +#============================================================================== @app.route('/clusters/', methods=['GET']) def clusters(): if 'testIdxGroup' in request.args.keys(): # form was submitted - # get parameters for redirecting to the concordance page IdxGroup = request.args.get('testIdxGroup') + # FIXME this might not work when dealing with only a few books, + # rather than an entire subcorpus, in that case better use: + # collection = args.getlist('testCollection') ## args is a + ## multiDictionary: use .getlist() to access individual books testCollection = request.args.get('testCollection') testIdxMod = request.args.get('testIdxMod') selectWords = "whole" + + args = request.args + clusters_result = fetchClusters(args) return render_template("clusters-results.html", IdxGroup=IdxGroup, testCollection=testCollection, testIdxMod=testIdxMod, - selectWords=selectWords) + selectWords=selectWords, + clusters=clusters_result) + else: return render_template("clusters-form.html") -@app.route('/about/', methods=['GET']) -def about(): - return render_template("about.html") - -@app.route('/documentation/', methods=['GET']) -def documentation(): - return render_template("documentation.html") - +#============================================================================== +# Chapters +#============================================================================== @app.route('/chapter///') @app.route('/chapter/////') def chapterView(number, book, word_index = None, search_term = None): @@ -78,7 +116,6 @@ def chapterView(number, book, word_index = None, search_term = None): return render_template("chapter-view.html", content=chapter, book_title=book_title) - -@app.errorhandler(404) -def page_not_found(error): - return render_template('page-not-found.html'), 404 +# TODO delete? +#if __name__ == '__main__': +# app.run() \ No newline at end of file diff --git a/clic/web/static/img/AHRC10th_horiz_RGB.png b/clic/web/static/img/AHRC10th_horiz_RGB.png new file mode 100644 index 0000000..c31de43 Binary files /dev/null and b/clic/web/static/img/AHRC10th_horiz_RGB.png differ diff --git a/clic/web/static/img/AHRC10th_horiz_small_RGB.png b/clic/web/static/img/AHRC10th_horiz_small_RGB.png new file mode 100644 index 0000000..4b58e04 Binary files /dev/null and b/clic/web/static/img/AHRC10th_horiz_small_RGB.png differ diff --git a/clic/web/templates/clusters-results.html b/clic/web/templates/clusters-results.html index 6337d7b..ff7679e 100644 --- a/clic/web/templates/clusters-results.html +++ b/clic/web/templates/clusters-results.html @@ -10,14 +10,30 @@ {% endblock %} {% block title %} - Concordance Search {{ super() }} + Clusters {{ super() }} {% endblock %} {% block body %}

Clusters Results

-
+
+ + + + + + + + + + + {% for cluster in clusters %} + + {% endfor %} + + +
{% endblock %} @@ -30,29 +46,12 @@

Clusters Results

- + -{% endblock %} + +{% endblock %} \ No newline at end of file diff --git a/clic/web/templates/keywords-results.html b/clic/web/templates/keywords-results.html index beaaf8a..320f64f 100644 --- a/clic/web/templates/keywords-results.html +++ b/clic/web/templates/keywords-results.html @@ -10,14 +10,43 @@ {% endblock %} {% block title %} - Keywords Search {{ super() }} + Keywords {{ super() }} {% endblock %} {% block body %}

Keywords Results

-
+
+ + + + + + + + + + + + + + + {% for keyword in keywords %} + + + + + + + + + + + {% endfor %} + + +
{% endblock %} @@ -33,36 +62,9 @@

Keywords Results

+ {% endblock %} diff --git a/clic/web/templates/layout/default.html b/clic/web/templates/layout/default.html index 06f64f2..4643824 100644 --- a/clic/web/templates/layout/default.html +++ b/clic/web/templates/layout/default.html @@ -21,8 +21,8 @@
- - + +

CLiC

diff --git a/deploy/uwsgi/apps-include.ini b/deploy/uwsgi/apps-include.ini index 760e731..9525832 100644 --- a/deploy/uwsgi/apps-include.ini +++ b/deploy/uwsgi/apps-include.ini @@ -6,4 +6,4 @@ logfile-chown = true # Process Management master = true -processes = 2 \ No newline at end of file +processes = 5 diff --git a/requirements/dev.txt b/requirements/dev.txt index 4510116..21ffcfb 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,4 +1,5 @@ -r testing.txt +flask-debug-toolbar==0.10.0 ipython==2.4.1 lxml==3.4.1