Backend/Frontend: Added all fields for photography section.
This commit is contained in:
parent
7549aa7bea
commit
3a6213d412
4 changed files with 51 additions and 44 deletions
|
@ -2,10 +2,12 @@ package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"backend/util"
|
"backend/util"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -21,6 +23,12 @@ type PictureData struct {
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PictureJson struct {
|
||||||
|
Title string `json:"title"`
|
||||||
|
Localisation string `json:"localisation"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
}
|
||||||
|
|
||||||
var picd []PictureData
|
var picd []PictureData
|
||||||
|
|
||||||
func listFiles(path string, actualdir string, picd []PictureData) []PictureData {
|
func listFiles(path string, actualdir string, picd []PictureData) []PictureData {
|
||||||
|
@ -40,7 +48,7 @@ func listFiles(path string, actualdir string, picd []PictureData) []PictureData
|
||||||
picd = listFiles(path+"/"+info.Name(), info.Name(), picd)
|
picd = listFiles(path+"/"+info.Name(), info.Name(), picd)
|
||||||
} else {
|
} else {
|
||||||
// fmt.Printf("\uf15b %s: %do\n", entry.Name(), info.Size())
|
// fmt.Printf("\uf15b %s: %do\n", entry.Name(), info.Size())
|
||||||
picd = getFileInfo(info, picd, actualdir)
|
picd = getFileInfo(path, info, picd, actualdir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return picd
|
return picd
|
||||||
|
@ -56,19 +64,40 @@ func isPicture(s string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFileInfo(info fs.FileInfo, picd []PictureData, actualdir string) []PictureData {
|
func getFileInfo(path string, info fs.FileInfo, picd []PictureData, actualdir string) []PictureData {
|
||||||
if isPicture(info.Name()) {
|
if isPicture(info.Name()) {
|
||||||
|
title := strings.TrimSuffix(info.Name(), filepath.Ext(info.Name()))
|
||||||
|
file, err := os.Open(filepath.Join(path, title+".json"))
|
||||||
|
var pictureinfo PictureJson
|
||||||
|
if err == nil {
|
||||||
|
decoder := json.NewDecoder(file)
|
||||||
|
decoder.DisallowUnknownFields()
|
||||||
|
decoder.Decode(&pictureinfo)
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
// Setting parameters
|
||||||
|
if pictureinfo.Title != "" {
|
||||||
|
title = pictureinfo.Title
|
||||||
|
}
|
||||||
|
|
||||||
picd = append(picd, PictureData{
|
picd = append(picd, PictureData{
|
||||||
Name: info.Name(),
|
Name: info.Name(),
|
||||||
Date: info.ModTime(),
|
Date: info.ModTime(),
|
||||||
Album: actualdir,
|
Album: actualdir,
|
||||||
URL: "http://localhost:8085/photo/" + actualdir + "/" + info.Name(),
|
URL: "http://localhost:8085/photo/" + actualdir + "/" + info.Name(),
|
||||||
Title: strings.TrimSuffix(info.Name(), filepath.Ext(info.Name())),
|
Title: title,
|
||||||
Localisation: "Paris, France",
|
Localisation: pictureinfo.Localisation,
|
||||||
|
Description: pictureinfo.Description,
|
||||||
})
|
})
|
||||||
util.Logformatrn(util.INFO, "Reading %d files...", len(picd))
|
util.Logformatrn(util.INFO, "Reading %d files...", len(picd))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ordering by most recent
|
||||||
|
sort.Slice(picd, func(i, j int) bool {
|
||||||
|
return picd[i].Date.After(picd[j].Date) // descending: newer dates first
|
||||||
|
})
|
||||||
|
|
||||||
return picd
|
return picd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,10 +101,15 @@
|
||||||
bind:this={divHoverCardMetadata.div}
|
bind:this={divHoverCardMetadata.div}
|
||||||
>
|
>
|
||||||
<h1 bind:this={divHoverCardMetadata.title}>{title}</h1>
|
<h1 bind:this={divHoverCardMetadata.title}>{title}</h1>
|
||||||
<div bind:this={divHoverCardMetadata.localisation} class="flex align-center">
|
{#if localisation}
|
||||||
|
<div
|
||||||
|
bind:this={divHoverCardMetadata.localisation}
|
||||||
|
class="flex align-center"
|
||||||
|
>
|
||||||
<SvgIcon type="mdi" path={mdiMapMarker}></SvgIcon>
|
<SvgIcon type="mdi" path={mdiMapMarker}></SvgIcon>
|
||||||
<p>{localisation}</p>
|
<p>{localisation}</p>
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import "$lib/css/hover-card.css";
|
import "$lib/css/hover-card.css";
|
||||||
import { mdiMapMarker } from '@mdi/js'
|
import { mdiMapMarker } from "@mdi/js";
|
||||||
import SvgIcon from "@jamescoyle/svelte-icon/src/svg-icon.svelte";
|
import SvgIcon from "@jamescoyle/svelte-icon/src/svg-icon.svelte";
|
||||||
|
|
||||||
export let title = "";
|
export let title = "";
|
||||||
|
@ -12,10 +12,13 @@
|
||||||
<div class="hover-card-popup-container flex">
|
<div class="hover-card-popup-container flex">
|
||||||
<div class="hover-card-popup-text">
|
<div class="hover-card-popup-text">
|
||||||
<h1>{title}</h1>
|
<h1>{title}</h1>
|
||||||
|
{#if localisation}
|
||||||
<div class="flex align-center">
|
<div class="flex align-center">
|
||||||
<SvgIcon type="mdi" path={mdiMapMarker}></SvgIcon>
|
<SvgIcon type="mdi" path={mdiMapMarker}></SvgIcon>
|
||||||
<span>{localisation}</span>
|
<span>{localisation}</span>
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<p>{description}</p>
|
<p>{description}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="hover-card-popup-picture">
|
<div class="hover-card-popup-picture">
|
||||||
|
|
|
@ -49,35 +49,5 @@
|
||||||
"photo": {
|
"photo": {
|
||||||
"title": "Photographie",
|
"title": "Photographie",
|
||||||
"description": "Je ne suis pas un professionnel, mais il faut avouer que prendre des photos, faire du montage dessus, ou simplement régler la colorimétrie fait partie de mes passions. Cette petite galerie montre mes dernières photos, souvent liées à une émotion actuelle."
|
"description": "Je ne suis pas un professionnel, mais il faut avouer que prendre des photos, faire du montage dessus, ou simplement régler la colorimétrie fait partie de mes passions. Cette petite galerie montre mes dernières photos, souvent liées à une émotion actuelle."
|
||||||
},
|
|
||||||
"photos": [
|
|
||||||
{
|
|
||||||
"urlcompressed": "https://cloud.etheryo.fr/s/azb63ct3bGn84Da/download?path=&files=IMG20240728150532_compressed.jpg",
|
|
||||||
"url": "https://share.etheryo.fr/rando/2024.07.28/IMG20240728150532.jpg",
|
|
||||||
"title": "Tarnished Peak (afterwar)",
|
|
||||||
"localisation": "Cruach Adrain, Écosse",
|
|
||||||
"description": "L'appel à l'aventure était trop fort. Je ne voulais plus m'arrêter, mais comme à mon habitude, mon corps ne pouvait suivre mes pensées. Je me suis posé pendant plusieurs minutes devant cette falaise, me demandant ce qu'il y'avait derrière. Les nuages flottants et changeant de place à la vitesse du vent était un reflet de mes émotions qui changeaient."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"urlcompressed": "https://cloud.etheryo.fr/s/azb63ct3bGn84Da/download?path=&files=IMG20240728142327_compressed.jpg",
|
|
||||||
"url": "https://share.etheryo.fr/rando/2024.07.28/IMG20240728142327.jpg",
|
|
||||||
"title": "Whitewashed",
|
|
||||||
"localisation": "Cruach Adrain, Écosse",
|
|
||||||
"description": "Photo modifiée pour ajouter cet effet de brume lointaine. Le ciel était bien bleu mais les nuages cachaient cette lumière et laissait paraître une ambiance blanchâtre."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"urlcompressed": "https://cloud.etheryo.fr/s/azb63ct3bGn84Da/download?path=&files=Groupe%20Ombre%20Lac%20Montagne%20Rouge%20Bleu_compressed.jpg",
|
|
||||||
"url": "https://share.etheryo.fr/rando/2023.11.01/Groupe%20Ombre%20Lac%20Montagne%20Rouge%20Bleu.jpg",
|
|
||||||
"title": "Compagnons",
|
|
||||||
"localisation": "Lac d'Oô, France",
|
|
||||||
"description": "Lors de notre petit periple avec quelques camarades de l'INSA nous avons décidé de nous balader vers l'autre bout du lac. Cette photo est une prise de vue de loin par ma part de mes camarades, observant leurs divers déplacements devant le coucher du soleil."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"urlcompressed": "https://cloud.etheryo.fr/s/azb63ct3bGn84Da/download?path=&files=IMG20240728155726_compressed.jpg",
|
|
||||||
"url": "https://share.etheryo.fr/rando/2024.07.28/IMG20240728155726.jpg",
|
|
||||||
"title": "Replica",
|
|
||||||
"localisation": "Cruach Adrain, Écosse",
|
|
||||||
"description": "'Replca' ou 'Replique' montre la nature fractale des collines écossaises."
|
|
||||||
}
|
}
|
||||||
]
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue