let XDate = require('xdate') return async (env, head, body) => { let feedback_form = await _require('/feedback_form.jst') let globals = await env.site.get_json('/_config/globals.json') let icon_search = await env.site.get_min_svg('/_svg/icon_search.svg') let logo_large = await env.site.get_min_svg('/_svg/logo_large.svg') let page = await _require('/page.jst') await page( env, // head async _out => { title { _out.push( globals.site_title + ": " + (globals.page_to_title[env.parsed_url.pathname] || env.parsed_url.pathname) ) } await head(_out) }, // body async _out => { div(style="padding-left: calc(100vw - 100%);") { div.container(style="margin-top: 15px; margin-bottom: 15px;") { //div.row { // div.col-sm-12(style="text-align: right;") { // a(href="/login.html") {'Login'} // } //} div.row { div.'col-sm-8'.vbottom { _out.push(logo_large) } div.'col-sm-4'.vbottom(style="padding-bottom: 15px;") { form(action="/search.html") { div.input-group { input.form-control(name="query" type="text" placeholder="Search") {} span.input-group-btn { button.btn.btn-default(type="submit") { _out.push(icon_search) } } } } } } } } nav.navbar.navbar-default(style="margin-top: 0px; margin-bottom: 0px;") { div(style="padding-left: calc(100vw - 100%);") { div.container { //-fluid") { // Brand and toggle get grouped for better mobile display div.navbar-header { button.navbar-toggle.collapsed(type="button" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false") { span.sr-only {'Toggle navigation'} span.icon-bar {} span.icon-bar {} span.icon-bar {} } //a.navbar-brand(href="#") {'Brand'} } // Collect the nav links, forms, and other content for toggling div.collapse.navbar-collapse#bs-example-navbar-collapse-1 { ul.nav.navbar-nav { let navigation = globals.navigation for (let i = 0; i < navigation.length; ++i) { let page = navigation[i] let title = globals.page_to_title[page] || page if (page === env.parsed_url.pathname) li.active { a(href=page) { `${title}` span.sr-only {'(current)'} } } else li { a(href=page) {`${title}`} } } } ul.nav.navbar-nav.navbar-right { li { a#give-feedback {'Give feedback'} } } } } } } div(style="padding-left: calc(100vw - 100%);") { div.container { await body(_out) } } div.footer(style="padding-left: calc(100vw - 100%);") { div.container { //-fluid") { a(rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/") { img(alt="Creative Commons License" style="border-width:0" src="/images/by-sa_3.0_88x31.png") {} } p { 'This website is ' a(href="https://git.ndcode.org/public/ndcode_site.git") { 'open source' } ' and licensed under a ' a(rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/") { 'Creative Commons Attribution-ShareAlike 3.0 Unported License' } '.' } p {'Example code fragments embedded within the text are placed in the public domain unless otherwise noted.'} p {`Copyright © ${new XDate().getUTCFullYear()} Integration Logic Pty Ltd trading as NDCODE and contributors.`} } } // hidden part div#feedback-modal.modal.fade(role="dialog") { div.modal-dialog { div.modal-content { div.modal-header { button.close(type="button" data-dismiss="modal") { '×' } h4.modal-title { 'Give feedback' } } div.modal-body { p { 'Did you notice something not quite right, or just want to share your impression of this page?' } await feedback_form(env, _out) } div.modal-footer { button.btn.btn-primary(type="submit" form="feedback-form") { 'Submit' } button.btn.btn-default(type="button" data-dismiss="modal") { 'Close' } } } } } div#message-modal.modal.fade(role="dialog") { div.modal-dialog { div.modal-content { div.modal-header { button.close(type="button" data-dismiss="modal") { '×' } h4.modal-title { 'Message' } } div.modal-body { p#message-modal-message {} } div.modal-footer { button.btn.btn-default(type="button" data-dismiss="modal") { 'Close' } } } } } }, // scripts async _out => { // when feedback form is submitted, do not reload the page script { $(document).ready(function() { $('#give-feedback').click(function() { $('#feedback-modal').modal('show') $('#feedback-form-message').text('') }) $('#feedback-modal').on('shown.bs.modal', function() { $('#feedback-form-message').focus() }) $(document).on('submit', '#feedback-form', function(e) { e.preventDefault() $.ajax({ url: '/feedback.html', type: 'POST', data: { page: window.location.href, message: $('#feedback-form-message').val() }, success: function(data, textStatus, jqXHR) { $('#feedback-modal').modal('hide') $('#message-modal-message').text(data) $('#message-modal').modal('show') }, error: function(jqXHR, textStatus, errorThrown) { $('#feedback-modal').modal('hide') $('#message-modal-message').text(errorThrown) $('#message-modal').modal('show') } }) }) }) } } ) }