⚡ produce some basic statistics on recievers of messages
This commit is contained in:
parent
bbb7976a31
commit
148a9f309d
50
main.js
50
main.js
@ -8,14 +8,15 @@ const app = express();
|
|||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var listenPort = 8088;
|
var listenPort = 8088;
|
||||||
var jsonParsedLikes, jsonParsedOutbox;
|
var jsonParsedLikes, jsonParsedOutbox;
|
||||||
const min_length = 1000; // filter only long toots
|
const min_length = 1050; // filter only long toots
|
||||||
const TemplateVars = {
|
const TemplateVars = {
|
||||||
pageTitle: "Mastodon export converter to HTML",
|
pageTitle : 'Mastodon export converter to HTML',
|
||||||
likes: jsonParsedLikes,
|
likes : jsonParsedLikes,
|
||||||
outbox: jsonParsedOutbox,
|
outbox : jsonParsedOutbox,
|
||||||
outbox_all: jsonParsedOutbox,
|
outboxStatistics: {},
|
||||||
min_length: min_length,
|
outbox_all : jsonParsedOutbox,
|
||||||
}
|
min_length : min_length,
|
||||||
|
};
|
||||||
// read file likes
|
// read file likes
|
||||||
fs.readFile('source_data/likes.json',
|
fs.readFile('source_data/likes.json',
|
||||||
// callback function that is called when reading file is done
|
// 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);
|
console.log('likes length', lengthOfLikes);
|
||||||
const example = jsonParsedLikes.orderedItems[0];
|
const example = jsonParsedLikes.orderedItems[0];
|
||||||
|
|
||||||
console.log('example', example)
|
console.log('example', example);
|
||||||
|
|
||||||
});
|
});
|
||||||
fs.readFile('source_data/outbox.json',
|
fs.readFile('source_data/outbox.json',
|
||||||
@ -39,22 +40,39 @@ fs.readFile('source_data/outbox.json',
|
|||||||
jsonParsedOutbox = JSON.parse(jsonData);
|
jsonParsedOutbox = JSON.parse(jsonData);
|
||||||
// access elements
|
// access elements
|
||||||
console.log('outbox toots length', jsonParsedOutbox.orderedItems.length);
|
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;
|
return item['object'].content && item['object'].content.length > min_length;
|
||||||
} )
|
});
|
||||||
console.log('min_chars', min_length)
|
console.log('min_chars', min_length);
|
||||||
console.log('toots min char corresponding', minchartoots.length)
|
console.log('toots min char corresponding', minchartoots.length);
|
||||||
TemplateVars.outbox = minchartoots ;
|
TemplateVars.outbox = minchartoots;
|
||||||
console.log('TemplateVars.outbox.length', TemplateVars.outbox.length,TemplateVars.outbox[5]['object'].content.length )
|
|
||||||
|
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;
|
TemplateVars.example = example;
|
||||||
|
console.log('example', example);
|
||||||
});
|
});
|
||||||
app.use(express.static('public'));
|
app.use(express.static('public'));
|
||||||
app.set('view engine', 'pug');
|
app.set('view engine', 'pug');
|
||||||
|
|
||||||
app.get('/', (req, res) => {
|
app.get('/', (req, res) => {
|
||||||
res.render( 'index.pug', TemplateVars);
|
res.render('index.pug', TemplateVars);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
11
public/stylesheets/main.css
Normal file
11
public/stylesheets/main.css
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
body{
|
||||||
|
background: #222;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
a{
|
||||||
|
color: #5561ff;
|
||||||
|
}
|
||||||
|
.status{
|
||||||
|
background:
|
||||||
|
border-bottom: 1px solid #42495c;
|
||||||
|
}
|
@ -2,15 +2,24 @@ doctype html
|
|||||||
html(lang="en")
|
html(lang="en")
|
||||||
head
|
head
|
||||||
title= pageTitle
|
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
|
body
|
||||||
h1=pageTitle
|
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}
|
h2 #{outbox.length} Messages in your outbox. Filtered by a minimal length of #{min_length}
|
||||||
each oredredItem in outbox
|
.columns-area__panels__main
|
||||||
fieldset
|
div.column
|
||||||
a(href=oredredItem.object.id)
|
div.item-list
|
||||||
=oredredItem.object.published
|
each oredredItem in outbox
|
||||||
div.published=oredredItem.object.published
|
article
|
||||||
blockquote.published(unescaped!=oredredItem.object.content)
|
div.status.status-public
|
||||||
//- each object in outbox
|
a(href=oredredItem.object.url)="see"
|
||||||
|
div.published=oredredItem.object.published
|
||||||
|
blockquote.published(unescaped!=oredredItem.object.content)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user