Skip to content

Commit

Permalink
Renamed mountPath to proxyPath
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudio Cicali committed Dec 22, 2015
1 parent db58ad7 commit 3605b82
Show file tree
Hide file tree
Showing 18 changed files with 201 additions and 168 deletions.
7 changes: 3 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ rules:
wrap-iife: 2

globals:
define: true
require: true
requirejs: true
process: true
require: true
module: true
console: true
__dirname: true
Buffer: true
Git: true
global: true
jQuery: true,
global: true
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ Configuration options reference

####application.proxyPath

If you want jingo to work "behind" another website (for example in a /wiki directory of already existing intranet), you need to configure it to be aware of that so that it can write all the outbound URLs accordingly. Use this option to pass it the name of the directory that you've configured in your proxy_pass option in nginx or apache. See also an nginx example in the /etc directory of the jingo source distribution.
If you want jingo to work "behind" another website (for example in a /wiki directory of an already existing intranet), you need to configure it to be aware of that situation so that it can write all the outbound URLs accordingly. Use this option to pass it the name of the directory that you've configured in your proxy_pass option in nginx or apache. See also an nginx example in the /etc directory of the jingo source distribution.

Please note that jingo won't work correctly if this option is activated.

####authentication.staticWhitelist

Expand Down
22 changes: 22 additions & 0 deletions etc/nginx_api.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
daemon off;
error_log /dev/stdout info;

events {
worker_connections 1024;
}

http {
server {
listen 8080;

server_name jingo.dev;

location / {

root /Users/claudioc/Documents/jingo;
}
}
}



8 changes: 3 additions & 5 deletions lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,8 @@ module.exports.initialize = function (config) {
get appTitle() {
return config.get("application").title;
},
get mountPath() {
return config.getMountPath();
},
get staticPath() {
return config.getStaticPath();
get proxyPath() {
return config.getProxyPath();
},
get jingoVersion() {
return program.version();
Expand Down Expand Up @@ -138,6 +135,7 @@ module.exports.initialize = function (config) {

app.set("views", __dirname + "/../views");
app.set("view engine", "jade");
app.set("x-powered-by", false);

app.use(function (req, res, next) {

Expand Down
51 changes: 26 additions & 25 deletions lib/components.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var fs = require('fs'),
models = require("./models"),
Promise = require("bluebird"),
renderer = require('./renderer'),
Configurable = require("./configurable");
var fs = require("fs"),
models = require("./models"),
Promiser = require("bluebird"),
renderer = require("./renderer"),
Configurable = require("./configurable");

models.use(Git);

Expand All @@ -17,20 +17,21 @@ function Component(name, file) {

Component.prototype = Object.create(Configurable.prototype);

Component.prototype.exists = function() {
Component.prototype.exists = function () {

this.file = this.getConfig().customizations[this.name];

// The user can provide footer and sidebar without extension,
// so we add a default '.md' in that case. This test is 'good enough' for Jingo
if (this.file.indexOf('.') === -1) {
this.file += '.md';
if (this.file.indexOf(".") === -1) {
this.file += ".md";
}

if ((Date.now() - this.timer) > 30000) {
this.timer = Date.now();
this.cache = null;
} else {
}
else {
return this._exists;
}

Expand All @@ -43,7 +44,7 @@ Component.prototype.exists = function() {
return this._exists;
};

Component.prototype.fetchAsync = function(cb) {
Component.prototype.fetchAsync = function (cb) {

if (!this.exists()) {
cb.call(null, null);
Expand All @@ -57,12 +58,12 @@ Component.prototype.fetchAsync = function(cb) {

var page = new models.Page(this.getConfig().customizations[this.name]);

page.fetch().then(function() {
page.fetch().then(function () {
cb.call(null, null, this.cache = renderer.render(page.content));
});
};

Component.prototype.fetchSync = function() {
Component.prototype.fetchSync = function () {

if (!this.exists()) {
return null;
Expand All @@ -75,7 +76,7 @@ Component.prototype.fetchSync = function() {
return this.cache;
};

module.exports = (function() {
module.exports = (function () {

var components = [
new Component("sidebar"),
Expand All @@ -85,54 +86,54 @@ module.exports = (function() {
];

function find(name) {
return components.filter(function(c) {
return components.filter(function (c) {
return c.name == name;
})[0];
}

var publicMethods = {

expire: function(name) {
expire: function (name) {
find(name).cache = null;
},

hasSidebar: function() {
hasSidebar: function () {
return find("sidebar").exists();
},

hasFooter: function() {
hasFooter: function () {
return find("footer").exists();
},

hasCustomStyle: function() {
hasCustomStyle: function () {
return find("style").exists();
},

hasCustomScript: function() {
hasCustomScript: function () {
return find("script").exists();
},

sidebar: function(cb) {
sidebar: function (cb) {
find("sidebar").fetchAsync(cb);
},

footer: function(cb) {
footer: function (cb) {
find("footer").fetchAsync(cb);
},

customStyle: function() {
customStyle: function () {
// Read sync because this info is needed by the layout
return find("style").fetchSync();
},

customScript: function() {
customScript: function () {
// Read sync because this info is needed by the layout
return find("script").fetchSync();
}
};

publicMethods.sidebarAsync = Promise.promisify(publicMethods.sidebar, publicMethods);
publicMethods.footerAsync = Promise.promisify(publicMethods.footer, publicMethods);
publicMethods.sidebarAsync = Promiser.promisify(publicMethods.sidebar, publicMethods);
publicMethods.footerAsync = Promiser.promisify(publicMethods.footer, publicMethods);

return publicMethods;

Expand Down
27 changes: 5 additions & 22 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ module.exports = (function () {
pedanticMarkdown: true,
gfmBreaks: true,
staticWhitelist: "/\\.png$/i, /\\.jpg$/i, /\\.gif$/i",
mountPath: "",
staticPath: ""
proxyPath: ""
},

authentication: {
Expand Down Expand Up @@ -233,29 +232,13 @@ module.exports = (function () {
return config[key];
},

getMountPath: function () {
getProxyPath: function () {

var path = config.application.mountPath.trim();
var path = config.application.proxyPath.trim();

// @TODO make sure the path is something that makes sense (?)
if (path.length == 0) {
return "/";
}

if (path.charAt(0) != "/") {
path = "/" + path;
}

return path;
},

getStaticPath: function () {

var path = config.application.staticPath.trim();

// @TODO make sure the path is something that makes sense (?)
if (path.length == 0) {
return "/";
if (path.length == 0 || path == "/") {
return "";
}

if (path.charAt(0) != "/") {
Expand Down
Loading

0 comments on commit 3605b82

Please sign in to comment.