Docs: create overview of online services (for F-Droid acceptance); inline ELI again

This commit is contained in:
Pieter Vander Vennet 2025-06-27 18:36:02 +02:00
parent 1a75823f17
commit e9209f6b7c
26 changed files with 1099 additions and 298 deletions

View file

@ -9,10 +9,18 @@ import { SpecialVisualization, SpecialVisualizationState } from "../SpecialVisua
import SvelteUIElement from "../Base/SvelteUIElement"
import PlantNet from "../PlantNet/PlantNet.svelte"
import { default as PlantNetCode } from "../../Logic/Web/PlantNet"
import { ServerSourceInfo } from "../../Models/SourceOverview"
export class PlantNetDetectionViz extends SpecialVisualization {
funcName = "plantnet_detection"
needsUrls = [PlantNetCode.baseUrl]
needsUrls: ServerSourceInfo[] = [<ServerSourceInfo>{ url : PlantNetCode.baseUrl,
description: "Planet provides an API that, based on images, detects a plant species",
category: "feature",
openData: true,
selfhostable: "unknown",
trigger:["specific_feature", "specific_theme", "clear_consent"],
moreInfo: ["https://plantnet.org","https://github.com/plantnet"]
}]
group = "data_import"
docs =

View file

@ -15,6 +15,7 @@ import Toggle from "../Input/Toggle"
import ComparisonTool from "../Comparison/ComparisonTool.svelte"
import { Utils } from "../../Utils"
import TagApplyViz from "./TagApplyViz"
import { ServerSourceInfo } from "../../Models/SourceOverview"
class MaprouletteSetStatus extends SpecialVisualizationSvelte {
funcName = "maproulette_set_status"
@ -128,7 +129,22 @@ class LinkedDataFromWebsite extends SpecialVisualization {
doc: "If the containing accordion should be closed",
},
]
needsUrls = [Constants.linkedDataProxy, "http://www.schema.org"]
needsUrls: ServerSourceInfo[] = [
Constants.linkedDataProxyInfo,
{
url: "http://www.schema.org",
description: "Only needed for the velopark-theme",
category: "feature",
openData: true,
},
{
url: "https://data.velopark.be",
description: "Only needed for the velopark-theme",
openData: true,
selfhostable: false,
category: "feature",
},
]
constr(
state: SpecialVisualizationState,

View file

@ -13,6 +13,7 @@ import TagRenderingConfig from "../../Models/ThemeConfig/TagRenderingConfig"
import BaseUIElement from "../BaseUIElement"
import TagRenderingEditable from "../Popup/TagRendering/TagRenderingEditable.svelte"
import Combine from "../Base/Combine"
import { ServerSourceInfo } from "../../Models/SourceOverview"
class StealViz extends SpecialVisualization {
funcName = "steal"
@ -232,7 +233,14 @@ class OpenInJosm extends SpecialVisualizationSvelte {
group = "tagrendering_manipulation"
docs = "Opens the current view in the JOSM-editor"
args = []
needsUrls = ["http://127.0.0.1:8111/load_and_zoom"]
needsUrls = [<ServerSourceInfo> { url: "http://127.0.0.1:8111/load_and_zoom",
sourceAvailable: true,
selfhostable: "not applicable",
category: "feature",
description: "JOSM is a desktop program to edit OpenStreetMap. If a user clicks the 'open here in JOSM'-button, JOSM will be contacted on localhost to open this location. This button is hidden on small screens (i.e. mobile)",
moreInfo: ["https://josm.openstreetmap.de/", "https://wiki.openstreetmap.org/wiki/JOSM"]
}]
constr(state): SvelteUIElement {
return new SvelteUIElement(OpenJosm, { state })

View file

@ -27,6 +27,7 @@ import UserRelatedState from "../Logic/State/UserRelatedState"
import FeaturePropertiesStore from "../Logic/FeatureSource/Actors/FeaturePropertiesStore"
import SvelteUIElement from "./Base/SvelteUIElement"
import { Utils } from "../Utils"
import { ServerSourceInfo } from "../Models/SourceOverview"
/**
* The state needed to render a special Visualisation.
@ -94,7 +95,7 @@ export abstract class SpecialVisualization {
*/
readonly group?: string
readonly example?: string
readonly needsUrls?: string[] | ((args: string[]) => string | string[])
readonly needsUrls?: (string | ServerSourceInfo)[] | ((args: string[]) => string | string[] | ServerSourceInfo | ServerSourceInfo[])
readonly definedIn = Utils.runningFromConsole ? Utils.getLocationInCode(2) : undefined;
/**

View file

@ -18,6 +18,7 @@ import {
} from "./SpecialVisualisations/WebAndCommunicationSpecialVisualisations"
import { DataVisualisations } from "./Popup/DataVisualisations"
import { DataExportVisualisations } from "./Popup/DataExportVisualisations"
import { Utils } from "../Utils"
export default class SpecialVisualizations {
public static specialVisualizations: SpecialVisualization[] = SpecialVisualizations.initList()
@ -30,7 +31,7 @@ export default class SpecialVisualizations {
for (const specialVisualization of SpecialVisualizations.specialVisualizations) {
SpecialVisualizations.specialVisualisationsDict.set(
specialVisualization.funcName,
specialVisualization
specialVisualization,
)
}
}
@ -47,7 +48,7 @@ export default class SpecialVisualizations {
"`{" + viz.funcName + "(" + viz.args.map((arg) => arg.defaultValue).join(",") + ")}`"
let definitionPlace = ""
if(viz.definedIn){
if (viz.definedIn) {
const path = viz.definedIn
definitionPlace = `Defined in [${path.markdownLocation}](${path.markdownLocation})`
}
@ -56,15 +57,15 @@ export default class SpecialVisualizations {
viz.docs,
viz.args.length > 0
? MarkdownUtils.table(
["name", "default", "description"],
viz.args.map((arg) => {
let defaultArg = arg.defaultValue ?? "_undefined_"
if (defaultArg == "") {
defaultArg = "_empty string_"
}
return [arg.name, defaultArg, arg.doc]
})
)
["name", "default", "description"],
viz.args.map((arg) => {
let defaultArg = arg.defaultValue ?? "_undefined_"
if (defaultArg == "") {
defaultArg = "_empty string_"
}
return [arg.name, defaultArg, arg.doc]
}),
)
: undefined,
definitionPlace,
"#### Example usage of " + viz.funcName,
@ -74,12 +75,12 @@ export default class SpecialVisualizations {
public static constructSpecification(
template: string,
extraMappings: SpecialVisualization[] = []
extraMappings: SpecialVisualization[] = [],
): RenderingSpecification[] {
return SpecialVisualisationUtils.constructSpecification(
template,
SpecialVisualizations.specialVisualisationsDict,
extraMappings
extraMappings,
)
}
@ -112,7 +113,7 @@ export default class SpecialVisualizations {
"Special visualisations which reuse other tagRenderings to show data, but with a twist.",
web_and_communication:
"Tools to show data from external websites, which link to external websites or which link to external profiles",
ui: "Elements to support the user interface, e.g. 'title', 'translated'"
ui: "Elements to support the user interface, e.g. 'title', 'translated'",
}
const helpTexts: string[] = []
@ -161,7 +162,7 @@ export default class SpecialVisualizations {
},
},
null,
" "
" ",
)
const firstPart = [
@ -171,7 +172,7 @@ export default class SpecialVisualizations {
"# Using expanded syntax",
`Instead of using \`{"render": {"en": "{some_special_visualisation(some_arg, some other really long message, more args)} , "nl": "{some_special_visualisation(some_arg, een boodschap in een andere taal, more args)}}\`, one can also write`,
"```\n" + example + "\n```\n",
'In other words: use `{ "before": ..., "after": ..., "special": {"type": ..., "argname": ...argvalue...}`. The args are in the `special` block; an argvalue can be a string, a translation or another value. (Refer to class `RewriteSpecial` in case of problems)',
"In other words: use `{ \"before\": ..., \"after\": ..., \"special\": {\"type\": ..., \"argname\": ...argvalue...}`. The args are in the `special` block; an argvalue can be a string, a translation or another value. (Refer to class `RewriteSpecial` in case of problems)",
"# Overview of all special components",
].join("\n\n")
return firstPart + "\n\n" + helpTexts.join("\n\n")
@ -196,28 +197,31 @@ export default class SpecialVisualizations {
specialVisualizations.push(new AutoApplyButtonVis(specialVisualizations))
const regex = /[a-zA-Z_]+/
const invalid = specialVisualizations
.map((sp, i) => ({ sp, i }))
.filter((sp) => sp.sp.funcName === undefined || !sp.sp.funcName.match(regex))
if (Utils.runningFromConsole) {
// Some sanity checks
const regex = /[a-zA-Z_]+/
const invalid = specialVisualizations
.map((sp, i) => ({ sp, i }))
.filter((sp) => sp.sp.funcName === undefined || !sp.sp.funcName.match(regex))
if (invalid.length > 0) {
throw (
"Invalid special visualisation found: funcName is undefined or doesn't match " +
regex +
invalid.map((sp) => sp.i).join(", ") +
'. Did you perhaps type \n funcName: "funcname" // type declaration uses COLON\ninstead of:\n funcName = "funcName" // value definition uses EQUAL'
)
}
const allNames = specialVisualizations.map((f) => f.funcName)
const seen = new Set<string>()
for (let name of allNames) {
name = name.toLowerCase()
if (seen.has(name)) {
throw "Invalid special visualisations: detected a duplicate name: " + name
if (invalid.length > 0) {
throw (
"Invalid special visualisation found: funcName is undefined or doesn't match " +
regex +
invalid.map((sp) => sp.i).join(", ") +
". Did you perhaps type \n funcName: \"funcname\" // type declaration uses COLON\ninstead of:\n funcName = \"funcName\" // value definition uses EQUAL"
)
}
const allNames = specialVisualizations.map((f) => f.funcName)
const seen = new Set<string>()
for (let name of allNames) {
name = name.toLowerCase()
if (seen.has(name)) {
throw "Invalid special visualisations: detected a duplicate name: " + name
}
seen.add(name)
}
seen.add(name)
}
return specialVisualizations