Skip to content

Commit

Permalink
Merge pull request #1795 from placeAtlas/cleanup
Browse files Browse the repository at this point in the history
Made links configurable
  • Loading branch information
AnonymousRandomPerson authored Jul 19, 2024
2 parents 91222d8 + 412a2ca commit 99bddf8
Show file tree
Hide file tree
Showing 8 changed files with 260 additions and 296 deletions.
1 change: 1 addition & 0 deletions data/read-ids.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7188,3 +7188,4 @@
1dps0t4
1e24aqx
1e3ql1b
1e5p1d3
86 changes: 86 additions & 0 deletions web/_js/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,92 @@ window.defaultPeriod = defaultPeriod
const useNumericalId = true
window.useNumericalId = useNumericalId

const externalLinksConfig = [
{
name: "Website",
id: "website",
generateLink: (link) => link,
listingClass: "bi-globe",
generateListingName: (link) => {
try {
const urlObject = new URL(link)
return urlObject.hostname.replace(/^www./, "")
} catch (e) {
return "Website"
}
},
displayHTML: "{urlid}",
placeholder: "https://example.org",
configureInputField: (inputField) => {
inputField.type = "url"
inputField.placeholder = "https://example.com"
inputField.pattern = "https?://.*"
inputField.title = "Website URL using the http:// or https:// protocol"
}
},
{
name: "Discord",
id: "discord",
generateLink: (link) => "https://discord.gg/" + link,
generateListingName: (link) => link,
listingClass: "bi-discord",
editorPrefix: "discord.gg/",
placeholder: "r/example",
configureInputField: (inputField) => {
inputField.placeholder = "pJkm23b2nA"
},
extractId: (content) => {
const discordPattern = /^(?:(?:https?:\/\/)?(?:www\.)?(?:(?:discord)?\.?gg|discord(?:app)?\.com\/invite)\/)?([^\s/]+?)(?=\b)$/
id = content.trim().match(discordPattern)?.[1]
if (id) {
return id;
}
return content;
}
},
{
name: "Subreddit",
id: "subreddit",
generateLink: (link) => "https://reddit.com/" + link,
listingClass: "bi-reddit",
generateListingName: (link) => "r/" + link,
editorPrefix: "reddit.com/",
placeholder: "pJkm23b2nA",
configureInputField: (inputField) => {
inputField.placeholder = "r/example"
inputField.pattern = "^r\/[A-Za-z0-9][A-Za-z0-9_]{1,50}$"
inputField.title = "Subreddit in format of r/example"
inputField.minLength = "4"
inputField.maxLength = "50"
},
extractId: (content) => {
const subredditPattern = /^(?:(?:(?:(?:(?:https?:\/\/)?(?:(?:www|old|new|np)\.)?)?reddit\.com)?\/)?[rR]\/)?([A-Za-z0-9][A-Za-z0-9_]{1,20})(?:\/[^" ]*)*$/
id = content.trim().match(subredditPattern)?.[1]
if (id) {
return id;
}
return content;
},
formatIdInEditor: (content) => {
if (content != "") {
return "r/" + content;
}
return "";
}
},
{
name: "Wiki",
id: "wiki",
generateLink: (link) => "https://place-wiki.stefanocoding.me/wiki/" + link,
listingClass: "bi-wiki",
generateListingName: () => "r/place Wiki Article",
displayHTML: "{urlid}",
placeholder: "r/place Wiki Article",
configureInputField: () => {},
hideInput: true
},
];

console.info(`%cThe 2023 r/place Atlas
%cCopyright (c) 2017 Roland Rytz <[email protected]>
Copyright (c) 2023 Place Atlas Initiative and contributors
Expand Down
Loading

0 comments on commit 99bddf8

Please sign in to comment.