on master help sign in
validation: fixing validation in various places, fixing published bug, adding invalid purge
5795043Hunter Miller
desk/app/sphinx.hoon+17−6
@@ -59,10 +59,11 @@
59 ::
59 ::
60 ++ get-state-2
60 ++ get-state-2
61 |= =directory:s
61 |= =directory:s
62+ =/ purged (purge-invalid directory)
62 :* %2
63 :* %2
63 (reindex directory)
64 (reindex directory)
64− directory
65+ purged
65− (purge directory)
66+ (purge-foreign purged)
66 ==
67 ==
67 ++ reindex
68 ++ reindex
68 |= =directory:s
69 |= =directory:s
@@ -70,7 +71,15 @@
70 ~(tap by directory)
71 ~(tap by directory)
71 |= [[=hash:s l=listing:s] i=index:s]
72 |= [[=hash:s l=listing:s] i=index:s]
72 (~(catalog delver i) hash l)
73 (~(catalog delver i) hash l)
73− ++ purge
74+ ++ purge-invalid
75+ |= =directory:s
76+ ^- directory:s
77+ %- malt
78+ %+ skim
79+ ~(tap by directory)
80+ |= [=hash:s =listing:s]
81+ (listing-valid listing)
82+ ++ purge-foreign
74 |= =directory:s
83 |= =directory:s
75 ^- directory:s
84 ^- directory:s
76 %- malt
85 %- malt
@@ -151,6 +160,7 @@
151 ?: (~(has by directory) hash.listing)
160 ?: (~(has by directory) hash.listing)
152 ~& 'Listing already exists.'
161 ~& 'Listing already exists.'
153 cor
162 cor
163+ ?. (listing-valid listing) cor
154 di-abet:(di-publish:(di-abed:di-core:core hash.listing) listing)
164 di-abet:(di-publish:(di-abed:di-core:core hash.listing) listing)
155 --
165 --
156::
166::
@@ -177,8 +187,9 @@
177 =+ !<(=listing:s vase)
187 =+ !<(=listing:s vase)
178 ?> =(hash.listing (digest post.listing))
188 ?> =(hash.listing (digest post.listing))
179 ?: (~(has by directory) hash.listing)
189 ?: (~(has by directory) hash.listing)
180− ~& 'Listing already exists.'
190+ ~& 'Listing already exists.'
181− cor
191+ cor
192+ ?. (listing-valid listing) cor
182 di-abet:(di-receive:(di-abed:di-core hash.listing) listing)
193 di-abet:(di-receive:(di-abed:di-core hash.listing) listing)
183 ::
194 ::
184 %directory
195 %directory
@@ -315,7 +326,7 @@
315 =. index (~(catalog delver index) hash l)
326 =. index (~(catalog delver index) hash l)
316 =. published
327 =. published
317 ?. =(source.listing our:bowl) published
328 ?. =(source.listing our:bowl) published
318− (~(put by directory) hash.listing listing)
329+ (~(put by published) hash.listing listing)
319 =. cor (emit (invent:gossip %directory-listing !>(listing)))
330 =. cor (emit (invent:gossip %directory-listing !>(listing)))
320 di-core
331 di-core
321 ++ di-receive
332 ++ di-receive
desk/desk.docket-0+2−2
@@ -2,9 +2,9 @@
2 info+'A search engine powered by you and your pals for finding answers to your riddles'
2 info+'A search engine powered by you and your pals for finding answers to your riddles'
3 color+0xb2.5068
3 color+0xb2.5068
4 image+'https://nyc3.digitaloceanspaces.com/hmillerdev/nocsyx-lassul/2022.7.16..04.35.22-sphinx-web-shifted.svg'
4 image+'https://nyc3.digitaloceanspaces.com/hmillerdev/nocsyx-lassul/2022.7.16..04.35.22-sphinx-web-shifted.svg'
5− glob-http+['https://nyc3.digitaloceanspaces.com/hmillerdev/sphinx/glob-0v7.58bpe.gauar.d272t.l9jhq.uqhkn.glob' 0v7.58bpe.gauar.d272t.l9jhq.uqhkn]
5+ glob-http+['https://nyc3.digitaloceanspaces.com/hmillerdev/sphinx/glob-0v4.rk6nd.h0t14.4j4tv.q4bia.9m66a.glob' 0v4.rk6nd.h0t14.4j4tv.q4bia.9m66a]
6 base+'sphinx'
6 base+'sphinx'
7− version+[0 4 2]
7+ version+[0 4 3]
8 website+'https://github.com'
8 website+'https://github.com'
9 license+'MIT'
9 license+'MIT'
10==
10==
desk/gen/state.hoonnew file+8
@@ -0,0 +1,8 @@
1+/- s=sphinx
2+:- %say
3+|= $: [now=@da eny=@uv =beak]
4+ [~ ~]
5+ ==
6+=/ our (scot %p p.beak)
7+=/ wen (scot %da now)
8+noun+.^(state:s /gx/[our]/sphinx/[wen]/state/noun)
desk/lib/sphinx.hoon+25−14
@@ -47,6 +47,30 @@
47 %+ turn
47 %+ turn
48 entries
48 entries
49 |=(=entry hash.entry)
49 |=(=entry hash.entry)
50+++ lengths-valid
51+ |= l=listing
52+ ?& (lte (lent (trip title.post.l)) 77)
53+ (lte (lent (trip description.post.l)) 256)
54+ (lte (lent tags.post.l) 8)
55+ (lte (lent (trip link.post.l)) 1.024)
56+ (lte (lent (trip image.post.l)) 1.024)
57+ ==
58+++ urls-valid
59+ |= l=listing
60+ =/ image
61+ ?: =(image.post.l '') 'X'
62+ (validate image.post.l)
63+ =/ link (validate link.post.l)
64+ &(!=(image ~) !=(link ~))
65+++ listing-valid
66+ |= l=listing
67+ =/ lengths (lengths-valid l)
68+ =/ urls (urls-valid l)
69+ :: ~& title.post.l
70+ :: ~& hash.l
71+ :: ~& ['urls' ?:(urls 'valid' 'invalid')]
72+ :: ~& ['lengths' ?:(lengths 'valid' 'invalid')]
73+ &(lengths urls)
50++ delver
74++ delver
51 |_ [=lookup =trigrams =phonetics =trail]
75 |_ [=lookup =trigrams =phonetics =trail]
52 ++ get
76 ++ get
@@ -54,20 +78,7 @@
54 [lookup trigrams phonetics trail]
78 [lookup trigrams phonetics trail]
55 ++ catalog
79 ++ catalog
56 |= [=hash l=listing]
80 |= [=hash l=listing]
57− ?.
81+ ?. (listing-valid l) get
58− ?& (lte (lent (trip title.post.l)) 77)
59− (lte (lent (trip description.post.l)) 256)
60− (lte (lent tags.post.l) 8)
61− (lte (lent (trip link.post.l)) 1.024)
62− (lte (lent (trip image.post.l)) 1.024)
63− ==
64− get
65− =/ image
66− ?: =(image.post.l '') 'X'
67− (validate image.post.l)
68− =/ link (validate link.post.l)
69− ?: |(=(image ~) =(link ~))
70− get
71 =/ entries=^lookup
82 =/ entries=^lookup
72 %- malt
83 %- malt
73 ^- (list [@t (list entry)])
84 ^- (list [@t (list entry)])
ui/src/state/posts.ts+2−2
@@ -136,11 +136,11 @@ export function getSnippet(body: Content[]): { image: string, content: string }
136 }, '');
136 }, '');
137 const image = body.filter((c: Content): c is UrlContent => 'url' in c && IMAGE_REGEX.test(c.url)).map(c => c.url)[0] || '';
137 const image = body.filter((c: Content): c is UrlContent => 'url' in c && IMAGE_REGEX.test(c.url)).map(c => c.url)[0] || '';
138 const content = removeMd(firstContent.replace(/!\[.*\]\((.*)\)\s*/g, ''));
138 const content = removeMd(firstContent.replace(/!\[.*\]\((.*)\)\s*/g, ''));
139− const end = content.length > 256 ? 255 : content.length;
139+ const end = content.length > 256 ? 253 : content.length;
140 const start = content.substring(0, end);
140 const start = content.substring(0, end);
141
141
142 return {
142 return {
143− content: start === firstContent ? start : `${start}...`,
143+ content: start === content ? start : `${start}...`,
144 image: getImage(firstContent) || image
144 image: getImage(firstContent) || image
145 }
145 }
146}
146}