Fixes issue #0 (#688)

* option 1  (this is the quickest fix)

* option 2: This shows how to handle it inline

* whoops, fix prev commit (I forgot to pull out of the "if")

* closes https://github.com/fleetdm/fleet/issues/0 -- this remove headerClass altogether in favor of using existing "page" local, eliminating the need for a headerClass view local -- see https://github.com/fleetdm/fleet/issues/0#issuecomment-827752563 for explanation

* one further simplification that avoids `page` getting unintentionally used elsewhere in other .ejs files (also isHomepage is easier to cmd+f and find in code)
This commit is contained in:
Mike McNeil 2021-04-27 13:08:33 -05:00 committed by GitHub
parent 8e1742805a
commit dfbc9f9961
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 11 deletions

View file

@ -13,7 +13,7 @@ module.exports.routes = {
// ╦ ╦╔═╗╔╗ ╔═╗╔═╗╔═╗╔═╗╔═╗
// ║║║║╣ ╠╩╗╠═╝╠═╣║ ╦║╣ ╚═╗
// ╚╩╝╚═╝╚═╝╩ ╩ ╩╚═╝╚═╝╚═╝
'GET /': { action: 'view-homepage-or-redirect', locals: { page: 'homepage', headerClass: 'homepage-header' } },
'GET /': { action: 'view-homepage-or-redirect', locals: { isHomepage: true } },
'/blog': 'https://medium.com/fleetdm',
@ -31,9 +31,9 @@ module.exports.routes = {
'/company/about': '/blog', // FUTURE: brief "about" page explaining the origins of the company
'/company/stewardship': 'https://github.com/fleetdm/fleet', // FUTURE: page about how we approach open source and our commitments to the community
'GET /company/contact': { action: 'view-contact', locals: { page: 'contact', headerClass: 'header' } },
'GET /get-started': { action: 'view-get-started', locals: { page: 'get-started', headerClass: 'header' } },
'GET /pricing': { action: 'view-pricing', locals: { page: 'pricing', headerClass: 'header' } },
'GET /company/contact': { action: 'view-contact' },
'GET /get-started': { action: 'view-get-started' },
'GET /pricing': { action: 'view-pricing' },
'/try-fleet': '/get-started',
'/documentation': 'https://github.com/fleetdm/fleet/tree/master/docs',
'/contribute': 'https://github.com/fleetdm/fleet/tree/master/docs/3-Contribution',

View file

@ -1,8 +1,10 @@
<% if(typeof me === 'undefined') {
<%
// In case we're displaying the 404 or 500 page and relevant code in the "custom" hook was not able to run,
// we make sure `me` exists. This ensures we don't have to do `typeof` checks below.
var me = undefined;
} %><!DOCTYPE html>
// we make sure certain view locals exist that are commonly used in this layout.ejs file. This ensures we
// don't have to do `typeof` checks below.
var me;
var isHomepage;
%><!DOCTYPE html>
<html>
<head>
<title>Fleet for osquery | Open source device management</title>
@ -50,10 +52,10 @@
</head>
<body>
<div purpose="page-wrap">
<div style="max-width: 1440px" class="<%= headerClass %> container-fluid d-flex justify-content-between align-items-center pt-3 pb-3 px-4 px-sm-5" purpose="page-header">
<div style="max-width: 1440px" class="<%= isHomepage ? 'homepage-header' : 'header' %> container-fluid d-flex justify-content-between align-items-center pt-3 pb-3 px-4 px-sm-5" purpose="page-header">
<a href="/">
<% /* The homepage-header on the homepage has a white fleet logo */ %>
<% if (page === 'homepage') { %>
<% if (isHomepage) { %>
<img alt="Fleet logo" src="/images/logo-white-162x92@2x.png" style="height: 92px; width: 162px;"/>
<% } else { %>
<img alt="Fleet logo" src="/images/logo-blue-162x92@2x.png" style="height: 92px; width: 162px;"/>
@ -63,7 +65,7 @@
<button style="font-size: 16px; text-decoration: none;" class="header-btn btn btn-link d-flex align-items-center" data-toggle="collapse" data-target="#navbarToggleExternalContent">
<span class="mr-2">Menu</span>
<% /* The hamburger icon on the homepage is white */ %>
<% if (page === 'homepage') { %>
<% if (isHomepage) { %>
<img alt="An icon indicating that interacting with this button will open the navigation menu." src="/images/icon-hamburger-16x14@2x.png" style="width: 16px;" />
<% } else { %>
<img alt="An icon indicating that interacting with this button will open the navigation menu." src="/images/icon-hamburger-blue-16x14@2x.png" style="width: 16px;" />