From 2ab5da4bfdce9f41e93a27082900da6ea72db6ed Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Tue, 29 Jul 2014 18:50:09 -0400 Subject: Webapp now show three columns image, original text and corrected text. The highlighting is functional as well. --- web/main.py | 4 ++-- web/static/css/style.css | 12 ++++++++++++ web/static/js/main.js | 24 +++++++++++++----------- web/templates/index.html | 31 +++++++++++++++++++++---------- web/utils.py | 12 ++++++------ 5 files changed, 54 insertions(+), 29 deletions(-) (limited to 'web') diff --git a/web/main.py b/web/main.py index 206eb86..b5174d8 100644 --- a/web/main.py +++ b/web/main.py @@ -9,9 +9,9 @@ import io class MainHandler(RequestHandler): def get(self, page_number): - areas, words = utils.gen_html(self.settings["book"], page_number) + orig_coords, orig_words, corr_coords_index, corr_words = utils.gen_html(self.settings["book"], page_number) self.render("index.html", page_number=page_number, - areas=areas, words=words) + orig_coords=orig_coords, orig_words=orig_words, corr_words=corr_words, corr_coords_index=corr_coords_index) class ImageHandler(RequestHandler): diff --git a/web/static/css/style.css b/web/static/css/style.css index e42975d..3005bc5 100644 --- a/web/static/css/style.css +++ b/web/static/css/style.css @@ -10,3 +10,15 @@ span:hover { float: left; margin-right: 1em; } + +#texte-non-corrige { + margin-top:0cm; + width: 10cm; + float: left; +} + +#texte-corrige { + margin-top:0cm; + width: 10cm; + float: left; +} diff --git a/web/static/js/main.js b/web/static/js/main.js index ff09fd1..2adf3ea 100644 --- a/web/static/js/main.js +++ b/web/static/js/main.js @@ -1,19 +1,21 @@ $(document).ready(function() { $('#page').mapster({ - mapKey: 'data-id', - fillColor: 'ff0000', - fillOpacity: 0.3, - onMouseover: function (e) { - $("#" + e.key).addClass("selected"); - }, - onMouseout: function (e) { - $("#" + e.key).removeClass("selected"); - } - + mapKey: 'data-id', + fillColor: 'ff0000', + fillOpacity: 0.3, + onMouseover: function (e) { + $("#" + "orig-" + e.key).addClass("selected"); + $("#" + "corr-" + e.key).addClass("selected"); + }, + onMouseout: function (e) { + $("#" + "orig-" + e.key).removeClass("selected"); + $("#" + "corr-" + e.key).removeClass("selected"); + } + }).mapster('resize', 500); $("span").mouseenter(function() { - $('area[data-id='+$(this).attr("id")+']').mapster("highlight"); + $('area[data-id='+$(this).attr("id").replace(/\D+/,"")+']').mapster("highlight"); }); $("span").mouseout(function() { diff --git a/web/templates/index.html b/web/templates/index.html index b3b5fe0..2ba18c1 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -1,14 +1,25 @@ {% extends "layout.html" %} {% block main %} -
- -
- {% for id, coords in areas %} - {% end %} - -
- {% for id, word in words %} - {{word}} {% end %} -
+
+ +
+ + {% for i, coord in enumerate(orig_coords) %} + + {% end %} + + +
+

Texte original

+ {% for i, word in enumerate(orig_words) %} + {{word}} + {% end %} +
+
+

Texte corrigé

+ {% for i, word in enumerate(corr_words) %} + {{word}} + {% end %} +
{% end %} diff --git a/web/utils.py b/web/utils.py index 8522841..71a5048 100644 --- a/web/utils.py +++ b/web/utils.py @@ -10,12 +10,12 @@ def gen_html(book, page_number): corrected_text = get_page(book, int(page_number)) corrected_words = su.simplify(corrected_text).split() if d: - words, coords = zip(*d) - C = su.align(corrected_words, list(words), list(coords)) - r = su.alignment_to_sexp(corrected_text.split(), words, coords, C[1]) - corrected_words, coords = zip(*r) - coords_html = du.convert_to_htmlcoord(coords, page.size[1]) - return (list(enumerate(coords_html)), list(enumerate(corrected_words))) + orig_words, orig_coords = zip(*d) + C = su.align(corrected_words, list(orig_words), list(orig_coords)) + r = su.alignment_to_coord(corrected_text.split(), C[1]) + corr_words, corr_coords_index = zip(*r) + orig_coords_html = du.convert_to_htmlcoord(orig_coords, page.size[1]) + return orig_coords_html, orig_words, corr_coords_index, corr_words if __name__ == "__main__": gen_html(*sys.argv[1:3]) -- cgit v1.2.3-70-g09d2