docpad-plugin-cleanurls
Advanced tools
Comparing version 2.4.3 to 2.5.0
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.6.2 | ||
// Generated by CoffeeScript 1.6.3 | ||
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, | ||
@@ -9,3 +9,2 @@ __hasProp = {}.hasOwnProperty, | ||
var CleanUrlsPlugin, _ref; | ||
return CleanUrlsPlugin = (function(_super) { | ||
@@ -15,3 +14,4 @@ __extends(CleanUrlsPlugin, _super); | ||
function CleanUrlsPlugin() { | ||
this.cleanUrlsForDocument = __bind(this.cleanUrlsForDocument, this); _ref = CleanUrlsPlugin.__super__.constructor.apply(this, arguments); | ||
this.cleanUrlsForDocument = __bind(this.cleanUrlsForDocument, this); | ||
_ref = CleanUrlsPlugin.__super__.constructor.apply(this, arguments); | ||
return _ref; | ||
@@ -25,17 +25,21 @@ } | ||
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, url; | ||
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); | ||
document.addUrl(relativeBaseUrl + '/'); | ||
document.setUrl(relativeBaseUrl + (trailingSlashes ? '/' : '')); | ||
document.addUrl(relativeBaseUrl + (trailingSlashes ? '' : '/')); | ||
} | ||
@@ -47,3 +51,2 @@ return document; | ||
var database, docpad; | ||
docpad = this.docpad; | ||
@@ -59,3 +62,2 @@ database = docpad.getCollection('html'); | ||
var TaskGroup, addWriteTask, config, database, docpad, docpadConfig, getCleanOutPathFromUrl, pathUtil, safefs, tasks; | ||
config = this.config; | ||
@@ -91,3 +93,2 @@ docpad = this.docpad; | ||
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) { | ||
@@ -94,0 +95,0 @@ return; |
{ | ||
"name": "docpad-plugin-cleanurls", | ||
"version": "2.4.3", | ||
"version": "2.5.0", | ||
"description": "Adds support for clean urls to DocPad", | ||
@@ -17,3 +17,4 @@ "homepage": "http://docpad.org/plugin/cleanurls", | ||
"contributors": [ | ||
"Benjamin Lupton <b@lupton.cc> (https://github.com/balupton)" | ||
"Benjamin Lupton <b@lupton.cc> (https://github.com/balupton)", | ||
"Adam Hull (https://github.com/hurrymaplelad)" | ||
], | ||
@@ -25,3 +26,3 @@ "bugs": { | ||
"type": "git", | ||
"url": "http://github.com/bevry/docpad-extras.git" | ||
"url": "https://github.com/bevry/docpad-extras.git" | ||
}, | ||
@@ -38,4 +39,5 @@ "engines" : { | ||
"coffee-script": "~1.6.2", | ||
"chai": "~1.5.0", | ||
"request": "~2.16.6" | ||
"docpad": ">=6.37 <7", | ||
"chai": "~1.6.0", | ||
"request": "~2.21.0" | ||
}, | ||
@@ -42,0 +44,0 @@ "main": "./out/cleanurls.plugin.js", |
@@ -1,2 +0,8 @@ | ||
# Clean URLs Plugin for DocPad | ||
# 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") | ||
Adds support for clean URLs to [DocPad](https://docpad.org) | ||
@@ -28,7 +34,15 @@ | ||
### trailingSlashes | ||
Enable to generate `document.url`s like `'/beep/'` instead of `/beep`. Defaults to `false`. | ||
## History | ||
You can discover the history inside the `History.md` file | ||
[You can discover the history inside the `History.md` file](https://github.com/bevry/docpad-plugin-cleanurls/blob/master/History.md#files) | ||
## Contributing | ||
[You can discover the contributing instructions inside the `Contributing.md` file](https://github.com/bevry/docpad-plugin-cleanurls/blob/master/Contributing.md#files) | ||
## License | ||
@@ -35,0 +49,0 @@ Licensed under the incredibly [permissive](http://en.wikipedia.org/wiki/Permissive_free_software_licence) [MIT License](http://creativecommons.org/licenses/MIT/) |
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
50
0
11395
4
6
118