From e7c0906cb266052e1ab758c77269e0e0970a1772 Mon Sep 17 00:00:00 2001 From: Nick Kocharhook Date: Mon, 27 Nov 2023 22:47:24 +0000 Subject: [PATCH 1/2] [#760] Add image titles and captions to the info panel. --- .gitignore | 4 ++++ .tool-versions | 1 + angular.json | 3 ++- .../model/database/enitites/MediaEntity.ts | 3 +++ src/backend/model/fileaccess/MetadataLoader.ts | 3 +++ src/common/DataStructureVersion.ts | 2 +- src/common/entities/MediaDTO.ts | 2 ++ src/common/entities/PhotoDTO.ts | 1 + src/frontend/app/app.module.ts | 3 ++- .../info-panel.lightbox.gallery.component.css | 4 ++++ .../info-panel.lightbox.gallery.component.html | 15 +++++++++++++++ 11 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 .tool-versions diff --git a/.gitignore b/.gitignore index f9fcf631..5965b197 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.angular/ .idea/ PiGallery2.iml node_modules/ @@ -30,3 +31,6 @@ test.* /test/cypress/screenshots/ /extensions/ /extension/lib/ +*.sublime-project +*.sublime-workspace +.DS_Store diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 00000000..8ead549e --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +nodejs 18.16.0 diff --git a/angular.json b/angular.json index f52ddf25..63db2700 100644 --- a/angular.json +++ b/angular.json @@ -4,7 +4,8 @@ "schematicCollections": [ "@angular-eslint/schematics", "@schematics/angular" - ] + ], + "analytics": false }, "version": 1, "newProjectRoot": "projects", diff --git a/src/backend/model/database/enitites/MediaEntity.ts b/src/backend/model/database/enitites/MediaEntity.ts index 3d959198..52bbf600 100644 --- a/src/backend/model/database/enitites/MediaEntity.ts +++ b/src/backend/model/database/enitites/MediaEntity.ts @@ -86,6 +86,9 @@ export class MediaMetadataEntity implements MediaMetadata { @Column('text') caption: string; + @Column('text') + title?: string; + @Column(() => MediaDimensionEntity) size: MediaDimensionEntity; diff --git a/src/backend/model/fileaccess/MetadataLoader.ts b/src/backend/model/fileaccess/MetadataLoader.ts index 8a6187fa..0b9c9ff0 100644 --- a/src/backend/model/fileaccess/MetadataLoader.ts +++ b/src/backend/model/fileaccess/MetadataLoader.ts @@ -342,6 +342,9 @@ export class MetadataLoader { .replace(/\0/g, '') .trim(); } + if (iptcData.object_name) { + metadata.title = iptcData.object_name.replace(/\0/g, '').trim(); + } if (iptcData.caption) { metadata.caption = iptcData.caption.replace(/\0/g, '').trim(); } diff --git a/src/common/DataStructureVersion.ts b/src/common/DataStructureVersion.ts index d7b968fe..3f62a4e3 100644 --- a/src/common/DataStructureVersion.ts +++ b/src/common/DataStructureVersion.ts @@ -1,4 +1,4 @@ /** * This version indicates that the sql/entities/*Entity.ts files got changed and the db needs to be recreated */ -export const DataStructureVersion = 34; +export const DataStructureVersion = 35; diff --git a/src/common/entities/MediaDTO.ts b/src/common/entities/MediaDTO.ts index b56136ca..ff04429f 100644 --- a/src/common/entities/MediaDTO.ts +++ b/src/common/entities/MediaDTO.ts @@ -19,6 +19,8 @@ export interface MediaMetadata { fileSize: number; keywords?: string[]; rating?: RatingTypes; + title?: string; + caption?: string; } export interface MediaDimension { diff --git a/src/common/entities/PhotoDTO.ts b/src/common/entities/PhotoDTO.ts index 1bd6b090..a4af1c24 100644 --- a/src/common/entities/PhotoDTO.ts +++ b/src/common/entities/PhotoDTO.ts @@ -27,6 +27,7 @@ export interface FaceRegion { } export interface PhotoMetadata extends MediaMetadata { + title?: string; caption?: string; cameraData?: CameraMetadata; positionData?: PositionMetaData; diff --git a/src/frontend/app/app.module.ts b/src/frontend/app/app.module.ts index 34f24d03..51e21661 100644 --- a/src/frontend/app/app.module.ts +++ b/src/frontend/app/app.module.ts @@ -130,6 +130,7 @@ import { ionContractOutline, ionCopyOutline, ionDocumentOutline, + ionDocumentTextOutline, ionDownloadOutline, ionExpandOutline, ionFileTrayFullOutline, @@ -243,7 +244,7 @@ Marker.prototype.options.icon = MarkerFactory.defIcon; ionAlbumsOutline, ionSettingsOutline, ionLogOutOutline, ionChevronForwardOutline, ionChevronDownOutline, ionChevronBackOutline, ionTrashOutline, ionSaveOutline, ionAddOutline, ionRemoveOutline, - ionTextOutline, ionFolderOutline, ionDocumentOutline, ionImageOutline, + ionTextOutline, ionFolderOutline, ionDocumentOutline, ionDocumentTextOutline, ionImageOutline, ionPricetagOutline, ionLocationOutline, ionSunnyOutline, ionMoonOutline, ionVideocamOutline, ionInformationCircleOutline, diff --git a/src/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.css b/src/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.css index fa0793e9..8e58b9a3 100644 --- a/src/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.css +++ b/src/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.css @@ -27,6 +27,10 @@ padding-right: 5px; } +.caption-body { + white-space: pre-wrap; +} + .yaga-map { width: 100%; height: 100%; diff --git a/src/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.html b/src/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.html index 02a1fcd1..3e1cbbfa 100644 --- a/src/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.html +++ b/src/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.html @@ -4,6 +4,21 @@ + +
+
+ +
+
+

+ {{media.metadata.title}} +

+
+
{{media.metadata.caption}}
+
+
+
+
From 45d9398deaf98a446451b6b753ad7915b60e58f7 Mon Sep 17 00:00:00 2001 From: Nick Kocharhook Date: Wed, 6 Dec 2023 16:40:08 +0000 Subject: [PATCH 2/2] Add titles to caption tests. --- test/backend/assets/edge_case_exif_data/before_epoch.json | 3 ++- test/backend/assets/test image öüóőúéáű-.,.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/backend/assets/edge_case_exif_data/before_epoch.json b/test/backend/assets/edge_case_exif_data/before_epoch.json index 7806ca50..51ddb9a6 100644 --- a/test/backend/assets/edge_case_exif_data/before_epoch.json +++ b/test/backend/assets/edge_case_exif_data/before_epoch.json @@ -40,5 +40,6 @@ "size": { "height": 7, "width": 10 - } + }, + "title": "Bambi Title" } diff --git a/test/backend/assets/test image öüóőúéáű-.,.json b/test/backend/assets/test image öüóőúéáű-.,.json index 9ea5dcbe..31a6954b 100644 --- a/test/backend/assets/test image öüóőúéáű-.,.json +++ b/test/backend/assets/test image öüóőúéáű-.,.json @@ -49,5 +49,6 @@ "size": { "height": 10, "width": 14 - } + }, + "title": "Test caption" }