From 0dd146f2a3bec91dcc17392a53aaaffa7803506a Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Sun, 21 Mar 2021 04:38:30 +0300 Subject: [PATCH] Added server/platform metadata and more detailed server views. --- images/friendica-32px.png | Bin 0 -> 1120 bytes images/mastodon-32px.png | Bin 0 -> 1626 bytes images/pleroma-32px.png | Bin 0 -> 399 bytes index.html | 13 +++++++++++++ js/functions.js | 14 ++++++-------- js/list-servers.js | 38 ++++++++++++++++++++++++++------------ js/random-server.js | 27 ++++++++++++++++++++++----- js/servers.js | 26 +++++++++++++++++++------- servers.html | 14 +++++++++++--- 9 files changed, 97 insertions(+), 35 deletions(-) create mode 100644 images/friendica-32px.png create mode 100644 images/mastodon-32px.png create mode 100644 images/pleroma-32px.png diff --git a/images/friendica-32px.png b/images/friendica-32px.png new file mode 100644 index 0000000000000000000000000000000000000000..c3ee0f48b3c0cf3b13a904b36b0b7e4765dfb7aa GIT binary patch literal 1120 zcmV-m1fTnfP)hJ=H{-c`T6;YTCKJ;HKvAV9!_8>L5T)@g0?pFH6VT)8$bJXh0B?P^gKA@ z3lPBw7~}iebtqlAfS0{>eSCcUF*}pVyf-qShi9gfBy=l5D`~3`-8NP!mC0@NlB_yG z1&9d|j1j#1pCSL%NB3p3ORv~#Yiq}!p6bEUn=J&psY1KharisTAI^i`Y|;^yh7s6PH$U!Szo>9l3) zhr#RWK%jR)?)&9Zfm~q}C!B(Iaw9^eS|gv&+xGJEGL@_g2S!09{Dp-yflAP-Z3Rdm zQmB;jS6oUX6IhPdK-tnn{1MxKFd&Y9ZDZg3RNyynimn5b+r|Je4qf~2K~N|a{AfCu z9eS!$sIRu?$WaC!e_;p6e`eO6qTLbje-vQv9O7H5*J7~8qu<`_7*}%)j!s~8C-+c* zz;|c%AzVbMiycE>`=G#l`VmH6d~5FnD5W}or7@G(eK+=>uYo%Pb|pYW!p&o^ZP%aS z+aDIWwQhEdyYj0G1OGxmxO#T$(FlJd9f>qzQu~GLdG|<};+<>P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tcT~zY9;ESK4K+ zw|Fmx#q#!kpj(r8F$#3pmT7OK(=K*c;q;5+u13v+Mz;)X)XI3Nr Y7bfU%7ED#UbpQYW07*qoM6N<$g4_k>l>h($ literal 0 HcmV?d00001 diff --git a/images/pleroma-32px.png b/images/pleroma-32px.png new file mode 100644 index 0000000000000000000000000000000000000000..3699f75d55d9fc6b1793505e8e1646f6823dc8b0 GIT binary patch literal 399 zcmV;A0dW3_P)mjezpdH?^vHVTg4%?bIh zt*J@9q8Oh8K=K?SO8=P!72%j&Sc$rI0U-y_yfPYf03io}s%vgBB^1mjp-dkK@BuL> z%bjTRLBUlK*7VDUqa`6W2h7NFq;87{y~%~IN%ntL

