From cd6ed45634f79bbcaef28341381368f327f3ebef Mon Sep 17 00:00:00 2001 From: Baptiste Lemoine Date: Mon, 20 Jul 2020 14:52:44 +0200 Subject: [PATCH] :zap: display config vars --- conversion.js | 15 +++++++++------ main.js | 2 ++ package.json | 2 +- public/stylesheets/main.css | 2 +- views/partials/config.pug | 8 +++++++- views/partials/medias.pug | 2 +- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/conversion.js b/conversion.js index 06752c5..48bde4d 100755 --- a/conversion.js +++ b/conversion.js @@ -21,26 +21,29 @@ class Conversion { } filterToots(toots, options) { - let minchartoots; + let filteredToots = toots; + if(options.showMostRecentTootsOnTop){ + filteredToots = filteredToots.reverse(); + } if (options.filterBiggerTottsBeforeSlicing) { - minchartoots = toots.filter(item => { + filteredToots = filteredToots.filter(item => { return item['object'].content && item['object'].content.length > options.min_length; }); - minchartoots = minchartoots.slice(0, options.max_toots); + filteredToots = filteredToots.slice(0, options.max_toots); } else { const slice = toots.slice(0, options.max_toots); - minchartoots = slice.filter(item => { + filteredToots = slice.filter(item => { return item['object'].content && item['object'].content.length > options.min_length; }); } - minchartoots.forEach(toot => { + filteredToots.forEach(toot => { toot = this.findMediaUrl(toot); toot = this.removeLastChars(toot); return toot; }); - return minchartoots; + return filteredToots; } // diff --git a/main.js b/main.js index 20a5bcc..d0b0b4f 100755 --- a/main.js +++ b/main.js @@ -15,6 +15,7 @@ const max_toots = 10; // filter only long toots const filterBiggerTottsBeforeSlicing = false; // filter only long toots const filterOnlyHavingMedias = true; // filter only toots having medias const writeStatsJson = false; // filter only toots having medias +const showMostRecentTootsOnTop = true; // filter only toots having medias const TemplateVars = { pageTitle : 'Mastodon export converter to HTML', likes : jsonParsedLikes, @@ -26,6 +27,7 @@ const TemplateVars = { filterOnlyHavingMedias, filterBiggerTottsBeforeSlicing, writeStatsJson, + showMostRecentTootsOnTop }; const masto_converter = require('./conversion'); diff --git a/package.json b/package.json index 3d33e81..2825245 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "scripts": { - "start": "node main.js" + "start": "nodemon main.js" }, "dependencies": { "bulma": "^0.9.0", diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css index 98f3587..7ac9542 100644 --- a/public/stylesheets/main.css +++ b/public/stylesheets/main.css @@ -33,7 +33,7 @@ a { } .media-media-displayed { - min-height: 500px; + min-height: 300px; margin-right: 1em; } diff --git a/views/partials/config.pug b/views/partials/config.pug index 22516c3..e370062 100644 --- a/views/partials/config.pug +++ b/views/partials/config.pug @@ -1 +1,7 @@ -h2 #{outbox.length} of Messages #{outboxTotalLength} in your outbox.First #{max_toots} toots, filtered by a minimal length of #{min_length} characters of content. +h2 Configuration of this page +div.config + p Showing #{outbox.length} of Messages #{outboxTotalLength} in your outbox.First #{max_toots} toots, filtered by a minimal length of #{min_length} characters of content. + p filter bigger toots: #{filterBiggerTottsBeforeSlicing} + p write statistics in output folder #{writeStatsJson} + p showing only toots with medias attached to them #{filterOnlyHavingMedias} + p show most recent toot first #{showMostRecentTootsOnTop} diff --git a/views/partials/medias.pug b/views/partials/medias.pug index 609a9b5..e000618 100644 --- a/views/partials/medias.pug +++ b/views/partials/medias.pug @@ -13,4 +13,4 @@ div.media-gallery if(media.mediaType.search('image') != -1) figure.media-media-displayed.media-image a(href=media.href) - img(src=media.href,alt=media.href) + img(src=media.href,alt=media.href)