Skip to content

Commit fdf8eaf

Browse files
committed
New: Count images/pages in file info if they are not in the metadata
1 parent 36c67fb commit fdf8eaf

3 files changed

Lines changed: 49 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
3434
- Support MyAnimeList tracking [`5f40b4a`](https://github.com/ollm/OpenComic/commit/5f40b4af1b70e8cfaad0beb79fec676c9c1c83fe)
3535
- Multi-layer folder labeling/favoriting and header bar filter options [`652a6a5`](https://github.com/ollm/OpenComic/commit/652a6a522b32fb9bf77a8dbfebafc0496050c634)
3636
- Option to disable tap zones [`aa7bb3c`](https://github.com/ollm/OpenComic/commit/aa7bb3cc4350616bc527c622be5ed7ddf2d5d611)
37-
- Refactored navigation history logic (`goBack`, `goForward`, etc.)
37+
- Refactored navigation history logic (`goBack`, `goForward`, etc.) [`a4b6c3d`](https://github.com/ollm/OpenComic/commit/a4b6c3db4fbd447f6c129da1329d05d16b891074)
38+
- Count images/pages in file info if they are not in the metadata
3839

3940
##### 🐛 Bug Fixes
4041

scripts/check-releases.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const sanitizeHtml = require('sanitize-html'),
33

44
function showReleaseDialog(release)
55
{
6-
release.releases_url = 'https://github.com/ollm/OpenComic?tab=readme-ov-file#download';
6+
release.releases_url = 'https://opencomic.app/docs/installation/download';
77
release.html_url = 'https://github.com/ollm/OpenComic/releases';
88

99
const parsed = marked.parse(release.body).replace(/(\<a\s)\s*/ig, '$1 target="_blank"').replace(/\<h5\>/ig, '<h5 class="title-small">');

scripts/dom/file-info.js

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ const epubConvertKeys = {
109109
async function show(path, opds = false)
110110
{
111111
let metadata = {};
112+
let runCountImages = false;
112113

113114
if(opds)
114115
{
@@ -143,7 +144,13 @@ async function show(path, opds = false)
143144
readingProgress = readingProgress[path] || false;
144145

145146
if(readingProgress)
146-
metadata.readingDate = readingProgress.lastReading;
147+
metadata.readingDate = readingProgress.lastReading;
148+
149+
if(!metadata.pages)
150+
{
151+
metadata.pages = '<span class="file-info-pages">...</span>';
152+
runCountImages = true;
153+
}
147154
}
148155

149156
metadata.contributor = parseContributor(metadata);
@@ -283,7 +290,12 @@ async function show(path, opds = false)
283290
dom.fileInfo.resize(true);
284291

285292
if(!opds)
293+
{
286294
getFileSize();
295+
296+
if(runCountImages)
297+
countImages();
298+
}
287299
}
288300

289301
async function getFileSize()
@@ -300,6 +312,38 @@ async function getFileSize()
300312
dom.queryAll('.file-info-size').html(size);
301313
}
302314

315+
async function _countImages(path, file)
316+
{
317+
const files = await file.read({}, path);
318+
319+
let count = 0;
320+
321+
for(let i = 0, len = files.length; i < len; i++)
322+
{
323+
const _file = files[i];
324+
325+
if(_file.folder || _file.compressed)
326+
{
327+
count += await _countImages(_file.path, file);
328+
}
329+
else if(compatible.image(_file.path))
330+
{
331+
count++;
332+
}
333+
}
334+
335+
return count;
336+
}
337+
338+
async function countImages()
339+
{
340+
const file = fileManager.file(currentPath);
341+
const images = await _countImages(currentPath, file);
342+
file.destroy();
343+
344+
dom.queryAll('.file-info-pages').html(images);
345+
}
346+
303347
function parseValue(value, key)
304348
{
305349
switch (key)
@@ -574,7 +618,7 @@ function sanitizeHtml(string)
574618
{
575619
return _sanitizeHtml(string, {
576620
allowedClasses: {
577-
span: ['file-info-size'],
621+
span: ['file-info-size', 'file-info-pages'],
578622
div: ['file-info-subject'],
579623
i: ['material-icon'],
580624
},

0 commit comments

Comments
 (0)