Commit d944f452 authored by ty kayn's avatar ty kayn

hop color toots

parent a9f365eb
...@@ -30,26 +30,36 @@ class Conversion { ...@@ -30,26 +30,36 @@ class Conversion {
filterToots(toots, options) { filterToots(toots, options) {
let filteredToots = toots; 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) { if (options.showMostRecentTootsOnTop) {
filteredToots = filteredToots.reverse(); filteredToots = filteredToots.reverse();
} }
if (options.filterBiggerTottsBeforeSlicing) { if (options.filterBiggerTootsBeforeSlicing) {
filteredToots = filteredToots.filter(item => { 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); filteredToots = filteredToots.slice(0, options.max_toots);
} else { } else {
const slice = toots.slice(0, options.max_toots); const slice = toots.slice(0, options.max_toots);
filteredToots = slice.filter(item => { 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 => { // filteredToots.forEach(toot => {
toot = this.findMediaUrl(toot); // toot = this.findMediaUrl(toot);
toot = this.removeLastChars(toot); // toot = this.removeLastChars(toot);
return toot; // return toot;
}); // });
console.log('after slicing filteredToots.length' , filteredToots.length)
}
return filteredToots; return filteredToots;
} }
......
...@@ -13,13 +13,17 @@ var jsonParsedLikes, jsonParsedOutbox; ...@@ -13,13 +13,17 @@ 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 = 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 max_toots = 20// maximum length
const filterBiggerTootsBeforeSlicing = false; // filter only long toots const filterBiggerTootsBeforeSlicing = false; // filter only long toots
const filterOnlyHavingMedias = false; // filter only toots having medias const filterOnlyHavingMedias = true; // filter only toots having medias
const displayMedias = true; // display medias in toots const displayMedias = false; // display medias in toots
const writeStatsJson = false; // write json export file about statistics
const showMostRecentTootsOnTop = true; // sorting order 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 = { const TemplateVars = {
pageTitle : 'Mastodon export converter to HTML', pageTitle : 'Mastodon export converter to HTML',
likes : jsonParsedLikes, likes : jsonParsedLikes,
...@@ -27,6 +31,7 @@ const TemplateVars = { ...@@ -27,6 +31,7 @@ const TemplateVars = {
outboxStatistics : {}, outboxStatistics : {},
outbox_all : jsonParsedOutbox, outbox_all : jsonParsedOutbox,
min_length, min_length,
max_length,
max_toots, max_toots,
toot_counter : 0, toot_counter : 0,
filterOnlyHavingMedias, filterOnlyHavingMedias,
...@@ -34,6 +39,8 @@ const TemplateVars = { ...@@ -34,6 +39,8 @@ const TemplateVars = {
writeStatsJson, writeStatsJson,
showMostRecentTootsOnTop, showMostRecentTootsOnTop,
displayMedias, displayMedias,
writeStatsJson,
writeHtml
}; };
const masto_converter = require('./conversion'); const masto_converter = require('./conversion');
...@@ -67,7 +74,6 @@ fs.readFile('source_data/outbox.json', ...@@ -67,7 +74,6 @@ fs.readFile('source_data/outbox.json',
const example = TemplateVars.outbox[1]['object']; const example = TemplateVars.outbox[1]['object'];
TemplateVars.example = example; TemplateVars.example = example;
// console.log('example', example)
if (writeStatsJson) { if (writeStatsJson) {
fs.writeFile('output/statistics.json', JSON.stringify(TemplateVars.outboxStatistics), errfileHandler); fs.writeFile('output/statistics.json', JSON.stringify(TemplateVars.outboxStatistics), errfileHandler);
...@@ -88,7 +94,10 @@ app.get('/', (req, res) => { ...@@ -88,7 +94,10 @@ app.get('/', (req, res) => {
const html = pug.render('index.pug', TemplateVars); 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); res.render('index.pug', TemplateVars);
......
...@@ -27,6 +27,10 @@ a { ...@@ -27,6 +27,10 @@ a {
max-height: 15em; max-height: 15em;
overflow: auto; overflow: auto;
} }
#tootsList {
max-height: 35em;
overflow: auto;
}
.media-gallery { .media-gallery {
...@@ -48,3 +52,11 @@ video{ ...@@ -48,3 +52,11 @@ video{
img{ img{
max-width: 100%; max-width: 100%;
} }
a.u-url{
color :#1a6aff;
}
a.hashtag{
color : #0c245b;
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
img.header(src='/header.jpg') img.header(src='/header.jpg')
div.container div.container#tootsList
div.column div.column
div.item-list div.item-list
#{toot_counter = outbox.length} #{toot_counter = outbox.length}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment