From d2a0bc487e27367df9a8a9174be0f0beebbe9c20 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Feb 22 2021 22:55:31 +0000 Subject: [PATCH 1/2] website: simple display of language list --- diff --git a/build_website.py b/build_website.py index 464928a..e2d0af3 100755 --- a/build_website.py +++ b/build_website.py @@ -166,6 +166,13 @@ def main(): generate_static_pages_packages(args.results, code, content, dest_file) + log.info("Generating indexes") + dest_file = os.path.join(static_langs_folder, "_index.md") + generate_language_index(args.results, dest_file) + + dest_file = os.path.join(static_pkgs_folder, "_index.md") + generate_package_index(args.results, dest_file) + log.info("Copy translation memories") languages = [ f for f in os.listdir(tm_folder) if os.path.isfile(os.path.join(tm_folder, f)) @@ -383,6 +390,38 @@ def generate_static_pages_packages(results, code, content, dest_file): write_out.write(outputText) +def generate_language_index(distribution, dest_file): + log = logging.getLogger("buildWebsite.generate_language_index") + data = dict() + data["distribution"] = distribution + data["now"] = datetime.datetime.utcnow() + + templateLoader = jinja2.FileSystemLoader(searchpath="./templates/") + templateEnv = jinja2.Environment(loader=templateLoader, undefined=jinja2.Undefined) + TEMPLATE_FILE = "_index.language.md" + template = templateEnv.get_template(TEMPLATE_FILE) + outputText = template.render(data) + + with open(dest_file, "w") as write_out: + write_out.write(outputText) + + +def generate_package_index(distribution, dest_file): + log = logging.getLogger("buildWebsite.generate_package_index") + data = dict() + data["distribution"] = distribution + data["now"] = datetime.datetime.utcnow() + + templateLoader = jinja2.FileSystemLoader(searchpath="./templates/") + templateEnv = jinja2.Environment(loader=templateLoader, undefined=jinja2.Undefined) + TEMPLATE_FILE = "_index.package.md" + template = templateEnv.get_template(TEMPLATE_FILE) + outputText = template.render(data) + + with open(dest_file, "w") as write_out: + write_out.write(outputText) + + def store_json_file(content, dest_file): with open(dest_file, "w") as f: f.write(json.dumps(content, indent=2)) diff --git a/templates/_index.language.md b/templates/_index.language.md new file mode 100644 index 0000000..bb7141a --- /dev/null +++ b/templates/_index.language.md @@ -0,0 +1,5 @@ +--- +title: "Languages for {{ distribution }}" +date: {{ now }} +layout: "list_languages" +--- \ No newline at end of file diff --git a/templates/_index.package.md b/templates/_index.package.md new file mode 100644 index 0000000..a973b26 --- /dev/null +++ b/templates/_index.package.md @@ -0,0 +1,4 @@ +--- +title: "Packages for {{ distribution }}" +date: {{ now }} +--- \ No newline at end of file diff --git a/templates/language.md b/templates/language.md index 9ac40af..622d9d8 100644 --- a/templates/language.md +++ b/templates/language.md @@ -1,6 +1,10 @@ --- -title: "{{ lang_name_en }} ({{ lang_name_local }})" +title: "{{ lang_code }}-{{ lang_name_en }} ({{ lang_name_local }})" date: {{ now }} +code: {{ lang_code }} +name_english: {{ lang_name_en }} +name_local: {{ lang_name_local }} +progress_d: {{ progress_d }} --- Language progress for {{ lang_name_en }} ({{ lang_code }}) in Fedora {{ results }} is: diff --git a/website/config.toml b/website/config.toml index c777f70..9beb5cf 100644 --- a/website/config.toml +++ b/website/config.toml @@ -1,5 +1,8 @@ baseURL = "https://jibecfed.fedorapeople.org/partage/fedora-localization-statistics/" languageCode = "en-us" -title = "Temporary demo" +title = "Fedora localization statistics" theme = "beautifulhugo" staticDir = "static" + +[markup.goldmark.renderer] +unsafe= true \ No newline at end of file diff --git a/website/themes/beautifulhugo/layouts/_default/f33.html b/website/themes/beautifulhugo/layouts/_default/f33.html new file mode 100644 index 0000000..1a00bdc --- /dev/null +++ b/website/themes/beautifulhugo/layouts/_default/f33.html @@ -0,0 +1,12 @@ +{{ define "main" }} +
+
+ {{ .Content }} + +
+
+{{ end }} diff --git a/website/themes/beautifulhugo/layouts/_default/list.html b/website/themes/beautifulhugo/layouts/_default/list.html index e08da36..5f7bf09 100644 --- a/website/themes/beautifulhugo/layouts/_default/list.html +++ b/website/themes/beautifulhugo/layouts/_default/list.html @@ -7,11 +7,6 @@ {{.}} {{ end }} -
- {{ range .Paginator.Pages }} - {{ partial "post_preview.html" .}} - {{ end }} -
{{ if or (.Paginator.HasPrev) (.Paginator.HasNext) }} diff --git a/website/themes/beautifulhugo/layouts/partials/breadcrumb.html b/website/themes/beautifulhugo/layouts/partials/breadcrumb.html new file mode 100644 index 0000000..62f1b66 --- /dev/null +++ b/website/themes/beautifulhugo/layouts/partials/breadcrumb.html @@ -0,0 +1,13 @@ + +{{ define "breadcrumbnav" }} +{{ if .p1.Parent }} +{{ template "breadcrumbnav" (dict "p1" .p1.Parent "p2" .p2 ) }} +{{ else if not .p1.IsHome }} +{{ template "breadcrumbnav" (dict "p1" .p1.Site.Home "p2" .p2 ) }} +{{ end }} + + {{ .p1.Title }} + +{{ end }} \ No newline at end of file From af7f4791cfebf1e0d9833dac954dbc979850528c Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Feb 22 2021 23:03:10 +0000 Subject: [PATCH 2/2] website: allow to sort language table --- diff --git a/website/themes/beautifulhugo/layouts/_default/list_languages.html b/website/themes/beautifulhugo/layouts/_default/list_languages.html index 42b9620..d108de7 100644 --- a/website/themes/beautifulhugo/layouts/_default/list_languages.html +++ b/website/themes/beautifulhugo/layouts/_default/list_languages.html @@ -3,12 +3,13 @@
{{ .Content }} - +
+ - - - - + + + + {{ range sort .Pages "Title" "asc" }} @@ -21,4 +22,60 @@
Click on columns headers to sort values
codeEnglish nameLocal nameProgresscodeEnglish nameLocal nameProgress
+ {{ end }} \ No newline at end of file