Skip to content

Commit

Permalink
Merge pull request #21 from dr-dimitru/master
Browse files Browse the repository at this point in the history
v1.2.10
  • Loading branch information
jazeee committed Oct 7, 2015
2 parents e27d308 + 8ebb3e0 commit 2f5bf3f
Show file tree
Hide file tree
Showing 18 changed files with 247 additions and 177 deletions.
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ spiderable-longer-timeout
- [Differentiate Phantomjs spider rendering from normal web browsing](#customquery-booleanstring)
- [Supported redirects](#supported-redirects)
- [On/Off debug messages](#debug-boolean)
- [Response statuses](#response-statuses)
- [Enable 404 page and correct responses](#enable-default-404-response-if-youre-using-iron-router)
- [Important notes](#important)
- [How to install Phantomjs to server](#install-phantomjs-on-your-server)
Expand Down Expand Up @@ -119,17 +120,22 @@ Show/hide server's console messages, set `Spiderable.debug` to `true` to show se
Spiderable.debug = true
```

##### Response statuses
You able to send any response status from phantomjs, this behavior may be easily controlled via special `HTML`/`JADE` comment:
- `201` - `<!-- response:status-code=201 -->`
- `401` - `<!-- response:status-code=401 -->`
- `403` - `<!-- response:status-code=403 -->`
- `500` - `<!-- response:status-code=500 -->`

This directive accepts any 3-digit value, so you may return any standard or custom response code.

##### Enable default `404` response if you're using Iron-Router
- Create template which you prefer to return, when page is not found
- Set `Spiderable.customQuery`
- Set iron router's `notFoundTemplate`
- Include a comment '<!-- response:status-code=404 -->' on your template. This way, we can ensure spiderable sends a 404 status code in the response headers
- Include a comment `<!-- response:status-code=404 -->` on your template. This way, we can ensure spiderable sends a `404` status code in the response headers
- Enable iron router's `dataNotFound` plugin. See below or read more about [iron-router plugins](http://iron-meteor.github.io/iron-router/#plugins)

```coffeescript
if Meteor.isServer
Spiderable.customQuery = true

Router.configure
notFoundTemplate: '_404'

Expand All @@ -139,11 +145,21 @@ Router.plugin 'dataNotFound',

```jade
template(name="_404")
// response:status-code=404
h1 404
h3 Oops, page not found
p Sorry, page you're requested is not exists or was deleted
```

```html
<template name="_404">
<!--response:status-code=404-->
<h1>404</h1>
<h3>Oops, page not found</h3>
<p>Sorry, page you're requested is not exists or was deleted</p>
</template>
```

##### Supported redirects
```coffeescript
window.location.href = 'http://example.com/another/page'
Expand Down
4 changes: 4 additions & 0 deletions examples/minimal-app/.meteor/.finished-upgraders
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ notices-for-0.9.0
notices-for-0.9.1
0.9.4-platform-file
notices-for-facebook-graph-api-2
1.2.0-standard-minifiers-package
1.2.0-meteor-platform-split
1.2.0-cordova-changes
1.2.0-breaking-changes
17 changes: 15 additions & 2 deletions examples/minimal-app/.meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,22 @@
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

meteor-platform
coffeescript

jazeee:spiderable-longer-timeout
iron:router
mquandalle:jade
mquandalle:jade
standard-minifiers
meteor-base
mobile-experience
mongo
blaze-html-templates
session
jquery
tracker
logging
reload
random
ejson
spacebars
check
2 changes: 1 addition & 1 deletion examples/minimal-app/.meteor/release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
METEOR@1.1.0.2
METEOR@1.2.0.2
118 changes: 66 additions & 52 deletions examples/minimal-app/.meteor/versions
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
autoupdate@1.2.1
base64@1.0.3
binary-heap@1.0.3
blaze@2.1.2
blaze-tools@1.0.3
boilerplate-generator@1.0.3
callback-hook@1.0.3
check@1.0.5
cmather:handlebars-server@0.2.0
coffeescript@1.0.6
ddp@1.1.0
deps@1.0.7
ejson@1.0.6
fastclick@1.0.3
geojson-utils@1.0.3
handlebars@1.0.3
html-tools@1.0.4
htmljs@1.0.4
http@1.1.0
id-map@1.0.3
autoupdate@1.2.3
babel-compiler@5.8.24_1
babel-runtime@0.1.4
base64@1.0.4
binary-heap@1.0.4
blaze@2.1.3
blaze-html-templates@1.0.1
blaze-tools@1.0.4
boilerplate-generator@1.0.4
caching-compiler@1.0.0
caching-html-compiler@1.0.2
callback-hook@1.0.4
check@1.0.6
coffeescript@1.0.10
ddp@1.2.2
ddp-client@1.2.1
ddp-common@1.2.1
ddp-server@1.2.1
deps@1.0.9
diff-sequence@1.0.1
ecmascript@0.1.5
ecmascript-collections@0.1.6
ejson@1.0.7
fastclick@1.0.7
geojson-utils@1.0.4
hot-code-push@1.0.0
html-tools@1.0.5
htmljs@1.0.5
http@1.1.1
id-map@1.0.4
iron:controller@1.0.8
iron:core@1.0.8
iron:dynamic-template@1.0.8
Expand All @@ -26,37 +36,41 @@ iron:location@1.0.9
iron:middleware-stack@1.0.9
iron:router@1.0.9
iron:url@1.0.9
jazeee:spiderable-longer-timeout@1.2.4
jquery@1.11.3_2
json@1.0.3
launch-screen@1.0.2
livedata@1.0.13
logging@1.0.7
meteor@1.1.6
meteor-platform@1.2.2
minifiers@1.1.5
minimongo@1.0.8
mobile-status-bar@1.0.3
mongo@1.1.0
mquandalle:jade@0.4.3
jazeee:spiderable-longer-timeout@1.2.10
jquery@1.11.4
launch-screen@1.0.4
livedata@1.0.15
logging@1.0.8
meteor@1.1.9
meteor-base@1.0.1
minifiers@1.1.7
minimongo@1.0.10
mobile-experience@1.0.1
mobile-status-bar@1.0.6
mongo@1.1.2
mongo-id@1.0.1
mquandalle:jade@0.4.3_1
mquandalle:jade-compiler@0.4.3
observe-sequence@1.0.6
ordered-dict@1.0.3
npm-mongo@1.4.39_1
observe-sequence@1.0.7
ordered-dict@1.0.4
ostrio:meteor-root@1.0.0
random@1.0.3
reactive-dict@1.1.0
reactive-var@1.0.5
reload@1.1.3
retry@1.0.3
routepolicy@1.0.5
session@1.1.0
sha@1.0.3
spacebars@1.0.6
spacebars-compiler@1.0.6
templating@1.1.1
tracker@1.0.7
ui@1.0.6
underscore@1.0.3
url@1.0.4
webapp@1.2.0
webapp-hashing@1.0.3
promise@0.5.0
random@1.0.4
reactive-dict@1.1.2
reactive-var@1.0.6
reload@1.1.4
retry@1.0.4
routepolicy@1.0.6
session@1.1.1
spacebars@1.0.7
spacebars-compiler@1.0.7
standard-minifiers@1.0.1
templating@1.1.4
templating-tools@1.0.0
tracker@1.0.9
ui@1.0.8
underscore@1.0.4
url@1.0.5
webapp@1.2.2
webapp-hashing@1.0.5
1 change: 1 addition & 0 deletions examples/minimal-app/client/_404.jade
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
template(name="_404")
// response:status-code=404
h1 404
h3 Oops, page not found
p Sorry, your requested page does not exist
5 changes: 5 additions & 0 deletions examples/minimal-app/client/_500.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
template(name="_500")
<!--response:status-code=500-->
h1 500
h3 Oops, server error occured
p Sorry, but your request caused server error!
1 change: 0 additions & 1 deletion examples/minimal-app/lib/Router.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ Router.plugin 'dataNotFound',
notFoundTemplate: Router.options.notFoundTemplate

if Meteor.isServer
Spiderable.customQuery = true
#Technically, not minimal requirement, but helps debugging
Spiderable.debug = true
6 changes: 5 additions & 1 deletion examples/minimal-app/lib/index.router.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
Meteor.startup ->
Router.route 'index',
template: 'index'
path: '/'
path: '/'

Router.route '_500',
template: '_500'
path: '/_500'
4 changes: 4 additions & 0 deletions examples/test-app/.meteor/.finished-upgraders
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ notices-for-0.9.0
notices-for-0.9.1
0.9.4-platform-file
notices-for-facebook-graph-api-2
1.2.0-standard-minifiers-package
1.2.0-meteor-platform-split
1.2.0-cordova-changes
1.2.0-breaking-changes
17 changes: 15 additions & 2 deletions examples/test-app/.meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,22 @@
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

meteor-platform
coffeescript

jazeee:spiderable-longer-timeout
iron:router
mquandalle:jade
mquandalle:jade
standard-minifiers
meteor-base
mobile-experience
mongo
blaze-html-templates
session
jquery
tracker
logging
reload
random
ejson
spacebars
check
2 changes: 1 addition & 1 deletion examples/test-app/.meteor/release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
METEOR@1.1.0.2
METEOR@1.2.0.2
Loading

0 comments on commit 2f5bf3f

Please sign in to comment.