mirror of
https://github.com/ilyakooo0/urbit.git
synced 2025-01-05 13:55:54 +03:00
Merge branch 'nobreach' into pittyp
This commit is contained in:
commit
3f613aaffe
34
ape/write.hoon
Normal file
34
ape/write.hoon
Normal file
@ -0,0 +1,34 @@
|
||||
:: File writer
|
||||
::
|
||||
:::: /hoon/write/app
|
||||
::
|
||||
|_ [bowl ~]
|
||||
++ beak-now byk(r [%da now])
|
||||
++ poke-json
|
||||
|= jon=json
|
||||
=- (poke--data (need (- jon.+)))
|
||||
=> jo
|
||||
%- ot :~
|
||||
pax/(cu deft (su fel:stab))
|
||||
dat/(of json/some mime/(pe / (cu taco so)) ~) :: XX mite
|
||||
==
|
||||
::
|
||||
++ poke-write-paste
|
||||
|= [typ=?(%hoon %md %txt) txt=@t]
|
||||
(poke--data [`typ /pub/paste/(scot %da now)] %mime / (taco txt))
|
||||
::
|
||||
++ poke--data
|
||||
|= [[ext=(unit ,@t) pax=path] dat=$%([%json json] [%mime mime])]
|
||||
?~ ext $(ext [~ -.dat])
|
||||
=+ cay=?-(-.dat %json [-.dat !>(+.dat)], %mime [-.dat !>(+.dat)])
|
||||
?: =(u.ext -.dat) (made pax ~ `cay)
|
||||
[[ost %exec pax our ~ beak-now %cast u.ext `cay]~ +>.$] :: XX defer %nice
|
||||
::
|
||||
++ made
|
||||
|= [pax=wire @ res=gage]
|
||||
?+ -.res ~|(gage/-.res !!)
|
||||
%| (mean p.res)
|
||||
%& =- [[ost %info / our -]~ +>.$]
|
||||
(foal :(welp (tope beak-now ~) pax /[-.p.res]) p.res)
|
||||
==
|
||||
--
|
@ -3,12 +3,21 @@ CodeMirror.defineMode("hoon", function() {
|
||||
term = /^[$&|]|^[a-z]([a-z0-9\-]*[a-z0-9])?/
|
||||
num = /-?-?^[0-9]([0-9.]*|[xwbv]?[0-9a-zA-Z.-~]*)/
|
||||
res = {}
|
||||
res.startState = function(){return {soblock: false, doqblock:false, sail:false, space:true}}
|
||||
res.startState = function(){return {soblock: false, doqblock:false, inter:[], sail:false, space:true}}
|
||||
var propOrVar = function(c){
|
||||
if(c == '.')
|
||||
return 'property'
|
||||
return 'variable'
|
||||
}
|
||||
var nomQuote = function(stream,state){
|
||||
reg = new RegExp('^[^'+state.inter[0]+'{\\\\]')
|
||||
while(stream.match(reg) || stream.match(/\\./));
|
||||
if(!stream.eat("{")) {
|
||||
if(state.inter[0]){stream.eat(state.inter[0])}
|
||||
state.inter.shift()
|
||||
}
|
||||
return 'string'
|
||||
}
|
||||
res.token = function(stream, state){
|
||||
if(state.soqblock && stream.sol()){
|
||||
if(stream.match(/\s*'''/)){
|
||||
@ -28,6 +37,9 @@ CodeMirror.defineMode("hoon", function() {
|
||||
}
|
||||
return "string"
|
||||
}
|
||||
if((state.inter.length) && stream.eat('}')){
|
||||
return nomQuote(stream,state)
|
||||
}
|
||||
|
||||
if(stream.sol())
|
||||
state.space = true
|
||||
@ -36,6 +48,7 @@ CodeMirror.defineMode("hoon", function() {
|
||||
if(stream.peek().match(/[^#./() ]/)||stream.eol()){
|
||||
state.sail = false
|
||||
if(stream.match(/:? /)){
|
||||
// state.inter = ''
|
||||
stream.skipToEnd()
|
||||
return 'string'
|
||||
}
|
||||
@ -62,9 +75,8 @@ CodeMirror.defineMode("hoon", function() {
|
||||
stream.skipToEnd()
|
||||
return 'string'
|
||||
}
|
||||
while(stream.match(/^[^"\\]/) || stream.match(/\\./));
|
||||
stream.eat('"')
|
||||
return 'string'
|
||||
state.inter.unshift('"')
|
||||
return nomQuote(stream,state)
|
||||
}
|
||||
if(stream.match(' ;')){
|
||||
if(stream.eat(' ')){
|
||||
@ -149,7 +161,11 @@ CodeMirror.defineMode("hoon", function() {
|
||||
state.space = true
|
||||
return
|
||||
}
|
||||
if(stream.eat(')') || stream.eat(']')){ // XX paren match
|
||||
return
|
||||
}
|
||||
stream.next()
|
||||
return "error"
|
||||
}
|
||||
res.lineComment = '::'
|
||||
res.fold = "indent"
|
||||
|
12
mar/write-paste.hoon
Normal file
12
mar/write-paste.hoon
Normal file
@ -0,0 +1,12 @@
|
||||
::
|
||||
:::: /hoon/core/save/mar
|
||||
::
|
||||
!:
|
||||
|_ [typ=?(%hoon %md %txt) txt=@t]
|
||||
++ grab
|
||||
|%
|
||||
++ noun ,[?(%hoon %md %txt) @t]
|
||||
++ json
|
||||
(corl need =>(jo (ot typ/(ci (soft ?(%hoon %md %txt)) so) txt/so ~)))
|
||||
--
|
||||
--
|
30
pub/paste/elem.hook
Normal file
30
pub/paste/elem.hook
Normal file
@ -0,0 +1,30 @@
|
||||
/= all /; flop /^ (list (pair time ,*)) /: /%%/ /& /mime/
|
||||
;div
|
||||
;script@"//code.jquery.com/jquery-2.1.4.min.js";
|
||||
;script@"/~/at/home/lib/urb.js";
|
||||
;script:'''
|
||||
urb.appl = 'write'
|
||||
urb.send.mark = 'write-paste'
|
||||
submit = function(){
|
||||
urb.send({
|
||||
txt:$("textarea").val(),
|
||||
typ:$("select :selected").val()
|
||||
}, function(){
|
||||
$.getJSON('paste/new.json',null,function(resp){
|
||||
if(!resp) throw "No paste"
|
||||
window.location = "paste/"+resp.u
|
||||
})})
|
||||
}
|
||||
'''
|
||||
::
|
||||
;p:textarea;
|
||||
;button(onclick "submit()"):"Submit"
|
||||
;select
|
||||
;option(value "md"): Markdown
|
||||
;option(value "txt"): Text
|
||||
;option(value "hoon"): Hoon
|
||||
==
|
||||
;hr;
|
||||
; recent:
|
||||
;* (turn all |=([a=time *] ;p:a/"paste/{<a>}":"{<a>}"))
|
||||
==
|
2
pub/paste/new/json.hook
Normal file
2
pub/paste/new/json.hook
Normal file
@ -0,0 +1,2 @@
|
||||
/= all /^ (list (pair time ,*)) /: /%%%/ /& /mime/
|
||||
?~(all ~ (joba %u |-(?~(t.all s/(scot %da p.i.all) $(all t.all)))))
|
Loading…
Reference in New Issue
Block a user