From c15af9be651d96e0de57292437fff0013cbe4e99 Mon Sep 17 00:00:00 2001 From: Claudio Cicali Date: Sun, 19 Jul 2015 14:12:57 +0200 Subject: [PATCH] Version 1.3.0 --- ChangeLog.md | 10 ++++++++++ jingo | 2 +- lib/gitmech.js | 2 +- lib/namer.js | 6 ++++-- package.json | 2 +- public/css/style.css | 24 +++++++++++++++++++++++- public/js/app.js | 1 + routes/search.js | 12 +++++++++++- test/spec/namerSpec.js | 12 ++++++++++-- test/spec/rendererSpec.js | 2 +- views/layout.jade | 24 ++++++++++++------------ views/mixins/form.jade | 5 +++++ views/search.jade | 14 +++++++++++--- 13 files changed, 91 insertions(+), 25 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 6ab90188..686e5323 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,13 @@ +Version 1.3.0, July 19th, 2015 +================================= + +- Fixes #80 – Crash when a title starts with / +- Fixes #87 – Better management of slashes in titles (replaced by "+") +- Adds the search form to the search pages, so that we could... +- ...show the login option on mobile (removes the search field) because we... +- ...added the search icon to the toolbox +- Merges #88 and #89 + Version 1.2.12, June 28th, 2015 ================================= diff --git a/jingo b/jingo index 222a09d4..ec26247f 100755 --- a/jingo +++ b/jingo @@ -17,7 +17,7 @@ var program = require('commander'), global.Git = require('./lib/gitmech'); -program.version('1.2.12') +program.version('1.3.0') .option('-c, --config ', 'Specify the config file') .option('-#, --hash-string ', 'Create an hash for a string') .option('-l, --local', 'Listen on localhost only') diff --git a/lib/gitmech.js b/lib/gitmech.js index 94bb6d97..973b84f8 100644 --- a/lib/gitmech.js +++ b/lib/gitmech.js @@ -381,7 +381,7 @@ var gitMech = { }, ls: function(pattern, callback) { - gitExec([ "ls-tree", "--name-only", "-r", "HEAD", docSubdir + pattern ], function(err, data) { + gitExec([ "ls-tree", "--name-only", "-r", "HEAD", "--", docSubdir + pattern ], function(err, data) { callback(null, data.toString().split("\n").filter(function(v) { return v !== ""; })); }); } diff --git a/lib/namer.js b/lib/namer.js index f9cb7504..bd618cc9 100644 --- a/lib/namer.js +++ b/lib/namer.js @@ -31,8 +31,8 @@ Namer.prototype.wikify = function (str) { // Replace < and > with '' (Gollum replaces it with '-') ret = ret.replace(/[<>]/g, ''); - // Replace / with '-' (Gollum replaces it with '') - ret = ret.replace(/\//g, '-'); + // Replace / with '+' (Gollum replaces it with '') + ret = ret.replace(/\//g, '+'); if (pc.title.asciiOnly) { ret = iconv.convert(ret) @@ -66,6 +66,8 @@ Namer.prototype.unwikify = function (str) { ret = ret.replace(new RegExp(wsReplacement, "g"), " "); + ret = ret.replace(/\+/g, "/"); + if (pc.title.lowercase) { // "something really hot" => "Something Really Hot" ret = ret.split(/\b/).map(function (v) { diff --git a/package.json b/package.json index 14ed2fe6..70efe809 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jingo", - "version": "1.2.12", + "version": "1.3.0", "description": "A nodejs based wiki engine (sort of Gollum port)", "author": "Claudio Cicali ", "keywords": [ diff --git a/public/css/style.css b/public/css/style.css index d5be63b5..21f11364 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -25,6 +25,7 @@ p.user { color: white; padding: 8px 0 0; margin-bottom: 0px; + margin-right: -20px; } #main { @@ -208,13 +209,21 @@ hr { /* Overrides Bootstrap */ +.navbar-right { + float: right; +} + .navbar-form { padding: 0; margin-top: 5px; } +.navbar-form.search { + display: none; +} + .navbar-header { - min-width: 50%; + width: 100%; } .navbar-brand { @@ -516,6 +525,10 @@ input#pageTitle { color: #aaa; } +.search .search-form { + margin-bottom: 20px; +} + .with-sidebar { background-color: rgba(255,255,255,0.5); padding: 10px; @@ -599,13 +612,22 @@ a.btn-auth:hover { padding-top: 60px; } + p.user { + margin-right: auto; + } + #content { padding: 40px 25px; } + .navbar-form.search { + display: block; + } + .tools { right: 280px; } + .tools-handle { top: 41px; left: 60%; diff --git a/public/js/app.js b/public/js/app.js index bc94de06..5025756f 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -13,6 +13,7 @@ qs, hl = null; if (location.search !== "") { + $("input[name=term]").focus(); qs = $.map(location.search.substr(1).split("&"), function(kv) { kv = kv.split("="); return { k: kv[0], v: decodeURIComponent(kv[1]) }; diff --git a/routes/search.js b/routes/search.js index 4df49a30..e681706f 100644 --- a/routes/search.js +++ b/routes/search.js @@ -12,7 +12,17 @@ function _getSearch(req, res) { record; res.locals.matches = []; - res.locals.term = req.query.term.trim(); + + if (req.query.term) { + res.locals.term = req.query.term.trim(); + } else { + res.locals.term = ""; + } + + if (res.locals.term.length == 0) { + renderResults(); + return; + } if (res.locals.term.length < 2) { diff --git a/test/spec/namerSpec.js b/test/spec/namerSpec.js index db5e0ec3..c9876737 100644 --- a/test/spec/namerSpec.js +++ b/test/spec/namerSpec.js @@ -37,7 +37,7 @@ describe("namer", function() { expect(namer.wikify(" nell - aria ")).to.equal("nell---aria"); expect(namer.wikify("Caffé")).to.equal("Caffé"); expect(namer.wikify("Caffé corretto!")).to.equal("Caffé-corretto!"); - expect(namer.wikify("Caff

