Permalink
Browse files

Updates, refactor for latest persvr and dgrid

  • Loading branch information...
1 parent ca3fd56 commit 9020c8ad2edd4b73d4a1b22e576603c4e91b147a @kriszyp committed Jan 6, 2012
@@ -2,9 +2,10 @@ define(function(require){
var claApprovedRepos = ["dojo", "ibm", "kriszyp", "jrburke/require"];
var exceptRepos = ["kriszyp/slick"];
var claRegex = new RegExp("https://github.com/(" + claApprovedRepos.join("|") + ")");
+ var put = require("put-selector/put");
var claRegexExcept = new RegExp(exceptRepos.join("|"));
var query = require("dojo/query");
- var Compose = require("compose"),
+ var Compose = require("compose/compose"),
QueryResults = require("dojo/store/util/QueryResults");
store = Compose(require("dojo/store/JsonRest"), {
query: function(id){
@@ -29,19 +30,17 @@ define(function(require){
return [{id:nextId++, name:"A number " + Math.random()}];
}
})({});
- require("cssx/css!../css/app.css");//.apply(document.body);
- require("cssx/css!../css/layout.css");
/* require("xstyle!../public/css/app").extend(require("xstyle/widget"), require("xstyle/generate"), require("xstyle/css3")).apply(document.body);*/
var nextId = 0;
/*require("remote-console").connectTo("http://192.168.0.6:8181/", "POST");*/
- var list = require("d-list/OnDemandList")({
+ var list = require("dgrid/OnDemandList")({
store: store,
/* data = [];
for(var i = 0;i < 20000; i++){
data.push({id:i, name:"A number " + Math.random()});
};
this.store = new (require("store/Memory"))({data: data});*/
- renderRow: function(row, object, options){
+ renderRow: function(object, options){
var licenses = [];
if(object.licenses){
for(var i = 0; i < object.licenses.length; i++){
@@ -50,67 +49,81 @@ define(function(require){
}
var claApproved = claRegex.test(object.repositories[0].url) && !claRegexExcept.test(object.repositories[0].url);
var icon = object.icon || "http://dojofoundation.org/images/icons/6.png";
+ var row = put('div');
row.innerHTML = '<img src="' + icon + '" /><div class="name">' + object.name +
'</div><div class="license">' + (licenses.join('/') || "&nbsp;") +
'</div><div class="cla' + (claApproved ? ' cla-approved' : '') + '"><span>&nbsp;</span>' +
'</div><div class="description">' + (object.description || '') + '</div>';
+ return row;
},
layout: [
- //require("d-list/Tree")({field:"id", sortable: true, width: "100px"}),
+ //require("dgrid/Tree")({field:"id", sortable: true, width: "100px"}),
{field:"name", sortable: true, width: "200px"}
]
}, query("#list")[0]);
- var tree = require("d-list/Tree")({field:"id", sortable: true, width: "100px"});
+ var tree = require("dgrid/Tree")({field:"id", sortable: true, width: "100px"});
tree.table = list;
list.on("click", function(event){
- var object = list.getObject(event);
- if(object){
- var row = list.getRowNode(object);
- var packageFull = query(".package-full", row)[0];
+ var row = list.row(event);
+ var object;
+ if(row && (object = row.data)){
+ row = row.element;
+ var packageFull = row.packageFull;
if(packageFull){
+ delete row.packageFull;
// already expanded
var parent = event.target;
while(parent != packageFull){
if(parent == null){
- row.removeChild(packageFull);
+ put(packageFull, "!");
return;
}
parent = parent.parentNode;
}
return;
}
- var packageFull = row.appendChild(document.createElement("div"));
- packageFull.className = "package-full";
- store.get(object.id).then(function(fullPackage){
- var versions = fullPackage.versions;
- for(var i in versions){
- if(i != "id"){
- var row = dojo.create("div",{
- className: "row"
- },packageFull);
- dojo.create("div",{
- className: "branch-name",
- innerHTML: i,
- href: "#" + i
- }, row);
- if(versions[i] && versions[i].dist){
- dojo.create("div",{
- className: "branch-description",
- innerHTML: '<a href="' + versions[i].dist.zip + '">download zip</a><br>' +
- '<a href="' + versions[i].dist.tarball + '">download tarball</a><br>' +
- (versions[i].dependencies ? 'Dependencies: ' + (function(dependencies){
+ var packageFull = put(row, "+div");
+ row.packageFull = packageFull;
+ var details = put(packageFull, ".package-full div.details");
+ put(details, "a", {
+ href: object.repositories[0].url,
+ innerHTML: "Go to project repo"
+ });
+ if(object.dependencies){
+ put(details, "div", {
+ innerHTML: "Dependencies: " + (function(dependencies){
var asHtml = "";
for(var i in dependencies){
asHtml += i + ' ' + dependencies[i];
}
return asHtml;
- })(versions[i].dependencies) : '')
- }, row);
- }
+ })(object.dependencies)
+ });
+ }
+ require("dojo/on")(put(details, "div", {
+ innerHTML: "Older versions"
+ }), "click", function(){
+ store.get(object.id).then(function(fullPackage){
+ var versions = fullPackage.versions;
+ for(var i in versions){
+ if(i != "id"){
+ var row = put(packageFull, "div.row");
+ put(row, "div.branch-name", {
+ innerHTML: i,
+ href: "#" + i
+ });
+ if(versions[i] && versions[i].dist){
+ put(row, "div.branch-description",{
+ innerHTML: '<a href="' + versions[i].dist.zip + '">download zip</a><br>' +
+ '<a href="' + versions[i].dist.tarball + '">download tarball</a><br>'
+
+ });
+ }
+ }
}
- }
+ });
});
}
});
- query("#list .d-list-header")[0].innerHTML= "Dojo Foundation Packages";
+ query("#list .dgrid-header")[0].innerHTML= "Dojo Foundation Packages";
});
@@ -1,6 +1,6 @@
/*@import url("/packages/dojo-mobile/themes/iphone/iphone.css") only screen(iphone);
@import url("/packages/dojo-mobile/themes/android/android.css") only screen(android);*/
-@import url("./claro.css") screen;
+@import url("/packages/dgrid/css/skins/claro.css") screen;
#list{
left: inherit;
@@ -11,13 +11,13 @@
width: 780px;
border: 1px solid #aaa;
margin: 5px;
- -webkit-border-radius: 5px;
- -webkit-box-shadow: 1px 1px 2px #888;
+ border-radius: 5px;
+ box-shadow: 1px 1px 2px #888;
background: -webkit-gradient(linear, left top, left bottom, from(#def), to(#fff), color-stop(0.5, #fff));
store: store;
- widget: require('d-list/OnDemandTable');
+ widget: require('dgrid/OnDemandTable');
/id {
- widget: require('d-list/Tree');
+ widget: require('dgrid/Tree');
sortable: true;
width: 100px;
};
@@ -27,29 +27,31 @@
};
}
-.d-list-header {
+.dgrid-header {
font-size: 1.5em;
padding: 10px;
}
-.d-list-row {
+.dgrid-row {
padding: 10px;
+ cursor: pointer;
+ height: 40px;
}
-.d-list-row img{
+.dgrid-row img{
float: left;
margin-right: 10px;
height: 32px;
width: 32px;
}
-.d-list-row .name{
+.dgrid-row .name{
float: left;
width: 400px;
}
-.d-list-row .license {
+.dgrid-row .license {
float: left;
width: 100px;
}
-.d-list-scroller {
+.dgrid-scroller {
top: 45px;
}
.branch-name {
@@ -87,7 +89,7 @@ input[type=range]{
/* could also do @import /packages/my-widget/css/claro-for-widget.css screen and (rule: .claro)
/ or @import /packages/dijit/themes/claro/Checkbox.css screen and (not missing-module: dijit/form/Checkbox)*/
-.d-list-row:hover {
+.dgrid-row:hover {
-webkit-transition-property: background-color;
-webkit-transition-duration: .3s;
background-color: #eff;
@@ -96,10 +98,10 @@ input[type=range]{
float: right;
width: 150px;
border: 1px solid #aaa;
- -webkit-border-radius: 5px;
+ border-radius: 5px;
padding: 5px;
margin: 5px;
- -webkit-box-shadow: 1px 1px 2px #888;
+ box-shadow: 1px 1px 2px #888;
background: -webkit-gradient(linear, left top, left bottom, from(#def), to(#fff), color-stop(0.5, #fff));
}
#package-setup div{
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
View
@@ -1,8 +1,8 @@
/**
* This is an example Wiki web application written on Pintura
*/
-var admins = require("commonjs-utils/settings").security.admins,
- copy = require("commonjs-utils/copy").copy,
+var admins = require("perstore/util/settings").security.admins,
+ copy = require("perstore/util/copy").copy,
Package = require("./model/package").Package,
Restrictive = require("perstore/facet").Restrictive,
FileSystem = require("perstore/store/filesystem").FileSystem,
View
@@ -1,46 +1,48 @@
// helpful for debugging
print = require("promised-io/process").print;
var pinturaApp,
- settings = require("commonjs-utils/settings"),
+ settings = require("perstore/util/settings"),
Static = require("pintura/jsgi/static").Static,
- multiNode = require("multi-node/multi-node");
-
-require.reloadable(function(){
pinturaApp = require("pintura/pintura").app;
- require("app");
-});
-
-var nodes = multiNode.listen({port: settings.port || 8080, nodes: settings.processes || 1},
- require( "http" ).createServer(
- require("jsgi-node").Listener(
- // uncomment this to enable compression with node-compress
- //require("pintura/jsgi/compress").Compress(
- require("pintura/jsgi/cascade").Cascade([
- // cascade from static to pintura REST handling
- Static({urls:["/packages"], root: ".."}),
- require("./jsgi/archive"),
-
- 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").forEngine("browser").useLocal().getModuleSource}),
- // main pintura app
- function(request){
- return pinturaApp(request);
- }
- ])
- )
- )
-);
+require("./app");
+try{
+var listener = require("jsgi-node").Listener(
+ // uncomment this to enable compression with node-compress
+ //require("pintura/jsgi/compress").Compress(
+ require("pintura/jsgi/cascade").Cascade([
+ // cascade from static to pintura REST handling
+ Static({urls:["/packages"], root: ".."}),
+ Static({urls:["/packages/dojo"], root: "/c/dev/dojo-toolkit/dojo"}),
+ require("./jsgi/archive"),
+ pinturaApp
+ ])
+ );
+}catch(e){
+console.log("a",e);
+}
+/*var nodes = multiNode.listen({port: settings.port || 8080, nodes: settings.processes || 1},
+ require("http").createServer(listener));
nodes.addListener("node", function(stream){
pinturaApp.addConnection(multiNode.frameStream(stream));
-});
-
+});*/
+require("http").createServer(listener).listen(7080);
+console.log("a2");
+try{
+var sslOptions = {
+ key: require('fs').readFileSync('privkey.pem'),
+ cert: require('fs').readFileSync('cacert.pem')
+};
+require("https").createServer(sslOptions, listener).listen(443);
+}catch(e){
+ console.log(e);
+}
// having a REPL is really helpful
-if(nodes.isMaster){
- require("pintura/util/repl").start();
+/*if(nodes.isMaster){
+ require("https").createServer(sslOptions, listener).listen(443);
+ require("pintura/util/repl").start();
}
// this is just to ensure the static analysis preloads the explorer package
-false&&require("persevere-client/explorer/explorer.js");
+false&&require("persevere-client/explorer/explorer.js");
+*/
View
@@ -5,15 +5,15 @@ var Model = require("perstore/model").Model,
DefaultStore = require("perstore/stores").DefaultStore,
promiseModule = require("promised-io/promise"),
queryRepo = require("./git").queryRepo,
- host = require("commonjs-utils/settings").host || "/",
+ host = require("perstore/util/settings").host || "/",
print = console.log,
httpClient = require("promised-io/http-client"),
when = promiseModule.when,
fs = require("promised-io/fs"),
all = promiseModule.all;
-var packageStore = DefaultStore(),
- versionsStore = DefaultStore();
+var packageStore = DefaultStore({log:false}),
+ versionsStore = DefaultStore({log:false});
versionsStore.setPath("Versions");
// now we create a class, all central model logic is defined here (make Page be a global for convenience)
PackageModel = exports.Package = Model(packageStore, {
View
@@ -7,7 +7,7 @@
"mappings":{
"perstore": "http://github.com/kriszyp/perstore/zipball/master",
"commonjs-utils": "http://github.com/kriszyp/commonjs-utils/zipball/master",
- "pintura": "jar:http://github.com/kriszyp/pintura/zipball/master!/lib/",
+ "pintura": "jar:http://github.com/kriszyp/pintura/zipball/master!/",
"promised-io": "jar:http://github.com/kriszyp/promised-io/zipball/master!/",
"patr": "jar:http://github.com/kriszyp/patr/zipball/master!/",
"rql": "jar:http://github.com/kriszyp/rql/zipball/master!/",
No changes.
View
@@ -1,11 +1,13 @@
require({"packages":[
{"name":"d-list","location":"/packages/d-list", "lib":"."},
-{"name":"compose","location":"/packages/compose", "main":"./compose"},
+{"name":"compose","location":"/packages/compose", "main":"./lib/compose"},
{"name":"cssx","location":"/packages/cssx", "lib":"src/cssx", "main":"./src/cssx/cssx"},
{"name":"lightning","location":"/packages/lightning", "lib":".", "main":"./lightning"},
{"name":"dojo","location":"/packages/dojo", "lib":".", "main": "./lib/main-browser"},
{"name":"dojox","location":"/dojox", "lib":"."},
{"name":"sizzle","location":"/packages/sizzle", "main": "./sizzle"},
{"name":"slick","location":"/packages/slick", "lib":"./Source", "main": "./Slick.Finder"}
]});
-define('packages',[],{load: function(id, parentRequire, onLoad){require([id], onLoad);}});
+define([],{load: function(id, parentRequire, onLoad){
+ require([id], onLoad);
+}});
Oops, something went wrong.

0 comments on commit 9020c8a

Please sign in to comment.