+ + + + + + + + + + + + +
ПлатформаMastodon
РегистрацияПремодерируемая
diff --git a/js/functions.js b/js/functions.js index 7bfef72..fca7ea2 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1,14 +1,12 @@ /** - * Returns random key from the object. + * Returns random item from given array. * - * @param {object} obj - * @returns {string} + * @param {array} array + * @returns {object} */ -function getRandomKey(obj) { - let keys = Object.keys(obj); - - return keys[ keys.length * Math.random() << 0 ]; -}; +function getRandomItem(array) { + return array[array.length * Math.random() << 0]; +} /** * Randomly sorts an array. diff --git a/js/list-servers.js b/js/list-servers.js index 03d0d20..56a540a 100644 --- a/js/list-servers.js +++ b/js/list-servers.js @@ -1,19 +1,33 @@ // Should be included using 'defer' after servers.js and functions.js -let listGroup = document.getElementById('server-list'); +let tableBody = document.getElementById('table-servers-body'); -let shuffledServerNames = shuffleArray(Object.keys(instances)); -console.log('shuffled: ', shuffledServerNames); +let shuffledServers = shuffleArray(instances); +console.log('shuffled: ', shuffledServers); -for (serverName of shuffledServerNames) { - let url = instances[serverName]; +for (server of shuffledServers) { + let platform = platforms[server.platform]; + let regMode = registrationModes[server.registration]; - // Creating list item - let item = document.createElement('a'); - item.setAttribute('class', 'list-group-item'); - item.setAttribute('href', url); - item.innerText = serverName; + let tr = document.createElement('tr'); - listGroup.appendChild(item); + let tdName = document.createElement('td'); + let tdPlatform = document.createElement('td'); + let tdRegistration = document.createElement('td'); + tr.appendChild(tdName); + tr.appendChild(tdPlatform); + tr.appendChild(tdRegistration); + + serverLink = document.createElement('a'); + serverLink.setAttribute('href', server.url); + serverLink.innerText = server.name; + tdName.appendChild(serverLink); + platformIcon = document.createElement('img'); + platformIcon.setAttribute('src', platform.icon); + tdPlatform.appendChild(platformIcon); + tdPlatform.appendChild(document.createTextNode(' ' + platform.name)); + tdRegistration.innerText = regMode.name; + + // Adding to table + tableBody.appendChild(tr); } - diff --git a/js/random-server.js b/js/random-server.js index 8dc58a1..5d52657 100644 --- a/js/random-server.js +++ b/js/random-server.js @@ -1,10 +1,27 @@ // Should be included using 'defer' after servers.js and functions.js -let serverName = getRandomKey(instances); -let url = instances[serverName]; +let server = getRandomItem(instances); -console.log('Randomly selected: ', serverName, url); +console.log('Randomly selected: ', server); +// Server link let linkElement = document.getElementById('reg-link'); -linkElement.setAttribute('href', url); -linkElement.innerText = 'Регистрация на ' + serverName; +linkElement.setAttribute('href', server.url); +linkElement.innerText = 'Регистрация на ' + server.name; + +let platform = platforms[server.platform]; +let regMode = registrationModes[server.registration]; + +// Additional metadata elements +let platformElement = document.getElementById('node-platform'); +let registrationElement = document.getElementById('node-registration'); + +// Icon element +let platformIcon = document.createElement('img'); +platformIcon.setAttribute('src', platform.icon); + +platformElement.innerHTML = ''; +platformElement.appendChild(platformIcon); +platformElement.appendChild(document.createTextNode(' ' + platform.name)); + +registrationElement.innerText = regMode.name; \ No newline at end of file diff --git a/js/servers.js b/js/servers.js index c7bcb94..00748e2 100644 --- a/js/servers.js +++ b/js/servers.js @@ -1,10 +1,22 @@ // You can add your instances here using Pull Request on Github -var instances = { - 'lor.sh': 'https://lor.sh', - 'mastodon.ml': 'https://mastodon.ml', - 'Expired Mentality': 'https://expired.mentality.rip', - 'Клуб "Свобода"': 'https://soc.phreedom.club', - 'zHub.link': 'https://zhub.link', - 'Дорогу осилит идущий': 'https://aspirant.de', +var instances = [ + {name: 'lor.sh', url: 'https://lor.sh', platform: 'mastodon', registration: 'premoderated'}, + {name: 'mastodon.ml', url: 'https://mastodon.ml', platform: 'mastodon', registration: 'open'}, + {name: 'Expired Mentality', url: 'https://expired.mentality.rip', platform: 'pleroma', registration: 'open'}, + {name: 'Клуб "Свобода"', url: 'https://soc.phreedom.club', platform: 'pleroma', registration: 'open'}, + {name: 'zHub.link', url: 'https://zhub.link', platform: 'mastodon', registration: 'open'}, + {name: 'Дорогу осилит идущий', url: 'https://aspirant.de', platform: 'mastodon', registration: 'open'}, +]; + +var platforms = { + mastodon: {name: 'Mastodon', icon: 'images/mastodon-32px.png'}, + pleroma: {name: 'Pleroma', icon: 'images/pleroma-32px.png'}, + friendica: {name: 'Friendica', icon: 'images/friendica-32px.png'}, + //misskey: {name: 'Misskey', icon: 'images/misskey.png'}, +}; + +var registrationModes = { + open: {name: 'Открытая', description: 'Свободная регистрация'}, + premoderated: {name: 'Премодерируемая', description: 'После регистрации необходимо дождаться проверки модератора'}, }; diff --git a/servers.html b/servers.html index 2f17c9e..3a35472 100644 --- a/servers.html +++ b/servers.html @@ -72,9 +72,17 @@

Рекомендованные русскоязычные серверы

-
- -
+ + + + + + + + + + +
СерверПлатформаРегистрация