Skip to content

Commit

Permalink
New: Option to set an image from the folder as a poster
Browse files Browse the repository at this point in the history
  • Loading branch information
ollm committed Aug 16, 2024
1 parent 531fb66 commit 0a952da
Show file tree
Hide file tree
Showing 26 changed files with 194 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Library Navigation using side mouse buttons [`96f4bb8`](https://github.com/ollm/OpenComic/commit/96f4bb8e0033bd58b78e9ec29155ae332c72ec8b)
- Move to trash and Delete permanently options [`2737fbe`](https://github.com/ollm/OpenComic/commit/2737fbe2b9a318c9e5a8b27885e153caa5e9b327)
- Improved reading load and memory usage [`f12cbdb`](https://github.com/ollm/OpenComic/commit/f12cbdbade5e487f5c608e253a6c82b8e7c554a4)
- Option to set an image from the folder as a poster


##### 🐛 Bug Fixes
Expand Down
3 changes: 3 additions & 0 deletions languages/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"deletePoster": "Esborrar pòster",
"cannotAddPoster": "No es pot afegir el pòster si la carpeta és dins d'un fitxer comprimit, haurà d'editar el fitxer mitjançant 7-zip, unrar, etc",
"cannotDeletePoster": "No es pot esborrar el pòster si està dins d'un fitxer comprimit, haurà d'editar el fitxer mitjançant 7-zip, unrar, etc",
"setAsPoster": "Usar imatge com a pòster",
"setAsPosterFolders": "Usar imatge com a pòster d'una altra carpeta",
"posterSetSuccessfully": "La imatge s'ha establert com a pòster",
"closeApp": "Tancar OpenComic"
},
"back": "Enrere",
Expand Down
3 changes: 3 additions & 0 deletions languages/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"deletePoster": "",
"cannotAddPoster": "",
"cannotDeletePoster": "",
"setAsPoster": "",
"setAsPosterFolders": "",
"posterSetSuccessfully": "",
"closeApp": ""
},
"back": "Zpět",
Expand Down
3 changes: 3 additions & 0 deletions languages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"deletePoster": "",
"cannotAddPoster": "",
"cannotDeletePoster": "",
"setAsPoster": "",
"setAsPosterFolders": "",
"posterSetSuccessfully": "",
"closeApp": ""
},
"back": "Zurück",
Expand Down
3 changes: 3 additions & 0 deletions languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"deletePoster": "Delete poster",
"cannotAddPoster": "It is not possible to add the poster if the folder is inside a compressed file, you will have to edit the file using 7-zip, unrar, etc",
"cannotDeletePoster": "It is not possible to delete the poster if is inside a compressed file, you will have to edit the file using 7-zip, unrar, etc",
"setAsPoster": "Set image as poster",
"setAsPosterFolders": "Set image as poster of another folder",
"posterSetSuccessfully": "The image has been set as poster",
"closeApp": "Close OpenComic"
},
"back": "Back",
Expand Down
3 changes: 3 additions & 0 deletions languages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"deletePoster": "Eliminar póster",
"cannotAddPoster": "No es posible añadir el póster si la carpeta está dentro de un archivo comprimido, tendrá que editar el archivo mediante 7-zip, unrar, etc",
"cannotDeletePoster": "No es posible eliminar el póster si está dentro de un archivo comprimido, tendrá que editar el archivo mediante 7-zip, unrar, etc",
"setAsPoster": "Usar imagen como póster",
"setAsPosterFolders": "Usar imagen como poster de otra carpeta",
"posterSetSuccessfully": "La imagen se ha establecido como póster",
"closeApp": "Cerrar OpenComic"
},
"back": "Atrás",
Expand Down
3 changes: 3 additions & 0 deletions languages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"deletePoster": "",
"cannotAddPoster": "",
"cannotDeletePoster": "",
"setAsPoster": "",
"setAsPosterFolders": "",
"posterSetSuccessfully": "",
"closeApp": ""
},
"back": "Retour",
Expand Down
3 changes: 3 additions & 0 deletions languages/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"deletePoster": "",
"cannotAddPoster": "",
"cannotDeletePoster": "",
"setAsPoster": "",
"setAsPosterFolders": "",
"posterSetSuccessfully": "",
"closeApp": ""
},
"back": "Vissza",
Expand Down
3 changes: 3 additions & 0 deletions languages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"deletePoster": "",
"cannotAddPoster": "",
"cannotDeletePoster": "",
"setAsPoster": "",
"setAsPosterFolders": "",
"posterSetSuccessfully": "",
"closeApp": ""
},
"back": "Indietro",
Expand Down
3 changes: 3 additions & 0 deletions languages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"deletePoster": "",
"cannotAddPoster": "",
"cannotDeletePoster": "",
"setAsPoster": "",
"setAsPosterFolders": "",
"posterSetSuccessfully": "",
"closeApp": ""
},
"back": "戻る",
Expand Down
3 changes: 3 additions & 0 deletions languages/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"deletePoster": "",
"cannotAddPoster": "",
"cannotDeletePoster": "",
"setAsPoster": "",
"setAsPosterFolders": "",
"posterSetSuccessfully": "",
"closeApp": "OpenComic 끝내기"
},
"back": "",
Expand Down
3 changes: 3 additions & 0 deletions languages/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"deletePoster": "",
"cannotAddPoster": "",
"cannotDeletePoster": "",
"setAsPoster": "",
"setAsPosterFolders": "",
"posterSetSuccessfully": "",
"closeApp": ""
},
"back": "Voltar",
Expand Down
3 changes: 3 additions & 0 deletions languages/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"deletePoster": "",
"cannotAddPoster": "",
"cannotDeletePoster": "",
"setAsPoster": "",
"setAsPosterFolders": "",
"posterSetSuccessfully": "",
"closeApp": ""
},
"back": "Назад",
Expand Down
3 changes: 3 additions & 0 deletions languages/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"deletePoster": "Ta bort affisch",
"cannotAddPoster": "Det går inte att lägga till affischen om mappen finns i en komprimerad fil, du måste redigera filen med 7-zip, unrar, osv.",
"cannotDeletePoster": "Det är inte möjligt att ta bort affischen om den finns i en komprimerad fil, du måste redigera filen med 7-zip, unrar, osv.",
"setAsPoster": "",
"setAsPosterFolders": "",
"posterSetSuccessfully": "",
"closeApp": "Stäng OpenComic"
},
"back": "Tillbaka",
Expand Down
3 changes: 3 additions & 0 deletions languages/th.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"deletePoster": "ลบปก",
"cannotAddPoster": "ไม่สามารถเพิ่มรูปภาพปกกรณีที่โฟลเดอร์อยู่ในไฟล์บีบอัดได้ คุณจะต้องแก้ไขไฟล์โดยใช้ 7-zip, unrar เป็นต้น",
"cannotDeletePoster": "ไม่สามารถนำรูปภาพปกกรณีที่โฟลเดอร์อยู่ในไฟล์บีบอัดออกได้ คุณจะต้องแก้ไขไฟล์โดยใช้ 7-zip, unrar เป็นต้น",
"setAsPoster": "",
"setAsPosterFolders": "",
"posterSetSuccessfully": "",
"closeApp": "ปิด OpenComic"
},
"back": "กลับ",
Expand Down
3 changes: 3 additions & 0 deletions languages/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"deletePoster": "Xóa ảnh bìa",
"cannotAddPoster": "Không thể thêm ảnh bìa nếu thư mục nằm trong một tệp nén, bạn sẽ phải sửa tệp tin bằng 7-zip, unrar hoặc các phần mềm tương tự",
"cannotDeletePoster": "Không thể xóa ảnh bìa nếu thư mục nằm trong một tệp nén, bạn sẽ phải sửa tệp tin bằng 7-zip, unrar hoặc các phần mềm tương tự",
"setAsPoster": "",
"setAsPosterFolders": "",
"posterSetSuccessfully": "",
"closeApp": "Đóng OpenComic"
},
"back": "Trở về",
Expand Down
3 changes: 3 additions & 0 deletions languages/zh-hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"deletePoster": "删除封面",
"cannotAddPoster": "如果文件夹位于压缩文件内,则无法添加封面,您必须使用 7-zip、unrar 等编辑文件",
"cannotDeletePoster": "如果封面位于压缩文件内,则无法删除,您必须使用 7-zip、unrar 等编辑该文件",
"setAsPoster": "",
"setAsPosterFolders": "",
"posterSetSuccessfully": "",
"closeApp": "关闭 OpenComic"
},
"back": "返回",
Expand Down
3 changes: 3 additions & 0 deletions languages/zh-hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"deletePoster": "",
"cannotAddPoster": "",
"cannotDeletePoster": "",
"setAsPoster": "",
"setAsPosterFolders": "",
"posterSetSuccessfully": "",
"closeApp": ""
},
"back": "返回",
Expand Down
9 changes: 7 additions & 2 deletions scripts/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,9 @@ function addCacheVars(path, size, sha)

