Commit 148a9f30 authored by ty kayn's avatar ty kayn

produce some basic statistics on recievers of messages

parent bbb7976a
......@@ -8,14 +8,15 @@ const app = express();
var fs = require('fs');
var listenPort = 8088;
var jsonParsedLikes, jsonParsedOutbox;
const min_length = 1000; // filter only long toots
const min_length = 1050; // filter only long toots
const TemplateVars = {
pageTitle: "Mastodon export converter to HTML",
likes: jsonParsedLikes,
outbox: jsonParsedOutbox,
outbox_all: jsonParsedOutbox,
min_length: min_length,
}
pageTitle : 'Mastodon export converter to HTML',
likes : jsonParsedLikes,
outbox : jsonParsedOutbox,
outboxStatistics: {},
outbox_all : jsonParsedOutbox,
min_length : min_length,
};
// read file likes
fs.readFile('source_data/likes.json',
// callback function that is called when reading file is done
......@@ -27,7 +28,7 @@ fs.readFile('source_data/likes.json',
console.log('likes length', lengthOfLikes);
const example = jsonParsedLikes.orderedItems[0];
console.log('example', example)
console.log('example', example);
});
fs.readFile('source_data/outbox.json',
......@@ -39,22 +40,39 @@ fs.readFile('source_data/outbox.json',
jsonParsedOutbox = JSON.parse(jsonData);
// access elements
console.log('outbox toots length', jsonParsedOutbox.orderedItems.length);
const example = jsonParsedOutbox.orderedItems[0];
const minchartoots = jsonParsedOutbox.orderedItems.filter(item =>{
const minchartoots = jsonParsedOutbox.orderedItems.filter(item => {
return item['object'].content && item['object'].content.length > min_length;
} )
console.log('min_chars', min_length)
console.log('toots min char corresponding', minchartoots.length)
TemplateVars.outbox = minchartoots ;
console.log('TemplateVars.outbox.length', TemplateVars.outbox.length,TemplateVars.outbox[5]['object'].content.length )
});
console.log('min_chars', min_length);
console.log('toots min char corresponding', minchartoots.length);
TemplateVars.outbox = minchartoots;
const example = minchartoots[1];
// make statistics on who do we talk to, based on the cc field
minchartoots.forEach(elem => {
if (elem['object'].cc) {
elem['object'].cc.forEach(copyFolk => {
if(!TemplateVars.outboxStatistics[copyFolk]){
TemplateVars.outboxStatistics[copyFolk] = {
name : copyFolk,
counter: 0
}
}
TemplateVars.outboxStatistics[copyFolk].counter += 1;
});
}
});
console.log('TemplateVars.outbox.length', TemplateVars.outbox.length, TemplateVars.outbox[5]['object'].content.length);
TemplateVars.example = example;
console.log('example', example);
});
app.use(express.static('public'));
app.set('view engine', 'pug');
app.get('/', (req, res) => {
res.render( 'index.pug', TemplateVars);
res.render('index.pug', TemplateVars);
});
......
body{
background: #222;
color: white;
}
a{
color: #5561ff;
}
.status{
background:
border-bottom: 1px solid #42495c;
}
......@@ -2,15 +2,24 @@ doctype html
html(lang="en")
head
title= pageTitle
style
link(rel='stylesheet', href='https://mastodon.cipherbliss.com/packs/css/common-f88705a5.css', type='text/css')
link(rel='stylesheet', href='stylesheets/main.css', type='text/css')
body
h1=pageTitle
h2 Statistics
fieldset.stats
h3 You did sent messages to these people
each someone in outboxStatistics
.name=someone.name
.counter=someone.counter
h2 #{outbox.length} Messages in your outbox. Filtered by a minimal length of #{min_length}
each oredredItem in outbox
fieldset
a(href=oredredItem.object.id)
=oredredItem.object.published
div.published=oredredItem.object.published
blockquote.published(unescaped!=oredredItem.object.content)
//- each object in outbox
.columns-area__panels__main
div.column
div.item-list
each oredredItem in outbox
article
div.status.status-public
a(href=oredredItem.object.url)="see"
div.published=oredredItem.object.published
blockquote.published(unescaped!=oredredItem.object.content)
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