mirror of
https://github.com/ilyakooo0/urbit.git
synced 2025-01-07 07:30:23 +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])?/
|
term = /^[$&|]|^[a-z]([a-z0-9\-]*[a-z0-9])?/
|
||||||
num = /-?-?^[0-9]([0-9.]*|[xwbv]?[0-9a-zA-Z.-~]*)/
|
num = /-?-?^[0-9]([0-9.]*|[xwbv]?[0-9a-zA-Z.-~]*)/
|
||||||
res = {}
|
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){
|
var propOrVar = function(c){
|
||||||
if(c == '.')
|
if(c == '.')
|
||||||
return 'property'
|
return 'property'
|
||||||
return 'variable'
|
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){
|
res.token = function(stream, state){
|
||||||
if(state.soqblock && stream.sol()){
|
if(state.soqblock && stream.sol()){
|
||||||
if(stream.match(/\s*'''/)){
|
if(stream.match(/\s*'''/)){
|
||||||
@ -28,6 +37,9 @@ CodeMirror.defineMode("hoon", function() {
|
|||||||
}
|
}
|
||||||
return "string"
|
return "string"
|
||||||
}
|
}
|
||||||
|
if((state.inter.length) && stream.eat('}')){
|
||||||
|
return nomQuote(stream,state)
|
||||||
|
}
|
||||||
|
|
||||||
if(stream.sol())
|
if(stream.sol())
|
||||||
state.space = true
|
state.space = true
|
||||||
@ -36,6 +48,7 @@ CodeMirror.defineMode("hoon", function() {
|
|||||||
if(stream.peek().match(/[^#./() ]/)||stream.eol()){
|
if(stream.peek().match(/[^#./() ]/)||stream.eol()){
|
||||||
state.sail = false
|
state.sail = false
|
||||||
if(stream.match(/:? /)){
|
if(stream.match(/:? /)){
|
||||||
|
// state.inter = ''
|
||||||
stream.skipToEnd()
|
stream.skipToEnd()
|
||||||
return 'string'
|
return 'string'
|
||||||
}
|
}
|
||||||
@ -62,9 +75,8 @@ CodeMirror.defineMode("hoon", function() {
|
|||||||
stream.skipToEnd()
|
stream.skipToEnd()
|
||||||
return 'string'
|
return 'string'
|
||||||
}
|
}
|
||||||
while(stream.match(/^[^"\\]/) || stream.match(/\\./));
|
state.inter.unshift('"')
|
||||||
stream.eat('"')
|
return nomQuote(stream,state)
|
||||||
return 'string'
|
|
||||||
}
|
}
|
||||||
if(stream.match(' ;')){
|
if(stream.match(' ;')){
|
||||||
if(stream.eat(' ')){
|
if(stream.eat(' ')){
|
||||||
@ -149,7 +161,11 @@ CodeMirror.defineMode("hoon", function() {
|
|||||||
state.space = true
|
state.space = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if(stream.eat(')') || stream.eat(']')){ // XX paren match
|
||||||
|
return
|
||||||
|
}
|
||||||
stream.next()
|
stream.next()
|
||||||
|
return "error"
|
||||||
}
|
}
|
||||||
res.lineComment = '::'
|
res.lineComment = '::'
|
||||||
res.fold = "indent"
|
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