diff --git a/TESTING_CHECKLIST.md b/TESTING_CHECKLIST.md deleted file mode 100644 index 27d7db1..0000000 --- a/TESTING_CHECKLIST.md +++ /dev/null @@ -1,276 +0,0 @@ -# Map Editor Plugin - Testing Checklist - -## Pre-Testing Setup - -1. [ ] Build the frontend: `npm run build` -2. [ ] Ensure Kirby is running (PHP server) -3. [ ] Log into Kirby Panel -4. [ ] Navigate to the map page (e.g., `/panel/pages/map+carte`) - -## Phase 1: Multi-Mode Testing (Map Page) - -### Basic Marker Operations - -1. [ ] **View existing markers** - - Open map page in Panel - - Verify markers are loaded and displayed on map - - Verify markers appear in sidebar list - -2. [ ] **Create marker via button** - - Click "Add Marker" button in sidebar - - Verify marker appears at map center - - Verify marker appears in sidebar - - Check browser console for errors - -3. [ ] **Create marker via map click** - - Click anywhere on the map - - Verify marker appears at clicked location - - Verify marker appears in sidebar - -4. [ ] **Select marker** - - Click marker in sidebar - - Verify map centers on marker - - Verify marker is highlighted - -5. [ ] **Drag marker** - - Drag a marker to new position - - Verify position updates in real-time - - Reload page and verify position persisted - -6. [ ] **Edit marker** - - Click "Edit" button for a marker in sidebar - - Verify redirect to marker page in Panel - - Verify marker page loads correctly - -7. [ ] **Delete marker** - - Click "Delete" button for a marker - - Verify confirmation dialog appears - - Confirm deletion - - Verify marker removed from map and sidebar - - Reload page and verify deletion persisted - -### Map Data Persistence - -8. [ ] **Map view changes** - - Pan and zoom the map - - Reload the page - - Verify map returns to same view - -9. [ ] **Check YAML data** - - View the mapdata field source - - Verify it contains: background, center, zoom - - Verify it does NOT contain markers array - -### Edge Cases - -10. [ ] **Max markers limit** - - Create markers up to the limit (default 50) - - Verify "Add Marker" button becomes disabled - - Verify map clicks don't create new markers - -11. [ ] **Geocode search** - - Use the address search in sidebar - - Search for an address - - Verify map centers on result - -12. [ ] **Error handling** - - Open browser DevTools Network tab - - Try operations with network offline (simulate) - - Verify errors are logged to console - -## Phase 2: Single-Mode Testing (Marker Page) - -### Marker Page Structure - -1. [ ] **Create test marker** - - In map page sidebar, click "Add Marker" - - Click "Edit" to open the marker page - -2. [ ] **Content tab** - - Verify "Contenu" tab exists - - Edit title field - - Add blocks (heading, text, image, etc.) - - Save and verify content persists - -3. [ ] **Position tab** - - Switch to "Position" tab - - Verify latitude/longitude fields on left - - Verify map preview on right - -### Single-Mode Map Functionality - -4. [ ] **View marker position** - - Verify single marker appears on map - - Verify marker is at coordinates shown in fields - -5. [ ] **Drag marker in single mode** - - Drag the marker to a new position - - Check browser console for API call - - Reload page - - Verify new position persisted - -6. [ ] **Update coordinates via fields** - - Edit latitude field (e.g., 43.8) - - Edit longitude field (e.g., 4.3) - - Save the page - - Verify marker moved on map preview - -7. [ ] **Geocode search in single mode** - - Use address search (if available) - - Verify map centers on result - - Drag marker to searched location - -### Single-Mode Restrictions - -8. [ ] **No CRUD buttons** - - Verify no "Add Marker" button - - Verify no "Delete" button - - Verify no marker list sidebar - -9. [ ] **Map size** - - Verify map height is smaller (400px) than multi-mode - -## Phase 3: Integration Testing - -### Subpage Management - -1. [ ] **View markers as subpages** - - In map page, check sidebar "Marqueurs" section - - Verify all markers listed as subpages - - Verify ordering by num - -2. [ ] **Reorder markers** - - Drag markers in Panel pages section - - Verify order updates - - View map editor - - Verify sidebar reflects new order - -3. [ ] **Delete marker via Panel** - - Delete a marker subpage via Panel (not map editor) - - View map page - - Verify marker removed from map - -4. [ ] **Create marker manually** - - Create a new marker subpage via Panel - - Set template to "marker" - - Add title, latitude, longitude - - View map page - - Verify marker appears on map - -### Multi-Marker Performance - -5. [ ] **Create 10 markers** - - Create 10 markers via map - - Verify performance is acceptable - - Check load time - -6. [ ] **Create 50 markers** (optional stress test) - - Create markers up to limit - - Verify UI remains responsive - - Check browser memory usage - -## Phase 4: Security & API Testing - -### Authentication - -1. [ ] **Logged out access** - - Log out of Panel - - Try accessing API directly (e.g., via curl) - - Verify 401 Unauthorized response - -### CSRF Protection - -2. [ ] **Invalid CSRF token** - - Use browser DevTools to modify X-CSRF header - - Try creating/updating/deleting marker - - Verify 403 Forbidden response - -### Permissions - -3. [ ] **Create restricted user** (optional) - - Create user with limited permissions - - Log in as that user - - Try marker operations - - Verify permission checks work - -### API Responses - -4. [ ] **Check API responses** - - Open DevTools Network tab - - Perform marker operations - - Verify responses match expected format: - ```json - { - "status": "success", - "data": { ... } - } - ``` - -5. [ ] **Test error responses** - - Try invalid coordinates (e.g., lat: 200) - - Verify 400 Bad Request response - - Verify error message is descriptive - -## Phase 5: Build & Deployment - -### Build Verification - -1. [ ] **Clean build** - - Run `npm run build` - - Verify no errors or warnings (except font warnings) - - Check dist folder created - -2. [ ] **Production test** - - Test on production server (if available) - - Verify all functionality works - -### Browser Compatibility - -3. [ ] **Test in Chrome** -4. [ ] **Test in Firefox** -5. [ ] **Test in Safari** -6. [ ] **Test in Edge** (optional) - -## Common Issues & Solutions - -### Issue: Markers not loading -- **Check**: Browser console for API errors -- **Check**: Network tab for 401/403 errors -- **Solution**: Verify user is logged in, CSRF token is valid - -### Issue: Drag doesn't update position -- **Check**: Console for API errors -- **Check**: Network tab for PATCH request -- **Solution**: Verify page permissions, CSRF token - -### Issue: Redirect to Panel doesn't work -- **Check**: Console for errors -- **Check**: panelUrl in API response -- **Solution**: Verify page ID format is correct - -### Issue: Single mode shows multiple markers -- **Check**: MapEditor component mode prop -- **Check**: Blueprint field configuration -- **Solution**: Verify `mode: single` in blueprint - -## Test Results Summary - -Date: __________ -Tester: __________ - -| Phase | Tests Passed | Tests Failed | Notes | -|-------|-------------|--------------|-------| -| Phase 1: Multi-Mode | __ / 12 | __ | | -| Phase 2: Single-Mode | __ / 9 | __ | | -| Phase 3: Integration | __ / 6 | __ | | -| Phase 4: Security | __ / 5 | __ | | -| Phase 5: Build | __ / 6 | __ | | -| **Total** | __ / 38 | __ | | - -## Next Steps After Testing - -- [ ] Document any bugs found -- [ ] Create GitHub issues for bugs -- [ ] Update README with usage instructions -- [ ] Add user documentation -- [ ] Consider implementing suggested improvements diff --git a/public/assets/svg/marker-pin.svg b/public/assets/svg/marker-pin.svg new file mode 100644 index 0000000..6df71cc --- /dev/null +++ b/public/assets/svg/marker-pin.svg @@ -0,0 +1 @@ + diff --git a/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/1_un-folklore-abyssal/chapitre.txt b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/1_un-folklore-abyssal/chapter.txt similarity index 100% rename from public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/1_un-folklore-abyssal/chapitre.txt rename to public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/1_un-folklore-abyssal/chapter.txt diff --git a/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/2_une-culture-fascinante/chapitre.txt b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/2_une-culture-fascinante/chapter.txt similarity index 100% rename from public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/2_une-culture-fascinante/chapitre.txt rename to public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/2_une-culture-fascinante/chapter.txt diff --git a/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/3_la-nouvelle-ere/1_carte-test/map-static.png b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/3_la-nouvelle-ere/1_carte-test/map-static.png new file mode 100644 index 0000000..2c4d8dd Binary files /dev/null and b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/3_la-nouvelle-ere/1_carte-test/map-static.png differ diff --git a/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/3_la-nouvelle-ere/1_carte-test/map-static.png.txt b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/3_la-nouvelle-ere/1_carte-test/map-static.png.txt new file mode 100644 index 0000000..6fe1571 --- /dev/null +++ b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/3_la-nouvelle-ere/1_carte-test/map-static.png.txt @@ -0,0 +1 @@ +Uuid: fveqiuck5suwp14v \ No newline at end of file diff --git a/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/3_la-nouvelle-ere/1_carte-test/map.txt b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/3_la-nouvelle-ere/1_carte-test/map.txt new file mode 100644 index 0000000..7fec40e --- /dev/null +++ b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/3_la-nouvelle-ere/1_carte-test/map.txt @@ -0,0 +1,24 @@ +Title: Carte test + +---- + +Tags: + +---- + +Text: + +---- + +Mapdata: + +background: + type: osm +center: + lat: 48.868167700000015 + lon: 2.3924468999999817 +zoom: 13 + +---- + +Uuid: qd3aqmiburbztsxq \ No newline at end of file diff --git a/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/3_la-nouvelle-ere/chapitre.txt b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/3_la-nouvelle-ere/chapter.txt similarity index 100% rename from public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/3_la-nouvelle-ere/chapitre.txt rename to public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/3_la-nouvelle-ere/chapter.txt diff --git a/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/4_test/map-static.png b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/4_test/map-static.png new file mode 100644 index 0000000..61aad30 Binary files /dev/null and b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/4_test/map-static.png differ diff --git a/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/4_test/map-static.png.txt b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/4_test/map-static.png.txt new file mode 100644 index 0000000..1b092bc --- /dev/null +++ b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/4_test/map-static.png.txt @@ -0,0 +1 @@ +Uuid: 9uhixxughhuqyphe \ No newline at end of file diff --git a/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/4_test/map.txt b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/4_test/map.txt new file mode 100644 index 0000000..c3cb097 --- /dev/null +++ b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/4_test/map.txt @@ -0,0 +1,24 @@ +Title: test + +---- + +Tags: + +---- + +Text: + +---- + +Mapdata: + +background: + type: osm +center: + lat: 43.836699 + lon: 4.360054 +zoom: 13 + +---- + +Uuid: o06wmgdr075lthky \ No newline at end of file diff --git a/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/geoformat.txt b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/geoformat.txt index 163cd02..b021f8c 100644 --- a/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/geoformat.txt +++ b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/1_plongez-dans-les-sources/geoformat.txt @@ -10,7 +10,7 @@ Tags: ---- -Cover: - file://15innylddvc2qann +Cover: ---- diff --git a/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/2_roadtrip-a-vos-risques-et-perils/.regenerate-map-image b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/2_roadtrip-a-vos-risques-et-perils/.regenerate-map-image new file mode 100644 index 0000000..26754c9 --- /dev/null +++ b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/2_roadtrip-a-vos-risques-et-perils/.regenerate-map-image @@ -0,0 +1 @@ +1772115179 \ No newline at end of file diff --git a/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/2_roadtrip-a-vos-risques-et-perils/1_marker-1769700434/marker.txt b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/2_roadtrip-a-vos-risques-et-perils/1_marker-1769700434/marker.txt index d3d9d07..3de6739 100644 --- a/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/2_roadtrip-a-vos-risques-et-perils/1_marker-1769700434/marker.txt +++ b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/2_roadtrip-a-vos-risques-et-perils/1_marker-1769700434/marker.txt @@ -2,7 +2,11 @@ Title: Nîmes ---- -Content: +Cover: + +---- + +Text: [{"content":{"text":"
Nisi nec morbi diam tortor quis interdum fusce quisque sit aliquam scelerisque a vivamus gravida id eros nisl tortor commodo amet mi quis tincidunt metus.
Congue proin urna eget quisque sem a fusce felis eros purus hendrerit facilisis hendrerit metus accumsan metus nec eu cursus elementum maecenas ut scelerisque sit.
"},"id":"1adbada8-6dee-4ab4-b33b-d914d4806b70","isHidden":false,"type":"text"}] ---- @@ -22,4 +26,8 @@ Markericonsize: 40 ---- +Content: + +---- + Uuid: lajqvh51bnvty5xr \ No newline at end of file diff --git a/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/narrative.txt b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/narrative.txt index b97c01d..3648b80 100644 --- a/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/narrative.txt +++ b/public/content/1_cohesion-des-mondes/5_test-avec-geoformat/narrative.txt @@ -25,13 +25,13 @@ Customcss: body { font-family: "DM Sans", sans-serif; text-align: left; - color: black; - background: transparent; + color: rgb(0, 0, 0); } +/* p { text-align: right; - font-size: 14px; + font-size: 49px; margin: 0mm; font-weight: 300; font-family: Arial; @@ -41,6 +41,7 @@ p { padding-bottom: 0mm; padding-left: 0mm; } +*/ h1 { font-family: DM Sans; diff --git a/public/content/1_cohesion-des-mondes/projet.txt b/public/content/1_cohesion-des-mondes/project.txt similarity index 100% rename from public/content/1_cohesion-des-mondes/projet.txt rename to public/content/1_cohesion-des-mondes/project.txt diff --git a/public/kirby/panel/dist.zip b/public/kirby/panel/dist.zip new file mode 100644 index 0000000..45a436f Binary files /dev/null and b/public/kirby/panel/dist.zip differ diff --git a/public/site/blueprints/blocks/map.yml b/public/site/blueprints/blocks/map.yml index 640308b..bdb8d78 100644 --- a/public/site/blueprints/blocks/map.yml +++ b/public/site/blueprints/blocks/map.yml @@ -1,8 +1,8 @@ name: Carte icon: map fields: - map: + map: label: Choisir la carte type: pages - query: page.parent.parent.children.filterBy('intendedTemplate', 'map') - multiple: false \ No newline at end of file + query: page.children.filterBy('intendedTemplate', 'map') + multiple: false diff --git a/public/site/blueprints/fields/blueprint.yml b/public/site/blueprints/fields/blueprint.yml new file mode 100644 index 0000000..1feb794 --- /dev/null +++ b/public/site/blueprints/fields/blueprint.yml @@ -0,0 +1,2 @@ +type: headline +label: Page "{{ page.blueprint.title }}" diff --git a/public/site/blueprints/pages/chapitre.yml b/public/site/blueprints/pages/chapitre.yml deleted file mode 100644 index c630786..0000000 --- a/public/site/blueprints/pages/chapitre.yml +++ /dev/null @@ -1,38 +0,0 @@ -title: Chapitre - -columns: - main: - width: 2/3 - sections: - fields: - type: fields - fields: - text: - label: Contenu - type: blocks - fieldsets: - text: - label: Texte - type: group - fieldsets: - - heading - - text - - list - - quote - media: - label: Medias - type: group - fieldsets: - - map - - image - - video - - sidebar: - width: 1/3 - sections: - files: - label: Fichiers - type: files - - - diff --git a/public/site/blueprints/pages/chapter.yml b/public/site/blueprints/pages/chapter.yml new file mode 100644 index 0000000..dfb9cb4 --- /dev/null +++ b/public/site/blueprints/pages/chapter.yml @@ -0,0 +1,41 @@ +title: Chapitre + +tabs: + contentTab: + label: Contenu + columns: + main: + width: 2/3 + sections: + fields: + type: fields + fields: + blueprint: fields/blueprint + text: + label: Contenu + type: blocks + fieldsets: + text: + label: Texte + type: group + fieldsets: + - heading + - text + - list + - quote + media: + label: Medias + type: group + fieldsets: + - map + - image + - video + sidebar: + width: 1/3 + sections: + maps: + label: Cartes + type: pages + template: map + + files: tabs/files diff --git a/public/site/blueprints/pages/geoformat.yml b/public/site/blueprints/pages/geoformat.yml index 1fca6dc..3104955 100644 --- a/public/site/blueprints/pages/geoformat.yml +++ b/public/site/blueprints/pages/geoformat.yml @@ -1,38 +1,44 @@ title: Géoformat -columns: - main: - width: 2/3 - sections: - fields: - type: fields - fields: - subtitle: - label: Sous-titre - type: text - width: 1/2 - tags: - label: Mots-clés - type: tags - width: 1/2 - cover: - label: Media de couverture - type: files - multiple: false - width: 1/2 - text: - label: Chapeau - type: writer - pages: - label: Chapitres - type: pages - template: chapitre - sidebar: - width: 1/3 - sections: - files: - label: Fichiers - type: files - - +tabs: + contentTab: + columns: + main: + width: 2/3 + sections: + fields: + type: fields + fields: + blueprint: fields/blueprint + subtitle: + label: Sous-titre + type: text + width: 1/2 + tags: + label: Mots-clés + type: tags + width: 1/2 + cover: + label: Media de couverture + type: files + query: page.coverFiles + text: "{{ file.coverLabel }}" + multiple: false + width: 1/2 + text: + label: Chapeau + type: writer + chapters: + label: Chapitres + type: pages + template: chapter + sidebar: + width: 1/3 + sections: + maps: + label: Cartes + type: pages + template: map + help: Créez des cartes ici avant de pouvoir les ajouter dans un bloc ou en couverture. + filesTab: tabs/files diff --git a/public/site/blueprints/pages/map.yml b/public/site/blueprints/pages/map.yml index 65d6662..0349133 100644 --- a/public/site/blueprints/pages/map.yml +++ b/public/site/blueprints/pages/map.yml @@ -7,21 +7,26 @@ columns: fields: type: fields fields: - tags: - label: Mots-clés - type: tags - text: - label: Présentation de la carte - type: writer + blueprint: fields/blueprint mapdata: label: Carte type: map-editor defaultCenter: [43.836699, 4.360054] defaultZoom: 13 maxMarkers: 50 + intro: + label: Présentation de la carte + type: writer sidebar: width: 1/3 sections: - files: - label: Fichiers - type: files + tagsSection: + type: fields + fields: + emptyField: + type: gap + secondEmptyField: + type: gap + tags: + label: Mots-clés + type: tags diff --git a/public/site/blueprints/pages/narrative.yml b/public/site/blueprints/pages/narrative.yml index ee1cdee..23dc680 100644 --- a/public/site/blueprints/pages/narrative.yml +++ b/public/site/blueprints/pages/narrative.yml @@ -1,44 +1,51 @@ -title: Narrative +title: Récit -columns: - main: - width: 2/3 - sections: - fields: - type: fields - fields: - blueprint: - type: headline - label: Page "{{ page.intendedTemplate }}" - author: - label: Auteur·ice(s) - type: text - width: 1/2 - cover: - label: Image de couverture +tabs: + contentTab: + label: Contenu + columns: + main: + width: 2/3 + sections: + fields: + type: fields + fields: + blueprint: fields/blueprint + author: + label: Auteur·ice(s) + type: text + width: 1/2 + cover: + label: Image de couverture + type: files + query: page.coverFiles + text: "{{ file.coverLabel }}" + multiple: false + width: 1/2 + introduction: + label: Introduction + type: writer + parts: + label: Parties + type: pages + template: + - map + - geoformat + info: "{{ page.blueprint.title }}" + sidebar: + width: 1/3 + sections: + files: + label: Fichiers type: files - multiple: false - width: 1/2 - introduction: - label: Introduction - type: writer - customCss: - label: Custom CSS - type: code-editor - language: css - help: Custom CSS styling for this narrative's print view - theme: monokai - size: large - pages: - label: Pages - type: pages - template: - - map - - geoformat - info: "{{ page.intendedTemplate }}" - sidebar: - width: 1/3 - sections: - files: - label: Fichiers - type: files + CSSTab: + label: CSS + icon: brush + fields: + customCss: + label: Custom CSS + type: code-editor + language: css + help: Custom CSS styling for this narrative's print view + theme: monokai + size: large diff --git a/public/site/blueprints/pages/projet.yml b/public/site/blueprints/pages/project.yml similarity index 93% rename from public/site/blueprints/pages/projet.yml rename to public/site/blueprints/pages/project.yml index fbcac36..32de087 100644 --- a/public/site/blueprints/pages/projet.yml +++ b/public/site/blueprints/pages/project.yml @@ -7,6 +7,7 @@ columns: fields: type: fields fields: + blueprint: fields/blueprint subtitle: label: Sous-titre type: text diff --git a/public/site/blueprints/site.yml b/public/site/blueprints/site.yml index 915996f..8c1294f 100644 --- a/public/site/blueprints/site.yml +++ b/public/site/blueprints/site.yml @@ -13,7 +13,7 @@ tabs: label: Projets type: pages templates: - - projet + - project secondary: width: 1/2 sections: diff --git a/public/site/blueprints/tabs/files.yml b/public/site/blueprints/tabs/files.yml new file mode 100644 index 0000000..be2f551 --- /dev/null +++ b/public/site/blueprints/tabs/files.yml @@ -0,0 +1,15 @@ +label: Fichiers +icon: attachment +columns: + - width: 1/4 + fields: + manageFilesInfo: + label: false + type: info + text: À droite, tous les fichiers que stocke la page. Pensez à supprimer les fichiers inutilisés éviter de surcharger inutilement le serveur. + + - width: 3/4 + sections: + filesSection: + label: Fichiers + type: files diff --git a/public/site/plugins/cover-files/index.php b/public/site/plugins/cover-files/index.php new file mode 100644 index 0000000..f17a27e --- /dev/null +++ b/public/site/plugins/cover-files/index.php @@ -0,0 +1,19 @@ + [ + 'coverFiles' => function () { + return $this->files()->add( + $this->children()->filterBy('intendedTemplate', 'map')->files() + ); + } + ], + 'fileMethods' => [ + 'coverLabel' => function () { + if ($this->parent()->intendedTemplate()->name() === 'map') { + return 'Carte "' . $this->parent()->title() . '"'; + } + return $this->filename(); + } + ] +]); diff --git a/public/site/plugins/virtual-print-page/index.php b/public/site/plugins/virtual-print-page/index.php index 9240cea..0bea7cf 100644 --- a/public/site/plugins/virtual-print-page/index.php +++ b/public/site/plugins/virtual-print-page/index.php @@ -3,7 +3,7 @@ * Virtual Print Page Plugin * * Creates a virtual /print page for each narrative - * Allows access to print editor via /projet/narrative/print + * Allows access to print editor via /project/narrative/print */ use Kirby\Cms\Page; diff --git a/public/site/templates/narrative.json.php b/public/site/templates/narrative.json.php index 3da5296..e4ab738 100644 --- a/public/site/templates/narrative.json.php +++ b/public/site/templates/narrative.json.php @@ -1,7 +1,7 @@ $block->map()->value() - ]; + $mapPage = $block->map()->toPages()->first(); + if ($mapPage) { + $blockData['content'] = parseMap($mapPage); + } else { + $blockData['content'] = [ + 'map' => $block->map()->value() + ]; + } break; default: @@ -122,31 +127,53 @@ function parseBlocks($blocksField, $page) { } /** - * Parse un chapitre + * Parse a chapter */ -function parseChapitre($chapitre) { +function parseChapter($chapter) { return [ - 'id' => $chapitre->id(), - 'uuid' => $chapitre->uuid()->toString(), - 'template' => 'chapitre', - 'title' => $chapitre->title()->value(), - 'slug' => $chapitre->slug(), - 'blocks' => parseBlocks($chapitre->text(), $chapitre) + 'id' => $chapter->id(), + 'uuid' => $chapter->uuid()->toString(), + 'template' => 'chapter', + 'title' => $chapter->title()->value(), + 'slug' => $chapter->slug(), + 'blocks' => parseBlocks($chapter->text(), $chapter) ]; } /** - * Parse une carte + * Parse a marker */ -function parseCarte($carte) { +function parseMarker($marker) { return [ - 'id' => $carte->id(), - 'uuid' => $carte->uuid()->toString(), + 'title' => $marker->title()->value(), + 'cover' => resolveFileUrl($marker->cover(), $marker), + 'icon' => $marker->markerIcon()->toFile() ? $marker->markerIcon()->toFile()->url() : null, + 'iconSize' => $marker->markerIconSize()->value() ?? 40, + 'blocks' => parseBlocks($marker->text(), $marker) + ]; +} + +/** + * Parse a map + */ +function parseMap($map) { + $markers = []; + foreach ($map->children()->listed() as $child) { + if ($child->intendedTemplate()->name() === 'marker') { + $markers[] = parseMarker($child); + } + } + $staticImage = $map->file('map-static.png'); + return [ + 'id' => $map->id(), + 'uuid' => $map->uuid()->toString(), 'template' => 'carte', - 'title' => $carte->title()->value(), - 'slug' => $carte->slug(), - 'tags' => $carte->tags()->isNotEmpty() ? $carte->tags()->split() : [], - 'text' => resolveImagesInHtml($carte->text()->value(), $carte) + 'title' => $map->title()->value(), + 'slug' => $map->slug(), + 'tags' => $map->tags()->isNotEmpty() ? $map->tags()->split() : [], + 'image' => $staticImage ? $staticImage->url() : null, + 'intro' => resolveImagesInHtml($map->text()->value(), $map), + 'markers' => $markers ]; } @@ -154,10 +181,13 @@ function parseCarte($carte) { * Parse un geoformat */ function parseGeoformat($geoformat) { - $chapitres = []; + $children = []; foreach ($geoformat->children()->listed() as $child) { - if ($child->intendedTemplate()->name() === 'chapitre') { - $chapitres[] = parseChapitre($child); + $template = $child->intendedTemplate()->name(); + if ($template === 'chapter') { + $children[] = parseChapter($child); + } elseif ($template === 'map') { + $children[] = parseMap($child); } } @@ -171,7 +201,7 @@ function parseGeoformat($geoformat) { 'tags' => $geoformat->tags()->isNotEmpty() ? $geoformat->tags()->split() : [], 'cover' => resolveFileUrl($geoformat->cover(), $geoformat), 'text' => resolveImagesInHtml($geoformat->text()->value(), $geoformat), - 'children' => $chapitres + 'children' => $children ]; } @@ -197,8 +227,8 @@ foreach ($page->children()->listed() as $child) { if ($template === 'geoformat') { $data['children'][] = parseGeoformat($child); - } elseif ($template === 'carte') { - $data['children'][] = parseCarte($child); + } elseif ($template === 'map') { + $data['children'][] = parseMap($child); } } diff --git a/public/site/templates/print.php b/public/site/templates/print.php index 3d9870c..ab8e7e3 100644 --- a/public/site/templates/print.php +++ b/public/site/templates/print.php @@ -1,7 +1,7 @@ -