From 70423773bea4a472602880955e5a1f69464210f4 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sat, 11 Nov 2023 14:35:45 +0100 Subject: [PATCH] Feature: add giggity support for SOTM --- assets/layers/indoors/indoors.json | 9 +++ src/Logic/State/UserSettingsMetaTagging.ts | 48 +++--------- src/UI/BigComponents/Giggity.svelte | 89 ++++++++++++++++++++++ src/UI/SpecialVisualizations.ts | 24 ++++++ 4 files changed, 132 insertions(+), 38 deletions(-) create mode 100644 src/UI/BigComponents/Giggity.svelte diff --git a/assets/layers/indoors/indoors.json b/assets/layers/indoors/indoors.json index 61b168bfe4..c2288146e8 100644 --- a/assets/layers/indoors/indoors.json +++ b/assets/layers/indoors/indoors.json @@ -117,6 +117,7 @@ ] } ], + "popupInFloatover": true, "pointRendering": [ { "label": { @@ -218,6 +219,14 @@ } ], "tagRenderings": [ + {"id":"sotm-events", + "render": { + "special": { + "type": "giggity", + "giggityUrl":"https://sotm.osmz.ru/sotmeu2023.xml" + } + } + }, "images", "level", { diff --git a/src/Logic/State/UserSettingsMetaTagging.ts b/src/Logic/State/UserSettingsMetaTagging.ts index 6e568c5c32..33a5ae85b5 100644 --- a/src/Logic/State/UserSettingsMetaTagging.ts +++ b/src/Logic/State/UserSettingsMetaTagging.ts @@ -1,42 +1,14 @@ import { Utils } from "../../Utils" /** This code is autogenerated - do not edit. Edit ./assets/layers/usersettings/usersettings.json instead */ export class ThemeMetaTagging { - public static readonly themeName = "usersettings" + public static readonly themeName = "usersettings" - public metaTaggging_for_usersettings(feat: { properties: Record }) { - Utils.AddLazyProperty(feat.properties, "_mastodon_candidate_md", () => - feat.properties._description - .match(/\[[^\]]*\]\((.*(mastodon|en.osm.town).*)\).*/) - ?.at(1) - ) - Utils.AddLazyProperty( - feat.properties, - "_d", - () => feat.properties._description?.replace(/</g, "<")?.replace(/>/g, ">") ?? "" - ) - Utils.AddLazyProperty(feat.properties, "_mastodon_candidate_a", () => - ((feat) => { - const e = document.createElement("div") - e.innerHTML = feat.properties._d - return Array.from(e.getElementsByTagName("a")).filter( - (a) => a.href.match(/mastodon|en.osm.town/) !== null - )[0]?.href - })(feat) - ) - Utils.AddLazyProperty(feat.properties, "_mastodon_link", () => - ((feat) => { - const e = document.createElement("div") - e.innerHTML = feat.properties._d - return Array.from(e.getElementsByTagName("a")).filter( - (a) => a.getAttribute("rel")?.indexOf("me") >= 0 - )[0]?.href - })(feat) - ) - Utils.AddLazyProperty( - feat.properties, - "_mastodon_candidate", - () => feat.properties._mastodon_candidate_md ?? feat.properties._mastodon_candidate_a - ) - feat.properties["__current_backgroun"] = "initial_value" - } -} + public metaTaggging_for_usersettings(feat: {properties: Record}) { + Utils.AddLazyProperty(feat.properties, '_mastodon_candidate_md', () => feat.properties._description.match(/\[[^\]]*\]\((.*(mastodon|en.osm.town).*)\).*/)?.at(1) ) + Utils.AddLazyProperty(feat.properties, '_d', () => feat.properties._description?.replace(/</g,'<')?.replace(/>/g,'>') ?? '' ) + Utils.AddLazyProperty(feat.properties, '_mastodon_candidate_a', () => (feat => {const e = document.createElement('div');e.innerHTML = feat.properties._d;return Array.from(e.getElementsByTagName("a")).filter(a => a.href.match(/mastodon|en.osm.town/) !== null)[0]?.href }) (feat) ) + Utils.AddLazyProperty(feat.properties, '_mastodon_link', () => (feat => {const e = document.createElement('div');e.innerHTML = feat.properties._d;return Array.from(e.getElementsByTagName("a")).filter(a => a.getAttribute("rel")?.indexOf('me') >= 0)[0]?.href})(feat) ) + Utils.AddLazyProperty(feat.properties, '_mastodon_candidate', () => feat.properties._mastodon_candidate_md ?? feat.properties._mastodon_candidate_a ) + feat.properties['__current_backgroun'] = 'initial_value' + } +} \ No newline at end of file diff --git a/src/UI/BigComponents/Giggity.svelte b/src/UI/BigComponents/Giggity.svelte new file mode 100644 index 0000000000..a2e92e4703 --- /dev/null +++ b/src/UI/BigComponents/Giggity.svelte @@ -0,0 +1,89 @@ + + +{#if $events === undefined} + Loading giggity events from {giggityUrl} +{:else} +
+

Upcoming events

+ {#each $events as event} +
+ {#if event.url} +

{event.title}

+ + {:else } +

{event.title}

+ {/if} +
{event.start}
+ By {event.persons} +
+ {event.abstract} +
+ {event.url} +
+ {/each} +
+{/if} diff --git a/src/UI/SpecialVisualizations.ts b/src/UI/SpecialVisualizations.ts index f6980cacff..feb14fc796 100644 --- a/src/UI/SpecialVisualizations.ts +++ b/src/UI/SpecialVisualizations.ts @@ -76,6 +76,7 @@ import StarsBarIcon from "./Reviews/StarsBarIcon.svelte" import ReviewForm from "./Reviews/ReviewForm.svelte" import Questionbox from "./Popup/TagRendering/Questionbox.svelte" import { TagUtils } from "../Logic/Tags/TagUtils" +import Giggity from "./BigComponents/Giggity.svelte" class NearbyImageVis implements SpecialVisualization { // Class must be in SpecialVisualisations due to weird cyclical import that breaks the tests @@ -90,6 +91,7 @@ class NearbyImageVis implements SpecialVisualization { "A component showing nearby images loaded from various online services such as Mapillary. In edit mode and when used on a feature, the user can select an image to add to the feature" funcName = "nearby_images" needsUrls = NearbyImagesSearch.apiUrls + constr( state: SpecialVisualizationState, tags: UIEventSource>, @@ -1447,6 +1449,28 @@ export default class SpecialVisualizations { ) }, }, + { + funcName: "giggity", + args: [ + { + name: "giggityUrl", + required: true, + doc: "The URL of the giggity-XML", + }, + ], + docs: "Shows events that are happening based on a Giggity URL", + needsUrls: ["*"], + constr( + state: SpecialVisualizationState, + tagSource: UIEventSource>, + argument: string[], + feature: Feature, + layer: LayerConfig + ): BaseUIElement { + const giggityUrl = argument[0] + return new SvelteUIElement(Giggity, { tags: tagSource, state, giggityUrl }) + }, + }, ] specialVisualizations.push(new AutoApplyButton(specialVisualizations))