Merge branch 'dev' of alemi.dev:fedicharter into dev

This commit is contained in:
əlemi 2023-10-18 00:38:56 +02:00
commit 588cc4bfbc
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 9 additions and 7 deletions

9
dist/index.html vendored
View file

@ -31,7 +31,7 @@
domain = domainParam; domain = domainParam;
console.log("scanning domain " + domain); console.log("scanning domain " + domain);
} else { } else {
domain = window.prompt("starting instance for charting", "social.alemi.dev"); domain = window.prompt("starting instance for charting", "ihatebeinga.live");
} }
fetch(`https://api.alemi.dev/akkoma/bubble/crawl?domain=${domain}`) fetch(`https://api.alemi.dev/akkoma/bubble/crawl?domain=${domain}`)
@ -47,8 +47,8 @@
'#05979A', '#05979A',
] ]
for (const i in graph.nodes) { for (const i in graph.nodes) {
if (graph.nodes[i].label === domain) graph.nodes[i].color = '#BF616A'; if (graph.nodes[i].label === domain) { graph.nodes[i].color = '#BF616A' }
else graph.nodes[i].color = palette[Math.floor(Math.random() * palette.length)];; else { graph.nodes[i].color = palette[Math.floor(Math.random() * palette.length)] }
} }
const nodes = new vis.DataSet(graph.nodes); const nodes = new vis.DataSet(graph.nodes);
@ -60,9 +60,8 @@
nodes: nodes, nodes: nodes,
edges: edges, edges: edges,
}; };
const options = { edges: { dashes: true, arrows: 'to' }, nodes: { mass: 2, color: "#bf616a", shape: "box" }}; const options = { edges: { dashes: true, arrows: 'to' }, nodes: { color: "#bf616a", shape: "box", scaling: { min: 1, max: 500, label: { enabled: true, min: 14, max: 56 }}}};
const network = new vis.Network(container, data, options); const network = new vis.Network(container, data, options);
document.getElementById("loader").remove();
})) }))
</script> </script>
</body> </body>

View file

@ -1,4 +1,4 @@
use std::{collections::{HashSet, HashMap}, sync::Arc}; use std::{collections::HashMap, sync::Arc};
use serde::Serialize; use serde::Serialize;
use tokio::sync::{mpsc, RwLock}; use tokio::sync::{mpsc, RwLock};
@ -38,7 +38,7 @@ impl MapCollector {
for (i, node) in nodes_domains.iter().enumerate() { for (i, node) in nodes_domains.iter().enumerate() {
nodes_map.insert( nodes_map.insert(
node.domain.clone(), node.domain.clone(),
Node { id: i, label: node.domain.clone(), title: node.name.clone(), value: 1 } Node { id: i, label: node.domain.clone(), title: node.name.clone(), value: 1, mass: 1. }
); );
} }
@ -46,6 +46,7 @@ impl MapCollector {
let from = { let from = {
if let Some(node) = nodes_map.get_mut(&vertex.from) { if let Some(node) = nodes_map.get_mut(&vertex.from) {
node.value += 1; node.value += 1;
node.mass += 0.1;
node.id node.id
} else { } else {
tracing::warn!("vertex from nonexisting node {}", vertex.from); tracing::warn!("vertex from nonexisting node {}", vertex.from);
@ -56,6 +57,7 @@ impl MapCollector {
let to = { let to = {
if let Some(node) = nodes_map.get_mut(&vertex.to) { if let Some(node) = nodes_map.get_mut(&vertex.to) {
node.value += 10; node.value += 10;
node.mass += 1.;
node.id node.id
} else { } else {
tracing::warn!("vertex to nonexisting node {}", vertex.to); tracing::warn!("vertex to nonexisting node {}", vertex.to);
@ -120,6 +122,7 @@ pub struct Node {
pub id: usize, pub id: usize,
pub label: String, pub label: String,
pub value: usize, pub value: usize,
pub mass: f32,
pub title: String, pub title: String,
} }