diff --git a/site.js b/site.js index 543184d..1073978 100644 --- a/site.js +++ b/site.js @@ -4,14 +4,15 @@ import { rankCalc } from "./rank.js"; let cache = {}; let site = process.env.site || 'darflen'; +let route = process.env.route || './test.txt'; let hh; async function textCollector(word, path, file) { - if (!hh) hh = await readFile(file,'utf8'); + if (!hh) hh = await readFile(file, 'utf8'); hh = hh.toLowerCase(); - let words = hh.split(/[\n.]+/g).filter(x => word.length == 0 || ` ${x} `.includes(` ${word} `)) ; + let words = hh.split(/[\n.]+/g).filter(x => word.length == 0 || ` ${x} `.includes(` ${word} `)); words = words.join(' ').split(/[^a-zA-Z0-9']+/g); words = [...new Set(words)]; return words; @@ -22,8 +23,8 @@ async function siteCollector(user, path, site) { let i = 1; let out = []; - if (site.startsWith('text_')) { - return await textCollector(user, path, site.split('text_')[1]); + if (site == 'file') { + return await textCollector(user, path, route); } while (true) { @@ -96,7 +97,7 @@ async function siteCollector(user, path, site) { break; } } - data[u] = {followers: [], following: []}; + data[u] = { followers: [], following: [] }; p.push(async function (k) { let j1 = await siteCollector(u, 'followers', site);