From b7443da57856dfa6295aad9c2cd3e69065553b70 Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Wed, 8 Feb 2017 13:19:38 +0000 Subject: Refactor main nav into reusable blocks --- templates/web/base/footer.html | 30 +---------------------- templates/web/base/main_nav.html | 35 +++++++++++++++++++++++++++ templates/web/base/main_nav_items.html | 44 ++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 29 deletions(-) create mode 100644 templates/web/base/main_nav.html create mode 100644 templates/web/base/main_nav_items.html diff --git a/templates/web/base/footer.html b/templates/web/base/footer.html index 5fd74b3a1..9f86f7519 100644 --- a/templates/web/base/footer.html +++ b/templates/web/base/footer.html @@ -9,35 +9,7 @@ diff --git a/templates/web/base/main_nav.html b/templates/web/base/main_nav.html new file mode 100644 index 000000000..31bd61af5 --- /dev/null +++ b/templates/web/base/main_nav.html @@ -0,0 +1,35 @@ +[% + SET base = ""; + SET base = c.cobrand.base_url IF admin; + + # DEFAULT would make sense here, except it treats the empty string as falsy + # and some cobrands want to set ul_class to an empty string. + SET ul_class="nav-menu nav-menu--main" UNLESS ul_class.defined; +%] +[% BLOCK navitem ~%] +
  • + [%~ IF c.req.uri.path == uri ~%] + [% label %] + [%~ ELSE ~%] + [% label %] + [%~ END ~%] +
  • +[%~ END %] + +[% UNLESS omit_wrapper %] + +[% END %] diff --git a/templates/web/base/main_nav_items.html b/templates/web/base/main_nav_items.html new file mode 100644 index 000000000..ca82b6560 --- /dev/null +++ b/templates/web/base/main_nav_items.html @@ -0,0 +1,44 @@ +[%~ INCLUDE navitem uri='/' label=loc('Report a problem') attrs='class="report-a-problem-btn"' ~%] + +[%~ IF c.user_exists ~%] + [%~ INCLUDE navitem uri='/my' label=loc('Your account') ~%] +[%~ ELSE ~%] + [%~ INCLUDE navitem uri='/auth' label=loc('Sign in') ~%] +[%~ END ~%] + +[%~ IF c.user_exists AND c.user.has_body_permission_to('planned_reports') ~%] + [%~ INCLUDE navitem uri='/my/planned' label=loc('Shortlist') ~%] +[%~ END ~%] + + +[%~ UNLESS hide_all_reports_link ~%] + [%~ + IF c.user_exists AND c.user.categories.size; + categories = c.user.categories.join(",") | uri; + cat_suffix = "?filter_category=" _ categories; + END; + + reports_uri = '/reports'; + IF body_name; + body_name = body_name | uri; + reports_uri = "${reports_uri}/${body_name}"; + END; + + INCLUDE navitem uri=reports_uri label=loc('All reports') suffix=cat_suffix; + ~%] +[%~ END ~%] + +[%~ + IF pc; + pc_uri = pc | uri; + pc_suffix = "/list?pc=" _ pc_uri; + END; + + INCLUDE navitem uri='/alert' label=loc('Local alerts') suffix=pc_suffix; +~%] + +[%~ INCLUDE navitem uri='/faq' label=loc('Help') ~%] + +[%~ UNLESS hide_privacy_link ~%] + [%~ INCLUDE navitem uri='/privacy' label=loc('Privacy') liattrs='class="nav-menu__item--privacy"' ~%] +[%~ END ~%] -- cgit v1.2.3