Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

docpad-plugin-cleanurls

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

docpad-plugin-cleanurls - npm Package Compare versions

Comparing version 2.2.5 to 2.3.0

out/cleanurls.test.js

5

History.md
## History
- v2.3.0 January 4, 2013
- Now supports static environments by changing the document's `outPath` to that of a directory with an `index.html` file inside.
- Updated tests to also check the directory output
- Updated coffeescript devDependency to v1.4.0
- v2.2.5 October 8, 2012

@@ -4,0 +9,0 @@ - Fixed plugin name (`cleanUrls` to `cleanurls`)

107

out/cleanurls.plugin.js

@@ -1,56 +0,69 @@

// Generated by CoffeeScript 1.3.3
(function() {
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
// Generated by CoffeeScript 1.4.0
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
module.exports = function(BasePlugin) {
var CleanUrlsPlugin;
return CleanUrlsPlugin = (function(_super) {
module.exports = function(BasePlugin) {
var CleanUrlsPlugin;
return CleanUrlsPlugin = (function(_super) {
__extends(CleanUrlsPlugin, _super);
__extends(CleanUrlsPlugin, _super);
function CleanUrlsPlugin() {
return CleanUrlsPlugin.__super__.constructor.apply(this, arguments);
}
function CleanUrlsPlugin() {
this.cleanUrlsForDocument = __bind(this.cleanUrlsForDocument, this);
return CleanUrlsPlugin.__super__.constructor.apply(this, arguments);
}
CleanUrlsPlugin.prototype.name = 'cleanurls';
CleanUrlsPlugin.prototype.name = 'cleanurls';
CleanUrlsPlugin.prototype.config = {
environments: {
"static": {
enabled: false
}
}
};
CleanUrlsPlugin.prototype.pathToUrl = function(path) {
var slashRegex;
slashRegex = /\\/g;
return path.replace(slashRegex, '/');
};
CleanUrlsPlugin.prototype.cleanURLize = function(document) {
var documentUrl, relativeBaseUrl, relativeDirUrl, slashRegex;
documentUrl = document.get('url');
slashRegex = /\\/g;
if (/\.html$/i.test(documentUrl)) {
relativeBaseUrl = '/' + document.get('relativeBase').replace(slashRegex, '/');
document.setUrl(relativeBaseUrl);
}
if (/index\.html$/i.test(documentUrl)) {
relativeDirUrl = '/' + document.get('relativeDirPath').replace(slashRegex, '/');
document.setUrl(relativeDirUrl);
}
return document;
};
CleanUrlsPlugin.prototype.cleanUrlsForDocument = function(document) {
var documentUrl, outDirPath, outFilename, outPath, pathUtil, relativeBaseUrl, relativeDirUrl, relativeOutDirPath, relativeOutPath, set;
pathUtil = require('path');
documentUrl = document.get('url');
if (__indexOf.call(this.docpad.getEnvironments(), 'static') >= 0 && document.get('outFilename') !== 'index.html' && document.get('outPath')) {
outFilename = 'index.html';
outPath = document.get('outPath').replace(/\.html$/, "/" + outFilename);
outDirPath = pathUtil.dirname(outPath);
relativeOutPath = document.get('relativeOutPath').replace(/\.html$/, "/" + outFilename);
relativeOutDirPath = pathUtil.dirname(relativeOutPath);
set = {
outFilename: outFilename,
outPath: outPath,
outDirPath: outDirPath,
relativeOutPath: relativeOutPath,
relativeOutDirPath: relativeOutDirPath
};
document.set(set);
}
if (/\.html$/i.test(documentUrl)) {
relativeBaseUrl = '/' + this.pathToUrl(document.get('relativeBase'));
document.setUrl(relativeBaseUrl);
}
if (/index\.html$/i.test(documentUrl)) {
relativeDirUrl = '/' + this.pathToUrl(document.get('relativeDirPath'));
document.setUrl(relativeDirUrl);
}
return document;
};
CleanUrlsPlugin.prototype.extendCollections = function(opts) {
var database, docpad;
docpad = this.docpad;
database = docpad.getCollection('html');
docpad.log('debug', 'Applying clean urls');
database.on('add change', this.cleanURLize);
docpad.log('debug', 'Applied clean urls');
return true;
};
CleanUrlsPlugin.prototype.extendCollections = function(opts) {
var database, docpad;
docpad = this.docpad;
database = docpad.getCollection('html');
docpad.log('debug', 'Applying clean urls');
database.on('add change', this.cleanUrlsForDocument);
docpad.log('debug', 'Applied clean urls');
return true;
};
return CleanUrlsPlugin;
return CleanUrlsPlugin;
})(BasePlugin);
};
}).call(this);
})(BasePlugin);
};

@@ -1,55 +0,54 @@

