diff --git a/conversion.js b/conversion.js index 3a6ff8b..6cb42e2 100755 --- a/conversion.js +++ b/conversion.js @@ -30,26 +30,36 @@ class Conversion { filterToots(toots, options) { let filteredToots = toots; + let filter = true; + console.log('before slicing filteredToots.length' , filteredToots.length) + // console.log('filteredToots[0]', filteredToots[0]) + + if(filter){ if (options.showMostRecentTootsOnTop) { filteredToots = filteredToots.reverse(); } - if (options.filterBiggerTottsBeforeSlicing) { + if (options.filterBiggerTootsBeforeSlicing) { filteredToots = filteredToots.filter(item => { - return item['object'].content && item['object'].content.length > options.min_length; + return (item['object'].content && item['object'].content.length > options.min_length && item['object'].content.length < options.max_length); }); + filteredToots = filteredToots.slice(0, options.max_toots); } else { const slice = toots.slice(0, options.max_toots); filteredToots = slice.filter(item => { - return item['object'].content && item['object'].content.length > options.min_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; - }); + // filteredToots.forEach(toot => { + // toot = this.findMediaUrl(toot); + // toot = this.removeLastChars(toot); + // return toot; + // }); + console.log('after slicing filteredToots.length' , filteredToots.length) + + + } return filteredToots; } diff --git a/main.js b/main.js index ea92b62..10b839b 100755 --- a/main.js +++ b/main.js @@ -13,13 +13,17 @@ var jsonParsedLikes, jsonParsedOutbox; * export configuration. * You can filter the export in the following vars */ -const min_length = 0; // minmum character length of toots to display +const min_length = 500; // minmum character length of toots to display +const max_length = 100000; // minmum character length of toots to display const max_toots = 20// maximum length const filterBiggerTootsBeforeSlicing = false; // filter only long toots -const filterOnlyHavingMedias = false; // filter only toots having medias -const displayMedias = true; // display medias in toots -const writeStatsJson = false; // write json export file about statistics +const filterOnlyHavingMedias = true; // filter only toots having medias +const displayMedias = false; // display medias in toots const showMostRecentTootsOnTop = true; // sorting order +// output write +const writeStatsJson = false; // write json export file about statistics +const writeHtml = true; // write json export file about statistics + const TemplateVars = { pageTitle : 'Mastodon export converter to HTML', likes : jsonParsedLikes, @@ -27,6 +31,7 @@ const TemplateVars = { outboxStatistics : {}, outbox_all : jsonParsedOutbox, min_length, + max_length, max_toots, toot_counter : 0, filterOnlyHavingMedias, @@ -34,6 +39,8 @@ const TemplateVars = { writeStatsJson, showMostRecentTootsOnTop, displayMedias, + writeStatsJson, + writeHtml }; const masto_converter = require('./conversion'); @@ -67,7 +74,6 @@ fs.readFile('source_data/outbox.json', const example = TemplateVars.outbox[1]['object']; TemplateVars.example = example; - // console.log('example', example) if (writeStatsJson) { fs.writeFile('output/statistics.json', JSON.stringify(TemplateVars.outboxStatistics), errfileHandler); @@ -88,7 +94,10 @@ app.get('/', (req, res) => { const html = pug.render('index.pug', TemplateVars); - // fs.writeFile('output/my_toots.html', html, errfileHandler); + if(writeHtml){ + fs.writeFile('output/my_toots.html', html, errfileHandler); + + } res.render('index.pug', TemplateVars); diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css index 7ac9542..b8b7c5d 100644 --- a/public/stylesheets/main.css +++ b/public/stylesheets/main.css @@ -27,6 +27,10 @@ a { max-height: 15em; overflow: auto; } +#tootsList { + max-height: 35em; + overflow: auto; +} .media-gallery { @@ -48,3 +52,11 @@ video{ img{ max-width: 100%; } + +a.u-url{ + color :#1a6aff; + +} +a.hashtag{ + color : #0c245b; +} diff --git a/views/partials/toots.pug b/views/partials/toots.pug index 2185a18..a278642 100644 --- a/views/partials/toots.pug +++ b/views/partials/toots.pug @@ -2,7 +2,7 @@ img.header(src='/header.jpg') -div.container +div.container#tootsList div.column div.item-list #{toot_counter = outbox.length}