From 651c10260f1efeea10f6b5475e13409febabfd28 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 15 Mar 2018 16:12:18 +0100 Subject: [PATCH] Dynamic instances list --- content/home.en.md | 28 +---------- content/home.fr.md | 28 +---------- .../layouts/partials/base/scripts.html | 1 + .../static/css/style.css | 23 +++++++++ .../static/js/instances.js | 47 +++++++++++++++++++ 5 files changed, 75 insertions(+), 52 deletions(-) create mode 100644 themes/hugo-bootstrap-premium/static/js/instances.js diff --git a/content/home.en.md b/content/home.en.md index 7c528c2..02253c7 100644 --- a/content/home.en.md +++ b/content/home.en.md @@ -118,32 +118,8 @@ or the entire fediverse. Liste des instances -
- -

Framatube

-

Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.

-
- -

List group item heading

-

Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.

-
- -

List group item heading

-

Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.

-
- -

List group item heading

-

Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.

-
- -

List group item heading

-

Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.

-
- -

List group item heading

-

Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.

-
-
+
+
This is like picking an e-mail hosting provider: the domain will also be part of your username!
{{% /grid %}} diff --git a/content/home.fr.md b/content/home.fr.md index 0a45b46..3d2b81d 100644 --- a/content/home.fr.md +++ b/content/home.fr.md @@ -117,33 +117,9 @@ or the entire fediverse. Liste des instances -
- -

Framatube

-

Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.

-
- -

List group item heading

-

Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.

-
- -

List group item heading

-

Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.

-
- -

List group item heading

-

Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.

-
- -

List group item heading

-

Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.

-
- -

List group item heading

-

Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.

-
-
+
+
This is like picking an e-mail hosting provider: the domain will also be part of your username!
{{% /grid %}} {{% /grid %}} diff --git a/themes/hugo-bootstrap-premium/layouts/partials/base/scripts.html b/themes/hugo-bootstrap-premium/layouts/partials/base/scripts.html index 7d62579..12e19de 100644 --- a/themes/hugo-bootstrap-premium/layouts/partials/base/scripts.html +++ b/themes/hugo-bootstrap-premium/layouts/partials/base/scripts.html @@ -17,6 +17,7 @@ {{ end }} + {{ with .Site.Params.googleAnalytics }} diff --git a/themes/hugo-bootstrap-premium/static/css/style.css b/themes/hugo-bootstrap-premium/static/css/style.css index 093c81c..b303482 100644 --- a/themes/hugo-bootstrap-premium/static/css/style.css +++ b/themes/hugo-bootstrap-premium/static/css/style.css @@ -197,3 +197,26 @@ body .medias .container { .getting-started h2 { color: #F1680D; } + +#instances-list { + max-height: 600px; + overflow-y: auto; +} + +#instances-list .list-group-item { + height: 70px; + display: flex; + flex-direction: column; + justify-content: center; +} + +#instances-list .list-group-item .list-group-item-heading { + margin-bottom: 0; +} + +#instances-list .list-group-item .list-group-item-text { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + margin-top: 5px; +} diff --git a/themes/hugo-bootstrap-premium/static/js/instances.js b/themes/hugo-bootstrap-premium/static/js/instances.js new file mode 100644 index 0000000..3dab9d7 --- /dev/null +++ b/themes/hugo-bootstrap-premium/static/js/instances.js @@ -0,0 +1,47 @@ +$(function () { + const instancesApi = 'https://instances.peertu.be/api/v1/instances' + const data = { + start: 0, + count: 100, + signup: true, + healthy: true + } + + $.get(instancesApi, data, function (res) { + const instances = res.data + + const lis = [] + instances.forEach(function (instance) { + const el = createInstanceElement(instance.host, instance.name, instance.shortDescription) + lis.push(el) + }) + + $('#instances-list').append(lis) + + }) + + function createInstanceElement (host, name, description) { + const a = $('', { + class: 'list-group-item', + href: 'https://' + host, + target: '_blank', + title: host + }) + + const h4 = $('

', { + class: 'list-group-item-heading', + text: name + }) + a.append(h4) + + if (description) { + const p = $('

', { + class: 'list-group-item-text', + text: description + }) + a.append(p) + } + + return a + } +})