From 7f985b2eb976ee64deb460458ef1562d3a035a6c Mon Sep 17 00:00:00 2001 From: Claudio Cicali Date: Sat, 20 May 2017 20:00:16 +0200 Subject: [PATCH] Small batches of fixes --- ChangeLog.md | 9 +++++++++ README.md | 14 ++++++++++++-- lib/app.js | 30 ++++++++++++++++++++++++++++-- lib/config.js | 5 ++++- package.json | 2 +- routes/pages.js | 4 ++-- views/layout.pug | 12 ++++++------ views/mixins/links.pug | 4 ++-- views/preview.pug | 2 -- 9 files changed, 64 insertions(+), 18 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 32e74b45..a70d979b 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,12 @@ +Version 1.8.2, May 20th, 2017 +================================== + +- Closes #152 (You can now disable Gravatar) +- Closes #129 (Adds logo support) +- Fixes #216 () +- Always uses local jQuery and not Google's +- Adds favicon support + Version 1.8.1, May 17th, 2017 ================================== diff --git a/README.md b/README.md index 20941c87..0ff9da8e 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,14 @@ Configuration options reference This will be showed on the upper left corner of all the pages, in the main toolbar +#### application.logo (string: "") + + Supply the full URL to an image to be shown as the logo of your wiki. It will appear on the left of the page title in the navigation bar. Just set the `application.title` to an empty string to only show the Logo image. Please note that Jingo does not resize the image in any way (you can do it yourself using a custom CSS of course) + +#### application.favicon (string: "") + + Supply the full URL to an image to be shown as the favicon of your wiki. Please note that Jingo will try to get the mime type of the image from its extension (this can easily fail for a lot of reasons) + #### application.repository (string: "") Absolute path for your documents repository (mandatory). @@ -337,13 +345,15 @@ Configuration options reference #### features.markitup (boolean: false) - Whether to enable Markitup or not + DEPRECATED: markitup support has been removed as of version 1.8.0 #### features.codemirror (boolean: true) Whether to enable Codemirror or not. - Please note that you cannot enable both editors at the same time. +#### features.gravatar (boolean: true) + + Whether to enable gravatar support or not #### server.hostname diff --git a/lib/app.js b/lib/app.js index 7365659a..f60304b0 100644 --- a/lib/app.js +++ b/lib/app.js @@ -53,8 +53,13 @@ module.exports.initialize = function (config) { get user () { return req.user }, - get appTitle () { - return config.get('application').title + get appBrand () { + var appTitle = config.get('application').title || '' + var appLogo = config.get('application').logo || '' + if (appLogo !== '') { + appLogo = 'Logo' + } + return appLogo + ' ' + appTitle }, get proxyPath () { return config.getProxyPath() @@ -65,6 +70,21 @@ module.exports.initialize = function (config) { get authentication () { return config.get('authentication') }, + get faviconMimeType () { + if (!this.hasFavicon()) { + return '' + } + var favicon = config.get('application').favicon.trim() + var match = favicon.match(/\.([0-9a-z]+)$/i) + return match ? 'image/' + match[1] : 'image/png' + }, + get faviconUrl () { + if (!this.hasFavicon()) { + return '' + } + return config.get('application').favicon.trim() + }, + isAnonymous: function () { return !req.user }, @@ -74,6 +94,12 @@ module.exports.initialize = function (config) { gravatar: function (email) { return gravatar }, + hasGravatar: function () { + return config.get('features').gravatar && req.user && req.user.email && req.user.email !== 'jingouser' + }, + hasFavicon: function () { + return config.get('application').favicon && config.get('application').favicon.trim().length > 0 + }, get isAjax () { return req.headers['x-requested-with'] && req.headers['x-requested-with'] === 'XMLHttpRequest' } diff --git a/lib/config.js b/lib/config.js index 545bf8cc..23a97061 100644 --- a/lib/config.js +++ b/lib/config.js @@ -47,6 +47,8 @@ module.exports = (function () { application: { title: 'Jingo', + logo: '', + favicon: '', repository: '', docSubdir: '', remote: '', @@ -102,7 +104,8 @@ module.exports = (function () { features: { markitup: false, - codemirror: true + codemirror: true, + gravatar: true }, server: { diff --git a/package.json b/package.json index 34c42596..9f80ef3f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jingo", - "version": "1.8.1", + "version": "1.8.2", "description": "A nodejs based wiki engine", "author": "Claudio Cicali ", "keywords": [ diff --git a/routes/pages.js b/routes/pages.js index 33a495a6..bf3a2bc3 100644 --- a/routes/pages.js +++ b/routes/pages.js @@ -66,7 +66,7 @@ function _getPagesNew (req, res) { delete req.session.formData res.render('create', { - title: 'Jingo – Create page ' + title, + title: app.locals.config.get('application').title + ' – Create page ' + title, pageTitle: title, pageName: page ? page.wikiname : '' }) @@ -250,7 +250,7 @@ function _getPagesEdit (req, res) { delete req.session.formData res.render('edit', { - title: 'Jingo – Edit page ' + page.title, + title: app.locals.config.get('application').title + ' – Edit page ' + page.title, page: page, warning: warning }) diff --git a/views/layout.pug b/views/layout.pug index 9e968b66..5b11e651 100644 --- a/views/layout.pug +++ b/views/layout.pug @@ -3,8 +3,10 @@ include mixins/links - if (!isAjax) doctype html html - head + head(profile=hasFavicon() ? "http://www.w3.org/2005/10/profile" : "") meta(charset="utf-8") + if hasFavicon() + link(rel="icon", type=faviconMimeType, href=faviconUrl) meta(name="generator", content="jingo " + jingoVersion) meta(name="viewport", content="width=device-width, initial-scale=1") title= title @@ -22,7 +24,7 @@ include mixins/links .navbar.navbar-inverse.navbar-fixed-top .container-fluid .navbar-header - +anchor("/", appTitle).navbar-brand + +anchor("/", appBrand).navbar-brand if canSearch() form(action=`${proxyPath}/search`).navbar-form.search.navbar-left .input-group.input-group-sm.search @@ -35,7 +37,7 @@ include mixins/links +anchor('/login?destination', 'logged in')#login(title='Access login page') else p.user - if user.email && user.email != 'jingouser' + if hasGravatar() img(src=gravatar().url(user.email, {s:24})) b  #{user.displayName}  +anchor('/logout')(title='Become anonymous') @@ -62,9 +64,7 @@ include mixins/links .col-md-8.with-footer .content !{_footer} - script(src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js") - script. - window.jQuery || document.write(""); + script(src=proxyPath + "/vendor/jquery.min.js") +asset("/vendor/bootstrap/js/bootstrap.min.js") +asset("/js/app.js") script. diff --git a/views/mixins/links.pug b/views/mixins/links.pug index f1ea2888..07ed956e 100644 --- a/views/mixins/links.pug +++ b/views/mixins/links.pug @@ -1,5 +1,5 @@ -mixin anchor(url, name) - a(href=`${proxyPath}${url}`)&attributes(attributes)= name +mixin anchor(url, text) + a(href=`${proxyPath}${url}`)&attributes(attributes) !{text} block mixin asset(url) diff --git a/views/preview.pug b/views/preview.pug index 35460117..34e73fbe 100644 --- a/views/preview.pug +++ b/views/preview.pug @@ -1,3 +1 @@ - #content!=content -