From 82d3366b80c0d904abb81b1299e6c00ae128e0fd Mon Sep 17 00:00:00 2001 From: kurbezz Date: Sat, 3 Oct 2020 18:00:48 +0300 Subject: [PATCH] Add descriptions --- public/generated_albums_config.json | 2 +- public/pictures/albums/album_1/album.yml | 4 ++++ scripts/collect-static-data.ts | 12 +++++++++++- src/store/albums/state.ts | 4 ++++ src/views/Album.vue | 14 +++++++++++++- 5 files changed, 33 insertions(+), 3 deletions(-) diff --git a/public/generated_albums_config.json b/public/generated_albums_config.json index 1103871..395025b 100644 --- a/public/generated_albums_config.json +++ b/public/generated_albums_config.json @@ -1 +1 @@ -[{"name":"Album 1 name","description":"Album 2 description","protected":false,"coverFileName":"IMG_20200811_060850.jpg","folderName":"album_1","files":["IMG_20200811_060850.jpg","IMG_20200811_074445.jpg","IMG_20200811_080037.jpg","IMG_20200811_081746.jpg","IMG_20200811_084017.jpg"],"files_360":["photo.jpg"]}] \ No newline at end of file +[{"name":"Album 1 name","description":"Album 2 description","protected":false,"coverFileName":"IMG_20200811_060850.jpg","photoDescription":{"IMG_20200811_060850.jpg":"Description 1","IMG_20200811_074445.jpg":"Description 2"},"folderName":"album_1","files":["IMG_20200811_060850.jpg","IMG_20200811_074445.jpg","IMG_20200811_080037.jpg","IMG_20200811_081746.jpg","IMG_20200811_084017.jpg"],"files_360":["photo.jpg"]}] \ No newline at end of file diff --git a/public/pictures/albums/album_1/album.yml b/public/pictures/albums/album_1/album.yml index 04578b5..70a0c41 100644 --- a/public/pictures/albums/album_1/album.yml +++ b/public/pictures/albums/album_1/album.yml @@ -3,3 +3,7 @@ description: Album 2 description protected: false coverFileName: 'IMG_20200811_060850.jpg' + +photoDescription: + IMG_20200811_060850.jpg: 'Description 1' + IMG_20200811_074445.jpg: 'Description 2' diff --git a/scripts/collect-static-data.ts b/scripts/collect-static-data.ts index 054187a..012292b 100644 --- a/scripts/collect-static-data.ts +++ b/scripts/collect-static-data.ts @@ -59,7 +59,17 @@ function processAlbum(folderName: string) { } else { console.error(red(`Error: File ${albumPath}/album.yml does not contains "${item}" key!`)); } - }) + }); + + if (parsedData['photoDescription']) { + Object.keys(parsedData['photoDescription']).forEach(item => { + if (!photos.includes(item)) { + console.warn(yellow(`Warning: Description for ${albumPath}/photos/${item} , but it doesn't exist!`)); + } + }); + + config['photoDescription'] = parsedData['photoDescription']; + } } } else { console.error(red(`Error: File ${albumPath}/album.yml does not exists!`)); diff --git a/src/store/albums/state.ts b/src/store/albums/state.ts index ea6477d..82e5675 100644 --- a/src/store/albums/state.ts +++ b/src/store/albums/state.ts @@ -5,7 +5,11 @@ export interface IAlbum { protected: boolean; folderName: string; + files: string[]; + files_360: string[]; + + photoDescription: {[key: string]: string}; } export default class AlbumsState { diff --git a/src/views/Album.vue b/src/views/Album.vue index 6260685..51131f8 100644 --- a/src/views/Album.vue +++ b/src/views/Album.vue @@ -81,7 +81,13 @@ export default class AlbumPage extends Vue { get images() { return this.album!.files - .map(item => `/pictures/albums/${this.album!.folderName}/photos/${item}`); + .map((item, index) => { + return { + id: `${this.album!.folderName}/${item}`, + href: `/pictures/albums/${this.album!.folderName}/photos/${item}`, + description: this.album!.photoDescription[item] || ' ', + }; + }); } updateFiles() { @@ -145,4 +151,10 @@ export default class AlbumPage extends Vue { background: none; color: white!important; } + +.blueimp-gallery-controls > .description { + margin-top: calc(100vh - 5em); + width: 100vw; + text-align: center; +}