From d7f51b0982362fee598b00b082e95ad6244c7696 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Thu, 25 Apr 2019 13:19:38 +0100 Subject: [PATCH] Rename XanaDoc to XanaPage. --- sourcing/cli.py | 10 +++--- sourcing/edl.py | 6 ++-- sourcing/model.py | 8 ++--- sourcing/parse.py | 4 +-- .../static/css/{xanadoc.css => xanapage.css} | 2 +- sourcing/static/js/viewer.js | 10 +++--- sourcing/static/js/xanaflight.js | 10 +++--- sourcing/templates/edit.html | 2 +- sourcing/templates/history.html | 2 +- sourcing/templates/home.html | 4 +-- sourcing/templates/realize.html | 2 +- sourcing/templates/view.html | 8 ++--- sourcing/templates/view/xanaflight.html | 2 +- .../view/{xanadoc.html => xanapage.html} | 2 +- sourcing/templates/xanaedit.html | 2 +- sourcing/view.py | 34 +++++++++---------- 16 files changed, 54 insertions(+), 54 deletions(-) rename sourcing/static/css/{xanadoc.css => xanapage.css} (99%) rename sourcing/templates/view/{xanadoc.html => xanapage.html} (98%) diff --git a/sourcing/cli.py b/sourcing/cli.py index 827e06e..60a53b9 100644 --- a/sourcing/cli.py +++ b/sourcing/cli.py @@ -60,19 +60,19 @@ def populate_references(): database.session.add(ref) seen.add(as_tuple) - for xanadoc in model.XanaDoc.query: - doc_edl = edl.parse_edl(xanadoc.text) + for xanapage in model.XanaPage.query: + doc_edl = edl.parse_edl(xanapage.text) if 'spans' not in doc_edl or not doc_edl['spans']: continue for url, start, length in doc_edl['spans']: src_doc = model.Item.from_external(url, home=home) if not src_doc.id: continue - print(xanadoc.id, '->', src_doc.id) - as_tuple = (xanadoc.id, src_doc.id) + print(xanapage.id, '->', src_doc.id) + as_tuple = (xanapage.id, src_doc.id) if as_tuple in seen: continue - ref = model.Reference(subject_id=xanadoc.id, object_id=src_doc.id) + ref = model.Reference(subject_id=xanapage.id, object_id=src_doc.id) database.session.add(ref) seen.add(as_tuple) diff --git a/sourcing/edl.py b/sourcing/edl.py index 23a13c2..a3a8b7f 100644 --- a/sourcing/edl.py +++ b/sourcing/edl.py @@ -1,5 +1,5 @@ from .url import get_url, get_text -from .parse import get_span, parse_span, parse_link, parse_sourcedoc_facet, xanadoc_span_html, span_html, get_urls +from .parse import get_span, parse_span, parse_link, parse_sourcedoc_facet, xanapage_span_html, span_html, get_urls from collections import defaultdict from html import escape from .utils import protect_start_spaces @@ -100,14 +100,14 @@ def fulfil_edl_with_links(edl, doc_num='', links=None, hide_all_transclusions=Fa break if link_end < start: continue - cls = 'xanadoclink link' + cls = 'xanapagelink link' link_span = (f'' + escape(span_text[link_start:link_end]) + '') new_text += escape(span_text[pos:link_start]) + link_span pos = link_end new_text += escape(span_text[pos:start + length]) - cur = xanadoc_span_html(num, new_text, url, start, length, highlight=highlight) + cur = xanapage_span_html(num, new_text, url, start, length, highlight=highlight) doc_spans.append(cur) doc = ''.join(doc_spans) diff --git a/sourcing/model.py b/sourcing/model.py index 8d93bfa..3ccb9a2 100644 --- a/sourcing/model.py +++ b/sourcing/model.py @@ -141,7 +141,7 @@ class Item(TimeStampedModel): id = Column(Integer, primary_key=True) user_id = Column(Integer, ForeignKey('user.id')) published = Column(DateTime) - type = Column(Enum('sourcedoc', 'xanadoc', 'xanalink', name='item_type'), + type = Column(Enum('sourcedoc', 'xanapage', 'xanalink', name='item_type'), nullable=False) filename = Column(Unicode) text = Column(UnicodeText) @@ -262,9 +262,9 @@ span: {},start=0,length={}'''.format(self.external_url, title_source_doc.externa q = cls.query.filter(User.username == username, cls.id == item_id) return q.one_or_none() -class XanaDoc(Item): - __tablename__ = 'xanadoc' - __mapper_args__ = {'polymorphic_identity': 'xanadoc'} +class XanaPage(Item): + __tablename__ = 'xanapage' + __mapper_args__ = {'polymorphic_identity': 'xanapage'} id = Column(Integer, ForeignKey(Item.id), primary_key=True) diff --git a/sourcing/parse.py b/sourcing/parse.py index 972799e..7421674 100644 --- a/sourcing/parse.py +++ b/sourcing/parse.py @@ -49,10 +49,10 @@ def find_min_max(spans, source): def span_html(span_type, num): return ''.format(num=num, span_type=span_type) -def xanadoc_span_html(num, text, url, start, length, highlight=True, censor=False): +def xanapage_span_html(num, text, url, start, length, highlight=True, censor=False): cls = [] if highlight: - cls = ['xanadoctransclusion', 'transclusion'] + cls = ['xanapagetransclusion', 'transclusion'] html_class = ' class="{}"'.format(' '.join(cls)) if cls else '' html = '{}'.format(num, html_class, escape(url), start, length, text) diff --git a/sourcing/static/css/xanadoc.css b/sourcing/static/css/xanapage.css similarity index 99% rename from sourcing/static/css/xanadoc.css rename to sourcing/static/css/xanapage.css index d1f0218..293f6e6 100644 --- a/sourcing/static/css/xanadoc.css +++ b/sourcing/static/css/xanapage.css @@ -13,7 +13,7 @@ background-color: #ffe; } -.xanadoc { +.xanapage { background-color: #eef; } diff --git a/sourcing/static/js/viewer.js b/sourcing/static/js/viewer.js index 5414075..66cd7b6 100644 --- a/sourcing/static/js/viewer.js +++ b/sourcing/static/js/viewer.js @@ -195,7 +195,7 @@ function new_document(doc) { var w = document.documentElement.clientWidth; var h = document.documentElement.clientHeight; - if (doc.doctype == 'xanadoc') { + if (doc.doctype == 'xanapage') { var x = (w / 2) - 400; var y = (h / 2) - 400; } else { @@ -316,9 +316,9 @@ function fulfil() { new_document(doc); } }); - new_document({'heading': 'xanadoc', + new_document({'heading': 'xanapage', 'text': doc.doc, - 'doctype': 'xanadoc'}); + 'doctype': 'xanapage'}); update(); @@ -338,7 +338,7 @@ function fulfil() { hover_link_bridge(this, false); }); - $('.xanadoclink').click(function(e) { + $('.xanapagelink').click(function(e) { var num = get_end_number(this.id); var source = $('#link' + num).closest( ".sourcedoc" ); @@ -357,7 +357,7 @@ function fulfil() { update(); }); - $('.xanadoctransclusion').click(function(e) { + $('.xanapagetransclusion').click(function(e) { var num = get_end_number(this.id); var source = $('#transclusion' + num).closest( ".sourcedoc" ); diff --git a/sourcing/static/js/xanaflight.js b/sourcing/static/js/xanaflight.js index 839a7c5..5cba802 100644 --- a/sourcing/static/js/xanaflight.js +++ b/sourcing/static/js/xanaflight.js @@ -194,7 +194,7 @@ function new_document(doc) { var w = document.documentElement.clientWidth; var h = document.documentElement.clientHeight; - if (doc.doctype == 'xanadoc') { + if (doc.doctype == 'xanapage') { element.css('height', (h - 100) + 'px'); var ratio = (doc.index + 1) / (doc.doc_count + 1) @@ -285,7 +285,7 @@ function fulfil(doc, index, doc_count, heading) { new_document({'heading': heading, 'text': doc.doc, - 'doctype': 'xanadoc', + 'doctype': 'xanapage', 'index': index, 'doc_count': doc_count}); @@ -299,7 +299,7 @@ function size_svg() { } function add_handlers() { - $('.xanadoclink').click(function(e) { + $('.xanapagelink').click(function(e) { var num = get_end_number(this.id); var bridge = document.getElementById('linkbridge' + num); @@ -311,11 +311,11 @@ function add_handlers() { update(); }); - $('.xanadoclink').bind('mouseover', function(e) { + $('.xanapagelink').bind('mouseover', function(e) { hover_link_bridge(this, true); }); - $('.xanadoclink').bind('mouseout', function(e) { + $('.xanapagelink').bind('mouseout', function(e) { hover_link_bridge(this, false); }); diff --git a/sourcing/templates/edit.html b/sourcing/templates/edit.html index df3742a..f6a0878 100644 --- a/sourcing/templates/edit.html +++ b/sourcing/templates/edit.html @@ -15,7 +15,7 @@ - {% if doc.type == 'xanadoc' %} + {% if doc.type == 'xanapage' %} diff --git a/sourcing/templates/history.html b/sourcing/templates/history.html index 3e5bf75..e7f06d0 100644 --- a/sourcing/templates/history.html +++ b/sourcing/templates/history.html @@ -8,7 +8,7 @@ - {% if doc.type == 'xanadoc' %} + {% if doc.type == 'xanapage' %} diff --git a/sourcing/templates/home.html b/sourcing/templates/home.html index 329fb56..1485843 100644 --- a/sourcing/templates/home.html +++ b/sourcing/templates/home.html @@ -4,7 +4,7 @@

new source document new xanalink -new xanadoc +new xanapage

{% endmacro %} @@ -22,7 +22,7 @@
item type
- {% for item_type in 'xanadoc', 'xanalink', 'sourcedoc' %} + {% for item_type in 'xanapage', 'xanalink', 'sourcedoc' %}
diff --git a/sourcing/templates/realize.html b/sourcing/templates/realize.html index 522e75e..cfdea0c 100644 --- a/sourcing/templates/realize.html +++ b/sourcing/templates/realize.html @@ -8,7 +8,7 @@ - {% if doc.type == 'xanadoc' %} + {% if doc.type == 'xanapage' %} diff --git a/sourcing/templates/view.html b/sourcing/templates/view.html index 875fd0d..65f2817 100644 --- a/sourcing/templates/view.html +++ b/sourcing/templates/view.html @@ -67,7 +67,7 @@ - {% if doc.type == 'xanadoc' %} + {% if doc.type == 'xanapage' %} @@ -106,7 +106,7 @@
- {% if doc.type == 'xanadoc' %} + {% if doc.type == 'xanapage' %}

Edit Decision List (EDL)

{% endif %}
@@ -129,7 +129,7 @@ {%- for start, line in iter_lines(text) if line != '\r\n' -%} {#

{% if line != "\n" and line != "\r\n" %}{{ line }}{% else %} {% endif %}

#} -

{{ nbsp_at_start(line) }}

+

{{ nbsp_at_start(line) }}

{%- endfor -%} {% endif %}
@@ -142,7 +142,7 @@

span:

{% endif %} -{% if doc.type == 'xanadoc' %} +{% if doc.type == 'xanapage' %}

Edit EDL diff --git a/sourcing/templates/view/xanaflight.html b/sourcing/templates/view/xanaflight.html index ffd4b71..f931772 100644 --- a/sourcing/templates/view/xanaflight.html +++ b/sourcing/templates/view/xanaflight.html @@ -7,7 +7,7 @@ {{ title | default("Xanadu") }} - + diff --git a/sourcing/templates/view/xanadoc.html b/sourcing/templates/view/xanapage.html similarity index 98% rename from sourcing/templates/view/xanadoc.html rename to sourcing/templates/view/xanapage.html index b9a3f96..5d4e2be 100644 --- a/sourcing/templates/view/xanadoc.html +++ b/sourcing/templates/view/xanapage.html @@ -7,7 +7,7 @@ {{ title | default("Xanadu") }} - + diff --git a/sourcing/templates/xanaedit.html b/sourcing/templates/xanaedit.html index be2f2ee..01bce88 100644 --- a/sourcing/templates/xanaedit.html +++ b/sourcing/templates/xanaedit.html @@ -7,7 +7,7 @@

{{ doc.title() }}

-

view xanadoc (cancel edit)

+

view xanapage (cancel edit)

diff --git a/sourcing/view.py b/sourcing/view.py index d023bfc..d8e9072 100644 --- a/sourcing/view.py +++ b/sourcing/view.py @@ -5,7 +5,7 @@ from flask_login import (login_user, current_user, logout_user, from .forms import (LoginForm, SignupForm, AccountSettingsForm, UploadSourceDocForm, SourceDocForm, ItemForm, ForgotPasswordForm, PasswordForm) -from .model import User, SourceDoc, Item, XanaDoc, XanaLink, Reference +from .model import User, SourceDoc, Item, XanaPage, XanaLink, Reference from .parse import parse_xanapage_facet, parse_link from .url import get_url from .mail import send_mail @@ -199,11 +199,11 @@ def get_source_doc(username, hashid): doc = None return doc if doc else abort(404) -def get_xanadoc(username, hashid): +def get_xanapage(username, hashid): doc = Item.get_by_hashid(hashid) if doc and doc.user.username != username: doc = None - return doc if doc and doc.type == 'xanadoc' else abort(404) + return doc if doc and doc.type == 'xanapage' else abort(404) def get_item(username, hashid): doc = Item.get_by_hashid(hashid) @@ -213,7 +213,7 @@ def get_item(username, hashid): @bp.route('///edl') def view_edl(username, hashid): - item = get_xanadoc(username, hashid) + item = get_xanapage(username, hashid) return render_template('view.html', doc=item, @@ -222,7 +222,7 @@ def view_edl(username, hashid): @bp.route('///realize') def realize_edl(username, hashid): - item = get_xanadoc(username, hashid) + item = get_xanapage(username, hashid) spans = list(fulfil_edl(item.text)) doc_text = ''.join(span['text'] for span in spans) @@ -246,7 +246,7 @@ def fulfil_xanaflight(item): all_links = [] for facet in facets: xanapage = Item.from_external(parse_xanapage_facet(facet)) - assert xanapage.type == 'xanadoc' + assert xanapage.type == 'xanapage' edl = parse_edl(xanapage.text) edl_list.append((xanapage, edl)) all_links += [parse_link(link['text']) for link in edl['links']] @@ -268,8 +268,8 @@ def fulfil_xanaflight(item): def fulfil(username, hashid): item = get_item(username, hashid) - if item.type == 'xanadoc': - return render_template('view/xanadoc.html', + if item.type == 'xanapage': + return render_template('view/xanapage.html', item=item, doc=fulfil_edl_with_sources(item.text)) if item.type == 'xanalink' and item.text.startswith('type=flight'): @@ -379,7 +379,7 @@ def view_item(username, hashid, raw=False): version = None text = item.text - if item.type == 'xanadoc': + if item.type == 'xanapage': spans = list(fulfil_edl(item.text)) doc_text = ''.join(span['text'] for span in spans) else: @@ -403,7 +403,7 @@ def history(username, hashid): @bp.route('///xanaedit') def xanaedit_item(username, hashid): - doc = get_xanadoc(username, hashid) + doc = get_xanapage(username, hashid) spans = list(fulfil_edl(doc.text)) doc_text = ''.join(span['text'] for span in spans) @@ -412,13 +412,13 @@ def xanaedit_item(username, hashid): @bp.route('///xanaedit', methods=['POST']) def save_xanaedit(username, hashid): - # doc = get_xanadoc(username, hashid) + # doc = get_xanapage(username, hashid) edits = json.loads(request.form['edits']) return jsonify(edits=edits) @bp.route('///finish', methods=['POST']) def finish_xanaedit(username, hashid): - doc = get_xanadoc(username, hashid) + doc = get_xanapage(username, hashid) current_edl = parse_edl(doc.text) spans = [Span(*span) for span in current_edl['spans']] @@ -505,18 +505,18 @@ def new_xanalink(): flash('New xanalink saved.') return jsonify(url=obj.url) -@bp.route('/new/xanadoc', methods=['GET', 'POST']) +@bp.route('/new/xanapage', methods=['GET', 'POST']) @login_required -def new_xanadoc(): +def new_xanapage(): form = ItemForm() if form.validate_on_submit(): - obj = XanaDoc(user=current_user) + obj = XanaPage(user=current_user) form.populate_obj(obj) session.add(obj) session.commit() - flash('New xanadoc saved.') + flash('New xanapage saved.') return redirect(obj.url) - return render_template('new.html', form=form, item_type='xanadoc') + return render_template('new.html', form=form, item_type='xanapage') @bp.route('/edit/', methods=['GET', 'POST']) @login_required