UX: Make header/footer HTML consistent for crawler and noscript

These were originally very similar, but have diverged over time. This makes it very difficult to manage styling.

This commit moves the noscript header and footer into partials so they can be reused in both the crawler view and the `<noscript>` view. It also makes browser-update render the noscript content **instead of** the `<section id='main'>`, rather than adding adding the noscript inside the `<section>`. This provides better parity with the server-rendered crawler view.
This commit is contained in:
David Taylor 2022-04-07 15:07:00 +01:00
parent 230e220710
commit 683b172104
5 changed files with 44 additions and 52 deletions

View File

@ -37,7 +37,7 @@
result += noscriptElements[i].childNodes[j].nodeValue;
}
mainElement.innerHTML = result;
mainElement.outerHTML = result;
break;
}
}

View File

@ -0,0 +1,32 @@
<footer class="container wrap">
<nav class='crawler-nav'>
<ul>
<li itemscope itemtype='http://schema.org/SiteNavigationElement'>
<span itemprop='name'>
<a href='<%= path "/" %>' itemprop="url"><%= t 'home_title' %> </a>
</span>
</li>
<li itemscope itemtype='http://schema.org/SiteNavigationElement'>
<span itemprop='name'>
<a href='<%= path "/categories" %>' itemprop="url"><%= t 'js.filters.categories.title' %> </a>
</span>
</li>
<li itemscope itemtype='http://schema.org/SiteNavigationElement'>
<span itemprop='name'>
<a href='<%= path "/guidelines" %>' itemprop="url"><%= t 'guidelines_topic.title' %> </a>
</span>
</li>
<li itemscope itemtype='http://schema.org/SiteNavigationElement'>
<span itemprop='name'>
<a href='<%= path "/tos" %>' itemprop="url"><%= t 'tos_topic.title' %> </a>
</span>
</li>
<li itemscope itemtype='http://schema.org/SiteNavigationElement'>
<span itemprop='name'>
<a href='<%= path "/privacy" %>' itemprop="url"><%= t 'privacy_topic.title' %> </a>
</span>
</li>
</ul>
</nav>
<p class='powered-by-link'><%= t 'powered_by_html' %></p>
</footer>

View File

@ -0,0 +1,5 @@
<header>
<a href="<%= path "/" %>">
<h1><%=SiteSetting.title%></h1>
</a>
</header>

View File

@ -73,25 +73,15 @@
<%= render_google_tag_manager_body_code %>
<noscript data-path="<%= request.env['PATH_INFO'] %>">
<%= render partial: 'header' %>
<%= render partial: "layouts/noscript_header" %>
<div id="main-outlet" class="wrap" role="main">
<!-- preload-content: -->
<%= yield %>
<!-- :preload-content -->
<footer class="noscript-footer-nav">
<nav itemscope itemtype='http://schema.org/SiteNavigationElement'>
<a href='<%= path "/" %>'><%= t 'home_title' %></a>
<%= link_to t('js.filters.categories.title'), path("/categories") %>
<%= link_to t('guidelines_topic.title'), path("/guidelines") %>
<%= link_to t('tos_topic.title'), path("/tos") %>
<%= link_to t('privacy_topic.title'), path("/privacy") %>
</nav>
</footer>
</div>
<footer id='noscript-footer'>
<p><%= t 'powered_by_html' %></p>
</footer>
<%= render partial: "layouts/noscript_footer" %>
</noscript>
<%- unless customization_disabled? %>

View File

@ -16,46 +16,11 @@
</head>
<body class="crawler">
<%= theme_lookup("header") %>
<header>
<a href="<%= path "/" %>">
<h1><%=SiteSetting.title%></h1>
</a>
</header>
<div id="main-outlet" class="wrap">
<%= render partial: "layouts/noscript_header" %>
<div id="main-outlet" class="wrap" role="main">
<%= yield %>
</div>
<footer class="container wrap">
<nav class='crawler-nav'>
<ul>
<li itemscope itemtype='http://schema.org/SiteNavigationElement'>
<span itemprop='name'>
<a href='<%= path "/" %>' itemprop="url"><%= t 'home_title' %> </a>
</span>
</li>
<li itemscope itemtype='http://schema.org/SiteNavigationElement'>
<span itemprop='name'>
<a href='<%= path "/categories" %>' itemprop="url"><%= t 'js.filters.categories.title' %> </a>
</span>
</li>
<li itemscope itemtype='http://schema.org/SiteNavigationElement'>
<span itemprop='name'>
<a href='<%= path "/guidelines" %>' itemprop="url"><%= t 'guidelines_topic.title' %> </a>
</span>
</li>
<li itemscope itemtype='http://schema.org/SiteNavigationElement'>
<span itemprop='name'>
<a href='<%= path "/tos" %>' itemprop="url"><%= t 'tos_topic.title' %> </a>
</span>
</li>
<li itemscope itemtype='http://schema.org/SiteNavigationElement'>
<span itemprop='name'>
<a href='<%= path "/privacy" %>' itemprop="url"><%= t 'privacy_topic.title' %> </a>
</span>
</li>
</ul>
</nav>
<p class='powered-by-link'><%= t 'powered_by_html' %></p>
</footer>
<%= render partial: "layouts/noscript_footer" %>
<%= theme_lookup("footer") %>
<%= theme_lookup("body_tag") %>
<% if show_browser_update? %>