add ability to search in fulltext
This commit is contained in:
parent
afef2388dc
commit
7dc1a6332a
@ -33,17 +33,30 @@ class Conversion {
|
|||||||
let filteredToots = toots;
|
let filteredToots = toots;
|
||||||
let filter = true;
|
let filter = true;
|
||||||
console.log('before slicing filteredToots.length', filteredToots.length)
|
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 (filter) {
|
||||||
|
|
||||||
if (options.filterOnlyHavingMedias) {
|
if (options.filterOnlyHavingMedias) {
|
||||||
toots = masto_converter.conversion.filterOnlyTootsWithMedias(toots);
|
toots = this.filterOnlyTootsWithMedias(toots);
|
||||||
console.log('toots.length only attachements', toots.length);
|
console.log('toots.length only attachements', toots.length);
|
||||||
}
|
}
|
||||||
if (options.showMostRecentTootsOnTop) {
|
if (options.showMostRecentTootsOnTop) {
|
||||||
filteredToots = filteredToots.reverse();
|
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) {
|
if (options.filterBiggerTootsBeforeSlicing) {
|
||||||
console.log('min length of content of toots ', options.min_length );
|
console.log('min length of content of toots ', options.min_length );
|
||||||
filteredToots = filteredToots.filter(item => {
|
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);
|
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)
|
console.log('after slicing filteredToots.length', filteredToots.length)
|
||||||
|
|
||||||
|
|
||||||
|
16
main.js
16
main.js
@ -13,18 +13,22 @@ var jsonParsedLikes, jsonParsedOutbox;
|
|||||||
* export configuration.
|
* export configuration.
|
||||||
* You can filter the export in the following vars
|
* 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_length = 100000; // max character length of toots to display
|
||||||
const max_toots = 200// maximum count of output
|
const max_toots = 30// maximum count of output
|
||||||
const filterBiggerTootsBeforeSlicing = false; // filter only long toots
|
const filterBiggerTootsBeforeSlicing = true; // filter only long toots
|
||||||
const filterOnlyHavingMedias = false; // filter only toots having medias
|
const filterOnlyHavingMedias = true; // filter only toots having medias
|
||||||
const displayMedias = false; // display medias in toots
|
const displayMedias = true; // display medias in toots
|
||||||
const showMostRecentTootsOnTop = true; // sorting order
|
const showMostRecentTootsOnTop = true; // sorting order
|
||||||
// output write
|
// output write
|
||||||
const writeStatsJson = false; // write json export file about statistics
|
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 = {
|
const TemplateVars = {
|
||||||
|
searchTerm,
|
||||||
|
instanceURL,
|
||||||
pageTitle : 'Mastodon export converter to HTML',
|
pageTitle : 'Mastodon export converter to HTML',
|
||||||
likes : jsonParsedLikes,
|
likes : jsonParsedLikes,
|
||||||
outbox : jsonParsedOutbox,
|
outbox : jsonParsedOutbox,
|
||||||
|
@ -5,7 +5,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: #00a7d1;
|
color: #002736 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status {
|
.status {
|
||||||
@ -19,7 +19,9 @@ a {
|
|||||||
.published {
|
.published {
|
||||||
width: 70ch;
|
width: 70ch;
|
||||||
}
|
}
|
||||||
|
blockquote {
|
||||||
|
padding-right: 3em;
|
||||||
|
}
|
||||||
.date-published {
|
.date-published {
|
||||||
font-size: 0.5em;
|
font-size: 0.5em;
|
||||||
}
|
}
|
||||||
|
@ -12,5 +12,5 @@ div.media-gallery
|
|||||||
audio(src=media.href,controls=controls)
|
audio(src=media.href,controls=controls)
|
||||||
if(media.mediaType.search('image') != -1)
|
if(media.mediaType.search('image') != -1)
|
||||||
figure.media-media-displayed.media-image
|
figure.media-media-displayed.media-image
|
||||||
a(href=media.href)
|
a(href=instanceURL+'/system/'+media.url)
|
||||||
img(src=media.href,alt=media.href)
|
img(src=instanceURL+'/system/'+media.url,alt=media.url)
|
||||||
|
@ -9,12 +9,14 @@ div.container#tootsList
|
|||||||
each oredredItem in outbox
|
each oredredItem in outbox
|
||||||
article
|
article
|
||||||
div.status.status-public.flex
|
div.status.status-public.flex
|
||||||
p.toot_counter= (toot_counter-=1)
|
p.toot_counter=(toot_counter-=1)
|
||||||
a(href=oredredItem['object'].url)
|
a(href=oredredItem['object'].url)
|
||||||
i.fa.fa-paperplane-o
|
i.fa.fa-paperplane-o
|
||||||
img.header(src='/avatar.gif')
|
img.header(src='/avatar.gif')
|
||||||
div.date-published=oredredItem['object'].published
|
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 oredredItem['object'].attachment && oredredItem['object'].attachment.length
|
||||||
if(!displayMedias)
|
if(!displayMedias)
|
||||||
sub.font-medium.no-media.bg-orange-300.p-2 Medias are not displayed
|
sub.font-medium.no-media.bg-orange-300.p-2 Medias are not displayed
|
||||||
|
Loading…
Reference in New Issue
Block a user