aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xgenerate_html_cs.py187
-rw-r--r--screen.css4
-rw-r--r--sworker.js2
-rw-r--r--templates/base.html6
4 files changed, 126 insertions, 73 deletions
diff --git a/generate_html_cs.py b/generate_html_cs.py
index 55c4c43..7b01a97 100755
--- a/generate_html_cs.py
+++ b/generate_html_cs.py
@@ -9,52 +9,90 @@ import jinja2
import xml.etree.ElementTree as et
-logging.basicConfig(format='%(levelname)s:%(funcName)s:%(message)s',
- level=logging.INFO)
+logging.basicConfig(
+ format="%(levelname)s:%(funcName)s:%(message)s", level=logging.INFO
+)
cur_year = 2020
book_abbrs = {
- "Gn": "Gen", "Ex": "Exod",
+ "Gn": "Gen",
+ "Ex": "Exod",
"Lv": "Lev", # NA in source code,
- "Nu": "Num", "Dt": "Deut", "Jos": "Josh", "Jdc": "Judg",
+ "Nu": "Num",
+ "Dt": "Deut",
+ "Jos": "Josh",
+ "Jdc": "Judg",
"Rth": "Ruth",
- "1Sm": "1%20Sam", "2Sm": "2%20Sam", "1Rg": "1%20Kgs", "2Rg": "2%20Kgs",
- "1Chr": "1%20Chr", "2Chr": "2%20Chr", "Esr": "Ezra", "Neh": "Neh",
+ "1Sm": "1%20Sam",
+ "2Sm": "2%20Sam",
+ "1Rg": "1%20Kgs",
+ "2Rg": "2%20Kgs",
+ "1Chr": "1%20Chr",
+ "2Chr": "2%20Chr",
+ "Esr": "Ezra",
+ "Neh": "Neh",
"Esth": "Esth", # NA in source code,
- "Job": "Job", "Ps": "Ps", "Prv": "Prov", "Eccl": "Eccl",
+ "Job": "Job",
+ "Ps": "Ps",
+ "Prv": "Prov",
+ "Eccl": "Eccl",
"Song": "Song", # NA in source code,
- "Is": "Isa", "Jr": "Jer", "Thr": "Lam", "Ez": "Ezek",
- "Dn": "Dan", "Hos": "Hos", "Joel": "Joel",
+ "Is": "Isa",
+ "Jr": "Jer",
+ "Thr": "Lam",
+ "Ez": "Ezek",
+ "Dn": "Dan",
+ "Hos": "Hos",
+ "Joel": "Joel",
"Am": "Amos",
"Obad": "Obad", # NA in source code
- "Jon": "Jonah", "Mch": "Mic",
+ "Jon": "Jonah",
+ "Mch": "Mic",
"Nah": "Nah", # NA in source code
- "Hab": "Hab", "Zph": "Zeph", "Hgg": "Hag",
- "Zch": "Zech", "Ml": "Mal",
- "Mt": "Matt", "Mc": "Mark", "L": "Luke", "J": "John",
+ "Hab": "Hab",
+ "Zph": "Zeph",
+ "Hgg": "Hag",
+ "Zch": "Zech",
+ "Ml": "Mal",
+ "Mt": "Matt",
+ "Mc": "Mark",
+ "L": "Luke",
+ "J": "John",
"Act": "Acts",
- "R": "Rom", "1K": "1%20Cor", "2K": "2%20Cor",
- "G": "Gal", "E": "Eph", "Ph": "Phil", "Kol": "Col",
- "1Th": "1%20Thess", "2Th": "2%20Thess", "1T": "1%20Tim", "2T": "2%20Tim",
+ "R": "Rom",
+ "1K": "1%20Cor",
+ "2K": "2%20Cor",
+ "G": "Gal",
+ "E": "Eph",
+ "Ph": "Phil",
+ "Kol": "Col",
+ "1Th": "1%20Thess",
+ "2Th": "2%20Thess",
+ "1T": "1%20Tim",
+ "2T": "2%20Tim",
"Tt": "Titus",
"Phm": "Phlm",
- "H": "Heb", "Jc": "Jas",
- "1P": "1%20Pet", "2P": "2%20Pet",
- "1J": "1%20John", "2J": "2%20John", "3J": "3%20John",
- "Jd": "Jude", "Ap": "Rev"
+ "H": "Heb",
+ "Jc": "Jas",
+ "1P": "1%20Pet",
+ "2P": "2%20Pet",
+ "1J": "1%20John",
+ "2J": "2%20John",
+ "3J": "3%20John",
+ "Jd": "Jude",
+ "Ap": "Rev",
}
def csv2dict(filename):
out_dict = {}
- split_re = re.compile(r'\s+')
- field_names = ['no', 'test', 'cs_abbr', 'cs_name',
- 'de_abbr', 'de_name']
- with codecs.open(filename, 'rb', 'utf8') as csvfile:
+ split_re = re.compile(r"\s+")
+ field_names = ["no", "test", "cs_abbr", "cs_name", "de_abbr", "de_name"]
+ with codecs.open(filename, "rb", "utf8") as csvfile:
for row in csvfile:
line_dict = dict(zip(field_names, split_re.split(row)))
- out_dict[line_dict['cs_abbr']] = line_dict
+ out_dict[line_dict["cs_abbr"]] = line_dict
logging.debug("out_dict:\n%s", out_dict)
return out_dict
@@ -91,38 +129,36 @@ def parse_body(elem):
if len(list(elem)) == 0:
return None
- wword = {
- 'text': ''
- }
- source_elem = elem.find('S')
+ wword = {"text": ""}
+ source_elem = elem.find("S")
logging.debug("S elem = %s", source_elem)
logging.debug("S elem = attrib %s", source_elem.attrib)
# biblical reference (computer readable)
- wword['ref_id'] = {
- "book": source_elem.attrib['b'],
- "chapter": source_elem.attrib['ch'],
- "verse": source_elem.attrib['v'],
+ wword["ref_id"] = {
+ "book": source_elem.attrib["b"],
+ "chapter": source_elem.attrib["ch"],
+ "verse": source_elem.attrib["v"],
}
- logging.debug("wword['ref_id'] = %s", wword['ref_id'])
+ logging.debug("wword['ref_id'] = %s", wword["ref_id"])
# biblical reference (compatible with the English Bible programs)
try:
- wword['int_ref_id'] = wword['ref_id'].copy()
- wword['int_ref_id']['book'] = book_abbrs[wword['ref_id']['book']]
+ wword["int_ref_id"] = wword["ref_id"].copy()
+ wword["int_ref_id"]["book"] = book_abbrs[wword["ref_id"]["book"]]
except KeyError:
- logging.error('book = %s', wword['ref_id'])
+ logging.error("book = %s", wword["ref_id"])
raise
# text of the verse
- wword['text'] = parse_verses(list(elem.iter("L")))
+ wword["text"] = parse_verses(list(elem.iter("L")))
# references
ref = elem.find("SL")
logging.debug("ref = %s", ref)
logging.debug("ref = len %s", len(ref))
if ref is not None:
- wword['ref'] = ref.text
+ wword["ref"] = ref.text
return wword
@@ -147,23 +183,34 @@ def parse_losung(elem):
"""
logging.debug("losung = %s", elem)
out = {}
- date_id = (cur_year, int(elem.attrib["m"]), int(elem.attrib["d"]),)
- out['date_id'] = "%4d-%02d-%02d" % (date_id)
- logging.debug('date_id = %s', out['date_id'])
-
- out['date_full'] = elem.find("TL").text
- out['watchwords'] = []
-
- for tst in ['OT', 'NT']:
+ date_id = (
+ cur_year,
+ int(elem.attrib["m"]),
+ int(elem.attrib["d"]),
+ )
+ out["date_id"] = "%4d-%02d-%02d" % (date_id)
+ logging.debug("date_id = %s", out["date_id"])
+
+ out["date_full"] = elem.find("TL").text
+ out["watchwords"] = []
+
+ for tst in ["OT", "NT"]:
sect = elem.find(tst)
- out['watchwords'].append(parse_body(sect))
+ out["watchwords"].append(parse_body(sect))
- out['readings'] = []
- for read in ['SR', 'CR']:
+ out["readings"] = []
+ for read in ["SR", "CR"]:
sect = elem.find(read)
logging.debug("read %s = %s", read, sect)
- out['readings'].append("\n".join([el.text
- for el in sect.findall("SL")]))
+ out["readings"].append(
+ "\n".join([el.text for el in sect.findall("SL")])
+ )
+
+ out["chronicles"] = []
+ for chron in elem.findall("C"):
+ out["chronicles"].append(
+ "\n".join([line.text for line in chron.findall("L")])
+ )
return date_id, out
@@ -190,30 +237,34 @@ def parse_day(elem, whole_dict):
<DAY d="13" m="1" type="week" name="Alianční modlitební týden ">
</DAY>
"""
- date_id = (cur_year, int(elem.attrib["m"]), int(elem.attrib["d"]),)
- logging.debug('date_id = %s', date_id)
+ date_id = (
+ cur_year,
+ int(elem.attrib["m"]),
+ int(elem.attrib["d"]),
+ )
+ logging.debug("date_id = %s", date_id)
out = whole_dict[date_id]
- if elem.attrib['type'] == "holiday":
- out['holy_name'] = elem.attrib['name'].strip()
- out['holy_text'] = parse_body(elem)
- elif elem.attrib['type'] == "sunday":
- out['sun_name'] = elem.attrib['name'].strip()
- if 'meaning' in elem.attrib:
- out['sun_mean'] = elem.attrib['meaning'].strip()
- out['sun_ord'] = int(elem.attrib['ord'])
- out['sun_text'] = parse_body(elem)
- elif elem.attrib['type'] == "week":
- out['week_title'] = elem.attrib['name'].strip()
+ if elem.attrib["type"] == "holiday":
+ out["holy_name"] = elem.attrib["name"].strip()
+ out["holy_text"] = parse_body(elem)
+ elif elem.attrib["type"] == "sunday":
+ out["sun_name"] = elem.attrib["name"].strip()
+ if "meaning" in elem.attrib:
+ out["sun_mean"] = elem.attrib["meaning"].strip()
+ out["sun_ord"] = int(elem.attrib["ord"])
+ out["sun_text"] = parse_body(elem)
+ elif elem.attrib["type"] == "week":
+ out["week_title"] = elem.attrib["name"].strip()
else:
- raise ValueError("Unknown DAY type = %s", elem.attrib['type'])
+ raise ValueError("Unknown DAY type = %s", elem.attrib["type"])
def parse_file(filename):
tree = et.parse(filename).getroot()
article_dict = {}
- env = jinja2.Environment(loader=jinja2.FileSystemLoader('templates'))
- template = env.get_template('czech.html')
+ env = jinja2.Environment(loader=jinja2.FileSystemLoader("templates"))
+ template = env.get_template("czech.html")
for los in tree.iter("LOSUNG"):
key, text = parse_losung(los)
diff --git a/screen.css b/screen.css
index c137b2b..7bda106 100644
--- a/screen.css
+++ b/screen.css
@@ -20,13 +20,13 @@ article {
display: block;
}
-ul.readings {
+ul.readings, ul.chronicles {
display: block;
clear: both;
padding-left: 0;
}
-ul.readings li {
+ul.readings li, ul.chronicles li {
display: block;
/* font-size: 80%; */
list-style: none;
diff --git a/sworker.js b/sworker.js
index d1bdcca..08d9d62 100644
--- a/sworker.js
+++ b/sworker.js
@@ -1,4 +1,4 @@
-var VERSION = 'v51 - 2019-12-26';
+var VERSION = 'v53 - 2020-01-06';
var toCache = [
'/',
'activePage.js',
diff --git a/templates/base.html b/templates/base.html
index 00af4c1..ca6ea59 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -53,8 +53,10 @@
{% for wword in art.watchwords %}{{ verses(wword) }}{% endfor %}
{%- if art.readings %}<ul class="readings">
{% for read in art.readings %}<li>{{ read }}</li>{% endfor %}
- </ul>
-{% endif %}
+ </ul>{% endif %}
+ {%- if art.chronicles %}<ul class="chronicles">
+ {% for chron in art.chronicles %}<li>{{ chron }}</li>{% endfor %}
+ </ul>{% endif %}
</article>
{%- endfor %}
<footer class="acknowledgment">