Skip to content

Commit

Permalink
pass wikiname to wikiApp
Browse files Browse the repository at this point in the history
  • Loading branch information
k16wire committed May 10, 2012
1 parent f909375 commit fee1177
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
9 changes: 1 addition & 8 deletions app.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Module dependencies.

express = require 'express'
routes = require './routes'
wiki = require './lib/wiki'

wikiApp = require './wikiApp'
userApp = require './userApp'
Expand Down Expand Up @@ -81,14 +80,8 @@ app.get ROOT_PATH+'/pages/:name/attachment.:format', fileApp.getAttachmentList
app.post ROOT_PATH+'/pages/:name/attachment.:format?', fileApp.postAttachment # file attachment
app.del ROOT_PATH+'/pages/:name/attachment/:filename', fileApp.delAttachment # attachment file delete

# wiki init on start
wiki.init (err) ->
console.log err.message if err
wiki.writePage 'frontpage', 'welcome to n4wiki', (err) ->
throw err if err

if not module.parent
wiki.init noop
wikiApp.init wikiname
LISTEN_PORT = 3000
app.listen LISTEN_PORT;
console.log "Express server listening on port %d in %s mode", LISTEN_PORT, app.settings.env
Expand Down
13 changes: 11 additions & 2 deletions wikiApp.coffee
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
wiki = require './lib/wiki'
url = require 'url'

ROOT_PATH = '/wikis/'

lastVisits = {}

exports.init = (wikiname, err) ->
ROOT_PATH += wikiname
wiki.init (err) ->
console.log err.message if err
wiki.writePage 'frontpage', 'welcome to n4wiki', (err) ->
throw err if err

error404 = (err, req, res, next) ->
res.render '404.jade',
title: "404 Not Found",
Expand Down Expand Up @@ -124,7 +133,7 @@ view = (name, req, res) ->
wiki.readCommit lastVisitId,
(err, commit) ->
changesUrl = url.format
pathname: '/wikis/note/pages/' + name,
pathname: ROOT_PATH+'/pages/' + name,
query:
action: 'diff',
a: lastVisitId,
Expand All @@ -149,7 +158,7 @@ exports.postNew = (req, res) ->

lastVisits[userId][name] = commitId

res.redirect '/wikis/note/pages/' + name
res.redirect ROOT_PATH+'/pages/' + name

exports.postDelete = (req, res) ->
wiki.deletePage req.params.name, (err) ->
Expand Down

0 comments on commit fee1177

Please sign in to comment.