From 1dea20a0d5081e8fa1f864e82977dc9d365a8565 Mon Sep 17 00:00:00 2001 From: Valerie R Young Date: Tue, 12 Jul 2016 10:35:42 -0400 Subject: reproducible debian: use main navigation template in bash scripts Signed-off-by: Holger Levsen --- bin/reproducible_common.sh | 199 ++++++++++++-------------------- bin/templates/basic_page.mustache | 4 +- bin/templates/main_navigation.mustache | 203 +++++++++++++++++---------------- 3 files changed, 183 insertions(+), 223 deletions(-) diff --git a/bin/reproducible_common.sh b/bin/reproducible_common.sh index 7f239608..52488936 100755 --- a/bin/reproducible_common.sh +++ b/bin/reproducible_common.sh @@ -106,6 +106,9 @@ done < $BIN_PATH/meta_pkgset.csv # mustache templates PAGE_FOOTER_TEMPLATE=$TEMPLATE_PATH/default_page_footer.mustache +PROJECT_LINKS_TEMPLATE=$TEMPLATE_PATH/project_links.mustache +MAIN_NAVIGATION_TEMPLATE=$TEMPLATE_PATH/main_navigation.mustache + # sleep 1-23 secs to randomize start times delay_start() { @@ -162,146 +165,92 @@ write_page_header() { # the solution is to write all html pages with python… rm -f $PAGE MAINVIEW="dashboard" - ALLSTATES="reproducible FTBR FTBFS depwait not_for_us 404 blacklisted" - ALLVIEWS="notes no_notes pkg_sets last_24h last_48h all_abc arch scheduled suite_stats dd-list dashboard issues repositories notify performance variations breakages" - GLOBALVIEWS="issues scheduled notify repositories dashboard performance variations breakages" - SUITEVIEWS="dd-list suite_stats" - SPOKENTARGET["issues"]="issues" - SPOKENTARGET["notes"]="packages with notes" - SPOKENTARGET["no_notes"]="packages without notes" - SPOKENTARGET["scheduled"]="currently scheduled" - SPOKENTARGET["last_24h"]="packages tested in the last 24h" - SPOKENTARGET["last_48h"]="packages tested in the last 48h" - SPOKENTARGET["all_abc"]="all tested packages (sorted alphabetically)" - SPOKENTARGET["notify"]="⚑ packages with enabled notifications" - SPOKENTARGET["dd-list"]="maintainers of unreproducible packages" - SPOKENTARGET["pkg_sets"]="package sets" - SPOKENTARGET["suite_stats"]="suite: $SUITE" - SPOKENTARGET["repositories"]="repositories overview" - SPOKENTARGET["dashboard"]="Debian dashboard" - SPOKENTARGET["performance"]="performance stats" - SPOKENTARGET["variations"]="variations tested" - SPOKENTARGET["breakages"]="broken pieces" write_page "" write_page "" write_page "" write_page "" write_page "$2" if [ "$1" != "$MAINVIEW" ] ; then - write_page "

$2

" + write_page "" + else + write_page "" + fi + + # Build context for the main_navigation mustache template. + + # Do not show package set links for "experimental" pages + if [ "$SUITE" != "experimental" ] ; then + # no pkg_sets are tested in experimental + include_pkgset_link="\"include_pkgset_link\" : \"true\"" + else + include_pkgset_link='' + fi + + # Used to highlight the link for the current page + if [ "$1" = "dashboard" ] || [ "$1" = "performance" ] || [ "$1" = "repositories" ] || [ "$1" = "variations" ] ; then + displayed_page="\"$1\": \"true\"" else - write_page "

$2

