Commit a516a7d9 authored by marius david's avatar marius david
Browse files

Add lemmy link type

parent 324b077b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ When you're happy with the shape you've drawn, press <kbd>Finish</kbd>. You will
- **Name**: A short, descriptive name.
- **Description**: A short description that can be understood by somebody not familiar with the topic. If you were involved in drawing this artwork, you may include the meta, describing the process of drawing the artwork in the event.
- **Links**: Some links that are most relevant to the topic, and/or regarding the process of the drawing the artwork in the event.
	- **Lemmy**: A Lemmy community or server, in the form of an URL
	- **Lemmy**: A Lemmy community, server or post in the form of an URL, `!community@example.com` or `@example.com`
	- **Matrix**: A matrix room id of the organizers, in the form of `#room_id:server.tld`
	- **Website**: If you're describing a project, the project's main website would be suitable here.
	- **Subreddit**: Format it like `r/subreddit`.
+50 −51
Original line number Diff line number Diff line
@@ -2,7 +2,11 @@
	"id": 8378322440,
	"name": "Factorio Cog",
	"description": "Some testing...",
    "links": {},
	"links": {
		"lemmy": [
			"!test@lemmy.mariusdavid.fr"
		]
	},
	"path": {
		"0": [
			[
@@ -44,10 +48,5 @@
			556,
			354
		]
    },
    "source_list": {
        "lemmy": [
            4145732
        ]
	}
}
 No newline at end of file
+22 −1
Original line number Diff line number Diff line
@@ -362,6 +362,28 @@ const useNumericalId = true
window.useNumericalId = useNumericalId

const externalLinksConfig = [
	{
		name: "Lemmy",
		id: "lemmy",
		generateLink: (link) => {
			if (link.startsWith("@")) {
				return "https://" + link + "/"
			} else if (link.startsWith("!") && link.indexOf("@") !== -1) {
				let community = link.substring(1).split("@")[0]
				let host = link.split("@")[1]
				return "https://" + host + "/c/" + community
			} else {
				return link
			}
		},
		listingClass: "bi-mastodon", //TODO: lemmy adaptation: actually put a lemmy icon
		generateListingName: (link) => link,
		placeholder: "!community@example.org",
		configureInputField: (inputField) => {
			inputField.placeholder = "!community@example.com"
			inputField.title = "Lemmy link using the !community@example.com format, a Lemmy domain using the @example.com format or a post with it’s url"
		},
	},
	{
		name: "Website",
		id: "website",
@@ -375,7 +397,6 @@ const externalLinksConfig = [
				return "Website"
			}
		},
		displayHTML: "{urlid}",
		placeholder: "https://example.org",
		configureInputField: (inputField) => {
			inputField.type = "url"
+1 −1
Original line number Diff line number Diff line
@@ -698,7 +698,7 @@ function initDraw() {
		descriptionField.value = entry.description

		for (const linkConfig of externalLinksConfig) {
			if (entry.links[linkConfig.id].length) {
			if (linkConfig.id in entry.links && entry.links[linkConfig.id].length) {
				for (const link of entry.links[linkConfig.id]) {
					addFieldGeneric(link, linkConfig.id)
				}