-
-
Notifications
You must be signed in to change notification settings - Fork 659
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1795 from placeAtlas/cleanup
Made links configurable
- Loading branch information
Showing
8 changed files
with
260 additions
and
296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7188,3 +7188,4 @@ | |
1dps0t4 | ||
1e24aqx | ||
1e3ql1b | ||
1e5p1d3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
Oops, something went wrong.