Fixes to the server list
This commit is contained in:
parent
76249cc6ec
commit
7f397fe497
6 changed files with 60 additions and 23 deletions
|
@ -422,16 +422,19 @@ if (datalist) {
|
|||
setTimeout(checkInstance, 10);
|
||||
}
|
||||
for (const instance of json) {
|
||||
if (instance.display === false) {
|
||||
continue;
|
||||
}
|
||||
const option = document.createElement("option");
|
||||
option.value = instance.name;
|
||||
if (instance.URL) {
|
||||
stringURLMap.set(option.value, instance.URL);
|
||||
if (instance.URLs) {
|
||||
stringURLsMap.set(instance.URL, instance.URLs);
|
||||
if (instance.url) {
|
||||
stringURLMap.set(option.value, instance.url);
|
||||
if (instance.urls) {
|
||||
stringURLsMap.set(instance.url, instance.urls);
|
||||
}
|
||||
}
|
||||
else if (instance.URLs) {
|
||||
stringURLsMap.set(option.value, instance.URLs);
|
||||
else if (instance.urls) {
|
||||
stringURLsMap.set(option.value, instance.urls);
|
||||
}
|
||||
else {
|
||||
option.disabled = true;
|
||||
|
|
|
@ -5,9 +5,12 @@ inside of webpage you'll see a file called `instances.json` in that file you'll
|
|||
"name":<name>,
|
||||
"description"?:<short description>,
|
||||
"descriptionLong"?:<A description for the instance that can be longer>,
|
||||
"src"?:<URL to image repersenting your instance>,
|
||||
"URL"?:<The URL that can be used to get your wellknown>,
|
||||
"URLs"?:{
|
||||
"image"?:<URL to image repersenting your instance>,
|
||||
"url"?:<The URL that can be used to get your wellknown>,
|
||||
"language":<what language your server is in>,
|
||||
"country":<what country your server is in>,
|
||||
"display":<true or false depending on wether it should display>,
|
||||
"urls"?:{
|
||||
"wellknown":<wellknown URL>,
|
||||
"api":<API URL>,
|
||||
"cdn":<CDN URL>,
|
||||
|
@ -26,6 +29,8 @@ inside of webpage you'll see a file called `instances.json` in that file you'll
|
|||
```
|
||||
anything with a `?` in-front of its `:` are optional, though you must either include `"URL"` or `"URLs"`, but you may include both, though the client will most likely ignore `"URLs"` in favor of `"URL"`, though it may use `"URLs"` as a fallback if `"URL"` does not resolve, do not rely on this behavior.
|
||||
Some of these values may not be used right now, though they will likely be used in the future, so feel free to fill out what you like, though the more you fill out the more information we can give the users about your instance in the future.
|
||||
language should be [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1_codes).
|
||||
Country should be [ISO 8166-2 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
|
||||
# Questions
|
||||
## Do I have to do this to let Jank Client connect to my server?
|
||||
No, you may choose to not do this, this just makes it easier for people using Jank Client to find and use your instance as it's in the dropdown menu for instances, though the user may enter any instance they please.
|
||||
|
|
28
index.js
28
index.js
|
@ -4,8 +4,29 @@ const compression = require('compression')
|
|||
const express = require('express');
|
||||
const fs = require('fs');
|
||||
const app = express();
|
||||
const instances=require("./webpage/instances.json")
|
||||
const instancenames=new Map();
|
||||
for(const instance of instances){
|
||||
instancenames.set(instance.name,instance);
|
||||
}
|
||||
app.use(compression())
|
||||
|
||||
fetch("https://raw.githubusercontent.com/spacebarchat/spacebarchat/master/instances/instances.json").then(_=>_.json()).then(json=>{
|
||||
for(const instance of json){
|
||||
console.log(instance);
|
||||
if(!instancenames.has(instance.name)){
|
||||
console.log("pushed");
|
||||
instances.push(instance);
|
||||
console.log(instances)
|
||||
}else{
|
||||
const ofinst=instancenames.get(instance.name)
|
||||
for(const key of Object.keys(instance)){
|
||||
if(!ofinst[key]){
|
||||
ofinst[key]=instance[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
app.use("/getupdates",(req, res) => {
|
||||
const out=fs.statSync(`${__dirname}/webpage`);
|
||||
|
@ -142,6 +163,11 @@ app.use('/', async (req, res) => {
|
|||
res.send("dud");
|
||||
return;
|
||||
}
|
||||
if(req.path.startsWith("/instances.json")){
|
||||
console.log("grabbed")
|
||||
res.send(JSON.stringify(instances));
|
||||
return;
|
||||
}
|
||||
if(req.path.startsWith("/invite/")){
|
||||
res.sendFile(`./webpage/invite.html`, {root: __dirname});
|
||||
return;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[
|
||||
{
|
||||
"name":"Spacebar Official",
|
||||
"description":"The official instance of spacebar!",
|
||||
"src":"https://cdn.old.server.spacebar.chat/icons/1006649183970562092/fb5218b5dfad5e1c7b452c17ddb1701e.png",
|
||||
"URL":"https://spacebar.chat"
|
||||
"name":"Spacebar",
|
||||
"description":"The official Spacebar instance.",
|
||||
"image":"https://raw.githubusercontent.com/spacebarchat/spacebarchat/master/branding/png/Spacebar__Icon-Discord.png",
|
||||
"url":"https://spacebar.chat"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -405,22 +405,25 @@ export {mobile, getBulkUsers,getBulkInfo,setTheme,Specialuser,getapiurls,adduser
|
|||
const datalist=document.getElementById("instances");
|
||||
console.warn(datalist);
|
||||
if(datalist){
|
||||
fetch("/instances.json").then(_=>_.json()).then((json:{name:string,description?:string,src?:string,URL?:string,URLs:{wellknown:string,api:string,cdn:string,gateway:string,login?:string}}[])=>{
|
||||
fetch("/instances.json").then(_=>_.json()).then((json:{name:string,description?:string,src?:string,url?:string,display?:boolean,urls:{wellknown:string,api:string,cdn:string,gateway:string,login?:string}}[])=>{
|
||||
console.warn(json);
|
||||
if(instancein&&instancein.value===""){
|
||||
instancein.value=json[0].name;
|
||||
setTimeout(checkInstance,10);
|
||||
}
|
||||
for(const instance of json){
|
||||
if(instance.display===false){
|
||||
continue;
|
||||
}
|
||||
const option=document.createElement("option");
|
||||
option.value=instance.name;
|
||||
if(instance.URL){
|
||||
stringURLMap.set(option.value,instance.URL);
|
||||
if(instance.URLs){
|
||||
stringURLsMap.set(instance.URL,instance.URLs);
|
||||
if(instance.url){
|
||||
stringURLMap.set(option.value,instance.url);
|
||||
if(instance.urls){
|
||||
stringURLsMap.set(instance.url,instance.urls);
|
||||
}
|
||||
}else if(instance.URLs){
|
||||
stringURLsMap.set(option.value,instance.URLs);
|
||||
}else if(instance.urls){
|
||||
stringURLsMap.set(option.value,instance.urls);
|
||||
}else{
|
||||
option.disabled=true;
|
||||
}
|
||||
|
|
|
@ -20,12 +20,12 @@
|
|||
</div>
|
||||
<div>
|
||||
<label for="uname"><b>Email:</b></label><br>
|
||||
<input type="text" placeholder="Enter Email" name="email" id="email" required>
|
||||
<input type="text" placeholder="Enter Email" name="uname" id="uname" required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="uname"><b>Username:</b></label><br>
|
||||
<input type="text" placeholder="Enter Username" name="uname" id="uname" required>
|
||||
<input type="text" placeholder="Enter Username" name="username" id="username" required>
|
||||
</div>
|
||||
<div>
|
||||
<label for="psw"><b>Password:</b></label><br>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue