mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-29 12:15:43 +03:00
rename lib/react to lib/elem-to-react-json
This commit is contained in:
parent
b11f924b4e
commit
ed1525d893
74
lib/elem-to-react-json.hoon
Normal file
74
lib/elem-to-react-json.hoon
Normal file
@ -0,0 +1,74 @@
|
||||
::
|
||||
:::: /hoon/elem-to-react-json/lib
|
||||
::
|
||||
/? 310
|
||||
|%
|
||||
++ react-attrs
|
||||
~+ ^- (map term cord)
|
||||
%- molt ^- (list (pair term cord))
|
||||
:- [%class 'className']
|
||||
=- (rash - (more next (cook |=(a/tape [(cass a) (crip a)]) (star alf))))
|
||||
'''
|
||||
accept acceptCharset accessKey action allowFullScreen allowTransparency alt
|
||||
async autoComplete autoFocus autoPlay cellPadding cellSpacing charSet checked
|
||||
classID className colSpan cols content contentEditable contextMenu controls
|
||||
coords crossOrigin data dateTime defer dir disabled download draggable encType
|
||||
form formAction formEncType formMethod formNoValidate formTarget frameBorder
|
||||
headers height hidden high href hrefLang htmlFor httpEquiv icon id label lang
|
||||
list loop low manifest marginHeight marginWidth max maxLength media mediaGroup
|
||||
method min multiple muted name noValidate open optimum pattern placeholder
|
||||
poster preload radioGroup readOnly rel required role rowSpan rows sandbox
|
||||
scope scoped scrolling seamless selected shape size sizes span spellCheck
|
||||
src srcDoc srcSet start step style tabIndex target title type useMap value
|
||||
width wmode
|
||||
'''
|
||||
::
|
||||
++ urb-codemirror :: reactify <pre urb:codemirror>foo</pre>
|
||||
|= src/manx ^- manx
|
||||
?> ?=({{$pre *} _;/(**) $~} src)
|
||||
;codemirror(value "{v.i.a.g.i.c.src}");
|
||||
::
|
||||
++ urb-exec :: reactify <pre urb:exec>foo</pre>
|
||||
|= src/manx
|
||||
?> ?=({{$pre *} _;/(**) $~} src) :: verify its only a text node
|
||||
=* code v.i.a.g.i.c.src
|
||||
=+ =< result=(mule .)
|
||||
!.(|.((slap !>(.) (ream (crip code))))) :: compile and run safely
|
||||
=+ claz=?-(-.result $& "rancode", $| "failedcode")
|
||||
;div(class "{claz}")
|
||||
;pre:"{code}"
|
||||
;+ ?- -.result
|
||||
$& ;code:"{~(ram re (sell p.result))}"
|
||||
$| ;pre
|
||||
;div:"error"
|
||||
;* %+ turn p.result
|
||||
|= a/tank
|
||||
^- manx
|
||||
;div:"{~(ram re a)}"
|
||||
== == ==
|
||||
::
|
||||
++ elem-to-react-json
|
||||
|= src/manx ^- json
|
||||
?: ?=(_;/(**) src)
|
||||
(jape v.i.a.g.src)
|
||||
=+ atr=(molt `(list (pair mane tape))`a.g.src)
|
||||
?: (~(has by atr) [%urb %codemirror])
|
||||
$(src (urb-codemirror src))
|
||||
?: (~(has by atr) [%urb %exec]) :: runnable code attribute tag
|
||||
$(src (urb-exec src))
|
||||
%- jobe :~
|
||||
c+a+(turn c.src ..$)
|
||||
gn+s+(mane-to-cord n.g.src)
|
||||
=< ga+(jobe (turn a.g.src .))
|
||||
|= {a/mane b/tape} ^- {cord json}
|
||||
:_ (jape b)
|
||||
?^ a (mane-to-cord a)
|
||||
(fall (~(get by react-attrs) a) a)
|
||||
==
|
||||
::
|
||||
++ mane-to-cord |=(a/mane `cord`?@(a a (rap 3 -.a ':' +.a ~)))
|
||||
--
|
||||
::
|
||||
::::
|
||||
::
|
||||
elem-to-react-json
|
137
lib/react.hoon
137
lib/react.hoon
@ -1,137 +0,0 @@
|
||||
::
|
||||
:::: /hoon/react/lib
|
||||
::
|
||||
/? 310
|
||||
|%
|
||||
++ react-elems :: XX /~
|
||||
~+ %- silt ^- (list term)
|
||||
:~ %a %abbr %address %area %article %aside %audio %b %base
|
||||
%bdi %bdo %big %blockquote %body %br %button %canvas %caption
|
||||
%cite %code %col %colgroup %data %datalist %dd %del %details
|
||||
%dfn %dialog %div %dl %dt %em %embed %fieldset %figcaption
|
||||
%figure %footer %form %h1 %h2 %h3 %h4 %h5 %h6 %head %header
|
||||
%hr %html %i %iframe %img %input %ins %kbd %keygen %label
|
||||
%legend %li %link %main %map %mark %menu %menuitem %meta
|
||||
%meter %nav %noscript %object %ol %optgroup %option %output %p
|
||||
%param %picture %pre %progress %q %rp %rt %ruby %s %samp
|
||||
%script %section %select %small %source %span %strong %style
|
||||
%sub %summary %sup %table %tbody %td %textarea %tfoot %th
|
||||
%thead %time %title %tr %track %u %ul %var %video %wbr
|
||||
%circle %defs %ellipse %g %line %linear-gradient %mask %path
|
||||
%pattern %polygon %polyline %radial-gradient %rect %stop %svg
|
||||
%text %tspan
|
||||
==
|
||||
++ react-attrs
|
||||
~+ ^- (map term cord)
|
||||
%- molt ^- (list (pair term cord))
|
||||
:- [%class 'className']
|
||||
=- (rash - (more next (cook |=(a/tape [(cass a) (crip a)]) (star alf))))
|
||||
'''
|
||||
accept acceptCharset accessKey action allowFullScreen allowTransparency alt
|
||||
async autoComplete autoFocus autoPlay cellPadding cellSpacing charSet checked
|
||||
classID className colSpan cols content contentEditable contextMenu controls
|
||||
coords crossOrigin data dateTime defer dir disabled download draggable encType
|
||||
form formAction formEncType formMethod formNoValidate formTarget frameBorder
|
||||
headers height hidden high href hrefLang htmlFor httpEquiv icon id label lang
|
||||
list loop low manifest marginHeight marginWidth max maxLength media mediaGroup
|
||||
method min multiple muted name noValidate open optimum pattern placeholder
|
||||
poster preload radioGroup readOnly rel required role rowSpan rows sandbox
|
||||
scope scoped scrolling seamless selected shape size sizes span spellCheck
|
||||
src srcDoc srcSet start step style tabIndex target title type useMap value
|
||||
width wmode
|
||||
'''
|
||||
++ react-vale
|
||||
~(has in react-elems)
|
||||
::
|
||||
++ react-to-json
|
||||
|= src/manx ^- json
|
||||
?: ?=(_;/(**) src)
|
||||
(jape v.i.a.g.src)
|
||||
=+ atr=(molt `(list (pair mane tape))`a.g.src)
|
||||
?: (~(has by atr) [%urb %codemirror])
|
||||
?> ?=({{$pre *} _;/(**) $~} src)
|
||||
=. a.g.src
|
||||
[value+v.i.a.g.i.c.src (skip a.g.src |=({a/mane *} ?=(^ a)))]
|
||||
$(src [[%codemirror a.g.src] ~])
|
||||
?: (~(has by atr) [%urb %exec]) :: runnable code attribute tag
|
||||
?> ?=({{$pre *} _;/(**) $~} src) :: verify its only a text node
|
||||
=* code v.i.a.g.i.c.src
|
||||
%_ $
|
||||
src
|
||||
=+ =< result=(mule .)
|
||||
!.(|.((slap !>(.) (ream (crip code))))) :: compile and run safely
|
||||
=+ claz=?:(-.result "rancode" "failedcode")
|
||||
;div(class "{claz}")
|
||||
;pre:"{code}"
|
||||
;+ ?: ?=($& -.result)
|
||||
;code:"{~(ram re (sell p.result))}"
|
||||
;pre
|
||||
;div:"error"
|
||||
;* %+ turn p.result
|
||||
|= a/tank
|
||||
^- manx
|
||||
;div:"{~(ram re a)}"
|
||||
== ==
|
||||
==
|
||||
%- jobe :~
|
||||
c+a+(turn c.src ..$)
|
||||
gn+s+(mane-to-cord n.g.src)
|
||||
=< ga+(jobe (turn a.g.src .))
|
||||
|= {a/mane b/tape} ^- {cord json}
|
||||
:_ (jape b)
|
||||
?^ a (mane-to-cord a)
|
||||
(fall (~(get by react-attrs) a) a)
|
||||
==
|
||||
::
|
||||
++ mane-to-cord |=(a/mane `cord`?@(a a (rap 3 -.a ':' +.a ~)))
|
||||
:: generates React javascript XX deprecated
|
||||
++ react-to-tape
|
||||
|= src/manx ^- tape
|
||||
?: (~(has by (molt `(list (pair mane tape))`a.g.src)) [%urb %codemirror])
|
||||
?> ?=({{$pre *} _;/(**) $~} src)
|
||||
$(src ;codemirror(value "{v.i.a.g.i.c.src}");)
|
||||
?: (~(has by (molt `(list (pair mane tape))`a.g.src)) [%urb %exec])
|
||||
?> ?=({{$pre *} _;/(**) $~} src) :: verify its only a text node
|
||||
=* code v.i.a.g.i.c.src
|
||||
=+ ^= result
|
||||
(mule |.((slap !>(.) (ream (crip code))))) :: compile and run safely
|
||||
?: ?=($.y -.result) :: it was ok
|
||||
=+ ^= new
|
||||
;div(class "rancode")
|
||||
;pre:"{code}"
|
||||
;code:"{~(ram re (sell p.result))}"
|
||||
==
|
||||
$(src new)
|
||||
=+ ^= error
|
||||
;div(class "failedcode")
|
||||
;pre:"{code}"
|
||||
;pre
|
||||
;div:"error"
|
||||
;* %+ turn
|
||||
(scag (dec (lent p.result)) p.result) :: hide react trace
|
||||
|= a/tank
|
||||
^- manx
|
||||
;div:"{~(ram re a)}"
|
||||
==
|
||||
==
|
||||
$(src error)
|
||||
;: weld
|
||||
"React.createElement("
|
||||
?^ n.g.src !! :: namespaces unsupported
|
||||
?: (react-vale n.g.src)
|
||||
"'{(trip n.g.src)}'"
|
||||
(trip n.g.src)
|
||||
", "
|
||||
=- (pojo (jobe (turn a.g.src -)))
|
||||
|= {a/mane b/tape}
|
||||
=. a ?+(a a $class 'className')
|
||||
?^(a !! [a (jape b)])
|
||||
", "
|
||||
=< ~(ram re %rose [", " "[" "]"] (turn c.src .))
|
||||
|= a/manx
|
||||
?: ?=(_;/(**) a)
|
||||
leaf+(pojo (jape v.i.a.g.a))
|
||||
leaf+^$(src a)
|
||||
")"
|
||||
==
|
||||
--
|
@ -2,7 +2,7 @@
|
||||
:::: /hoon/comments/tree/mar
|
||||
::
|
||||
/? 310
|
||||
/+ react, time-to-id
|
||||
/+ elem-to-react-json, time-to-id
|
||||
!:
|
||||
::::
|
||||
::
|
||||
@ -16,7 +16,7 @@
|
||||
(sort all |=({a/* b/*} (lor b a)))
|
||||
|= {a/time b/ship c/marl} ^- ^json
|
||||
=+ bod=[[%div id+(time-to-id a) ~] c]
|
||||
(jobe time+(jode a) user+(jape +:<b>) body+(react-to-json:react bod) ~)
|
||||
(jobe time+(jode a) user+(jape +:<b>) body+(elem-to-react-json bod) ~)
|
||||
--
|
||||
++ grab |% :: convert from
|
||||
++ noun (list {time manx}) :: clam from %noun
|
||||
|
@ -2,8 +2,8 @@
|
||||
:::: /hoon/index/tree/mar
|
||||
::
|
||||
/? 310
|
||||
/+ tree,react,map-to-json
|
||||
[. tree react]
|
||||
/+ tree,map-to-json,elem-to-react-json
|
||||
[. tree]
|
||||
!:
|
||||
::::
|
||||
::
|
||||
@ -15,7 +15,7 @@
|
||||
%. all
|
||||
%+ map-to-json
|
||||
|=(a/path (crip (spud a)))
|
||||
|=(a/marl [%a (turn a react-to-json)])
|
||||
|=(a/marl [%a (turn a elem-to-react-json)])
|
||||
--
|
||||
++ grab |% :: convert from
|
||||
++ noun (map path marl) :: clam from %noun
|
||||
|
@ -3,7 +3,7 @@
|
||||
::
|
||||
/? 310
|
||||
/- tree-include
|
||||
/+ react
|
||||
/+ elem-to-react-json
|
||||
/= mime /mime/
|
||||
/= body /tree-elem/
|
||||
/= sect /&json&/tree-index/
|
||||
@ -15,7 +15,7 @@
|
||||
/tree-comments/
|
||||
!:
|
||||
^- tree-include
|
||||
=+ rj=react-to-json:react
|
||||
=* rj elem-to-react-json
|
||||
:* mime
|
||||
(rj body)
|
||||
(rj /h1 hed.snip) :: head
|
||||
|
@ -15,8 +15,6 @@
|
||||
|= gas/epic ^- {? ?} :: check if the query
|
||||
:- (~(has by qix.gas) 'dbg.nopack') :: dictates separate files
|
||||
(~(has by qix.gas) 'dbg.nomin') :: and/or unminified assets
|
||||
/= extras /: /===/ren/tree/head/extras :: additional scripts
|
||||
/^ (map knot cord) /_ /js/
|
||||
::
|
||||
|%
|
||||
++ cdnjs
|
||||
@ -47,7 +45,6 @@
|
||||
;script(type "text/javascript", src "{(cdnjs "react/0.14.6/react")}");
|
||||
;script(type "text/javascript", src "{(cdnjs "react/0.14.6/react-dom")}");
|
||||
;script(type "text/javascript", src "{(cdnjs "flux/2.1.1/Flux")}");
|
||||
;* (turn (~(tap by extras)) |=({@ a/@t} ;script(type "text/javascript"):"{(trip a)}"))
|
||||
:: ;script(type "text/javascript", src "//cdnjs.cloudflare.com/ajax/libs/codemirror/4.3.0/codemirror.js");
|
||||
:: ;script(type "text/javascript", src "//cdnjs.cloudflare.com/ajax/libs/".
|
||||
:: "codemirror/4.3.0/mode/markdown/markdown.min.js");
|
||||
|
Loading…
Reference in New Issue
Block a user