on master help sign in
parsing: fixing byte length counting and bad char removal
commitd6bd4b03d154dab643720f846dd764857f894d80 authorHunter Miller <hunter@hmiller.dev> dateSun 7 Aug 2022, 00:27 (4 years ago) parent5795043
3 files changed+17−12
desk/desk.docket-0+2−2 desk/lib/sift.hoon+9−8 ui/src/state/posts.ts+6−2
desk/desk.docket-0+2−2
@@ -2,9 +2,9 @@
22 info+'A search engine powered by you and your pals for finding answers to your riddles'
33 color+0xb2.5068
44 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]
66 base+'sphinx'
7− version+[0 4 3]
7+ version+[0 4 4]
88 website+'https://github.com'
99 license+'MIT'
1010==
desk/lib/sift.hoon+9−8
@@ -9,19 +9,22 @@
99 (~(has in words) word)
1010++ norm
1111 |= corpus=@t
12+ ^- @t
1213 ?: =(corpus '') ''
13− (crip (cass (trimall (crip (expunge corpus)))))
14+ (crip (cass (expunge (crip (trimall corpus)))))
1415++ split
1516 |= corpus=@t
1617 ^- (list @t)
1718 ?: =(corpus '') ~
18− %+ rash (norm corpus)
19− (more ace (cook crip (plus ;~(pose aln hep))))
19+ =/ test (norm corpus)
20+ %+ rash test
21+ (more (plus ws) (cook crip (plus ;~(pose aln hep))))
2022++ allowed ;~(pose aln hep ace)
21−++ banned ;~(less allowed prn)
23+++ banned ;~(less allowed next)
24+++ ws (mask " \0a\0d\09")
2225++ expunge
2326 |= corpus=@t
24− ^- (list @t)
27+ ^- tape
2528 ?: =(corpus '') ~
2629 %- zing
2730 %+ rash corpus
@@ -33,7 +36,7 @@
3336 ==
3437++ trimall
3538 |= corpus=@t
36− |^ ^- tape
39+ ^- tape
3740 ?: =(corpus '') ~
3841 %+ rash corpus
3942 %+ ifix [(star ws) (star ws)]
@@ -42,8 +45,6 @@
4245 ;~(plug (plus ws) ;~(less next (easy ~)))
4346 ;~(pose (cold ' ' (plus ws)) next)
4447 ==
45− ++ ws (mask " \0a\0d\09")
46− --
4748++ words
4849 %- silt
4950 :~ 'a'
ui/src/state/posts.ts+6−2
@@ -137,8 +137,12 @@ export function getSnippet(body: Content[]): { image: string, content: string }
137137 const image = body.filter((c: Content): c is UrlContent => 'url' in c && IMAGE_REGEX.test(c.url)).map(c => c.url)[0] || '';
138138 const content = removeMd(firstContent.replace(/!\[.*\]\((.*)\)\s*/g, ''));
139139 const end = content.length > 256 ? 253 : content.length;
140− const start = content.substring(0, end);
141−
140+ let start = content.substring(0, end);
141+ const length = new Blob([start]).size;
142+ if (length > end) {
143+ start = start.substring(0, end - (length - end))
144+ }
145+
142146 return {
143147 content: start === content ? start : `${start}...`,
144148 image: getImage(firstContent) || image