Skip to content

Commit

Permalink
Version 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
claudioc committed Jul 19, 2015
1 parent 9f37eac commit c15af9b
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 25 deletions.
10 changes: 10 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -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
=================================

Expand Down
2 changes: 1 addition & 1 deletion jingo
Original file line number Diff line number Diff line change
Expand Up @@ -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 <path>', 'Specify the config file')
.option('-#, --hash-string <string>', 'Create an hash for a string')
.option('-l, --local', 'Listen on localhost only')
Expand Down
2 changes: 1 addition & 1 deletion lib/gitmech.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 !== ""; }));
});
}
Expand Down
6 changes: 4 additions & 2 deletions lib/namer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
"keywords": [
Expand Down
24 changes: 23 additions & 1 deletion public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ p.user {
color: white;
padding: 8px 0 0;
margin-bottom: 0px;
margin-right: -20px;
}

#main {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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%;
Expand Down
1 change: 1 addition & 0 deletions public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]) };
Expand Down
12 changes: 11 additions & 1 deletion routes/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down
12 changes: 10 additions & 2 deletions test/spec/namerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<p>e</p> senza schiuma")).to.equal("Caffpe-p-senza-schiuma");
expect(namer.wikify("Caff<p>e</p> 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");
});
Expand Down Expand Up @@ -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: {
Expand All @@ -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<p>e</p> senza schiuma")).to.equal("caffpe-p-senza-schiuma");
expect(namer.wikify("Caff<p>e</p> 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");
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/spec/rendererSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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("<p>a <a class=\"internal\" href=\"/wiki/Foo---Bar\">Foo / Bar</a> b</p>\n");
expect(Renderer.render(text)).to.be.equal("<p>a <a class=\"internal\" href=\"/wiki/Foo-%2B-Bar\">Foo / Bar</a> b</p>\n");
});


Expand Down
24 changes: 12 additions & 12 deletions views/layout.jade
Original file line number Diff line number Diff line change
Expand Up @@ -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&nbsp;
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 &nbsp;#{user.displayName}&nbsp;
a.logout(href='/logout', title='Become anonymous')
i.icon.ion-power
.navbar-right
if isAnonymous()
p.user You're not&nbsp;
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 &nbsp;#{user.displayName}&nbsp;
a.logout(href='/logout', title='Become anonymous')
i.icon.ion-power

.tools
block tools
Expand Down
5 changes: 5 additions & 0 deletions views/mixins/form.jade
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions views/search.jade
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@ include mixins/form

block content

#content
#content.search.show

mixin warning()

h2 #{title} for&nbsp;
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&nbsp;
b.page-param #{term}

dl.search-results
each match in matches
Expand Down

0 comments on commit c15af9b

Please sign in to comment.