hop color toots

This commit is contained in:
Baptiste Lemoine 2020-10-18 18:38:19 +02:00
parent a9f365eb44
commit d944f45236
4 changed files with 46 additions and 15 deletions

View File

@ -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;
}

21
main.js
View File

@ -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);

View File

@ -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;
}

View File

@ -2,7 +2,7 @@
img.header(src='/header.jpg')
div.container
div.container#tootsList
div.column
div.item-list
#{toot_counter = outbox.length}