mirror of
https://github.com/LemmyNet/joinlemmy-site.git
synced 2024-11-22 04:11:15 +00:00
Update crawler to latest version
This commit is contained in:
parent
41370ea9ab
commit
02423ccb2c
4 changed files with 6188 additions and 633 deletions
28
crawl.mjs
28
crawl.mjs
|
@ -1,7 +1,7 @@
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { exit } from 'process';
|
import { exit } from 'process';
|
||||||
import { spawnSync } from 'child_process';
|
import { spawn } from 'child_process';
|
||||||
|
|
||||||
const outDir = "src/shared/translations/";
|
const outDir = "src/shared/translations/";
|
||||||
const recommendationsFile = "recommended-instances.json";
|
const recommendationsFile = "recommended-instances.json";
|
||||||
|
@ -18,13 +18,27 @@ try {
|
||||||
all_recommended.push(...recommended_instances[k]);
|
all_recommended.push(...recommended_instances[k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const run = spawnSync("cargo",
|
const run = spawn("cargo",
|
||||||
["run", "--", "--start-instances", all_recommended, "--exclude", recommended_instances.exclude], {
|
["run", "--", "--start-instances", all_recommended,
|
||||||
cwd: "../lemmy-stats-crawler/",
|
"--exclude-instances", recommended_instances.exclude], {
|
||||||
|
cwd: "../lemmy-stats-crawler",
|
||||||
encoding : 'utf8'
|
encoding : 'utf8'
|
||||||
});
|
});
|
||||||
//console.log("crawler run output: ", run.output);
|
let savedOutput = '';
|
||||||
const stats = JSON.parse(run.stdout);
|
|
||||||
|
run.stdout.on('data', data => {
|
||||||
|
const strData = data.toString();
|
||||||
|
process.stdout.write(strData);
|
||||||
|
savedOutput += strData;
|
||||||
|
});
|
||||||
|
|
||||||
|
run.stderr.on('data', data => {
|
||||||
|
const strData = data.toString();
|
||||||
|
process.stdout.write(strData);
|
||||||
|
});
|
||||||
|
|
||||||
|
run.on('close', exitCode => {
|
||||||
|
const stats = JSON.parse(savedOutput);
|
||||||
|
|
||||||
let stats2 = {
|
let stats2 = {
|
||||||
stats: stats,
|
stats: stats,
|
||||||
|
@ -34,6 +48,8 @@ try {
|
||||||
let data = `export const instance_stats = \n `;
|
let data = `export const instance_stats = \n `;
|
||||||
data += JSON.stringify(stats2, null, 2) + ";";
|
data += JSON.stringify(stats2, null, 2) + ";";
|
||||||
fs.writeFileSync(instanceStatsFile, data);
|
fs.writeFileSync(instanceStatsFile, data);
|
||||||
|
});
|
||||||
|
run.await;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,11 @@ export class Instances extends Component<any, any> {
|
||||||
if (!recommended_instances) {
|
if (!recommended_instances) {
|
||||||
recommended_instances = instance_stats.recommended["en"];
|
recommended_instances = instance_stats.recommended["en"];
|
||||||
}
|
}
|
||||||
console.log(recommended_instances);
|
|
||||||
var recommended = [];
|
var recommended = [];
|
||||||
var remaining = [];
|
var remaining = [];
|
||||||
for (var i of instance_stats.stats.instance_details) {
|
for (var i of instance_stats.stats.instance_details) {
|
||||||
if (recommended_instances.indexOf(i.domain) > -1) {
|
if (recommended_instances.indexOf(i.domain) > -1) {
|
||||||
console.log(i.domain);
|
|
||||||
recommended.push(i);
|
recommended.push(i);
|
||||||
} else {
|
} else {
|
||||||
remaining.push(i);
|
remaining.push(i);
|
||||||
|
@ -69,36 +68,40 @@ export class Instances extends Component<any, any> {
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1 class="is-marginless">{header}</h1>
|
<h1 class="is-marginless">{header}</h1>
|
||||||
|
|
||||||
{instances.map(i => (
|
{instances.map(instance => {
|
||||||
|
const site = instance.site_info.site_view.site;
|
||||||
|
const counts = instance.site_info.site_view.counts;
|
||||||
|
return (
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<img
|
<img
|
||||||
class="join-icon"
|
class="join-icon"
|
||||||
src={i.icon || "/static/assets/images/lemmy.svg"}
|
src={site.icon || "/static/assets/images/lemmy.svg"}
|
||||||
/>
|
/>
|
||||||
<div class="join-text">
|
<div class="join-text">
|
||||||
<div class="join-header">
|
<div class="join-header">
|
||||||
<h4 class="join-title">{i.name}</h4>
|
<h4 class="join-title">{site.name}</h4>
|
||||||
<i>
|
<i>
|
||||||
{numToSI(i.users_active_month)} {i18n.t("users")} /{" "}
|
{numToSI(counts.users_active_month)} {i18n.t("users")} /{" "}
|
||||||
{i18n.t("month")}
|
{i18n.t("month")}
|
||||||
</i>
|
</i>
|
||||||
</div>
|
</div>
|
||||||
<p class="join-desc">{i.description}</p>
|
<p class="join-desc">{site.description}</p>
|
||||||
</div>
|
</div>
|
||||||
{i.require_application ? (
|
{site.require_application ? (
|
||||||
<a
|
<a
|
||||||
class="button primary button-yellow"
|
class="button primary button-yellow"
|
||||||
href={`https://${i.domain}`}
|
href={`https://${instance.domain}`}
|
||||||
>
|
>
|
||||||
{i18n.t("apply_to_join")}
|
{i18n.t("apply_to_join")}
|
||||||
</a>
|
</a>
|
||||||
) : (
|
) : (
|
||||||
<a class="button primary" href={`https://${i.domain}`}>
|
<a class="button primary" href={`https://${instance.domain}`}>
|
||||||
{i18n.t("join")}
|
{i18n.t("join")}
|
||||||
</a>
|
</a>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
))}
|
);
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -11,11 +11,6 @@ git fetch weblate
|
||||||
git merge weblate/main
|
git merge weblate/main
|
||||||
git push
|
git push
|
||||||
|
|
||||||
popd
|
|
||||||
pushd ../lemmy-instance-stats
|
|
||||||
./update.sh
|
|
||||||
popd
|
|
||||||
|
|
||||||
git submodule update --remote
|
git submodule update --remote
|
||||||
git add joinlemmy-translations
|
git add joinlemmy-translations
|
||||||
git add lemmy-translations
|
git add lemmy-translations
|
||||||
|
|
Loading…
Reference in a new issue