var cacheImagesDeleted = [];

async function deleteInCache(path)
async function deleteInCache(path, type = false)
{
let sha = sha1(path);
let sha = (type) ? sha1(path+'?type='+type) : sha1(path);
let cachePath = p.join(cacheFolder, sha+'.jpg');

if(data[sha])
Expand All @@ -524,6 +524,11 @@ async function deleteInCache(path)
}

cacheImagesDeleted[sha] = cacheImagesDeleted[sha] ? cacheImagesDeleted[sha] + 1 : 1;

if(!type)
{
await deleteInCache(path, 'poster');
}

return;
}
Expand Down
24 changes: 20 additions & 4 deletions scripts/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -1267,8 +1267,6 @@ function indexPathControlGoBack()
}
else if(indexPathControlA.length > 0)
{
console.log(indexPathControlA);

let goBack = indexPathControlA[indexPathControlA.length - 2];

indexLabel = goBack.indexLabel;
Expand Down Expand Up @@ -1864,7 +1862,7 @@ function nightModeConfig(_app = false)
}

// Show the comic context menu
async function comicContextMenu(path, fromIndex = true, fromIndexNotMasterFolders = true, folder = false, gamepad = false)
async function comicContextMenu(path, mainPath, fromIndex = true, fromIndexNotMasterFolders = true, folder = false, gamepad = false)
{
let isServer = fileManager.isServer(path);
if(!fromIndex && isServer) return;
Expand Down Expand Up @@ -1970,7 +1968,7 @@ async function comicContextMenu(path, fromIndex = true, fromIndexNotMasterFolder
}
else
{
dom.query('#index-context-menu .separator-poster').css({display: folder ? 'block' : 'none'});
dom.query('#index-context-menu .separator-poster').css({display: 'block'});

// Open file location
let openFileLocation = document.querySelector('#index-context-menu .context-menu-open-file-location');
Expand Down Expand Up @@ -2021,6 +2019,24 @@ async function comicContextMenu(path, fromIndex = true, fromIndexNotMasterFolder

openFileLocation.querySelector('span').innerHTML = language.global.contextMenu.openFileLocation;
}

// Set image as poster
let setAsPoster = document.querySelector('#index-context-menu .context-menu-set-as-poster');
let setAsPosterFolders = document.querySelector('#index-context-menu .context-menu-set-as-poster-folders');

if(!folder)
{
setAsPoster.style.display = 'block';
setAsPosterFolders.style.display = 'block';

setAsPoster.setAttribute('onclick', 'dom.poster.setAsPoster(\''+escapeQuotes(escapeBackSlash(path), 'simples')+'\');');
setAsPosterFolders.setAttribute('onclick', 'dom.poster.setAsPosterFolders(\''+escapeQuotes(escapeBackSlash(path), 'simples')+'\', \''+escapeQuotes(escapeBackSlash(mainPath), 'simples')+'\');');
}
else
{
setAsPoster.style.display = 'none';
setAsPosterFolders.style.display = 'none';
}
}

// File info
Expand Down
Loading

0 comments on commit 0a952da

Please sign in to comment.