mirror of
https://github.com/urbit/shrub.git
synced 2024-11-30 11:42:21 +03:00
search for library, blog
This commit is contained in:
parent
544bcfba62
commit
70ba8eba40
@ -1,5 +1,5 @@
|
||||
:: ++down rendering arms
|
||||
::
|
||||
!:
|
||||
::::
|
||||
::
|
||||
|%
|
||||
@ -25,6 +25,11 @@
|
||||
%alt [~ b]
|
||||
==
|
||||
==
|
||||
++ sanitize
|
||||
|= a=marl ^- tape
|
||||
=- (zing `wall`(scan (flat a) fel))
|
||||
=< fel=;~(sfix (star ;~(plug (cold '-' -) (plus +))) (star next))
|
||||
[(star ;~(less aln prn)) ;~(pose nud low (cook |=(a=@ (add a ' ')) hig))]
|
||||
::
|
||||
++ sang :: tight item children
|
||||
|= a=(list elem)
|
||||
@ -113,7 +118,10 @@
|
||||
?- -.a :: :/("unimplemented {<p.a>}")
|
||||
%html !! :: handled earlier XX do type stuff
|
||||
%para [/p (sung p.a)]
|
||||
%head [/(add %h0 (lsh 3 1 p.a)) (sung q.a)]
|
||||
%head
|
||||
=+ [hed=(add %h0 (lsh 3 1 p.a)) kid=(sung q.a)]
|
||||
[[hed id/(sanitize kid) ~] kid]
|
||||
::
|
||||
%hrul ;hr;
|
||||
:: %html
|
||||
::=+ tex=(role (turn p.a crip))
|
||||
|
@ -1,6 +1,20 @@
|
||||
/- tree-include
|
||||
!:
|
||||
|%
|
||||
++ extract
|
||||
|= a=marl ^- tape
|
||||
?~ a ~
|
||||
%- weld :_ $(a t.a)
|
||||
?. ?=(_:/(**) i.a)
|
||||
$(a c.i.a)
|
||||
v.i.a.g.i.a
|
||||
::
|
||||
++ getall
|
||||
|= tag=(list mane)
|
||||
|= ele=manx ^- marl
|
||||
?: (lien tag |=(a=mane =(a n.g.ele)))
|
||||
~[ele]
|
||||
(zing (turn c.ele ..$))
|
||||
++ baff |*([a=(unit) b=(trap)] ?^(a a *b))
|
||||
++ find-in-tree
|
||||
|* [paz=fist:jo fun=$+(* (unit))]
|
||||
@ -15,6 +29,12 @@
|
||||
(baff (baff (fun c) try(a b)) try(a t.a))
|
||||
--
|
||||
::
|
||||
++ map-to-json
|
||||
|* [a=$+(* cord) b=$+(* json)]
|
||||
|* c=(map) ^- json
|
||||
~! c
|
||||
(jobe (turn (~(tap by c)) |*([k=* v=*] [(a k) (b v)])))
|
||||
::
|
||||
++ json-front
|
||||
|= a=json ^- json
|
||||
=- (fall `(unit json)`- ~)
|
||||
|
21
mar/index.hoon
Normal file
21
mar/index.hoon
Normal file
@ -0,0 +1,21 @@
|
||||
::
|
||||
:::: /hoon/core/elem/mar
|
||||
::
|
||||
/? 314
|
||||
/+ tree,react
|
||||
!:
|
||||
::::
|
||||
|_ all=(map path marl)
|
||||
::
|
||||
++ grow :: convert to
|
||||
|%
|
||||
++ json
|
||||
%. all
|
||||
%+ map-to-json
|
||||
|=(a=path (crip (spud a)))
|
||||
|=(a=marl [%a (turn a react-to-json)])
|
||||
--
|
||||
++ grab |% :: convert from
|
||||
++ noun (map path marl) :: clam from %noun
|
||||
::++ elem |=(a=manx `_all`[[/ ((getall %h1) a)] ~ ~])
|
||||
-- --
|
@ -12,6 +12,7 @@
|
||||
++ atr-key ;~(sfix (star ;~(less col prn)) col ace)
|
||||
++ grow
|
||||
|%
|
||||
++ front atr
|
||||
++ mime [/text/x-markdown (taco (role txt))]
|
||||
++ txt ['---' (welp atr-lines '---' (lore mud))] :: omit if empty?
|
||||
++ md mud
|
||||
|
@ -17,14 +17,6 @@
|
||||
$(a t.a)
|
||||
[c.i.a (weld (flop met) (limit words t.a))]
|
||||
::
|
||||
++ extract
|
||||
|= a=marl ^- tape
|
||||
?~ a ~
|
||||
%- weld :_ $(a t.a)
|
||||
?. ?=(_:/(**) i.a)
|
||||
$(a c.i.a)
|
||||
v.i.a.g.i.a
|
||||
::
|
||||
++ limit
|
||||
|= [lim=@u mal=marl]
|
||||
=< res
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
# Log —
|
||||
|
||||
<search/>
|
||||
|
||||
<list dataPreview="true" dataType="post"></list>
|
||||
|
||||
Please direct all questions or inquiries to [urbit@urbit.org](mailto:urbit@urbit.org). You can also subscribe to the [urbit-dev]() mailing list or follow [@urbit_]() on twitter.
|
||||
|
@ -8,4 +8,7 @@ title: Advantages
|
||||
<h2 class="sub">2015-7-18</h2>
|
||||
<h2 class="sub">Philip Monk</h2>
|
||||
|
||||
# Item 1
|
||||
# Item 2
|
||||
|
||||
</div>
|
||||
|
@ -2,3 +2,6 @@ Library
|
||||
========
|
||||
|
||||
<list dataPreview="true" titlesOnly="true"></list>
|
||||
|
||||
|
||||
<search/>
|
||||
|
@ -1,4 +1,4 @@
|
||||
clas = require 'classnames'
|
||||
clas = require 'classnames'
|
||||
|
||||
BodyComponent = React.createFactory require './BodyComponent.coffee'
|
||||
query = require './Async.coffee'
|
||||
|
@ -46,10 +46,18 @@ module.exports = (queries, Child, load=_load)-> recl
|
||||
if _.isEmpty request.kids
|
||||
delete request.kids
|
||||
request unless _.isEmpty request
|
||||
|
||||
|
||||
scrollHash: -> @getHashElement()?.scrollIntoView()
|
||||
getHashElement: ->
|
||||
{hash} = document.location
|
||||
if hash then document.getElementById hash[1..]
|
||||
|
||||
render: -> div {},
|
||||
if @filterQueries()?
|
||||
React.createElement load, @props
|
||||
else React.createElement Child,
|
||||
(_.extend {}, @props, @state.got),
|
||||
@props.children
|
||||
else
|
||||
if not @getHashElement() # onmount?
|
||||
setTimeout @scrollHash,0
|
||||
React.createElement Child,
|
||||
(_.extend {}, @props, @state.got),
|
||||
@props.children
|
||||
|
@ -42,14 +42,14 @@ module.exports = query {
|
||||
gn: 'h1'
|
||||
c: [elem.meta.title]
|
||||
else title = elem.head
|
||||
title ||= (h1 {},item)
|
||||
parts.push title
|
||||
if @props.dataPreview
|
||||
if @props.dataType is 'post'
|
||||
parts.push (elem.snip.c.slice 0,2)...
|
||||
else
|
||||
parts.push elem.snip
|
||||
if @props.titlesOnly
|
||||
parts = [elem.head]
|
||||
unless @props.titlesOnly # redundant? this seems familiar
|
||||
if @props.dataPreview
|
||||
if @props.dataType is 'post'
|
||||
parts.push (elem.snip.c.slice 0,2)...
|
||||
else
|
||||
parts.push elem.snip
|
||||
li {key:item,className:@props.dataType ? ""},
|
||||
a {href,className:(clas preview: @props.dataPreview?)},
|
||||
reactify
|
||||
|
@ -10,11 +10,11 @@ walk = (root,_nil,_str,_comp)->
|
||||
when typeof elem == "string" then _str elem
|
||||
when elem.gn?
|
||||
{gn,ga,c} = elem
|
||||
c = c?.map _walk ? []
|
||||
c = (c?.map _walk) ? []
|
||||
_comp.call elem, {gn,ga,c}, key
|
||||
else throw "Bad react-json #{JSON.stringify elem}"
|
||||
_walk root
|
||||
|
||||
|
||||
Virtual = recl
|
||||
displayName: "Virtual"
|
||||
render: ->
|
||||
|
@ -2,17 +2,30 @@ query = require './Async.coffee'
|
||||
reactify = require './Reactify.coffee'
|
||||
|
||||
recl = React.createClass
|
||||
{div,input} = React.DOM
|
||||
{a,div,input} = React.DOM
|
||||
|
||||
|
||||
module.exports = query {kids: sect:'r'}, recl
|
||||
module.exports = query {name:'t', kids: sect:'j'}, recl
|
||||
hash:null
|
||||
displayName: "Search"
|
||||
getInitialState: -> search: 'dva'
|
||||
getInitialState: -> search: 'wut'
|
||||
onKeyUp: (e)-> @setState search: e.target.value
|
||||
wrap: (elem,dir,path)->
|
||||
path = path[...-1] if path[-1...] is "/"
|
||||
href = @props.name+"/"+dir+path
|
||||
if elem?.ga?.id
|
||||
{gn,ga,c} = elem
|
||||
ga = _.clone ga
|
||||
href += "#"+ga.id
|
||||
delete ga.id
|
||||
elem = {gn,ga,c}
|
||||
{gn:'div', c:[{gn:'a', ga:{href}, c:[elem]}]}
|
||||
|
||||
render: -> div {},
|
||||
input {@onKeyUp,ref:'inp',defaultValue:'dva'}
|
||||
_(c for x,{sect:{c}} of @props.kids)
|
||||
input {@onKeyUp,ref:'inp',defaultValue:'wut'}
|
||||
_(@props.kids)
|
||||
.map(({sect},dir)=> @wrap h,dir,path for h in heds for path,heds of sect)
|
||||
.flatten()
|
||||
.flatten()
|
||||
.map(@highlight)
|
||||
.filter()
|
||||
|
@ -368,8 +368,19 @@ module.exports = function(queries, Child, load) {
|
||||
return request;
|
||||
}
|
||||
},
|
||||
scrollHash: function() {
|
||||
var ref1;
|
||||
return (ref1 = this.getHashElement()) != null ? ref1.scrollIntoView() : void 0;
|
||||
},
|
||||
getHashElement: function() {
|
||||
var hash;
|
||||
hash = document.location.hash;
|
||||
if (hash) {
|
||||
return document.getElementById(hash.slice(1));
|
||||
}
|
||||
},
|
||||
render: function() {
|
||||
return div({}, this.filterQueries() != null ? React.createElement(load, this.props) : React.createElement(Child, _.extend({}, this.props, this.state.got), this.props.children));
|
||||
return div({}, this.filterQueries() != null ? React.createElement(load, this.props) : (!this.getHashElement() ? setTimeout(this.scrollHash, 0) : void 0, React.createElement(Child, _.extend({}, this.props, this.state.got), this.props.children)));
|
||||
}
|
||||
});
|
||||
};
|
||||
@ -552,17 +563,17 @@ module.exports = query({
|
||||
} else {
|
||||
title = elem.head;
|
||||
}
|
||||
title || (title = h1({}, item));
|
||||
parts.push(title);
|
||||
if (this.props.dataPreview) {
|
||||
if (this.props.dataType === 'post') {
|
||||
parts.push.apply(parts, elem.snip.c.slice(0, 2));
|
||||
} else {
|
||||
parts.push(elem.snip);
|
||||
if (!this.props.titlesOnly) {
|
||||
if (this.props.dataPreview) {
|
||||
if (this.props.dataType === 'post') {
|
||||
parts.push.apply(parts, elem.snip.c.slice(0, 2));
|
||||
} else {
|
||||
parts.push(elem.snip);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.props.titlesOnly) {
|
||||
parts = [elem.head];
|
||||
}
|
||||
results.push(li({
|
||||
key: item,
|
||||
className: (ref5 = this.props.dataType) != null ? ref5 : ""
|
||||
@ -637,7 +648,7 @@ load = React.createFactory(require('./LoadComponent.coffee'));
|
||||
walk = function(root, _nil, _str, _comp) {
|
||||
var _walk;
|
||||
_walk = function(elem, key) {
|
||||
var c, ga, gn;
|
||||
var c, ga, gn, ref1;
|
||||
switch (false) {
|
||||
case !(elem == null):
|
||||
return _nil();
|
||||
@ -645,7 +656,7 @@ walk = function(root, _nil, _str, _comp) {
|
||||
return _str(elem);
|
||||
case elem.gn == null:
|
||||
gn = elem.gn, ga = elem.ga, c = elem.c;
|
||||
c = c != null ? c.map(_walk != null ? _walk : []) : void 0;
|
||||
c = (ref1 = c != null ? c.map(_walk) : void 0) != null ? ref1 : [];
|
||||
return _comp.call(elem, {
|
||||
gn: gn,
|
||||
ga: ga,
|
||||
@ -692,7 +703,7 @@ module.exports = _.extend(reactify, {
|
||||
|
||||
|
||||
},{"./LoadComponent.coffee":9}],11:[function(require,module,exports){
|
||||
var div, input, query, reactify, recl, ref,
|
||||
var a, div, input, query, reactify, recl, ref,
|
||||
slice = [].slice;
|
||||
|
||||
query = require('./Async.coffee');
|
||||
@ -701,18 +712,19 @@ reactify = require('./Reactify.coffee');
|
||||
|
||||
recl = React.createClass;
|
||||
|
||||
ref = React.DOM, div = ref.div, input = ref.input;
|
||||
ref = React.DOM, a = ref.a, div = ref.div, input = ref.input;
|
||||
|
||||
module.exports = query({
|
||||
name: 't',
|
||||
kids: {
|
||||
sect: 'r'
|
||||
sect: 'j'
|
||||
}
|
||||
}, recl({
|
||||
hash: null,
|
||||
displayName: "Search",
|
||||
getInitialState: function() {
|
||||
return {
|
||||
search: 'dva'
|
||||
search: 'wut'
|
||||
};
|
||||
},
|
||||
onKeyUp: function(e) {
|
||||
@ -720,22 +732,61 @@ module.exports = query({
|
||||
search: e.target.value
|
||||
});
|
||||
},
|
||||
wrap: function(elem, dir, path) {
|
||||
var c, ga, gn, href, ref1;
|
||||
if (path.slice(-1) === "/") {
|
||||
path = path.slice(0, -1);
|
||||
}
|
||||
href = this.props.name + "/" + dir + path;
|
||||
if (elem != null ? (ref1 = elem.ga) != null ? ref1.id : void 0 : void 0) {
|
||||
gn = elem.gn, ga = elem.ga, c = elem.c;
|
||||
ga = _.clone(ga);
|
||||
href += "#" + ga.id;
|
||||
delete ga.id;
|
||||
elem = {
|
||||
gn: gn,
|
||||
ga: ga,
|
||||
c: c
|
||||
};
|
||||
}
|
||||
return {
|
||||
gn: 'div',
|
||||
c: [
|
||||
{
|
||||
gn: 'a',
|
||||
ga: {
|
||||
href: href
|
||||
},
|
||||
c: [elem]
|
||||
}
|
||||
]
|
||||
};
|
||||
},
|
||||
render: function() {
|
||||
var c, x;
|
||||
return div({}, input({
|
||||
onKeyUp: this.onKeyUp,
|
||||
ref: 'inp',
|
||||
defaultValue: 'dva'
|
||||
}), _((function() {
|
||||
var ref1, results;
|
||||
ref1 = this.props.kids;
|
||||
results = [];
|
||||
for (x in ref1) {
|
||||
c = ref1[x].sect.c;
|
||||
results.push(c);
|
||||
}
|
||||
return results;
|
||||
}).call(this)).flatten().map(this.highlight).filter().map(reactify).value());
|
||||
defaultValue: 'wut'
|
||||
}), _(this.props.kids).map((function(_this) {
|
||||
return function(arg, dir) {
|
||||
var h, heds, path, results, sect;
|
||||
sect = arg.sect;
|
||||
results = [];
|
||||
for (path in sect) {
|
||||
heds = sect[path];
|
||||
results.push((function() {
|
||||
var i, len, results1;
|
||||
results1 = [];
|
||||
for (i = 0, len = heds.length; i < len; i++) {
|
||||
h = heds[i];
|
||||
results1.push(this.wrap(h, dir, path));
|
||||
}
|
||||
return results1;
|
||||
}).call(_this));
|
||||
}
|
||||
return results;
|
||||
};
|
||||
})(this)).flatten().flatten().map(this.highlight).filter().map(reactify).value());
|
||||
},
|
||||
highlight: function(e) {
|
||||
var got, res;
|
||||
@ -1530,7 +1581,7 @@ QUERIES = {
|
||||
body: 'r',
|
||||
head: 'r',
|
||||
snip: 'r',
|
||||
sect: 'r',
|
||||
sect: 'j',
|
||||
meta: 'j'
|
||||
};
|
||||
|
||||
|
@ -7,7 +7,7 @@ _tree = {}
|
||||
_data = {}
|
||||
_curr = ""
|
||||
|
||||
QUERIES = {body:'r', head:'r', snip:'r', sect:'r', meta:'j'}
|
||||
QUERIES = {body:'r', head:'r', snip:'r', sect:'j', meta:'j'}
|
||||
|
||||
TreeStore = _.extend EventEmitter.prototype, {
|
||||
addChangeListener: (cb) -> @on 'change', cb
|
||||
|
@ -1,8 +1,11 @@
|
||||
/+ tree
|
||||
/= body /: /=== /% /react-json/
|
||||
/= head /: /=== /% /react-head-json/
|
||||
/= snip /: /=== /% /react-snip-json/
|
||||
/= sect /: /=== /% /react-headers-json/
|
||||
/= meta /: /=== /% /; json-front /react-snip-json/
|
||||
/+ tree, react
|
||||
/= body /: /=== /% /elem/
|
||||
/= snip /: /=== /% /snip/
|
||||
/= meta /: /=== /% /front/
|
||||
/= sect /: /=== /% /index/
|
||||
!:
|
||||
^- tree-include
|
||||
[body head snip meta sect]
|
||||
=+ rj=react-to-json
|
||||
=+ fj=|=(atr=(map span span) [%o (~(run by atr) |=(a=span s/a))])
|
||||
=+ ij=(map-to-json |=(a=path (crip (spud a))) |=(a=marl [%a (turn a rj)]))
|
||||
[(rj body) (rj /h1 hed.snip) (rj /div tal.snip) (fj meta) (ij sect)]
|
||||
|
@ -21,7 +21,7 @@
|
||||
$% [%kids p=(list query)]
|
||||
[%name %t]
|
||||
[%path %t]
|
||||
[%sect %r]
|
||||
[%sect %j]
|
||||
[%snip %r]
|
||||
[%head %r]
|
||||
[%body %r]
|
||||
|
Loading…
Reference in New Issue
Block a user