-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a34318d
Showing
30 changed files
with
1,023 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
This is an example Wiki built with Persevere 2.0. It is recommended that you | ||
use [Nodules](http://github.com/kriszyp/nodules) on Node to run this example so that | ||
all dependencies will be automatically resolved, or you can also use the nightly | ||
build that bundles with Narwhal. Once installed, you can download this package and from | ||
the root folder simply run: | ||
|
||
node /path/to/nodules | ||
|
||
or for Narwhal: | ||
|
||
jackup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
These are the scripts for running from Narwhal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
if [ -z "${BASH_ARGV[0]}" ]; then | ||
|
||
# as a last recourse, use the present working directory | ||
PACKAGE_HOME=$(pwd) | ||
|
||
else | ||
|
||
# get the absolute path of the executable | ||
SELF_PATH=$( | ||
cd -P -- "$(dirname -- "${BASH_ARGV[0]}")" \ | ||
&& pwd -P | ||
) && SELF_PATH=$SELF_PATH/$(basename -- "${BASH_ARGV[0]}") | ||
|
||
# resolve symlinks | ||
while [ -h "$SELF_PATH" ]; do | ||
DIR=$(dirname -- "$SELF_PATH") | ||
SYM=$(readlink -- "$SELF_PATH") | ||
SELF_PATH=$(cd -- "$DIR" && cd -- $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM") | ||
done | ||
|
||
PACKAGE_HOME=$(dirname -- "$(dirname -- "$SELF_PATH")") | ||
|
||
fi | ||
|
||
export PACKAGE_HOME | ||
|
||
# which -s narwhal doesn't work (os x 10.5, kriskowal) | ||
if [ -f "$PACKAGE_HOME"/bin/narwhal ]; then | ||
NARWHAL="$PACKAGE_HOME"/bin/narwhal | ||
elif [ -f "$PACKAGE_HOME"/packages/narwhal/bin/narwhal ]; then | ||
NARWHAL="$PACKAGE_HOME"/packages/narwhal/bin/narwhal | ||
else | ||
env narwhal -e '' >/dev/null 2>&1 | ||
if [ "$?" -ne 127 ]; then | ||
NARWHAL=narwhal | ||
else | ||
echo "ERROR: narwhal is not in your PATH nor in $PACKAGE_HOME/bin." >&2 | ||
fi | ||
fi | ||
|
||
if [ -f "$PACKAGE_HOME"/narwhal.conf ]; then | ||
source "$PACKAGE_HOME"/narwhal.conf | ||
export NARWHAL_DEFAULT_ENGINE | ||
fi | ||
|
||
if [ "$NARWHAL" ]; then | ||
export PATH="$("$NARWHAL" --package "$PACKAGE_HOME" --path :)" | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
if [ -z "${BASH_ARGV[0]}" ]; then | ||
|
||
# as a last recourse, use the present working directory | ||
PACKAGE_HOME=$(pwd) | ||
|
||
else | ||
|
||
# get the absolute path of the executable | ||
SELF_PATH=$( | ||
cd -P -- "$(dirname -- "${BASH_ARGV[0]}")" \ | ||
&& pwd -P | ||
) && SELF_PATH=$SELF_PATH/$(basename -- "${BASH_ARGV[0]}") | ||
|
||
# resolve symlinks | ||
while [ -h "$SELF_PATH" ]; do | ||
DIR=$(dirname -- "$SELF_PATH") | ||
SYM=$(readlink -- "$SELF_PATH") | ||
SELF_PATH=$(cd -- "$DIR" && cd -- $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM") | ||
done | ||
|
||
PACKAGE_HOME=$(dirname -- "$(dirname -- "$SELF_PATH")") | ||
|
||
fi | ||
|
||
export PACKAGE_HOME | ||
|
||
# which -s narwhal doesn't work (os x 10.5, kriskowal) | ||
if [ -f "$PACKAGE_HOME"/bin/narwhal ]; then | ||
NARWHAL="$PACKAGE_HOME"/bin/narwhal | ||
elif [ -f "$PACKAGE_HOME"/packages/narwhal/bin/narwhal ]; then | ||
NARWHAL="$PACKAGE_HOME"/packages/narwhal/bin/narwhal | ||
else | ||
env narwhal -e '' >/dev/null 2>&1 | ||
if [ "$?" -ne 127 ]; then | ||
NARWHAL=narwhal | ||
else | ||
echo "ERROR: narwhal is not in your PATH nor in $PACKAGE_HOME/bin." >&2 | ||
fi | ||
fi | ||
|
||
if [ -f "$PACKAGE_HOME"/narwhal.conf ]; then | ||
source "$PACKAGE_HOME"/narwhal.conf | ||
export NARWHAL_DEFAULT_ENGINE | ||
fi | ||
|
||
if [ "$NARWHAL" ]; then | ||
export PATH="$("$NARWHAL" --package "$PACKAGE_HOME" --path :)" | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@echo off | ||
|
||
set PATH=%~dp0;%PATH% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
# this script is intended to work both in narwhal/bin and in | ||
# any project's bin dir; it's copied by tusk --init. | ||
|
||
# get the absolute path of the executable | ||
SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && SELF_PATH=$SELF_PATH/$(basename -- "$0") | ||
|
||
# resolve symlinks | ||
while [ -h "$SELF_PATH" ]; do | ||
DIR=$(dirname -- "$SELF_PATH") | ||
SYM=$(readlink -- "$SELF_PATH") | ||
SELF_PATH=$(cd -- "$DIR" && cd -- $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM") | ||
done | ||
|
||
export PACKAGE_HOME=$(dirname -- "$(dirname -- "$SELF_PATH")") | ||
|
||
source "$PACKAGE_HOME/bin/activate.bash" | ||
|
||
export OLDSEA="$SEA" | ||
export SEA="$PACKAGE_HOME" | ||
export SEALVL="$((SEALVL + 1))" | ||
|
||
if [ "$#" -lt 1 ]; then | ||
echo PATH="$PATH" >&2 | ||
echo SEA="$SEA" >&2 | ||
echo SEALVL="$SEALVL" >&2 | ||
"$SHELL" | ||
else | ||
"$SHELL" -c "$*" | ||
fi | ||
if [ "$OLDSEA" != "" ]; then | ||
echo SEA="$OLDSEA" >&2 | ||
fi | ||
echo SEALVL="$((SEALVL - 1))" >&2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
@echo off | ||
setlocal | ||
|
||
set SHELL=cmd.exe | ||
|
||
set PACKAGE_HOME=%~dp0\.. | ||
|
||
call %PACKAGE_HOME%\bin\activate.cmd | ||
|
||
set OLDSEA=%SEA% | ||
set SEA=%PACKAGE_HOME% | ||
set /a SEALVL=%SEALVL% + 1 | ||
|
||
if "%1" == "" ( | ||
echo SEALVL=%SEALVL% | ||
echo SEA=%SEA% | ||
echo PATH=%PATH% | ||
%SHELL% | ||
) else ( | ||
%SHELL% %* | ||
) | ||
|
||
set /a SEALVL=%SEALVL% - 1 | ||
echo SEALVL=%SEALVL% | ||
echo SEA=%OLDSEA% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is the default location for data files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* The starting point for Pintura running as a Jack app. | ||
*/ | ||
try{ | ||
var pintura = require("pintura/pintura"); | ||
}catch(e){ | ||
// old loaders need to use this type of access, pintura will fix things from there | ||
pintura = require("pintura"); | ||
} | ||
|
||
var File = require("file"), | ||
transporter = require("pintura/jsgi/transporter"); | ||
|
||
require("app"); | ||
|
||
// setup the Jack application | ||
exports.app = | ||
// this will provide module wrapping for the server side CommonJS libraries for the client | ||
transporter.Transporter({}, | ||
// make the root url redirect to /Page/Root | ||
require("pintura/jsgi/redirect-root").RedirectRoot( | ||
// main Pintura handler | ||
pintura.app | ||
) | ||
); | ||
|
||
// now setup the development environment, handle static files before reloading the app | ||
// for better performance | ||
exports.development = function(app, options){ | ||
return require("jack/cascade").Cascade([ | ||
// cascade from static to pintura REST handling | ||
/* // this will provide module wrapping for the Dojo modules for the client | ||
transporter.Transporter({ | ||
urlPrefix:"/js/", | ||
paths:["../../persevere/public/js/"], | ||
converter: transporter.Dojo | ||
}),*/ | ||
// the main place for static files accessible from the web | ||
require("jack/static").Static(null, {urls:[""],root:"public"}), | ||
// the typical reloader scenario | ||
(!options || options.reload) ? require("jack/reloader").Reloader(File.join(File.cwd(), "jackconfig"), "app") : | ||
exports.app | ||
]); | ||
}; | ||
|
||
// we start the REPL (the interactive JS console) because it is really helpful | ||
new (require("worker").SharedWorker)("narwhal/repl"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* Defines the capabilities of different users | ||
*/ | ||
var pageFacets = require("facet/page"), | ||
pageChangeFacets = require("facet/page-change"), | ||
admins = require("commonjs-utils/settings").admins, | ||
Register = require("pintura/security").Register, | ||
security = require("pintura/pintura").config.security; | ||
|
||
security.getAllowedFacets = function(user, request){ | ||
if(user){ | ||
if(admins.indexOf(user.name)>-1){ | ||
return [pageFacets.AdminFacet, pageChangeFacets.AdminFacet]; | ||
} | ||
return [pageFacets.UserFacet, pageChangeFacets.PublicFacet]; | ||
} | ||
return [pageFacets.PublicFacet, pageChangeFacets.PublicFacet, Register]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* This is an example Wiki web application written on Pintura | ||
*/ | ||
|
||
// registers the HTML representation handler that generates HTML from wiki content | ||
require("media/wiki-html"); | ||
// Defines the capabilities of the users | ||
require("access"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* These are the page facets for the Wiki example application (in progress) | ||
*/ | ||
|
||
var PageChange = require("model/page-change").PageChange, | ||
Permissive = require("facet").Permissive, | ||
Restrictive = require("facet").Restrictive; | ||
|
||
|
||
// These are the different facets that are available for accessing this data | ||
// This facet uses the Restrictive constructor, so any modifying action must be explicilty | ||
// be enabled (by defining a handler) | ||
exports.PublicFacet = Restrictive(PageChange, { | ||
prototype: { | ||
}, | ||
quality:0.5 | ||
|
||
}); | ||
// note that general users can't change page history | ||
|
||
// This facet is for administrators and grants full access to data | ||
exports.AdminFacet = Permissive(PageChange, { | ||
properties: { | ||
}, | ||
quality: 1 | ||
}); |
Oops, something went wrong.