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.5.1 to 2.5.2

History.md

14

LICENSE.md

@@ -1,6 +0,10 @@

# The MIT License
Copyright &copy; 2012+ [Bevry Pty Ltd](http://bevry.me) <us@bevry.me>
<br/>Copyright &copy; 2011 [Benjamin Lupton](http://balupton.com) <b@lupton.cc>
<!-- LICENSEFILE/ -->
# License
Copyright &copy; 2012+ Bevry Pty Ltd <us@bevry.me> (http://bevry.me)
<br/>Copyright &copy; 2011 Benjamin Lupton <b@lupton.cc> (http://balupton.com)
## The MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

@@ -11,1 +15,5 @@

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
<!-- /LICENSEFILE -->
// Generated by CoffeeScript 1.6.3
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; };
(function() {
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, _ref;
return CleanUrlsPlugin = (function(_super) {
__extends(CleanUrlsPlugin, _super);
module.exports = function(BasePlugin) {
var CleanUrlsPlugin, _ref;
return CleanUrlsPlugin = (function(_super) {
__extends(CleanUrlsPlugin, _super);
function CleanUrlsPlugin() {
this.cleanUrlsForDocument = __bind(this.cleanUrlsForDocument, this);
_ref = CleanUrlsPlugin.__super__.constructor.apply(this, arguments);
return _ref;
}
function CleanUrlsPlugin() {
this.cleanUrlsForDocument = __bind(this.cleanUrlsForDocument, this);
_ref = CleanUrlsPlugin.__super__.constructor.apply(this, arguments);
return _ref;
}
CleanUrlsPlugin.prototype.name = 'cleanurls';
CleanUrlsPlugin.prototype.name = 'cleanurls';
CleanUrlsPlugin.prototype.config = {
getRedirectTemplate: function(document) {
return "<!DOCTYPE html>\n<html>\n <head>\n <title>" + (document.get('title') || 'Redirect') + "</title>\n <meta http-equiv=\"REFRESH\" content=\"0;url=" + (document.get('url')) + "\">\n </head>\n <body>\n This page has moved. You will be automatically redirected to its new location. If you aren't forwarded to the new page, <a href=\"" + (document.get('url')) + "\">click here</a>.\n </body>\n</html>";
},
trailingSlashes: false
};
CleanUrlsPlugin.prototype.config = {
getRedirectTemplate: function(document) {
return "<!DOCTYPE html>\n<html>\n <head>\n <title>" + (document.get('title') || 'Redirect') + "</title>\n <meta http-equiv=\"REFRESH\" content=\"0;url=" + (document.get('url')) + "\">\n </head>\n <body>\n This page has moved. You will be automatically redirected to its new location. If you aren't forwarded to the new page, <a href=\"" + (document.get('url')) + "\">click here</a>.\n </body>\n</html>";
},
trailingSlashes: false
};
CleanUrlsPlugin.prototype.cleanUrlsForDocument = function(document) {
var pathUtil, relativeBaseUrl, relativeDirUrl, trailingSlashes, url;
url = document.get('url');
pathUtil = require('path');
trailingSlashes = this.config.trailingSlashes;
if (/index\.html$/i.test(url)) {
relativeDirUrl = pathUtil.dirname(url);
if (trailingSlashes && relativeDirUrl !== '/') {
relativeDirUrl += '/';
CleanUrlsPlugin.prototype.cleanUrlsForDocument = function(document) {
var pathUtil, relativeBaseUrl, relativeDirUrl, trailingSlashes, url;
url = document.get('url');
pathUtil = require('path');
trailingSlashes = this.config.trailingSlashes;
if (/index\.html$/i.test(url)) {
relativeDirUrl = pathUtil.dirname(url);
if (trailingSlashes && relativeDirUrl !== '/') {
relativeDirUrl += '/';
}
document.setUrl(relativeDirUrl);
} else if (/\.html$/i.test(url)) {
relativeBaseUrl = url.replace(/\.html$/, '');
document.setUrl(relativeBaseUrl + (trailingSlashes ? '/' : ''));
document.addUrl(relativeBaseUrl + (trailingSlashes ? '' : '/'));
}
document.setUrl(relativeDirUrl);
} else if (/\.html$/i.test(url)) {
relativeBaseUrl = url.replace(/\.html$/, '');
document.setUrl(relativeBaseUrl + (trailingSlashes ? '/' : ''));
document.addUrl(relativeBaseUrl + (trailingSlashes ? '' : '/'));
}
return document;
};
return document;
};
CleanUrlsPlugin.prototype.renderBefore = function(opts) {
var collection, docpad;
docpad = this.docpad;
collection = docpad.getCollection('html');
docpad.log('debug', 'Applying clean urls');
collection.forEach(this.cleanUrlsForDocument);
docpad.log('debug', 'Applied clean urls');
return this;
};
CleanUrlsPlugin.prototype.renderBefore = function(opts) {
var collection, docpad;
docpad = this.docpad;
collection = docpad.getCollection('html');
docpad.log('debug', 'Applying clean urls');
collection.forEach(this.cleanUrlsForDocument);
docpad.log('debug', 'Applied clean urls');
return this;
};
CleanUrlsPlugin.prototype.writeAfter = function(opts, next) {
var TaskGroup, addWriteTask, collection, config, docpad, docpadConfig, getCleanOutPathFromUrl, pathUtil, safefs, tasks;
config = this.config;
docpad = this.docpad;
docpadConfig = docpad.getConfig();
collection = docpad.getCollection('html');
TaskGroup = require('taskgroup').TaskGroup;
safefs = require('safefs');
pathUtil = require('path');
getCleanOutPathFromUrl = function(url) {
url = url.replace(/\/+$/, '');
if (/index.html$/.test(url)) {
return pathUtil.join(docpadConfig.outPath, url);
CleanUrlsPlugin.prototype.writeAfter = function(opts, next) {
var TaskGroup, addWriteTask, collection, config, docpad, docpadConfig, getCleanOutPathFromUrl, pathUtil, safefs, tasks;
config = this.config;
docpad = this.docpad;
docpadConfig = docpad.getConfig();
collection = docpad.getCollection('html');
TaskGroup = require('taskgroup').TaskGroup;
safefs = require('safefs');
pathUtil = require('path');
getCleanOutPathFromUrl = function(url) {
url = url.replace(/\/+$/, '');
if (/index.html$/.test(url)) {
return pathUtil.join(docpadConfig.outPath, url);
} else {
return pathUtil.join(docpadConfig.outPath, url.replace(/\.html$/, '') + '/index.html');
}
};
if (__indexOf.call(docpad.getEnvironments(), 'static') >= 0) {
docpad.log('debug', 'Writing static clean url files');
tasks = new TaskGroup().setConfig({
concurrency: 0
}).once('complete', function(err) {
docpad.log('debug', 'Wrote static clean url files');
return next(err);
});
addWriteTask = function(outPath, outContent, encoding) {
return tasks.addTask(function(complete) {
return safefs.writeFile(outPath, outContent, encoding, complete);
});
};
collection.forEach(function(document) {
var encoding, primaryOutPath, primaryUrl, primaryUrlOutPath, redirectContent, redirectOutPath, redirectOutPaths, url, urls, _i, _j, _len, _len1, _results;
if (document.get('write') === false || document.get('ignore') === true || document.get('render') === false) {
return;
}
encoding = document.get('encoding');
primaryUrl = document.get('url');
primaryUrlOutPath = getCleanOutPathFromUrl(primaryUrl);
primaryOutPath = document.get('outPath');
urls = document.get('urls');
redirectContent = config.getRedirectTemplate(document);
redirectOutPaths = [];
if (primaryUrlOutPath !== primaryOutPath) {
addWriteTask(primaryUrlOutPath, document.getOutContent(), encoding);
redirectOutPaths.push(primaryOutPath);
}
for (_i = 0, _len = urls.length; _i < _len; _i++) {
url = urls[_i];
redirectOutPath = getCleanOutPathFromUrl(url);
if ((__indexOf.call(redirectOutPaths, redirectOutPath) >= 0) === false && redirectOutPath !== primaryUrlOutPath) {
redirectOutPaths.push(redirectOutPath);
}
}
_results = [];
for (_j = 0, _len1 = redirectOutPaths.length; _j < _len1; _j++) {
redirectOutPath = redirectOutPaths[_j];
_results.push(addWriteTask(redirectOutPath, redirectContent, encoding));
}
return _results;
});
tasks.run();
} else {
return pathUtil.join(docpadConfig.outPath, url.replace(/\.html$/, '') + '/index.html');
next();
}
return this;
};
if (__indexOf.call(docpad.getEnvironments(), 'static') >= 0) {
docpad.log('debug', 'Writing static clean url files');
tasks = new TaskGroup().setConfig({
concurrency: 0
}).once('complete', function(err) {
docpad.log('debug', 'Wrote static clean url files');
return next(err);
});
addWriteTask = function(outPath, outContent, encoding) {
return tasks.addTask(function(complete) {
return safefs.writeFile(outPath, outContent, encoding, complete);
});
};
collection.forEach(function(document) {
var encoding, primaryOutPath, primaryUrl, primaryUrlOutPath, redirectContent, redirectOutPath, redirectOutPaths, url, urls, _i, _j, _len, _len1, _results;
if (document.get('write') === false || document.get('ignore') === true || document.get('render') === false) {
return;
}
encoding = document.get('encoding');
primaryUrl = document.get('url');
primaryUrlOutPath = getCleanOutPathFromUrl(primaryUrl);
primaryOutPath = document.get('outPath');
urls = document.get('urls');
redirectContent = config.getRedirectTemplate(document);
redirectOutPaths = [];
if (primaryUrlOutPath !== primaryOutPath) {
addWriteTask(primaryUrlOutPath, document.getOutContent(), encoding);
redirectOutPaths.push(primaryOutPath);
}
for (_i = 0, _len = urls.length; _i < _len; _i++) {
url = urls[_i];
redirectOutPath = getCleanOutPathFromUrl(url);
if ((__indexOf.call(redirectOutPaths, redirectOutPath) >= 0) === false && redirectOutPath !== primaryUrlOutPath) {
redirectOutPaths.push(redirectOutPath);
}
}
_results = [];
for (_j = 0, _len1 = redirectOutPaths.length; _j < _len1; _j++) {
redirectOutPath = redirectOutPaths[_j];
_results.push(addWriteTask(redirectOutPath, redirectContent, encoding));
}
return _results;
});
tasks.run();
} else {
next();
}
return this;
};
return CleanUrlsPlugin;
return CleanUrlsPlugin;
})(BasePlugin);
};
})(BasePlugin);
};
}).call(this);
{
"name": "docpad-plugin-cleanurls",
"version": "2.5.1",
"description": "Adds support for clean urls to DocPad",
"homepage": "http://docpad.org/plugin/cleanurls",
"keywords": [
"docpad",
"docpad-plugin",
"clean urls",
"seo"
],
"author": "Bevry Pty Ltd <us@bevry.me> (http://bevry.me)",
"maintainers": [
"Benjamin Lupton <b@lupton.cc> (https://github.com/balupton)"
],
"contributors": [
"Benjamin Lupton <b@lupton.cc> (https://github.com/balupton)",
"Adam Hull (https://github.com/hurrymaplelad)"
],
"bugs": {
"url": "https://github.com/bevry/docpad-extras/issues"
},
"repository" : {
"type": "git",
"url": "https://github.com/bevry/docpad-extras.git"
},
"engines" : {
"node": ">=0.4",
"docpad": ">=6.3 <7"
},
"dependencies": {
"safefs": "~3.0.1",
"taskgroup": "~3.2.0"
},
"devDependencies": {
"coffee-script": "~1.6.2",
"docpad": ">=6.37 <7",
"chai": "~1.7.1",
"request": "~2.27.0"
},
"main": "./out/cleanurls.plugin.js",
"scripts": {
"test": "node ./out/cleanurls.test.js"
}
"name": "docpad-plugin-cleanurls",
"version": "2.5.2",
"description": "Adds support for clean urls to DocPad",
"homepage": "http://docpad.org/plugin/cleanurls",
"license": {
"type": "MIT"
},
"badges": {
"travis": true,
"npm": true,
"gittip": "bevry",
"flattr": "344188/balupton-on-Flattr",
"paypal": "QB8GQPZAH84N6"
},
"keywords": [
"docpad",
"docpad-plugin",
"clean urls",
"seo"
],
"author": "2012+ Bevry Pty Ltd <us@bevry.me> (http://bevry.me), 2011 Benjamin Lupton <b@lupton.cc> (http://balupton.com)",
"maintainers": [
"Benjamin Lupton <b@lupton.cc> (https://github.com/balupton)"
],
"contributors": [],
"bugs": {
"url": "https://github.com/bevry/docpad-extras/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/bevry/docpad-extras.git"
},
"engines": {
"node": ">=0.4"
},
"dependencies": {
"safefs": "~3.0.1",
"taskgroup": "~3.3.2"
},
"devDependencies": {
"coffee-script": "~1.6.2",
"chai": "~1.8.1",
"request": "~2.27.0"
},
"main": "./out/cleanurls.plugin.js",
"scripts": {
"test": "node ./out/cleanurls.test.js"
},
"peerDependencies": {
"docpad": ">=6.3 <7"
}
}
# Clean URLs Plugin for [DocPad](https://docpad.org)
[![Build Status](https://secure.travis-ci.org/docpad/docpad-plugin-cleanurls.png?branch=master)](http://travis-ci.org/docpad/docpad-plugin-cleanurls "Check this project's build status on TravisCI")
[![NPM version](https://badge.fury.io/js/docpad-plugin-cleanurls.png)](https://npmjs.org/package/docpad-plugin-cleanurls "View this project on NPM")
[![Flattr donate button](https://raw.github.com/balupton/flattr-buttons/master/badge-89x18.gif)](http://flattr.com/thing/344188/balupton-on-Flattr "Donate monthly to this project using Flattr")
[![PayPayl donate button](https://www.paypalobjects.com/en_AU/i/btn/btn_donate_SM.gif)](https://www.paypal.com/au/cgi-bin/webscr?cmd=_flow&SESSION=IHj3DG3oy_N9A9ZDIUnPksOi59v0i-EWDTunfmDrmU38Tuohg_xQTx0xcjq&dispatch=5885d80a13c0db1f8e263663d3faee8d14f86393d55a810282b64afed84968ec "Donate once-off to this project using Paypal")
<!-- BADGES/ -->
[![Build Status](http://img.shields.io/travis-ci/bevry/docpad-plugin-cleanurls.png?branch=master)](http://travis-ci.org/bevry/docpad-plugin-cleanurls "Check this project's build status on TravisCI")
[![NPM version](http://badge.fury.io/js/docpad-plugin-cleanurls.png)](https://npmjs.org/package/docpad-plugin-cleanurls "View this project on NPM")
[![Gittip donate button](http://img.shields.io/gittip/bevry.png)](https://www.gittip.com/bevry/ "Donate weekly to this project using Gittip")
[![Flattr donate button](http://img.shields.io/flattr/donate.png?color=yellow)](http://flattr.com/thing/344188/balupton-on-Flattr "Donate monthly to this project using Flattr")
[![PayPayl donate button](http://img.shields.io/paypal/donate.png?color=yellow)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QB8GQPZAH84N6 "Donate once-off to this project using Paypal")
<!-- /BADGES -->
Adds support for clean URLs to [DocPad](https://docpad.org)

@@ -39,13 +45,56 @@

<!-- HISTORY/ -->
## History
[You can discover the history inside the `History.md` file](https://github.com/bevry/docpad-plugin-cleanurls/blob/master/History.md#files)
[Discover the change history by heading on over to the `History.md` file.](https://github.com/bevry/docpad-plugin-cleanurls/blob/master/History.md#files)
<!-- /HISTORY -->
## Contributing
[You can discover the contributing instructions inside the `Contributing.md` file](https://github.com/bevry/docpad-plugin-cleanurls/blob/master/Contributing.md#files)
<!-- CONTRIBUTE/ -->
## Contribute
[Discover how you can contribute by heading on over to the `Contributing.md` file.](https://github.com/bevry/docpad-plugin-cleanurls/blob/master/Contributing.md#files)
<!-- /CONTRIBUTE -->
<!-- BACKERS/ -->
## Backers
### Maintainers
These amazing people are maintaining this project:
- Benjamin Lupton <b@lupton.cc> (https://github.com/balupton)
### Sponsors
No sponsors yet! Will you be the first?
[![Gittip donate button](http://img.shields.io/gittip/bevry.png)](https://www.gittip.com/bevry/ "Donate weekly to this project using Gittip")
[![Flattr donate button](http://img.shields.io/flattr/donate.png?color=yellow)](http://flattr.com/thing/344188/balupton-on-Flattr "Donate monthly to this project using Flattr")
[![PayPayl donate button](http://img.shields.io/paypal/donate.png?color=yellow)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QB8GQPZAH84N6 "Donate once-off to this project using Paypal")
### Contributors
No contributors yet! Will you be the first?
[Discover how you can contribute by heading on over to the `Contributing.md` file.](https://github.com/bevry/docpad-plugin-cleanurls/blob/master/Contributing.md#files)
<!-- /BACKERS -->
<!-- LICENSE/ -->
## License
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; 2011 [Benjamin Lupton](http://balupton.com)
Licensed under the incredibly [permissive](http://en.wikipedia.org/wiki/Permissive_free_software_licence) [MIT license](http://creativecommons.org/licenses/MIT/)
Copyright &copy; 2012+ Bevry Pty Ltd <us@bevry.me> (http://bevry.me)
<br/>Copyright &copy; 2011 Benjamin Lupton <b@lupton.cc> (http://balupton.com)
<!-- /LICENSE -->

Sorry, the diff of this file is not supported yet

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