Skip to content

Commit

Permalink
v2.7.0. Improvement.
Browse files Browse the repository at this point in the history
- v2.7.0 February 13, 2014
	- Static mode is now a configuration option that is enabled by default in the static environment
  • Loading branch information
balupton committed Feb 13, 2014
1 parent d0e1e59 commit e96dffe
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 24 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# v1.3.8 November 7, 2013
# v1.3.14 February 6, 2014
# https://github.com/bevry/base
language: node_js
install: "npm install; ./node_modules/.bin/cake install"
Expand All @@ -7,9 +7,12 @@ script: "npm test"
node_js:
- "0.8"
- "0.10"
cache:
directories:
- node_modules
notifications:
irc:
- "irc.freenode.org#bevry-dev"
email:
recipients:
- [email protected]
- [email protected]
3 changes: 3 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# History

- v2.7.0 February 13, 2014
- Static mode is now a configuration option that is enabled by default in the static environment

- v2.6.2 January 10, 2014
- Updated dependencies

Expand Down
37 changes: 23 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[![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")
[![BitCoin donate button](http://img.shields.io/bitcoin/donate.png?color=yellow)](https://coinbase.com/checkouts/9ef59f5479eec1d97d63382c9ebcb93a "Donate once-off to this project using BitCoin")
[![Wishlist browse button](http://img.shields.io/wishlist/browse.png?color=yellow)](http://amzn.com/w/2F8TXKSNAFG4V "Buy an item on our wishlist for us")

<!-- /BADGES -->

Expand All @@ -26,33 +27,38 @@ docpad install cleanurls

## 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`.
### `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).
In non-static environments we work by setting the document's url to it's clean url. This means that redirection occurs on the dynamic server level.

For the `static` environment (i.e. when running docpad with the `--env static` flag, e.g. running `docpad generate --env static`) we will set the `static` plugin configuration option to `true`. This will in addition to performing redirections via the built-in dynamic server within DocPad for speed, we will also write special static redirection HTML files to the output directory, that will redirect the user to the new clean location (e.g. the document `pages/welcome.html` will not we outputted to `pages/welcome/index.html`, with `pages/welcome.html` now being a special HTML redirect document to the clean location).

If you would like to always use the static mode, you can set the `static` plugin configuration option to true by doing:

``` coffee
plugins:
cleanurls:
static: true
```

If you would like to disable the static mode for the static environment, you can do so by doing:

``` coffee
environments:
static:
plugins:
cleanurls:
enabled: false
static: false
```

If using a custom static server, you can set the staticServer option to true, as well.

``` coffee
plugins:
cleanurls:
staticServer: true
```
### `trailingSlashes`
Enable this plugin configuration option to generate `document.url`s like `'/beep/'` instead of `/beep`. Defaults to `false`.

### trailingSlashes
Enable to generate `document.url`s like `'/beep/'` instead of `/beep`. Defaults to `false`.

### collectionName
You can use this property (defaults to `html`) to tell the cleanurls plugin to use your own custom collection for which documents to apply cleanurls to.
### `collectionName`
You can use this plugin configuration option (defaults to `html`) to tell the cleanurls plugin to use your own custom collection for which documents to apply cleanurls to.

For insstance, if you are wanting to remove all cleanurls for all documents that have `cleanurls: false` in the meta data, then you could do the following in your docpad configuration file:

Expand Down Expand Up @@ -104,6 +110,7 @@ No sponsors yet! Will you be the first?
[![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")
[![BitCoin donate button](http://img.shields.io/bitcoin/donate.png?color=yellow)](https://coinbase.com/checkouts/9ef59f5479eec1d97d63382c9ebcb93a "Donate once-off to this project using BitCoin")
[![Wishlist browse button](http://img.shields.io/wishlist/browse.png?color=yellow)](http://amzn.com/w/2F8TXKSNAFG4V "Buy an item on our wishlist for us")

### Contributors

Expand All @@ -112,6 +119,8 @@ These amazing people have contributed code to this project:
- [Benjamin Lupton](https://github.com/balupton) <[email protected]>[view contributions](https://github.com/docpad/docpad-plugin-cleanurls/commits?author=balupton)
- [hurrymaplelad](https://github.com/hurrymaplelad)[view contributions](https://github.com/docpad/docpad-plugin-cleanurls/commits?author=hurrymaplelad)
- [misterdai](https://github.com/misterdai)[view contributions](https://github.com/docpad/docpad-plugin-cleanurls/commits?author=misterdai)
- [RobLoach](https://github.com/RobLoach)[view contributions](https://github.com/docpad/docpad-plugin-cleanurls/commits?author=RobLoach)
- [stongo](https://github.com/stongo)[view contributions](https://github.com/docpad/docpad-plugin-cleanurls/commits?author=stongo)
- [zenorocha](https://github.com/zenorocha)[view contributions](https://github.com/docpad/docpad-plugin-cleanurls/commits?author=zenorocha)

[Become a contributor!](https://github.com/docpad/docpad-plugin-cleanurls/blob/master/CONTRIBUTING.md#files)
Expand Down
15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docpad-plugin-cleanurls",
"version": "2.6.2",
"version": "2.7.0",
"description": "Adds support for clean urls to DocPad",
"homepage": "http://docpad.org/plugin/cleanurls",
"license": {
Expand All @@ -14,7 +14,8 @@
"gittip": "docpad",
"flattr": "344188/balupton-on-Flattr",
"paypal": "QB8GQPZAH84N6",
"bitcoin": "https://coinbase.com/checkouts/9ef59f5479eec1d97d63382c9ebcb93a"
"bitcoin": "https://coinbase.com/checkouts/9ef59f5479eec1d97d63382c9ebcb93a",
"wishlist": "http://amzn.com/w/2F8TXKSNAFG4V"
},
"keywords": [
"docpad",
Expand All @@ -30,6 +31,8 @@
"Benjamin Lupton <[email protected]> (https://github.com/balupton)",
"hurrymaplelad (https://github.com/hurrymaplelad)",
"misterdai (https://github.com/misterdai)",
"RobLoach (https://github.com/RobLoach)",
"stongo (https://github.com/stongo)",
"zenorocha (https://github.com/zenorocha)"
],
"bugs": {
Expand All @@ -51,10 +54,10 @@
},
"devDependencies": {
"docpad": ">=6.3 <7",
"coffee-script": "~1.6.2",
"chai": "~1.8.1",
"request": "~2.31.0",
"projectz": "~0.3.9"
"coffee-script": "~1.7.1",
"chai": "~1.9.0",
"request": "~2.33.0",
"projectz": "~0.3.10"
},
"main": "./out/cleanurls.plugin.js",
"scripts": {
Expand Down
10 changes: 8 additions & 2 deletions src/cleanurls.plugin.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ module.exports = (BasePlugin) ->

collectionName: 'html'

static: false

environments:
static:
static: true


# Clean URLs for Document
cleanUrlsForDocument: (document) =>
Expand Down Expand Up @@ -59,7 +65,7 @@ module.exports = (BasePlugin) ->

# When we get a new document, update its url
docpad.log 'debug', 'Applying clean urls'
collection.forEach @cleanUrlsForDocument
collection.forEach(@cleanUrlsForDocument)
docpad.log 'debug', 'Applied clean urls'

# All done
Expand All @@ -83,7 +89,7 @@ module.exports = (BasePlugin) ->
pathUtil.join(docpadConfig.outPath, url.replace(/\.html$/,'')+'/index.html')

# Static
if 'static' in docpad.getEnvironments() or config.staticServer?
if config.static is true
# Tasks
docpad.log 'debug', 'Writing static clean url files'
tasks = new TaskGroup().setConfig(concurrency:0).once 'complete', (err) ->
Expand Down

0 comments on commit e96dffe

Please sign in to comment.