Skip to content

Commit

Permalink
Page 404
Browse files Browse the repository at this point in the history
  • Loading branch information
obazoud committed Sep 8, 2012
1 parent e0e4067 commit b5bcfbb
Show file tree
Hide file tree
Showing 3 changed files with 223 additions and 0 deletions.
3 changes: 3 additions & 0 deletions contents/404.json
@@ -0,0 +1,3 @@
{
"template": "404.jade"
}
27 changes: 27 additions & 0 deletions templates/404.jade
@@ -0,0 +1,27 @@

extends layout

block append title
| » Page non trouvée

block content
!= page.html
- var archive = _.chain(contents.articles._.directories).map(function(item) {
- return item.index
- }).compact().filter(function(article) {
- return article.metadata.ignored !== true
- }).sortBy(function(item) {
- return -item.date
- }).groupBy(function(item) {
- return item.date.getFullYear()
- }).value()
- var map = _.chain(Date.CultureInfo.monthNames).map(function(item) {
- return item[0].toUpperCase() + item.substring(1)
- }).value()

section#page
.page-header
h1 Page non trouvée
.hero-unit
h2 404
p A work in progress
193 changes: 193 additions & 0 deletions test/notfound-test.coffee
@@ -0,0 +1,193 @@
vows = require 'vows'
assert = require 'assert'
phantom = require 'phantom'
sys = require 'sys'

describe = (name, bat) -> vows.describe(name).addBatch(bat).export(module)

# Make coffeescript not return anything
# This is needed because vows topics do different things if you have a return value
t = (fn) ->
(args...) ->
fn.apply this, args
return

describe "Page 404"
"A page":
topic: t ->
test = this
phantom.create (p) ->
p.createPage (page) ->
test.callback null, page, p

"can open a URL on localhost":
topic: t (page) ->
page.open "http://127.0.0.1:10113/404.html", (status) =>
page.includeJs "http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"
@callback null, page, status

"and succeed": (err, page, status) ->
assert.equal status, "success"

"and the page, once it loads,":
topic: t (page) ->
setTimeout =>
@callback null, page
, 1000

"has a title":
topic: t (page) ->
page.evaluate (-> document.title), (title) => @callback null, title

"which is correct": (title) ->
assert.equal title, "Le blog d'Olivier » Page non trouvée"

"has page title":
topic: t (page) ->
page.evaluate (-> $("h1").text()), (title) => @callback null, title

"which is correct": (title) ->
assert.equal title, "Page non trouvée"

"has navbar":
topic: t (page) ->
page.evaluate (-> $(".navbar.navbar-fixed-top").length), (navbar) => @callback null, navbar

"which is no empty": (navbar) ->
assert.equal navbar, 1

"has navbar title":
topic: t (page) ->
page.evaluate (-> $(".navbar.navbar-fixed-top a.brand").text()), (title) => @callback null, title

"which is correct": (title) ->
assert.equal title, "Le blog d'Olivier"

"has footer":
topic: t (page) ->
page.evaluate (-> $("footer").length), (footer) => @callback null, footer

"which is no empty": (footer) ->
assert.equal footer, 1

"has tags section":
topic: t (page) ->
page.evaluate (-> $("#tags").length), (tags) => @callback null, tags

"which is no empty": (tags) ->
assert.equal tags, 1

"has tags":
topic: t (page) ->
page.evaluate (-> $("#tags a").length), (tags) => @callback null, tags

"which is no empty": (tags) ->
assert.isTrue tags > 50

"has archives section":
topic: t (page) ->
page.evaluate (-> $("#archives").length), (archives) => @callback null, archives

"which is no empty": (archives) ->
assert.equal archives, 1

"has archives":
topic: t (page) ->
page.evaluate (-> $("#archives a").length), (archives) => @callback null, archives

"which is no empty": (archives) ->
assert.equal archives, 7

teardown: (page, ph) ->
ph.exit()


describe "Page 404 Not Found"
"A page":
topic: t ->
test = this
phantom.create (p) ->
p.createPage (page) ->
test.callback null, page, p

"can open a URL on localhost":
topic: t (page) ->
page.open "http://127.0.0.1:10113/wtf.html", (status) =>
page.includeJs "http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"
@callback null, page, status

"and succeed": (err, page, status) ->
assert.equal status, "success"

"and the page, once it loads,":
topic: t (page) ->
setTimeout =>
@callback null, page
, 1000

"has a title":
topic: t (page) ->
page.evaluate (-> document.title), (title) => @callback null, title

"which is correct": (title) ->
assert.equal title, "Le blog d'Olivier » Page non trouvée"

"has page title":
topic: t (page) ->
page.evaluate (-> $("h1").text()), (title) => @callback null, title

"which is correct": (title) ->
assert.equal title, "Page non trouvée"

"has navbar":
topic: t (page) ->
page.evaluate (-> $(".navbar.navbar-fixed-top").length), (navbar) => @callback null, navbar

"which is no empty": (navbar) ->
assert.equal navbar, 1

"has navbar title":
topic: t (page) ->
page.evaluate (-> $(".navbar.navbar-fixed-top a.brand").text()), (title) => @callback null, title

"which is correct": (title) ->
assert.equal title, "Le blog d'Olivier"

"has footer":
topic: t (page) ->
page.evaluate (-> $("footer").length), (footer) => @callback null, footer

"which is no empty": (footer) ->
assert.equal footer, 1

"has tags section":
topic: t (page) ->
page.evaluate (-> $("#tags").length), (tags) => @callback null, tags

"which is no empty": (tags) ->
assert.equal tags, 1

"has tags":
topic: t (page) ->
page.evaluate (-> $("#tags a").length), (tags) => @callback null, tags

"which is no empty": (tags) ->
assert.isTrue tags > 50

"has archives section":
topic: t (page) ->
page.evaluate (-> $("#archives").length), (archives) => @callback null, archives

"which is no empty": (archives) ->
assert.equal archives, 1

"has archives":
topic: t (page) ->
page.evaluate (-> $("#archives a").length), (archives) => @callback null, archives

"which is no empty": (archives) ->
assert.equal archives, 7

teardown: (page, ph) ->
ph.exit()

0 comments on commit b5bcfbb

Please sign in to comment.