aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2020-02-15 00:39:14 -0300
committerEuAndreh <eu@euandre.org>2020-02-15 00:39:14 -0300
commit4cbc208f49a12849216aeb6b344b345d8df52b03 (patch)
treee775574f15c0051b7b0a4af800d6155f66116398
parentMerge branch 'master' into wip (diff)
parentFix navigation bar links to Atom feeds (diff)
downloadeuandre.org-4cbc208f49a12849216aeb6b344b345d8df52b03.tar.gz
euandre.org-4cbc208f49a12849216aeb6b344b345d8df52b03.tar.xz
Merge branch 'master' into wip
-rw-r--r--_config.yml4
-rw-r--r--_layouts/default.html36
-rw-r--r--_layouts/index.html13
-rw-r--r--default.nix10
-rwxr-xr-xscripts/tidy-content.sh35
5 files changed, 71 insertions, 27 deletions
diff --git a/_config.yml b/_config.yml
index 8eabae1..91d9e90 100644
--- a/_config.yml
+++ b/_config.yml
@@ -43,8 +43,8 @@ t:
en: "EuAndreh's Feed"
pt: "Feed do EuAndreh"
feed_url:
- en: '/feed.en.xml'
- pt: '/feed.pt.xml'
+ en: '/feed.en.atom'
+ pt: '/feed.pt.atom'
date_format:
en: '%B %-d, %Y'
pt: '%-d de %B de %Y'
diff --git a/_layouts/default.html b/_layouts/default.html
index 1ff8c1d..6a0587b 100644
--- a/_layouts/default.html
+++ b/_layouts/default.html
@@ -28,25 +28,25 @@
<a href="{{ site.t.home_url[page.lang] }}">{{ site.t.home[page.lang] }}</a>
</div>
<div id="nav-right">
- <ul>
- {% if page.ref != nil %}
- {% assign lposts=site.posts | where:"ref", page.ref | sort: 'lang' %}
- {% for lpost in lposts %}
- <li>
- <a href="{{ lpost.url }}" class="{{ lpost.lang }}">{{ lpost.lang }}</a>
- </li>
- {% endfor %}
- {% endif %}
+ {% if page.ref != nil %}
+ {% if site.posts.size > 0 or site.pages.size > 0 %}
+ <ul>
+ {% assign lposts=site.posts | where:"ref", page.ref | sort: 'lang' %}
+ {% for lpost in lposts %}
+ <li>
+ <a href="{{ lpost.url }}" class="{{ lpost.lang }}">{{ lpost.lang }}</a>
+ </li>
+ {% endfor %}
- {% if page.ref != nil %}
- {% assign lpages=site.pages | where:"ref", page.ref | sort: 'lang' %}
- {% for lpage in lpages %}
- <li>
- <a href="{{ lpage.url }}" class="{{ lpage.lang }}">{{ lpage.lang }}</a>
- </li>
- {% endfor %}
+ {% assign lpages=site.pages | where:"ref", page.ref | sort: 'lang' %}
+ {% for lpage in lpages %}
+ <li>
+ <a href="{{ lpage.url }}" class="{{ lpage.lang }}">{{ lpage.lang }}</a>
+ </li>
+ {% endfor %}
+ </ul>
{% endif %}
- </ul>
+ {% endif %}
<a href="{{ site.t.about_url[page.lang] }}">{{ site.t.about[page.lang] }}</a>
<a href="{{ site.t.feed_url[page.lang] }}">
@@ -57,7 +57,7 @@
</header>
<main>
- <h1>{{ page.title }}</h1>
+ {% if page.title %}<h1>{{ page.title }}</h1>{% endif %}
{{ content }}
</main>
diff --git a/_layouts/index.html b/_layouts/index.html
index 3c145d0..037e0e3 100644
--- a/_layouts/index.html
+++ b/_layouts/index.html
@@ -2,12 +2,13 @@
layout: default
---
<h1>{{ site.t.recent_posts[page.lang] }}</h1>
-<ul>
- {%- for post in site.posts -%}
- {% if post.lang == page.lang %}
+{% assign lposts=site.posts | where:"lang", page.lang | sort: 'date' %}
+{% if lposts.size > 0 %}
+ <ul>
+ {%- for post in lposts -%}
<li>
<a href="{{ post.url }}">{{ post.title | escape }}</a> - {{ post.date | date: site.t.date_format[page.lang] }}
</li>
- {% endif %}
- {%- endfor -%}
-</ul>
+ {%- endfor -%}
+ </ul>
+{% endif %}
diff --git a/default.nix b/default.nix
index c664429..2f10691 100644
--- a/default.nix
+++ b/default.nix
@@ -33,9 +33,15 @@ in rec {
});
docs = utils.baseTask.overrideAttrs (baseAttrs: {
name = "${baseAttrs.name}-docs";
- buildInputs = [ jekyllEnv ];
+ buildInputs = [ jekyllEnv pkgs.html-tidy ];
buildPhase = ''
+ patchShebangs .
jekyll build -d $out
+ ./scripts/tidy-content.sh $out || {
+ echo 'Error in formatting HTML. Reproduce with: '
+ echo ' jekyll build && ./scripts/tidy-content.sh _site/'
+ exit 1
+ }
'';
});
};
@@ -45,12 +51,14 @@ in rec {
(utils.fixme null)
subtasks.hunspellCheck
subtasks.assertContent
+ subtasks.docs
];
shell = pkgs.mkShell rec {
name = "website-shell";
buildInputs = [
jekyllEnv
(pkgs.hunspellWithDicts (with pkgs.hunspellDicts; [ en-us ]))
+ pkgs.html-tidy
];
};
publishScript = utils.overwritingPublishScript {
diff --git a/scripts/tidy-content.sh b/scripts/tidy-content.sh
new file mode 100755
index 0000000..6dc13c6
--- /dev/null
+++ b/scripts/tidy-content.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+set -Eeuo pipefail
+
+end="\033[0m"
+red="\033[0;31m"
+red() { echo -e "${red}${1}${end}"; }
+
+usage() {
+ red "Missing argument <${1}>.\n"
+ cat <<EOF
+Usage:
+ $0 <INPUT_DIR>
+
+ Arguments:
+ INPUT_DIR Input directory with the static HTML to be tidy-ed
+
+Examples:
+ $0 _site/
+EOF
+}
+
+INPUT_DIR="${1:-}"
+[[ -z "${INPUT_DIR}" ]] && {
+ usage 'INPUT_DIR'
+ exit 2
+}
+
+format() {
+ echo "${1}" >&2
+ tidy --quiet yes -utf8 -indent -modify "${1}"
+}
+export -f format
+
+find "${INPUT_DIR}" -type f -name '*.html' -print0 | \
+ xargs -0 -I{} bash -c "format {}"