// Generated by CoffeeScript 1.3.3
(function() {
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
// Generated by CoffeeScript 1.4.0
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
module.exports = function(testers) {
var MyTester;
return MyTester = (function(_super) {
module.exports = function(testers) {
var MyTester;
return MyTester = (function(_super) {
__extends(MyTester, _super);
__extends(MyTester, _super);
function MyTester() {
return MyTester.__super__.constructor.apply(this, arguments);
}
function MyTester() {
return MyTester.__super__.constructor.apply(this, arguments);
}
MyTester.prototype.testServer = function(next) {
var expect, fsUtil, request, tester;
tester = this;
expect = testers.expect;
request = testers.request;
fsUtil = require('fs');
MyTester.__super__.testServer.apply(this, arguments);
return this.suite('cleanurls', function(suite, test) {
var baseUrl, filePath, fileUrl, outExpectedPath;
baseUrl = "http://localhost:" + tester.docpad.config.port;
outExpectedPath = tester.config.outExpectedPath;
fileUrl = "" + baseUrl + "/welcome";
filePath = "" + outExpectedPath + "/welcome.html";
return test('server should serve URLs without an extension', function(done) {
return request(fileUrl, function(err, response, actual) {
var actualStr;
MyTester.prototype.testGenerate = testers.RendererTester.prototype.testGenerate;
MyTester.prototype.testServer = function(next) {
var expect, fsUtil, request, tester;
tester = this;
expect = testers.expect;
request = testers.request;
fsUtil = require('fs');
MyTester.__super__.testServer.apply(this, arguments);
return this.suite('cleanurls', function(suite, test) {
var baseUrl, filePath, fileUrl, outExpectedPath;
baseUrl = "http://localhost:" + tester.docpad.config.port;
outExpectedPath = tester.config.outExpectedPath;
fileUrl = "" + baseUrl + "/welcome";
filePath = "" + outExpectedPath + "/welcome.html";
return test('server should serve URLs without an extension', function(done) {
return request(fileUrl, function(err, response, actual) {
var actualStr;
if (err) {
return done(err);
}
actualStr = actual.toString();
return fsUtil.readFile(filePath, function(err, expected) {
var expectedStr;
if (err) {
return done(err);
}
actualStr = actual.toString();
return fsUtil.readFile(filePath, function(err, expected) {
var expectedStr;
if (err) {
return done(err);
}
expectedStr = expected.toString();
expect(actualStr).to.equal(expectedStr);
return done();
});
expectedStr = expected.toString();
expect(actualStr).to.equal(expectedStr);
return done();
});
});
});
};
});
};
return MyTester;
return MyTester;
})(testers.ServerTester);
};
}).call(this);
})(testers.ServerTester);
};
{
"name": "docpad-plugin-cleanurls",
"version": "2.2.5",
"version": "2.3.0",
"description": "Adds support for clean urls to DocPad",

@@ -27,13 +27,13 @@ "homepage": "http://docpad.org/plugin/cleanurls",

"engines" : {
"node": ">=0.4.0",
"docpad": ">=6.3.0 <7.0.0"
"node": ">=0.4",
"docpad": ">=6.3 <7"
},
"dependencies": {},
"devDependencies": {
"coffee-script": "1.3.x"
"coffee-script": "1.4.x"
},
"main": "./out/cleanurls.plugin.js",
"scripts": {
"test": "node ./test/cleanurls.test.js"
"test": "node ./out/cleanurls.test.js"
}
}

@@ -12,2 +12,19 @@ # Clean URLs Plugin for DocPad

## Usage/Configure
For non-static environments we will set the document's url to it's clean url. This means that our document is still outputted to the same place on the file system as the clean url stuff is handled by the web server instead. This is the default.
For static environments we will set the document's `outPath` to that of a directory with a `index.html` file (e.g. `pages/welcome.html` will be outputted to `pages/welcome/index.html`). You can tell docpad to use the static environment by adding `--env static` to the end of your DocPad command, so to perform a one off generation for a static environment you'll run `docpad generate --env static`, to perform your usual generate, serve and watch it'll be `docpad run --env static`.
If you'd like to disable the static mode when working in the static environment you can add the following to your [docpad configuration file](http://docpad.org/docs/config).
``` coffee
environments:
static:
plugins:
cleanurls:
enabled: false
```
## History

@@ -19,3 +36,3 @@ You can discover the history inside the `History.md` file

Licensed under the incredibly [permissive](http://en.wikipedia.org/wiki/Permissive_free_software_licence) [MIT License](http://creativecommons.org/licenses/MIT/)
<br/>Copyright &copy; 2012 [Bevry Pty Ltd](http://bevry.me)
<br/>Copyright &copy; 2012+ [Bevry Pty Ltd](http://bevry.me)
<br/>Copyright &copy; 2011 [Benjamin Lupton](http://balupton.com)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc