From 7dc1a6332ac37bdc50b1f78dc7c6c9843659a89b Mon Sep 17 00:00:00 2001 From: Tykayn Date: Fri, 22 Oct 2021 15:06:44 +0200 Subject: [PATCH] add ability to search in fulltext --- conversion.js | 22 +++++++++++++++------- main.js | 16 ++++++++++------ public/stylesheets/main.css | 6 ++++-- views/partials/medias.pug | 4 ++-- views/partials/toots.pug | 6 ++++-- 5 files changed, 35 insertions(+), 19 deletions(-) diff --git a/conversion.js b/conversion.js index c66ee88..8e2ef14 100755 --- a/conversion.js +++ b/conversion.js @@ -33,17 +33,30 @@ class Conversion { let filteredToots = toots; let filter = true; console.log('before slicing filteredToots.length', filteredToots.length) - // console.log('filteredToots[0]', filteredToots[0]) + + filteredToots = filteredToots.filter(item => { + if(item['object'].content){ + + item['object'].content = item['object'].content.trim() + } + return item; + }); if (filter) { if (options.filterOnlyHavingMedias) { - toots = masto_converter.conversion.filterOnlyTootsWithMedias(toots); + toots = this.filterOnlyTootsWithMedias(toots); console.log('toots.length only attachements', toots.length); } if (options.showMostRecentTootsOnTop) { filteredToots = filteredToots.reverse(); } + if (options.searchTerm) { + console.log('filtrer les toots ayant pour contenu: ', options.searchTerm); + filteredToots = filteredToots.filter(item => { + return (item['object'].content && item['object'].content.length && item['object'].content.indexOf(options.searchTerm) !== -1); + }); + } if (options.filterBiggerTootsBeforeSlicing) { console.log('min length of content of toots ', options.min_length ); filteredToots = filteredToots.filter(item => { @@ -57,11 +70,6 @@ class Conversion { return (item['object'].content && item['object'].content.length >= options.min_length && item['object'].content.length <= options.max_length); }); } - // filteredToots.forEach(toot => { - // toot = this.findMediaUrl(toot); - // toot = this.removeLastChars(toot); - // return toot; - // }); console.log('after slicing filteredToots.length', filteredToots.length) diff --git a/main.js b/main.js index 8abb5d1..f88ce23 100755 --- a/main.js +++ b/main.js @@ -13,18 +13,22 @@ var jsonParsedLikes, jsonParsedOutbox; * export configuration. * You can filter the export in the following vars */ -const min_length = 300; // minmum character length of toots to display +const searchTerm = 'art'; +const instanceURL = 'https://mastodon.cipherbliss.com'; +const min_length = 1; // minmum character length of toots to display const max_length = 100000; // max character length of toots to display -const max_toots = 200// maximum count of output -const filterBiggerTootsBeforeSlicing = false; // filter only long toots -const filterOnlyHavingMedias = false; // filter only toots having medias -const displayMedias = false; // display medias in toots +const max_toots = 30// maximum count of output +const filterBiggerTootsBeforeSlicing = true; // filter only long toots +const filterOnlyHavingMedias = true; // filter only toots having medias +const displayMedias = true; // display medias in toots const showMostRecentTootsOnTop = true; // sorting order // output write const writeStatsJson = false; // write json export file about statistics -const writeHtml = false; // write json export file about statistics +const writeHtml = true; // write json export file about statistics const TemplateVars = { + searchTerm, + instanceURL, pageTitle : 'Mastodon export converter to HTML', likes : jsonParsedLikes, outbox : jsonParsedOutbox, diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css index 2593ee0..e1a25da 100644 --- a/public/stylesheets/main.css +++ b/public/stylesheets/main.css @@ -5,7 +5,7 @@ body { } a { - color: #00a7d1; + color: #002736 !important; } .status { @@ -19,7 +19,9 @@ a { .published { width: 70ch; } - +blockquote { + padding-right: 3em; +} .date-published { font-size: 0.5em; } diff --git a/views/partials/medias.pug b/views/partials/medias.pug index e000618..a433e43 100644 --- a/views/partials/medias.pug +++ b/views/partials/medias.pug @@ -12,5 +12,5 @@ div.media-gallery audio(src=media.href,controls=controls) if(media.mediaType.search('image') != -1) figure.media-media-displayed.media-image - a(href=media.href) - img(src=media.href,alt=media.href) + a(href=instanceURL+'/system/'+media.url) + img(src=instanceURL+'/system/'+media.url,alt=media.url) diff --git a/views/partials/toots.pug b/views/partials/toots.pug index a278642..6216acc 100644 --- a/views/partials/toots.pug +++ b/views/partials/toots.pug @@ -9,12 +9,14 @@ div.container#tootsList each oredredItem in outbox article div.status.status-public.flex - p.toot_counter= (toot_counter-=1) + p.toot_counter=(toot_counter-=1) a(href=oredredItem['object'].url) i.fa.fa-paperplane-o img.header(src='/avatar.gif') div.date-published=oredredItem['object'].published - blockquote.pl-6.published(!=oredredItem['object'].content) + blockquote.pl-6.published + | !{oredredItem['object'].content.trim()} + p.length=(oredredItem['object'].content.length) if oredredItem['object'].attachment && oredredItem['object'].attachment.length if(!displayMedias) sub.font-medium.no-media.bg-orange-300.p-2 Medias are not displayed