diff --git a/layouts/shortcodes/gpx-map.html b/layouts/shortcodes/gpx-map.html new file mode 100644 index 0000000..d498b7a --- /dev/null +++ b/layouts/shortcodes/gpx-map.html @@ -0,0 +1,52 @@ + +
+ + + + \ No newline at end of file diff --git a/static/admin/config.yml b/static/admin/config.yml index ea067ca..a278f35 100644 --- a/static/admin/config.yml +++ b/static/admin/config.yml @@ -53,6 +53,16 @@ collections: media_library: config: multiple: true + - label: "GPX Files" + name: "gpxFiles" + widget: "file" + required: false + choose_url: true + media_library: + media_folder: "/static/uploads/gpx" + public_folder: "/images/uploads" + config: + multiple: true - { label: "Body", name: "body", widget: "markdown" } ######################## # POSTS COLLECTION diff --git a/static/admin/index.html b/static/admin/index.html index 17915c8..34063f8 100644 --- a/static/admin/index.html +++ b/static/admin/index.html @@ -84,6 +84,44 @@ `; } }); + + // Register the GPX Map shortcode as an editor component + window.CMS.registerEditorComponent({ + id: "gpx-map", + label: "GPX Track Map", + fields: [ + { name: "lat", label: "Latitude", widget: "string" }, + { name: "lon", label: "Longitude", widget: "string" }, + { name: "gpx", label: "GPX File Path", widget: "string", hint: "Example: /uploads/gpx/my-track.gpx" }, + { name: "zoom", label: "Zoom Level", widget: "number", default: 13, required: false }, + { name: "height", label: "Height (e.g. 500px)", widget: "string", default: "500px", required: false } + ], + pattern: /{{<\s*gpx-map\s+lat="([^"]+)"\s+lon="([^"]+)"\s+gpx="([^"]+)"(?:\s+zoom="([^"]+)")?(?:\s+height="([^"]+)")?\s*>}}/, + fromBlock: function (match) { + return { + lat: match[1], + lon: match[2], + gpx: match[3], + zoom: match[4] || "13", + height: match[5] || "500px" + }; + }, + toBlock: function (obj) { + let params = `lat="${obj.lat}" lon="${obj.lon}" gpx="${obj.gpx}"`; + if (obj.zoom) params += ` zoom="${obj.zoom}"`; + if (obj.height) params += ` height="${obj.height}"`; + return `{{< gpx-map ${params} >}}`; + }, + toPreview: function (obj) { + // Simple preview (not interactive) + return `