added js urb.util.basepath, generalized tree frontent to work under aliases, proof-of-concept blog/{hymn,json}.hook pointing at tree/pub/blog

This commit is contained in:
Anton Dyudin 2015-07-17 14:34:58 -07:00
parent 71d7d9268c
commit 3a64d50e8a
9 changed files with 56 additions and 26 deletions

View File

@ -1108,13 +1108,13 @@
[~ ~]
?^ t.rax
[p.pok [ire q.pok]]:[pok=$(rax t.rax) ire=i.rax]
=+ ^- raf=(like tape)
%. [1^1 (flop (trip i.rax))]
;~(sfix (star ;~(less dot next)) dot)
=+ ^- raf=(like term)
=> |=(a=@ ((sand %tas) (crip (flop (trip a)))))
(;~(sfix (sear . sym) dot) [1^1 (flop (trip i.rax))])
?~ q.raf
[~ [i.rax ~]]
=+ `[ext=tape [@ @] fyl=tape]`u.q.raf
:- ?:(=(~ ext) ~ [~ (crip (flop ext))])
=+ `[ext=term [@ @] fyl=tape]`u.q.raf
:- `ext
?:(=(~ fyl) ~ [(crip (flop fyl)) ~])
::
++ fuel :: parse fcgi

2
blog/hymn.hook Normal file
View File

@ -0,0 +1,2 @@
/: /%%%/tree/pub/blog /% /hymn/
-<

2
blog/json.hook Normal file
View File

@ -0,0 +1,2 @@
/: /%%%/tree/pub/blog /% /json/
-<

View File

@ -127,7 +127,7 @@ window.urb.poll = function(params) {
}
}
dely = params.dely ? params.dely : $this.dely
dely = params.dely || $this.dely
if(err)
dely = dely+Math.ceil(dely*.02)
@ -187,11 +187,11 @@ window.urb.send = function(params,cb) {
var url, $this
params.ship = params.ship ? params.ship : this.ship
params.appl = params.appl ? params.appl : this.appl
params.mark = params.mark ? params.mark : "json"
params.xyro = params.data ? params.data : {}
params.wire = params.wire ? params.wire : "/"
params.ship = params.ship || this.ship
params.appl = params.appl || this.appl
params.mark = params.mark || "json"
params.xyro = params.data || {}
params.wire = params.wire || "/"
url = ["to",params.appl,params.mark]
@ -221,10 +221,10 @@ window.urb.bind = function(path, cb){ // or bind(path, params, cb, nicecb?)
params.path = path
if(params.path[0] !== "/") params.path = "/"+params.path
params.ship = params.ship ? params.ship : this.ship
params.appl = params.appl ? params.appl : this.appl
params.mark = params.mark ? params.mark : "json"
params.wire = params.wire ? params.wire : params.path
params.ship = params.ship || this.ship
params.appl = params.appl || this.appl
params.mark = params.mark || "json"
params.wire = params.wire || params.path
if(typeof path != "string")
throw new Error("You must specify a string path for urb.bind.")
@ -252,9 +252,9 @@ window.urb.bind = function(path, cb){ // or bind(path, params, cb, nicecb?)
window.urb.unsubscribe = function(params,cb) {
if(!params) throw new Error("You must supply params to urb.unsubscribe.")
params.ship = params.ship ? params.ship : this.ship
params.appl = params.appl ? params.appl : this.appl
params.wire = params.wire ? params.wire : params.path
params.ship = params.ship || this.ship
params.appl = params.appl || this.appl
params.wire = params.wire || params.path
if(!params.path) throw new Error("You must specify a path for urb.unsubscribe.")
if(!params.appl) throw new Error("You must specify an appl for urb.unsubscribe.")
@ -292,5 +292,31 @@ window.urb.util = {
'.' + pad(2, dat.getUTCMinutes()) +
'.' + pad(2, dat.getUTCSeconds()) +
'..' + pad(4, mils)
},
basepath: function(spur, pathname){
spur = spur || ''
pathname = pathname || window.location.pathname
if(pathname[0] == '/') pathname = pathname.slice(1)
pathname = pathname.split("/")
var pref, pred, prec, base = ""
while(base += "/"+(pref = pathname.shift()), pathname.length>0){
if(pref[0] !== '~') break;
if(pref === "~~") continue;
base += "/"+(pred = pathname.shift())
if(/[a-z\-]+/.test(pref.slice(1))){
base += "/"+(prec = pathname.shift())
if(prec == null) throw "Bad basepath."
break;
}
if(pref !== "~") throw "Bad basepath /"+pref
if(pred === "as"){
base += "/"+(prec = pathname.shift())
if(prec == null) throw "Bad basepath."
continue;
}
throw "Bad basepath /~/"+pred
}
return base+spur
}
}

1
pub/blog/~2015.7.16.md Normal file
View File

@ -0,0 +1 @@
# Post 1

1
pub/blog/~2015.7.17.md Normal file
View File

@ -0,0 +1 @@
# Post 2

View File

@ -15,10 +15,9 @@ $ ->
components = {kids:kids,list:list,lost:lost, codemirror:codemirror}
window.tree._basepath = window.location.pathname
window.tree._basepath = window.tree._basepath.split "/"
window.tree._basepath = window.tree._basepath.slice 0,window.tree._basepath.indexOf("tree")+1
window.tree._basepath = window.tree._basepath.join "/"
window.tree._basepath = window.urb.util.basepath("/")
window.tree._basepath +=
(window.location.pathname.replace window.tree._basepath, "").split("/")[0]
window.tree.basepath = (path) ->
if path[0] isnt "/" then path = "/"+path
window.tree._basepath + path

View File

@ -651,10 +651,8 @@ $(function() {
lost: lost,
codemirror: codemirror
};
window.tree._basepath = window.location.pathname;
window.tree._basepath = window.tree._basepath.split("/");
window.tree._basepath = window.tree._basepath.slice(0, window.tree._basepath.indexOf("tree") + 1);
window.tree._basepath = window.tree._basepath.join("/");
window.tree._basepath = window.urb.util.basepath("/");
window.tree._basepath += (window.location.pathname.replace(window.tree._basepath, "")).split("/")[0];
window.tree.basepath = function(path) {
if (path[0] !== "/") {
path = "/" + path;

View File

@ -26,6 +26,7 @@
;script(type "text/javascript", src "//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js");
;script(type "text/javascript", src "//cdnjs.cloudflare.com/ajax/libs/react/0.12.2/react.js");
;script(type "text/javascript", src "//cdnjs.cloudflare.com/ajax/libs/codemirror/4.3.0/codemirror.js");
;script(type "text/javascript", src "/{dez}/lib/urb.js");
;script(type "text/javascript", src "/{dez}/lib/syntax/hoon.js");
;script(type "text/javascript", src "/{dez}/pub/tree/src/js/main.js");
::;script(type "text/javascript", src "http://localhost:8000/docs/pub/tree/src/js/main.js");