on master help sign in
parsing: fixing byte length counting and bad char removal
d6bd4b0Hunter Miller
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-0v4.rk6nd.h0t14.4j4tv.q4bia.9m66a.glob' 0v4.rk6nd.h0t14.4j4tv.q4bia.9m66a]
5+ glob-http+['https://nyc3.digitaloceanspaces.com/hmillerdev/sphinx/glob-0v7.folii.k685s.mjn1b.46up6.but26.glob' 0v7.folii.k685s.mjn1b.46up6.but26]
6 base+'sphinx'
6 base+'sphinx'
7− version+[0 4 3]
7+ version+[0 4 4]
8 website+'https://github.com'
8 website+'https://github.com'
9 license+'MIT'
9 license+'MIT'
10==
10==
desk/lib/sift.hoon+9−8
@@ -9,19 +9,22 @@
9 (~(has in words) word)
9 (~(has in words) word)
10++ norm
10++ norm
11 |= corpus=@t
11 |= corpus=@t
12+ ^- @t
12 ?: =(corpus '') ''
13 ?: =(corpus '') ''
13− (crip (cass (trimall (crip (expunge corpus)))))
14+ (crip (cass (expunge (crip (trimall corpus)))))
14++ split
15++ split
15 |= corpus=@t
16 |= corpus=@t
16 ^- (list @t)
17 ^- (list @t)
17 ?: =(corpus '') ~
18 ?: =(corpus '') ~
18− %+ rash (norm corpus)
19+ =/ test (norm corpus)
20+ %+ rash test
19− (more ace (cook crip (plus ;~(pose aln hep))))
21+ (more (plus ws) (cook crip (plus ;~(pose aln hep))))
20++ allowed ;~(pose aln hep ace)
22++ allowed ;~(pose aln hep ace)
21−++ banned ;~(less allowed prn)
23+++ banned ;~(less allowed next)
24+++ ws (mask " \0a\0d\09")
22++ expunge
25++ expunge
23 |= corpus=@t
26 |= corpus=@t
24− ^- (list @t)
27+ ^- tape
25 ?: =(corpus '') ~
28 ?: =(corpus '') ~
26 %- zing
29 %- zing
27 %+ rash corpus
30 %+ rash corpus
@@ -33,7 +36,7 @@
33 ==
36 ==
34++ trimall
37++ trimall
35 |= corpus=@t
38 |= corpus=@t
36− |^ ^- tape
39+ ^- tape
37 ?: =(corpus '') ~
40 ?: =(corpus '') ~
38 %+ rash corpus
41 %+ rash corpus
39 %+ ifix [(star ws) (star ws)]
42 %+ ifix [(star ws) (star ws)]
@@ -42,8 +45,6 @@
42 ;~(plug (plus ws) ;~(less next (easy ~)))
45 ;~(plug (plus ws) ;~(less next (easy ~)))
43 ;~(pose (cold ' ' (plus ws)) next)
46 ;~(pose (cold ' ' (plus ws)) next)
44 ==
47 ==
45− ++ ws (mask " \0a\0d\09")
46− --
47++ words
48++ words
48 %- silt
49 %- silt
49 :~ 'a'
50 :~ 'a'
ui/src/state/posts.ts+6−2
@@ -137,8 +137,12 @@ export function getSnippet(body: Content[]): { image: string, content: string }
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 ? 253 : content.length;
139 const end = content.length > 256 ? 253 : content.length;
140− const start = content.substring(0, end);
140+ let start = content.substring(0, end);
141−
141+ const length = new Blob([start]).size;
142+ if (length > end) {
143+ start = start.substring(0, end - (length - end))
144+ }
145+
142 return {
146 return {
143 content: start === content ? start : `${start}...`,
147 content: start === content ? start : `${start}...`,
144 image: getImage(firstContent) || image
148 image: getImage(firstContent) || image