e

senza schiuma")).to.equal("Caffpe-p-senza-schiuma"); + expect(namer.wikify("Caff

e

senza schiuma")).to.equal("Caffpe+p-senza-schiuma"); expect(namer.wikify("Per favore: nessun, dico; E un punto...")).to.equal("Per-favore:-nessun,-dico;-E-un-punto..."); expect(namer.wikify("prova.md")).to.equal("prova.md"); }); @@ -77,6 +77,14 @@ describe("namer", function() { expect(namer.wikify("È@@@É")).to.equal("è@@@é"); }); + it ("should wikify a string with slashes", function() { + expect(namer.wikify("/1/")).to.equal("+1+"); + expect(namer.wikify("1/")).to.equal("1+"); + expect(namer.wikify("/1")).to.equal("+1"); + expect(namer.wikify("1//")).to.equal("1++"); + expect(namer.wikify("///")).to.equal("+++"); + }); + it ("should wikify a string with the defaults of Jingo < 1.0", function() { namer.configOverride({ pages: { @@ -96,7 +104,7 @@ describe("namer", function() { expect(namer.wikify(" nell - aria ")).to.equal("nell---aria"); expect(namer.wikify("Caffé")).to.equal("caffe"); expect(namer.wikify("Caffé corretto!")).to.equal("caffe-corretto"); - expect(namer.wikify("Caff

e

senza schiuma")).to.equal("caffpe-p-senza-schiuma"); + expect(namer.wikify("Caff

e

senza schiuma")).to.equal("caffpep-senza-schiuma"); expect(namer.wikify("Per favore: nessun, dico; E un punto...")).to.equal("per-favore-nessun-dico-e-un-punto"); }); }); diff --git a/test/spec/rendererSpec.js b/test/spec/rendererSpec.js index f84a92c5..1f5478c3 100644 --- a/test/spec/rendererSpec.js +++ b/test/spec/rendererSpec.js @@ -35,7 +35,7 @@ describe ("Renderer", function() { it ("should render bracket tags7", function() { var text = "a [[Foo / Bar]] b"; - expect(Renderer.render(text)).to.be.equal("

a Foo / Bar b

\n"); + expect(Renderer.render(text)).to.be.equal("

a Foo / Bar b

\n"); }); diff --git a/views/layout.jade b/views/layout.jade index 510e1edc..a72ab6ca 100644 --- a/views/layout.jade +++ b/views/layout.jade @@ -21,22 +21,22 @@ html .navbar-header a(href="/").navbar-brand #{appTitle} if canSearch() - form(action="/search").navbar-form.navbar-left + form(action="/search").navbar-form.search.navbar-left .input-group.input-group-sm.search input.form-control(type="text", value="#{term_ph}", data-i-search-input="true",name="term",placeholder="Search the wiki") span.input-group-btn button.btn.btn-primary(type="submit") Search - .navbar-collapse.collapse - if isAnonymous() - p.user.navbar-right You're not  - a(id='login',href='/login?destination', title='Access login page') logged in - else - p.user.navbar-right - if user.email - img(src=gravatar().url("#{user.email}", {s:24})) - b  #{user.displayName}  - a.logout(href='/logout', title='Become anonymous') - i.icon.ion-power + .navbar-right + if isAnonymous() + p.user You're not  + a(id='login',href='/login?destination', title='Access login page') logged in + else + p.user + if user.email + img(src=gravatar().url("#{user.email}", {s:24})) + b  #{user.displayName}  + a.logout(href='/logout', title='Become anonymous') + i.icon.ion-power .tools block tools diff --git a/views/mixins/form.jade b/views/mixins/form.jade index 41143ded..a97e0b52 100644 --- a/views/mixins/form.jade +++ b/views/mixins/form.jade @@ -25,6 +25,11 @@ mixin tools(action, pageName) a(href="/wiki", title="All pages").btn.btn-sm.btn-default i.icon.ion-grid + if canSearch() + li + a(href="/search", title="Search through the pages").btn.btn-sm.btn-default + i.icon.ion-search + if action == 'history' ul li diff --git a/views/search.jade b/views/search.jade index 82cf2ef1..bbe428dc 100644 --- a/views/search.jade +++ b/views/search.jade @@ -4,12 +4,20 @@ include mixins/form block content - #content + #content.search.show mixin warning() - h2 #{title} for  - b.page-param #{term} + if canSearch() + form(action="/search").search-form + .input-group.input-group-sm + input.form-control(type="text", value="#{term_ph}", data-i-search-input="true",name="term",placeholder="Search the wiki") + span.input-group-btn + button.btn.btn-primary(type="submit") Search + + if (term) + h2 #{title} for  + b.page-param #{term} dl.search-results each match in matches