Skip to content

Commit 8432247

Browse files
authored
Small batches of fixes (#219)
1 parent 52ecc0d commit 8432247

File tree

9 files changed

+64
-18
lines changed

9 files changed

+64
-18
lines changed

ChangeLog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
Version 1.8.2, May 20th, 2017
2+
==================================
3+
4+
- Closes #152 (You can now disable Gravatar)
5+
- Closes #129 (Adds logo support)
6+
- Fixes #216 ()
7+
- Always uses local jQuery and not Google's
8+
- Adds favicon support
9+
110
Version 1.8.1, May 17th, 2017
211
==================================
312

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,14 @@ Configuration options reference
207207

208208
This will be showed on the upper left corner of all the pages, in the main toolbar
209209

210+
#### application.logo (string: "")
211+
212+
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)
213+
214+
#### application.favicon (string: "")
215+
216+
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)
217+
210218
#### application.repository (string: "")
211219

212220
Absolute path for your documents repository (mandatory).
@@ -337,13 +345,15 @@ Configuration options reference
337345

338346
#### features.markitup (boolean: false)
339347

340-
Whether to enable Markitup or not
348+
DEPRECATED: markitup support has been removed as of version 1.8.0
341349

342350
#### features.codemirror (boolean: true)
343351

344352
Whether to enable Codemirror or not.
345353

346-
Please note that you cannot enable both editors at the same time.
354+
#### features.gravatar (boolean: true)
355+
356+
Whether to enable gravatar support or not
347357

348358
#### server.hostname
349359

lib/app.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,13 @@ module.exports.initialize = function (config) {
5353
get user () {
5454
return req.user
5555
},
56-
get appTitle () {
57-
return config.get('application').title
56+
get appBrand () {
57+
var appTitle = config.get('application').title || ''
58+
var appLogo = config.get('application').logo || ''
59+
if (appLogo !== '') {
60+
appLogo = '<img src="' + appLogo + '" alt="Logo">'
61+
}
62+
return appLogo + ' ' + appTitle
5863
},
5964
get proxyPath () {
6065
return config.getProxyPath()
@@ -65,6 +70,21 @@ module.exports.initialize = function (config) {
6570
get authentication () {
6671
return config.get('authentication')
6772
},
73+
get faviconMimeType () {
74+
if (!this.hasFavicon()) {
75+
return ''
76+
}
77+
var favicon = config.get('application').favicon.trim()
78+
var match = favicon.match(/\.([0-9a-z]+)$/i)
79+
return match ? 'image/' + match[1] : 'image/png'
80+
},
81+
get faviconUrl () {
82+
if (!this.hasFavicon()) {
83+
return ''
84+
}
85+
return config.get('application').favicon.trim()
86+
},
87+
6888
isAnonymous: function () {
6989
return !req.user
7090
},
@@ -74,6 +94,12 @@ module.exports.initialize = function (config) {
7494
gravatar: function (email) {
7595
return gravatar
7696
},
97+
hasGravatar: function () {
98+
return config.get('features').gravatar && req.user && req.user.email && req.user.email !== 'jingouser'
99+
},
100+
hasFavicon: function () {
101+
return config.get('application').favicon && config.get('application').favicon.trim().length > 0
102+
},
77103
get isAjax () {
78104
return req.headers['x-requested-with'] && req.headers['x-requested-with'] === 'XMLHttpRequest'
79105
}

lib/config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ module.exports = (function () {
4747

4848
application: {
4949
title: 'Jingo',
50+
logo: '',
51+
favicon: '',
5052
repository: '',
5153
docSubdir: '',
5254
remote: '',
@@ -102,7 +104,8 @@ module.exports = (function () {
102104

103105
features: {
104106
markitup: false,
105-
codemirror: true
107+
codemirror: true,
108+
gravatar: true
106109
},
107110

108111
server: {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jingo",
3-
"version": "1.8.1",
3+
"version": "1.8.2",
44
"description": "A nodejs based wiki engine",
55
"author": "Claudio Cicali <[email protected]>",
66
"keywords": [

routes/pages.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function _getPagesNew (req, res) {
6666
delete req.session.formData
6767

6868
res.render('create', {
69-
title: 'Jingo – Create page ' + title,
69+
title: app.locals.config.get('application').title + ' – Create page ' + title,
7070
pageTitle: title,
7171
pageName: page ? page.wikiname : ''
7272
})
@@ -250,7 +250,7 @@ function _getPagesEdit (req, res) {
250250
delete req.session.formData
251251

252252
res.render('edit', {
253-
title: 'Jingo – Edit page ' + page.title,
253+
title: app.locals.config.get('application').title + ' – Edit page ' + page.title,
254254
page: page,
255255
warning: warning
256256
})

views/layout.pug

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ include mixins/links
33
- if (!isAjax)
44
doctype html
55
html
6-
head
6+
head(profile=hasFavicon() ? "http://www.w3.org/2005/10/profile" : "")
77
meta(charset="utf-8")
8+
if hasFavicon()
9+
link(rel="icon", type=faviconMimeType, href=faviconUrl)
810
meta(name="generator", content="jingo " + jingoVersion)
911
meta(name="viewport", content="width=device-width, initial-scale=1")
1012
title= title
@@ -22,7 +24,7 @@ include mixins/links
2224
.navbar.navbar-inverse.navbar-fixed-top
2325
.container-fluid
2426
.navbar-header
25-
+anchor("/", appTitle).navbar-brand
27+
+anchor("/", appBrand).navbar-brand
2628
if canSearch()
2729
form(action=`${proxyPath}/search`).navbar-form.search.navbar-left
2830
.input-group.input-group-sm.search
@@ -35,7 +37,7 @@ include mixins/links
3537
+anchor('/login?destination', 'logged in')#login(title='Access login page')
3638
else
3739
p.user
38-
if user.email && user.email != 'jingouser'
40+
if hasGravatar()
3941
img(src=gravatar().url(user.email, {s:24}))
4042
b &nbsp;#{user.displayName}&nbsp;
4143
+anchor('/logout')(title='Become anonymous')
@@ -62,9 +64,7 @@ include mixins/links
6264
.col-md-8.with-footer
6365
.content !{_footer}
6466

65-
script(src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js")
66-
script.
67-
window.jQuery || document.write("<sc" + "ript src='#{proxyPath}/vendor/jquery.min.js'></scr" + "ipt>");
67+
script(src=proxyPath + "/vendor/jquery.min.js")
6868
+asset("/vendor/bootstrap/js/bootstrap.min.js")
6969
+asset("/js/app.js")
7070
script.

views/mixins/links.pug

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
mixin anchor(url, name)
2-
a(href=`${proxyPath}${url}`)&attributes(attributes)= name
1+
mixin anchor(url, text)
2+
a(href=`${proxyPath}${url}`)&attributes(attributes) !{text}
33
block
44

55
mixin asset(url)

views/preview.pug

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
21
#content!=content
3-

0 commit comments

Comments
 (0)