" + displayed_page='' fi - write_page "
    " - write_page "
  • $SUITE/$ARCH:
      " - local CLASS="" - for TARGET in $ALLVIEWS ; do - CLASS="" - if [ "$TARGET" = "pkg_sets" ] && [ "$SUITE" = "experimental" ] ; then - # no pkg_sets are tested in experimental - continue + + # Create json for suite links (a list of objects) + suite_links="\"suite_list\": [" + comma=0 + for i in $SUITES ; do + if [ "$1" = "suite_arch_stats" ] && [ "$i" = "$SUITE" ] ; then + class="class='active'" + else + class='' fi - SPOKEN_TARGET=${SPOKENTARGET[$TARGET]} - BASEURL="/debian/$SUITE/$ARCH" - local i - for i in $GLOBALVIEWS ; do - if [ "$TARGET" = "$i" ] ; then - BASEURL="/debian" - fi - done - for i in ${SUITEVIEWS} ; do - if [ "$TARGET" = "$i" ] ; then - BASEURL="/debian/$SUITE" - fi - done - # prepare unsorted lists - if [ "$TARGET" = "notes" ] ; then - write_page "
    • Notes
        " - elif [ "$TARGET" = "last_24h" ] ; then - write_page "
      • Recently tested:
          " + if [ $comma == 1 ] ; then + suite_links+=", {\"s\": \"$i\", \"class\": \"$class\"}" + else + suite_links+="{\"s\": \"$i\", \"class\": \"$class\"}" + comma=1 fi - # prepare links - if [ "$TARGET" = "scheduled" ] ; then - write_page "
        • ${SPOKEN_TARGET}
        • " - elif [ "$TARGET" = "notify" ] ; then - write_page "
        • ${SPOKEN_TARGET}
        • " - elif [ "$TARGET" = "arch" ] ; then - write_page "
        • Architectures:
          • " - for i in ${ARCHS} ; do - if [ "$1" = "suite_arch_stats" ] && [ "$i" = "$ARCH" ] ; then - CLASS=" class=\"active\"" - fi - write_page " $i  " - CLASS="" - done - write_page "
          • " - elif [ "$TARGET" = "suite_stats" ] ; then - write_page "
          • Suites:
            • " - for i in $SUITES ; do - if [ "$1" = "suite_arch_stats" ] && [ "$i" = "$SUITE" ] ; then - CLASS=" class=\"active\"" - fi - write_page " $i  " - CLASS="" - done - write_page "
            • " - elif [ "$TARGET" = "dashboard" ] ; then - if [ "$1" = "dashboard" ] ; then - CLASS=" class=\"active\"" - fi - write_page "
            • ${SPOKEN_TARGET}
                " + done + suite_links+="]" + + # Create json for arch links (a list of objects) + arch_links="\"arch_list\": [" + comma=0 + for i in ${ARCHS} ; do + if [ "$1" = "suite_arch_stats" ] && [ "$i" = "$ARCH" ] ; then + class="class='active'" else - if [ "$1" = "$TARGET" ] ; then - CLASS=" class=\"active\"" - fi - write_page "
              • ${SPOKEN_TARGET}
              • " + class='' fi - # close unsorted lists (and package states loop) - if [ "$TARGET" = "all_abc" ] ; then - write_page "
            • " - elif [ "$TARGET" = "last_48h" ] ; then - write_page "
          • " - elif [ "$TARGET" = "breakages" ] ; then - write_page "
        • " - elif [ "$TARGET" = "scheduled" ] ; then - write_page "
      • " - elif [ "$TARGET" = "dd-list" ] ; then - write_page "
    • " - elif [ "$TARGET" = "no_notes" ] ; then - write_page "
  • " - # after notes we have package states - write_page "
  • Package states:" - write_page "
    • " - for MY_STATE in $ALLSTATES ; do - set_icon $MY_STATE - write_icon - write_page " " - done - write_page "
  • " + if [ $comma == 1 ] ; then + arch_links+=", {\"a\": \"$i\", \"class\": \"$class\"}" + else + arch_links+="{\"a\": \"$i\", \"class\": \"$class\"}" + comma=1 fi done - write_page "
" - # project links - write_page " " - # end project links + arch_links+="]" + + # finally, the completely formed JSON context + context=$(printf '{ + "arch" : "%s", + "suite" : "%s", + "page_title" : "%s", + "debian_url" : "%s", + %s, + %s + ' "$ARCH" "$SUITE" "$2" "$DEBIAN_URL" "$arch_links" "$suite_links") + if [[ ! -z $displayed_page ]] ; then + context+=", $displayed_page" + fi + if [[ ! -z $include_pkgset_link ]] ; then + context+=", $include_pkgset_link" + fi + context+="}" + + write_page "
" + write_page "$(pystache3 $MAIN_NAVIGATION_TEMPLATE "$context")" + write_page "$(pystache3 $PROJECT_LINKS_TEMPLATE "{}")" write_page "
" + write_page "
" if [ "$1" = "$MAINVIEW" ] ; then write_page " +
  • Architectures:
  • +
  • Suites:
  • +
  • Debian dashboard +
  • + +{{{project_links_html}}} -- cgit v1.2.3-70-g09d2