mirror of
https://github.com/LemmyNet/joinlemmy-site.git
synced 2024-11-24 21:31:16 +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
46
crawl.mjs
46
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";
|
||||||
|
@ -15,25 +15,41 @@ try {
|
||||||
var all_recommended = [];
|
var all_recommended = [];
|
||||||
for (var k in recommended_instances) {
|
for (var k in recommended_instances) {
|
||||||
if (k != "exclude") {
|
if (k != "exclude") {
|
||||||
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], {
|
||||||
encoding : 'utf8'
|
cwd: "../lemmy-stats-crawler",
|
||||||
|
encoding : 'utf8'
|
||||||
|
});
|
||||||
|
let savedOutput = '';
|
||||||
|
|
||||||
|
run.stdout.on('data', data => {
|
||||||
|
const strData = data.toString();
|
||||||
|
process.stdout.write(strData);
|
||||||
|
savedOutput += strData;
|
||||||
});
|
});
|
||||||
//console.log("crawler run output: ", run.output);
|
|
||||||
const stats = JSON.parse(run.stdout);
|
|
||||||
|
|
||||||
let stats2 = {
|
run.stderr.on('data', data => {
|
||||||
stats: stats,
|
const strData = data.toString();
|
||||||
recommended: recommended_instances
|
process.stdout.write(strData);
|
||||||
}
|
});
|
||||||
|
|
||||||
let data = `export const instance_stats = \n `;
|
run.on('close', exitCode => {
|
||||||
data += JSON.stringify(stats2, null, 2) + ";";
|
const stats = JSON.parse(savedOutput);
|
||||||
fs.writeFileSync(instanceStatsFile, data);
|
|
||||||
|
let stats2 = {
|
||||||
|
stats: stats,
|
||||||
|
recommended: recommended_instances
|
||||||
|
}
|
||||||
|
|
||||||
|
let data = `export const instance_stats = \n `;
|
||||||
|
data += JSON.stringify(stats2, null, 2) + ";";
|
||||||
|
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 => {
|
||||||
<div class="card">
|
const site = instance.site_info.site_view.site;
|
||||||
<img
|
const counts = instance.site_info.site_view.counts;
|
||||||
class="join-icon"
|
return (
|
||||||
src={i.icon || "/static/assets/images/lemmy.svg"}
|
<div class="card">
|
||||||
/>
|
<img
|
||||||
<div class="join-text">
|
class="join-icon"
|
||||||
<div class="join-header">
|
src={site.icon || "/static/assets/images/lemmy.svg"}
|
||||||
<h4 class="join-title">{i.name}</h4>
|
/>
|
||||||
<i>
|
<div class="join-text">
|
||||||
{numToSI(i.users_active_month)} {i18n.t("users")} /{" "}
|
<div class="join-header">
|
||||||
{i18n.t("month")}
|
<h4 class="join-title">{site.name}</h4>
|
||||||
</i>
|
<i>
|
||||||
|
{numToSI(counts.users_active_month)} {i18n.t("users")} /{" "}
|
||||||
|
{i18n.t("month")}
|
||||||
|
</i>
|
||||||
|
</div>
|
||||||
|
<p class="join-desc">{site.description}</p>
|
||||||
</div>
|
</div>
|
||||||
<p class="join-desc">{i.description}</p>
|
{site.require_application ? (
|
||||||
|
<a
|
||||||
|
class="button primary button-yellow"
|
||||||
|
href={`https://${instance.domain}`}
|
||||||
|
>
|
||||||
|
{i18n.t("apply_to_join")}
|
||||||
|
</a>
|
||||||
|
) : (
|
||||||
|
<a class="button primary" href={`https://${instance.domain}`}>
|
||||||
|
{i18n.t("join")}
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{i.require_application ? (
|
);
|
||||||
<a
|
})}
|
||||||
class="button primary button-yellow"
|
|
||||||
href={`https://${i.domain}`}
|
|
||||||
>
|
|
||||||
{i18n.t("apply_to_join")}
|
|
||||||
</a>
|
|
||||||
) : (
|
|
||||||
<a class="button primary" href={`https://${i.domain}`}>
|
|
||||||
{i18n.t("join")}
|
|
||||||
</a>
|
|
||||||
)}
|
|
||||||
</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