From 63f0622d4185b68b345d0ec1aa981c2cc7ce5826 Mon Sep 17 00:00:00 2001 From: Nicolas Sebrecht Date: Fri, 22 Jul 2016 17:21:13 +0200 Subject: [PATCH] website-doc: order announces by date Signed-off-by: Nicolas Sebrecht --- docs/website-doc.sh | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/docs/website-doc.sh b/docs/website-doc.sh index 733fd43..efe4915 100755 --- a/docs/website-doc.sh +++ b/docs/website-doc.sh @@ -11,6 +11,7 @@ DOCBASE="${WEBSITE}/_doc" DESTBASE="${DOCBASE}/versions" VERSIONS_YML="${WEBSITE}/_data/versions.yml" ANNOUNCES_YML="${WEBSITE}/_data/announces.yml" +ANNOUNCES_YML_TMP="${ANNOUNCES_YML}.tmp" CONTRIB_YML="${WEBSITE}/_data/contribs.yml" CONTRIB="${DOCBASE}/contrib" HEADER="# DO NOT EDIT MANUALLY: it is generated by a script (website-doc.sh)." @@ -67,10 +68,10 @@ function api () { # $1: full release title # function parse_releases_get_link () { - echo $1 | sed -r -e 's,^### (OfflineIMAP.*)\),\1,' \ - | tr '[:upper:]' '[:lower:]' \ - | sed -r -e 's,[\.("],,g' \ - | sed -r -e 's, ,-,g' + echo $1 | sed -r -e 's,^### (OfflineIMAP.*)\),\1,' \ + | tr '[:upper:]' '[:lower:]' \ + | sed -r -e 's,[\.("],,g' \ + | sed -r -e 's, ,-,g' } # @@ -78,7 +79,15 @@ function parse_releases_get_link () { # $1: full release title # function parse_releases_get_version () { - echo $title | sed -r -e 's,^### [a-Z]+ (v[^ ]+).*,\1,' + echo $title | sed -r -e 's,^### [a-Z]+ (v[^ ]+).*,\1,' +} + +# +# Return date from release entry. +# $1: full release title +# +function parse_releases_get_date () { + echo $title | sed -r -e 's,.*\(([0-9]+-[0-9]+-[0-9]+)\),\1,' } # @@ -100,15 +109,19 @@ function releases () { do link="$(parse_releases_get_link $title)" v="$(parse_releases_get_version $title)" - echo "- {version: '${v}', link: 'Changelog.html#${link}'}" - done | tee -a "$ANNOUNCES_YML" + d="$(parse_releases_get_date $title)" + echo "- {date: '${d}', version: '${v}', link: 'Changelog.html#${link}'}" + done | tee -a "$ANNOUNCES_YML_TMP" # Announces for the maintenance releases. grep -E '^### OfflineIMAP' ./Changelog.maint.md | while read title do link="$(parse_releases_get_link $title)" v="$(parse_releases_get_version $title)" - echo "- {version: '${v}', link: 'Changelog.maint.html#${link}'}" - done | tee -a "$ANNOUNCES_YML" + d="$(parse_releases_get_date $title)" + echo "- {date: '${d}', version: '${v}', link: 'Changelog.maint.html#${link}'}" + done | tee -a "$ANNOUNCES_YML_TMP" + sort -nr "$ANNOUNCES_YML_TMP" >> "$ANNOUNCES_YML" + rm -f "$ANNOUNCES_YML_TMP" }