Skip to content

Commit

Permalink
Fixes #99 and #95
Browse files Browse the repository at this point in the history
  • Loading branch information
claudioc committed Oct 4, 2015
1 parent 32c0e9f commit 5d56a15
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 35 deletions.
7 changes: 7 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Version 1.3.1, October 4th, 2015
=================================

- Upgrades CodeMirror to 5.7
- Uses _github flavoured markdown_ as the default CodeMirror mode (Closes #99)
- Uses github username if the displayName is empty (Closes #95)

Version 1.3.0, July 19th, 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.3.0')
program.version('1.3.1')
.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
11 changes: 6 additions & 5 deletions lib/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ var tools = {

isAuthorized: function(email, pattern) {

if (!email || email.trim() === "") {
// Special case where the email is not returned by the backend authorization system
if (email == 'jingouser') {
return true;
}

if (!email || !email.match(/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i)) {
return false;
}

if (!pattern || pattern.trim() === "") {
return true;
}

if (!email.match(/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i)) {
return false;
}

var tests = pattern.split(",").map(function(str) { return str.trim(); });
var expr;
for (var i=0; i < tests.length; i++) {
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.3.0",
"version": "1.3.1",
"description": "A nodejs based wiki engine (sort of Gollum port)",
"author": "Claudio Cicali <[email protected]>",
"keywords": [
Expand Down
25 changes: 25 additions & 0 deletions public/css/codemirror-ext.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#content .CodeMirror.CodeMirror-fullscreen {
height: auto;
}

#content .CodeMirror-fullscreen {
margin-top: 40px;
}

#content .CodeMirror {
border: 1px solid #ccc;
height: 600px;
border-radius: 4px;
line-height: 1.6;
}

#content .CodeMirror .CodeMirror-gutter-wrapper {
position: absolute;
}

#content .CodeMirror-focused {
border-color: rgba(82,168,236,0.8);
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);
-moz-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);
box-shadow: inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);
}
22 changes: 0 additions & 22 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -468,28 +468,6 @@ ul.doc-list > li .message {
z-index: 10;
}

#content .CodeMirror {
border: 1px solid #ccc;
height: 600px;
border-radius: 4px;
line-height: 1.6;
}

#content .CodeMirror.CodeMirror-fullscreen {
height: auto;
}

#content .CodeMirror-focused {
border-color: rgba(82,168,236,0.8);
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);
-moz-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);
box-shadow: inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);
}

#content .CodeMirror-fullscreen {
margin-top: 40px;
}

input#pageTitle {
font-weight: bold;
font-size: 130%;
Expand Down
24 changes: 20 additions & 4 deletions public/vendor/codemirror/codemirror.min.js

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,20 @@ passport.serializeUser(function(user, done) {
});

passport.deserializeUser(function(user, done) {

if (user.emails && user.emails.length > 0) { // Google
user.email = user.emails[0].value;
delete user.emails;
}

if (!user.displayName && user.username) {
user.displayName = user.username;
}

if (!user.email) {
user.email = 'jingouser';
}

user.asGitAuthor = user.displayName + " <" + user.email + ">";
done(undefined, user);
});
Expand All @@ -142,7 +152,9 @@ function _getAuthDone(req, res) {
return;
}

if (!auth.alone.used && !auth.local.used && !tools.isAuthorized(res.locals.user.email, app.locals.config.get("authorization").validMatches)) {
if (!auth.alone.used &&
!auth.local.used &&
!tools.isAuthorized(res.locals.user.email, app.locals.config.get("authorization").validMatches)) {
req.logout();
req.session = null;
res.statusCode = 403;
Expand Down
4 changes: 4 additions & 0 deletions test/spec/toolsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ describe ("Tools", function() {
expect(Tools.isAuthorized(null)).to.equal(false);
});

it ("should authorize with 'jingouser'", function() {
expect(Tools.isAuthorized("jingouser")).to.equal(true);
});

it ("should authorize with empty pattern", function() {
expect(Tools.isAuthorized("[email protected]")).to.equal(true);
expect(Tools.isAuthorized("[email protected]", null)).to.equal(true);
Expand Down
3 changes: 2 additions & 1 deletion views/mixins/form.jade
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ mixin featuresStylesheets()
link(rel="stylesheet", type="text/css", href="/vendor/markitup/skins/simple/style.css")
link(rel="stylesheet", type="text/css", href="/vendor/markitup/sets/markdown/style.css")
if hasFeature('codemirror')
link(rel="stylesheet", type="text/css", href="/css/codemirror-ext.css")
link(rel="stylesheet", type="text/css", href="/vendor/codemirror/codemirror.css")
link(rel="stylesheet", type="text/css", href="/vendor/codemirror/fullscreen.css")

Expand All @@ -74,7 +75,7 @@ mixin featuresJavaScripts()
script.
Jingo.cmInstance = CodeMirror.fromTextArea(document.getElementById("editor"), {
lineNumbers: true,
mode: 'markdown',
mode: 'gfm',
matchBrackets: true,
lineWrapping: true,
extraKeys: {
Expand Down

0 comments on commit 5d56a15

Please sign in to comment.