on master help sign in
working publish and lookup
commit0b0074b25393d1903f38248ccca14c1ad139c00e authorHunter Miller <hunter@hmiller.dev> dateThu 30 Jun 2022, 00:21 (4 years ago) parent5651ef8
10 files changed+514−1
desk/app/seek.hoon+169 desk/desk.bill+2−1 desk/gen/publish.hoon+10 desk/lib/seek-json.hoon+26 desk/lib/seek.hoon+16 desk/lib/sift.hoon+214 desk/mar/directory-notice.hoon+14 desk/mar/listings.hoon+14 desk/mar/seek-action.hoon desk/sur/seek.hoon+49
desk/app/seek.hoonnew file+169
@@ -0,0 +1,169 @@
1+/- s=seek
2+/+ default-agent, verb, dbug
3+/+ *seek
4+/+ sift
5+^- agent:gall
6+=>
7+ |%
8+ +$ card card:agent:gall
9+ +$ state-0
10+ $: %0
11+ =lookup:s
12+ =trail:s
13+ =directory:s
14+ published=directory:s
15+ ==
16+ --
17+=| state-0
18+=* state -
19+=<
20+ %+ verb &
21+ %- agent:dbug
22+ |_ =bowl:gall
23+ +* this .
24+ def ~(. (default-agent this %.n) bowl)
25+ cor ~(. +> [bowl ~])
26+ ++ on-init
27+ ^- (quip card _this)
28+ =^ cards state
29+ abet:init:cor
30+ [cards this]
31+ ::
32+ ++ on-save !>(state)
33+ ++ on-load
34+ |= =vase
35+ ^- (quip card _this)
36+ =/ old=(unit state-0)
37+ (mole |.(!<(state-0 vase)))
38+ ?^ old `this(state u.old)
39+ ~& >>> "Incompatible load, nuking"
40+ =^ cards this on-init
41+ :_ this
42+ =- (welp - cards)
43+ %+ turn ~(tap in ~(key by wex.bowl))
44+ |= [=wire =ship =term]
45+ ^- card
46+ [%pass wire %agent [ship term] %leave ~]
47+ ::
48+ ++ on-poke
49+ |= [=mark =vase]
50+ ^- (quip card _this)
51+ =^ cards state
52+ abet:(poke:cor mark vase)
53+ [cards this]
54+ ++ on-watch
55+ |= =path
56+ ^- (quip card _this)
57+ =^ cards state
58+ abet:(watch:cor path)
59+ [cards this]
60+ ::
61+ ++ on-peek peek:cor
62+ ::
63+ ++ on-leave on-leave:def
64+ ++ on-fail on-fail:def
65+ ::
66+ ++ on-agent
67+ |= [=wire =sign:agent:gall]
68+ ^- (quip card _this)
69+ =^ cards state
70+ abet:(agent:cor wire sign)
71+ [cards this]
72+ ++ on-arvo
73+ |= [=wire sign=sign-arvo]
74+ ^- (quip card _this)
75+ =^ cards state
76+ abet:(arvo:cor wire sign)
77+ [cards this]
78+ --
79+|_ [=bowl:gall cards=(list card)]
80+++ abet [(flop cards) state]
81+++ cor .
82+++ emit |=(=card cor(cards [card cards]))
83+++ give |=(=gift:agent:gall (emit %give gift))
84+++ init
85+ ^+ cor
86+ cor
87+++ poke
88+ |= [=mark =vase]
89+ |^ ^+ cor
90+ ?+ mark ~|(bad-poke/mark !!)
91+ %directory-notice
92+ =+ !<(=notice:s vase)
93+ (publish notice)
94+ ==
95+ ++ publish
96+ |= =notice:s
97+ ^+ cor
98+ ?> =(src.bowl source.q.notice)
99+ ?> =(p.notice (digest q.notice))
100+ di-abet:(di-init:(di-abed:di-core p.notice) q.notice)
101+ --
102+::
103+++ watch
104+ |= =path
105+ ^+ cor
106+ cor
107+++ agent
108+ |= [=wire =sign:agent:gall]
109+ ^+ cor
110+ cor
111+++ arvo
112+ |= [=wire sign=sign-arvo]
113+ ^+ cor
114+ ~& arvo/wire
115+ cor
116+++ peek
117+ |= =path
118+ ^- (unit (unit cage))
119+ ?+ path [~ ~]
120+ [%x %lookup @ ~]
121+ =- ``listings+!>(-)
122+ ^- (list listing:s)
123+ %+ turn
124+ %+ turn
125+ %+ sort (~(gut by lookup) i.t.t.path *(list entry:s))
126+ |= [a=entry:s b=entry:s]
127+ (gte rank.a rank.b)
128+ |=(=entry:s hash.entry)
129+ |= =hash:s
130+ (~(got by directory) hash)
131+ ::
132+ ==
133+::
134+++ from-self =(our src):bowl
135+++ di-core
136+ |_ [=listing:s =hash:s]
137+ ++ di-core .
138+ ++ di-abet
139+ cor(directory (~(put by directory) hash listing))
140+ ++ di-abed
141+ |= h=hash:s
142+ di-core(hash h, listing (~(gut by directory) h *listing:s))
143+ ++ di-init
144+ |= l=listing:s
145+ =. listing l
146+ =/ entries=lookup:s
147+ %- malt
148+ %- zing
149+ :~ ~[[title.l ~[[hash rank=0]]]]
150+ %+ turn
151+ tags.l
152+ |= tag=@t
153+ [tag ~[[hash rank=1]]]
154+ %+ turn
155+ (sift:sift description.l)
156+ |= word=@t
157+ [word ~[[hash rank=2]]]
158+ ==
159+ ~& -:!>(entries)
160+ ~& -:!>(lookup)
161+ =. lookup
162+ %- ~(uni by entries)
163+ %- ~(rut by lookup)
164+ |= [=key:s value=(list entry:s)]
165+ ?. (~(has by entries) key) value
166+ (weld value (~(got by entries) key))
167+ di-core
168+ --
169+--
desk/desk.bill+2−1
@@ -1 +1,2 @@
1−~
1+:~ %seek
2+==
desk/gen/publish.hoonnew file+10
@@ -0,0 +1,10 @@
1+/- s=seek
2+/+ *seek
3+:- %say
4+|= $: [now=@da eny=@uv =beak]
5+ [[=listing:s ~] ~]
6+ ==
7+=. time.listing now
8+:- %directory-notice
9+^- notice:s
10+[(digest listing) listing]
desk/lib/seek-json.hoonnew file+26
@@ -0,0 +1,26 @@
1+/- s=seek
2+|%
3+++ enjs
4+ =, enjs:format
5+ |%
6+ ++ listings
7+ |= l=(list listing:s)
8+ a+(turn l listing)
9+ ++ listing
10+ |= l=listing:s
11+ %- pairs
12+ :~ title/s/title.l
13+ link/s/link.l
14+ description/s/description.l
15+ image/s/image.l
16+ source/s/(scot %p source.l)
17+ time/(time time.l)
18+ tags/a/(turn tags.l (lead %s))
19+ ==
20+ --
21+++ dejs
22+ =, dejs:format
23+ |%
24+
25+ --
26+--
desk/lib/seek.hoonnew file+16
@@ -0,0 +1,16 @@
1+/- *seek
2+|%
3+++ digest
4+ |= =listing
5+ ^- @uw
6+ %- shax
7+ %- crip
8+ :~ title.listing
9+ link.listing
10+ image.listing
11+ description.listing
12+ (crip tags.listing)
13+ `@t`source.listing
14+ `@t`time.listing
15+ ==
16+--
desk/lib/sift.hoonnew file+214
@@ -0,0 +1,214 @@
1+|%
2+++ sift
3+ |= corpus=@t
4+ ^- (list @t)
5+ %+ skip
6+ (split corpus)
7+ |= word=@t
8+ (~(has in words) word)
9+++ split
10+ |= corpus=@t
11+ ^- (list @t)
12+ =/ lines (crip (trimall corpus))
13+ %+ rash lines
14+ (more ace (cook crip (plus alf)))
15+++ trimall
16+ |= value=@t
17+ |^ ^- tape
18+ %+ rash value
19+ %+ ifix [(star ws) (star ws)]
20+ %- star
21+ ;~ less
22+ ;~(plug (plus ws) ;~(less next (easy ~)))
23+ ;~(pose (cold ' ' (plus ws)) next)
24+ ==
25+ ++ ws (mask " \0a\0d\09")
26+ --
27+++ words
28+ %- silt
29+ :~ 'a'
30+ 'about'
31+ 'above'
32+ 'actually'
33+ 'after'
34+ 'again'
35+ 'against'
36+ 'all'
37+ 'almost'
38+ 'also'
39+ 'although'
40+ 'always'
41+ 'am'
42+ 'an'
43+ 'and'
44+ 'any'
45+ 'are'
46+ 'as'
47+ 'at'
48+ 'be'
49+ 'became'
50+ 'become'
51+ 'because'
52+ 'been'
53+ 'before'
54+ 'being'
55+ 'below'
56+ 'between'
57+ 'both'
58+ 'but'
59+ 'by'
60+ 'can'
61+ 'could'
62+ 'did'
63+ 'do'
64+ 'does'
65+ 'doing'
66+ 'down'
67+ 'during'
68+ 'each'
69+ 'either'
70+ 'else'
71+ 'few'
72+ 'for'
73+ 'from'
74+ 'further'
75+ 'had'
76+ 'has'
77+ 'have'
78+ 'having'
79+ 'he'
80+ 'he\'d'
81+ 'he\'ll'
82+ 'hence'
83+ 'he\'s'
84+ 'her'
85+ 'here'
86+ 'here\'s'
87+ 'hers'
88+ 'herself'
89+ 'him'
90+ 'himself'
91+ 'his'
92+ 'how'
93+ 'how\'s'
94+ 'I'
95+ 'I\'d'
96+ 'I\'ll'
97+ 'I\'m'
98+ 'I\'ve'
99+ 'if'
100+ 'in'
101+ 'into'
102+ 'is'
103+ 'it'
104+ 'it\'s'
105+ 'its'
106+ 'itself'
107+ 'just'
108+ 'let\'s'
109+ 'may'
110+ 'maybe'
111+ 'me'
112+ 'might'
113+ 'mine'
114+ 'more'
115+ 'most'
116+ 'must'
117+ 'my'
118+ 'myself'
119+ 'neither'
120+ 'nor'
121+ 'not'
122+ 'of'
123+ 'oh'
124+ 'on'
125+ 'once'
126+ 'only'
127+ 'ok'
128+ 'or'
129+ 'other'
130+ 'ought'
131+ 'our'
132+ 'ours'
133+ 'ourselves'
134+ 'out'
135+ 'over'
136+ 'own'
137+ 'same'
138+ 'she'
139+ 'she\'d'
140+ 'she\'ll'
141+ 'she\'s'
142+ 'should'
143+ 'so'
144+ 'some'
145+ 'such'
146+ 'than'
147+ 'that'
148+ 'that\'s'
149+ 'the'
150+ 'their'
151+ 'theirs'
152+ 'them'
153+ 'themselves'
154+ 'then'
155+ 'there'
156+ 'there\'s'
157+ 'these'
158+ 'they'
159+ 'they\'d'
160+ 'they\'ll'
161+ 'they\'re'
162+ 'they\'ve'
163+ 'this'
164+ 'those'
165+ 'through'
166+ 'to'
167+ 'too'
168+ 'under'
169+ 'until'
170+ 'up'
171+ 'very'
172+ 'was'
173+ 'we'
174+ 'we\'d'
175+ 'we\'ll'
176+ 'we\'re'
177+ 'we\'ve'
178+ 'were'
179+ 'what'
180+ 'what\'s'
181+ 'when'
182+ 'whenever'
183+ 'when\'s'
184+ 'where'
185+ 'whereas'
186+ 'wherever'
187+ 'where\'s'
188+ 'whether'
189+ 'which'
190+ 'while'
191+ 'who'
192+ 'whoever'
193+ 'who\'s'
194+ 'whose'
195+ 'whom'
196+ 'why'
197+ 'why\'s'
198+ 'will'
199+ 'with'
200+ 'within'
201+ 'would'
202+ 'yes'
203+ 'yet'
204+ 'you'
205+ 'you\'d'
206+ 'you\'ll'
207+ 'you\'re'
208+ 'you\'ve'
209+ 'your'
210+ 'yours'
211+ 'yourself'
212+ 'yourselves'
213+ ==
214+--
desk/mar/directory-notice.hoonnew file+14
@@ -0,0 +1,14 @@
1+/- s=seek
2+/+ j=seek-json
3+|_ =notice:s
4+++ grad %noun
5+++ grow
6+ |%
7+ ++ noun notice
8+ --
9+++ grab
10+ |%
11+ ++ noun notice:s
12+ ++ json notice:dejs:j
13+ --
14+--
desk/mar/listings.hoonnew file+14
@@ -0,0 +1,14 @@
1+/- s=seek
2+/+ j=seek-json
3+|_ listings=(list listing:s)
4+++ grad %noun
5+++ grow
6+ |%
7+ ++ noun listings
8+ ++ json (listings:enjs:j listings)
9+ --
10+++ grab
11+ |%
12+ ++ noun (list listing:s)
13+ --
14+--
desk/mar/seek-action.hoonnew file

No changes to the content.

desk/sur/seek.hoonnew file+49
@@ -0,0 +1,49 @@
1+|%
2++$ key @t :: keyword that points to listings
3++$ hash @uw :: @uw version of shax result
4++$ rank @ud :: @ud representing priority of listing
5+::
6+:: an entry points to a listing hash and provides
7+:: a semblance of priority for the listing
8+::
9++$ entry
10+ $: =hash :: hash of listing contents
11+ =rank :: based on which attribute keyword came from
12+ ==
13+::
14+:: a listing represents a search result which points to some
15+:: external resource through a link. this is a rich result
16+:: which gives a summary of the resource as well as an image
17+:: and related topics.
18+::
19+:: each listing has a source and time so that they can be updated
20+:: via the source requesting to replace the listing and hash
21+::
22++$ listing
23+ $: title=@t
24+ link=@t
25+ description=@t
26+ tags=(list @t)
27+ image=@t
28+ source=@p
29+ time=@da
30+ ==
31+::
32+:: lookup acts as a search index for keywords, each key points to
33+:: an entry which points to a listing. listings are separate from
34+:: the lookup because they are repeated under different keys
35+::
36++$ lookup (map key (list entry))
37+::
38+:: trail is a way for us to know all the keys required to update
39+:: a listing with the new hash of it's contents
40+::
41++$ trail (map hash (list key))
42+::
43+:: directory is a hash table of all current listings. each hash is
44+:: created by taking the hash of the entire listings contents.
45+::
46++$ directory (map hash listing)
47+::
48++$ notice (pair hash listing)
49+--