mirror of
https://github.com/LemmyNet/joinlemmy-site.git
synced 2024-11-24 21:31:16 +00:00
Add recommended instances (#97)
* Add recommended instances * add translations * dont pull submodule main branch in ci * camelCase * remove unused code
This commit is contained in:
parent
fcd45027c4
commit
6e6d723f09
6 changed files with 76 additions and 54 deletions
|
@ -12,7 +12,7 @@ steps:
|
|||
image: alpine/git
|
||||
commands:
|
||||
- git submodule init
|
||||
- git submodule update --recursive --remote
|
||||
- git submodule update --recursive
|
||||
|
||||
- name: yarn
|
||||
image: node:14-alpine
|
||||
|
|
|
@ -1,21 +1,35 @@
|
|||
import fs from 'fs';
|
||||
import fetch from 'node-fetch';
|
||||
import path from 'path';
|
||||
|
||||
const translationDir = "joinlemmy-translations/translations/";
|
||||
const outDir = "src/shared/translations/";
|
||||
const translatorsJsonFile = "lemmy-translations/translators.json";
|
||||
const statsFile = "lemmy-instance-stats/stats.json";
|
||||
const recommendationsFile = "lemmy-instance-stats/recommended-instances.csv";
|
||||
const newsDir = "src/assets/news";
|
||||
const releasesLocation = "https://raw.githubusercontent.com/LemmyNet/lemmy/main/RELEASES.md";
|
||||
|
||||
fs.mkdirSync(outDir, { recursive: true });
|
||||
|
||||
// Write the stats file
|
||||
try {
|
||||
const json = JSON.parse(fs.readFileSync(statsFile, "utf8"));
|
||||
const stats = JSON.parse(fs.readFileSync(statsFile, "utf8"));
|
||||
const recommended_domains = fs.readFileSync(recommendationsFile, "utf8").split(',');
|
||||
const recommended = stats.instance_details.filter(i =>
|
||||
recommended_domains.includes(i.domain)
|
||||
);
|
||||
const remaining = stats.instance_details.filter(i =>
|
||||
!recommended_domains.includes(i.domain)
|
||||
);
|
||||
|
||||
let stats2 = {
|
||||
crawled_instances: stats.crawled_instances,
|
||||
total_users: stats.total_users,
|
||||
recommended: recommended,
|
||||
remaining: remaining,
|
||||
}
|
||||
|
||||
let data = `export const instance_stats = \n `;
|
||||
data += JSON.stringify(json, null, 2) + ";";
|
||||
data += JSON.stringify(stats2, null, 2) + ";";
|
||||
const target = outDir + "instance_stats.ts";
|
||||
fs.writeFileSync(target, data);
|
||||
} catch (err) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 178c575193bf45cbf3d220f6a760961e95b09259
|
||||
Subproject commit 6fc4a95b6eaf54e68983d217fb9a310e7c8ed63c
|
|
@ -1 +1 @@
|
|||
Subproject commit 9d7a7f751aa43cbbf062244523d448b94a81e7ee
|
||||
Subproject commit 8c7a2e001508f40b171417d18952ad1896af85cd
|
|
@ -1 +1 @@
|
|||
Subproject commit 2c557fdcf69659fb9ce587d786e362ca024bcca1
|
||||
Subproject commit ad40feba4263a850f135946847d3ddd1a890a6e7
|
|
@ -11,6 +11,25 @@ export class Instances extends Component<any, any> {
|
|||
super(props, context);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div class="container">
|
||||
<Helmet title={title}>
|
||||
<meta property={"title"} content={title} />
|
||||
</Helmet>
|
||||
<h1 class="is-marginless">{i18n.t("lemmy_servers")}</h1>
|
||||
{this.header()}
|
||||
<br />
|
||||
<br />
|
||||
{this.renderList(
|
||||
i18n.t("recommended_instances"),
|
||||
instance_stats.recommended
|
||||
)}
|
||||
{this.renderList(i18n.t("popular_instances"), instance_stats.remaining)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
header() {
|
||||
return (
|
||||
<i>
|
||||
|
@ -22,56 +41,45 @@ export class Instances extends Component<any, any> {
|
|||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
let instances = instance_stats.instance_details;
|
||||
renderList(header: string, instances: any[]) {
|
||||
return (
|
||||
<div>
|
||||
<Helmet title={title}>
|
||||
<meta property={"title"} content={title} />
|
||||
</Helmet>
|
||||
<div class="container">
|
||||
<h1 class="is-marginless">{i18n.t("lemmy_servers")}</h1>
|
||||
{this.header()}
|
||||
<br />
|
||||
<br />
|
||||
<p>{i18n.t("choose_and_join")}</p>
|
||||
|
||||
<div class="row">
|
||||
{instances.map(i => (
|
||||
<div class="card col-6">
|
||||
<header>
|
||||
<div class="row">
|
||||
<h4 class="col">{i.domain}</h4>
|
||||
<h4 class="col text-right">
|
||||
<i>
|
||||
{numToSI(i.users_active_month)} {i18n.t("users")} /{" "}
|
||||
{i18n.t("month")}
|
||||
</i>
|
||||
</h4>
|
||||
</div>
|
||||
</header>
|
||||
<div class="is-center">
|
||||
<img
|
||||
class="join-banner"
|
||||
src={i.icon || "/static/assets/images/lemmy.svg"}
|
||||
/>
|
||||
<h2>{header}</h2>
|
||||
<div class="row">
|
||||
{instances.map(i => (
|
||||
<div class="card col-6">
|
||||
<header>
|
||||
<div class="row">
|
||||
<h4 class="col">{i.domain}</h4>
|
||||
<h4 class="col text-right">
|
||||
<i>
|
||||
{numToSI(i.users_active_month)} {i18n.t("users")} /{" "}
|
||||
{i18n.t("month")}
|
||||
</i>
|
||||
</h4>
|
||||
</div>
|
||||
<br />
|
||||
<p class="join-desc">{i.description}</p>
|
||||
<footer>
|
||||
{i.require_application ? (
|
||||
<a class="button primary" href={`https://${i.domain}`}>
|
||||
{i18n.t("apply_to_join")}
|
||||
</a>
|
||||
) : (
|
||||
<a class="button primary" href={`https://${i.domain}`}>
|
||||
{i18n.t("join")}
|
||||
</a>
|
||||
)}
|
||||
</footer>
|
||||
</header>
|
||||
<div class="is-center">
|
||||
<img
|
||||
class="join-banner"
|
||||
src={i.icon || "/static/assets/images/lemmy.svg"}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<br />
|
||||
<p class="join-desc">{i.description}</p>
|
||||
<footer>
|
||||
{i.require_application ? (
|
||||
<a class="button primary" href={`https://${i.domain}`}>
|
||||
{i18n.t("apply_to_join")}
|
||||
</a>
|
||||
) : (
|
||||
<a class="button primary" href={`https://${i.domain}`}>
|
||||
{i18n.t("join")}
|
||||
</a>
|
||||
)}
|
||||
</footer>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue