-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.py
executable file
·62 lines (50 loc) · 1.84 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from flask import Flask
from capitains_nautilus.flask_ext import FlaskNautilus
from flask_nemo.chunker import level_grouper
from application.corpus import resolver
from application.extension import MyNemo, BreadcrumbTraduction
def get_citation_scheme(text):
# We create an empty list to store citations level names
citation_types = []
# We loop over the citation scheme of the Text
for citation in text.citation:
# We append the name of the citation level in the list we created
citation_types.append(citation.name)
# At this point, we just return
return citation_types
def generic_chunker(text, getreffs):
# We build a the citation type
citation_types = get_citation_scheme(text)
if "poem" in citation_types:
level = citation_types.index("poem") + 1
level_name = "" # "Poem"
excerpt_length = 1
else:
level = len(citation_types)
level_name = citation_types[-1]
excerpt_length = 20
if excerpt_length > 1:
reffs = level_grouper(text, getreffs, level, excerpt_length)
else:
reffs = getreffs(level=level)
reffs = [(reff, level_name + " " + reff) for reff in reffs]
return reffs
flask_app = Flask("Flask Application for Nemo")
nautilus_api = FlaskNautilus(name="Nautilus", prefix="/api", app=flask_app, resolver=resolver)
nemo = MyNemo(
name="InstanceNemo",
app=flask_app,
resolver=resolver,
base_url="",
css=["assets/css/theme.css"],
js=["assets/js/empty.js"],
statics=["assets/images/nemo.png"],
transform={"default": "components/main.xsl"},
templates={"main": "templates/main"},
chunker={"default": generic_chunker},
# Pour désactiver le breadcrumb original
original_breadcrumb=False,
plugins=[BreadcrumbTraduction()]
)
if __name__ == "__main__":
flask_app.run(debug=True)