Skip to content
Browse files

refactor for npm

  • Loading branch information...
1 parent c7745e3 commit 5af0c6568369e092dbdd3ade8bf5a5265d5fa91d @deanlandolt committed Apr 20, 2011
View
30 lib/app.js
@@ -1,20 +1,20 @@
/**
* This is an example Wiki web application written on Pintura
*/
-var pageFacets = require("./facet/page"),
- pageChangeFacets = require("./facet/page-change"),
- admins = require("commonjs-utils/settings").security.admins,
- copy = require("commonjs-utils/copy").copy,
- Restrictive = require("perstore/facet").Restrictive,
- FileSystem = require("perstore/store/filesystem").FileSystem,
- File = require("pintura/media").getFileModel(),
- Model = require("perstore/model").Model,
- Notifying = require("perstore/store/notifying").Notifying,
- pinturaConfig = require("pintura/pintura").config,
- User = pinturaConfig.security.getAuthenticationFacet();
+var pageFacets = require("./facet/page");
+var pageChangeFacets = require("./facet/page-change");
+var admins = require("commonjs-utils/lib/settings").security.admins;
+var copy = require("commonjs-utils/lib/copy").copy;
+var Restrictive = require("perstore/lib/facet").Restrictive;
+var FileSystem = require("perstore/lib/store/filesystem").FileSystem;
+var File = require("pintura/lib/media").getFileModel();
+var Model = require("perstore/lib/model").Model;
+var Notifying = require("perstore/lib/store/notifying").Notifying;
+var pinturaConfig = require("pintura").config;
+var User = pinturaConfig.security.getAuthenticationFacet();
// registers the HTML representation handler that generates HTML from wiki content
-require("media/wiki-html");
+require("./media/wiki-html");
// Defines the data model for the given user by request
pinturaConfig.getDataModel = function(request){
var user = request.remoteUser;
@@ -27,7 +27,7 @@ pinturaConfig.getDataModel = function(request){
return publicModel;
}
// we can use the class model for RESTful creation of models
-var ClassModel = Model(Notifying(require("perstore/stores").DefaultStore()),{});
+var ClassModel = Model(Notifying(require("perstore/lib/stores").DefaultStore()),{});
var fullModel = {
Page: require("./model/page").Page,
PageChange: require("./model/page-change").PageChange,
@@ -37,10 +37,10 @@ var fullModel = {
Module: FileSystem({dataFolder:"../lib"})
};
// initialize the data model
-require("perstore/model").initializeRoot(fullModel);
+require("perstore/lib/model").initializeRoot(fullModel);
// We can generate models from schemas stored in a store/model if we want
-exports.DataModel = fullModel = require("perstore/model").createModelsFromModel(ClassModel, fullModel);
+exports.DataModel = fullModel = require("perstore/lib/model").createModelsFromModel(ClassModel, fullModel);
// the data model for non-authenticated users
View
7 lib/edit.js
@@ -1,11 +1,11 @@
-var JSON = require("commonjs-utils/json");
+var JSON = require("commonjs-utils/lib/json");
pageName = location.search.match(/page=([^&]+)/);
pageName = decodeURIComponent(pageName && pageName[1]);
require("monitor");
document.title = "Editing " + pageName;
-var request = require("promised-io/http-client").request;
+var request = require("promised-io/lib/http-client").request;
document.getElementById("main-header").innerHTML = escapeHTML("Editing " + pageName);
request({
url: "Page/" + pageName,
@@ -93,7 +93,8 @@ function userRpc(method, params){
}
return body;
});
-
+
+}
function errorHandler(error){
alert(error);
View
6 lib/facet/page-change.js
@@ -2,9 +2,9 @@
* These are the page facets for the Wiki example application (in progress)
*/
-var PageChange = require("model/page-change").PageChange,
- Permissive = require("perstore/facet").Permissive,
- Restrictive = require("perstore/facet").Restrictive;
+var PageChange = require("../model/page-change").PageChange;
+var Permissive = require("perstore/lib/facet").Permissive;
+var Restrictive = require("perstore/lib/facet").Restrictive;
// These are the different facets that are available for accessing this data
View
6 lib/facet/page.js
@@ -2,9 +2,9 @@
* These are the page facets for the Wiki example application (in progress)
*/
-var Page = require("model/page").Page,
- Permissive = require("perstore/facet").Permissive,
- Restrictive = require("perstore/facet").Restrictive;
+var Page = require("../model/page").Page;
+var Permissive = require("perstore/lib/facet").Permissive;
+var Restrictive = require("perstore/lib/facet").Restrictive;
// These are the different facets that are available for accessing this data
View
48 lib/index.js
@@ -1,37 +1,45 @@
// helpful for debugging
-print = require("promised-io/process").print;
+print = require("promised-io/lib/process").print;
-var pinturaApp,
- settings = require("commonjs-utils/settings"),
- Static = require("pintura/jsgi/static").Static,
- start = require("pintura/start-node").start,
- multiNode = require("multi-node/multi-node");
+var pinturaApp;
+var settings = require("commonjs-utils/lib/settings");
+var multiNode = require("multi-node");
+var Static = require("pintura/lib/jsgi/static").Static;
+var start = require("pintura/lib/start-node").start;
+
+if (typeof require.reloadable === "function") {
+ require.reloadable(function(){
+ pinturaApp = require("pintura").app;
+ require("./app");
+ });
+}
+else {
+ pinturaApp = require("pintura").app;
+ require("./app");
+}
-require.reloadable(function(){
- pinturaApp = require("pintura/pintura").app;
- require("app");
-});
start(
// uncomment this to enable compression with node-compress
- //require("pintura/jsgi/compress").Compress(
+ //require("pintura/lib/jsgi/compress").Compress(
// make the root url redirect to /Page/Root
require("./jsgi/redirect-root").RedirectRoot(
- require("pintura/jsgi/cascade").Cascade([
- // cascade from static to pintura REST handling
+ require("pintura/lib/jsgi/cascade").Cascade([
+ // cascade from static to pintura REST handling
// the main place for static files accessible from the web
Static({urls:[""], root: "public", directoryListing: true}),
Static({urls:["/explorer"], root: require("nodules").getCachePath("persevere-client/") + "/explorer"}),
// this will provide access to the server side JS libraries from the client
- require("transporter/jsgi/transporter").Transporter({
- loader: require("nodules").forBrowser().useLocal().getModuleSource}),
- // main pintura app
- function(request){
- return pinturaApp(request);
- }
+ require("transporter").Transporter({
+ loader: require("nodules").forBrowser().useLocal().getModuleSource
+ }),
+ // main pintura app
+ function(request){
+ return pinturaApp(request);
+ }
])
)
//)
);
// this is just to ensure the static analysis preloads the explorer package
-false&&require("persevere-client/explorer/explorer.js");
+false&&require("persevere-client/public/explorer/explorer.js");
View
3 lib/jsgi/redirect-root.js
@@ -1,4 +1,5 @@
-var redirector = require("jack/redirect").Redirect("/Page/Example");
+var redirector = require("commonjs-utils/lib/jsgi/redirect").Redirect("/Page/Example");
+
exports.RedirectRoot = function(app){
return function(request){
if(request.pathInfo == "/"){
View
12 lib/media/wiki-html.js
@@ -2,11 +2,11 @@
* Media handler for generating HTML from Wiki markup-based pages
*/
-var Media = require("pintura/media").Media,
- escapeHTML = require("narwhal/html").escape,
- wikiToHtml = require("wiky/wiky").toHtml
+var Media = require("pintura/lib/media").Media;
+var escapeHTML = require("commonjs-utils/lib/html").escape;
+var wikiToHtml = require("wiky").toHtml;
-require("pintura/media/html").setupMediaHandler({
+require("pintura/lib/media/html").setupMediaHandler({
defaultQuality:1,
createContext: function(object, mediaParams, request, response){
return {
@@ -17,7 +17,7 @@ require("pintura/media/html").setupMediaHandler({
}
});
-var rules = require("wiky/wiky").rules,
- store = require("wiky/wiky").store;
+var rules = require("wiky").rules;
+var store = require("wiky").store;
// add a rule for [[target page]] style links
rules.wikiinlines.push({ rex:/\[\[([^\]]*)\]\]/g, tmplt:function($0,$1,$2){return store("<a href=\""+$1+"\">"+$1+"</a>");}});
View
6 lib/model/page-change.js
@@ -2,9 +2,9 @@
* This class is used for tracking all the changes of a page
*/
-var Model = require("perstore/model").Model,
- DefaultStore = require("perstore/stores").DefaultStore,
- auth = require("pintura/jsgi/auth");
+var Model = require("perstore/lib/model").Model;
+var DefaultStore = require("perstore/lib/stores").DefaultStore;
+var auth = require("pintura/lib/jsgi/auth");
// This class contains
var pageChangeStore = DefaultStore();
View
6 lib/model/page-mongo.js
@@ -2,9 +2,9 @@
* This provides the definition of the mongo store if used
*/
-var MongoDB = require("perstore/store/mongodb").MongoDB,
- // url takes this form - mongodb://<user>:<password>@<mongo-server>:<port>/<database>
- url = process.env.MONGO_URL;
+var MongoDB = require("perstore/lib/store/mongodb").MongoDB;
+// url takes this form - mongodb://<user>:<password>@<mongo-server>:<port>/<database>
+var url = process.env.MONGO_URL;
exports.pageStore = MongoDB({
collection: "Page",
View
3 lib/model/page-sql.js
@@ -2,7 +2,8 @@
* This provides the definition of the SQL store if used
*/
-var SQLStore = require("perstore/store/sql").SQLStore;
+var SQLStore = require("perstore/lib/store/sql").SQLStore;
+
//CREATE TABLE Page (id VARCHAR(100), status VARCHAR(10), content VARCHAR(100000), createdBy VARCHAR(20), lastModifiedBy VARCHAR(20), PRIMARY KEY(id))
exports.pageStore = SQLStore({
table: "Page",
View
14 lib/model/page.js
@@ -1,13 +1,13 @@
/**
* This is a page model for the Wiki example application
*/
-var Model = require("perstore/model").Model,
- DefaultStore = require("perstore/stores").DefaultStore,
- auth = require("pintura/jsgi/auth"),
- Notifying = require("perstore/store/notifying").Notifying,
- PageChange = require("./page-change").PageChange,
- promiseModule = require("promised-io/promise"),
- when = promiseModule.when;
+var Model = require("perstore/lib/model").Model;
+var DefaultStore = require("perstore/lib/stores").DefaultStore;
+var auth = require("pintura/lib/jsgi/auth");
+var Notifying = require("perstore/lib/store/notifying").Notifying;
+var PageChange = require("./page-change").PageChange;
+var promiseModule = require("promised-io/lib/promise");
+var when = promiseModule.when;
// Pintura consists of three primary layers: the store, the class (which acts as the
// model), and the facet. Here we define the store and create the class for the store
View
4 lib/monitor.js
@@ -1,5 +1,5 @@
-var JSON = require("commonjs-utils/json"),
- request = require("promised-io/http-client").request;
+var JSON = require("commonjs-utils/lib/json");
+var request = require("promised-io/lib/http-client").request;
//pageName = typeof pageName === "undefined" ? decodeURIComponent(location.pathname.match(/[^\/]*$/)[0]) : pageName;
function monitor(){

0 comments on commit 5af0c65

Please sign in to comment.
Something went wrong with that request. Please try again.