Skip to content

Commit 0e3b2a8

Browse files
committed
New: Improve relative path support for folder portable
1 parent 3b4e1ce commit 0e3b2a8

18 files changed

Lines changed: 345 additions & 119 deletions

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1414
- Separate order of browsing and reading [`e08faea`](https://github.com/ollm/OpenComic/commit/e08faea31038fc51c207a940d853734a45b32c7a)
1515
- Sort option to list compressed files first, separated from folders [`508fd1a`](https://github.com/ollm/OpenComic/commit/508fd1aa1886f11aee0ca6559754200d312da706)
1616
- Auto-prompt to track [`30608da`](https://github.com/ollm/OpenComic/commit/30608da602868c9e8c2ea2d528868c9b6464fc61)
17+
- Improve relative path support for folder portable
1718

1819
##### 🐛 Bug Fixes
1920

@@ -23,7 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2324
- Rare cases of blank images during reading [`e1f27b3`](https://github.com/ollm/OpenComic/commit/e1f27b315bc9023e35c7ea52122d3c918564f5e3)
2425
- Show magnifying glass instantaneous when enabled from shortcuts [`43bc73d`](https://github.com/ollm/OpenComic/commit/43bc73dcf85d80e756f1b674a64c66c7ce75529c)
2526
- goBack not working if OpenComic starts directly on reading [`2f6e2fc`](https://github.com/ollm/OpenComic/commit/2f6e2fc0ccb6d6d22eaa2c543a87d3a8b91bfc46)
26-
- Error on migrating some config
27+
- Error on migrating some config [`3b4e1ce`](https://github.com/ollm/OpenComic/commit/3b4e1ceb8c167bb76a7355a4085a09e2173c520d)
2728

2829
## [v1.6.0](https://github.com/ollm/OpenComic/releases/tag/v1.6.0) (27-07-2025)
2930

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@
3838
"rename-win-arm": "node scripts/rename.js --win-arm",
3939
"watch": "nodemon --ignore 'dist/' --ignore scripts/builded --watch * --exec npm run start",
4040
"build": "npm run prebuild && electron-builder build && npm run postbuild",
41-
"build-dist": "npm run prebuild && electron-builder --x64 --linux deb rpm AppImage 7z flatpak && electron-builder --arm64 --linux deb rpm AppImage 7z flatpak && npm run postbuild",
41+
"build-dist": "npm run build-linux-folder-portable && npm run prebuild && electron-builder --x64 --linux deb rpm AppImage 7z flatpak && electron-builder --arm64 --linux deb rpm AppImage 7z flatpak && npm run postbuild",
4242
"build-linux": "npm run prebuild && electron-builder --x64 --linux deb rpm AppImage 7z tar.gz && npm run postbuild",
43+
"build-linux-folder-portable": "npm run prebuild && npm run prebuild-folder-portable && electron-builder --x64 --linux 7z && electron-builder --arm64 --linux 7z && npm run rename-folder-portable && npm run postbuild",
4344
"build-deb": "npm run prebuild && electron-builder --x64 --linux deb && npm run postbuild",
4445
"build-rpm": "npm run prebuild && electron-builder --x64 --linux rpm && npm run postbuild",
4546
"build-snap": "npm run prebuild && electron-builder --x64 --linux snap && npm run postbuild",

scripts/dom.js

Lines changed: 37 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -95,36 +95,17 @@ function orderBy(a, b, mode, key = false, key2 = false)
9595
}
9696
}
9797

98-
99-
//Get reading progres of path
100-
function getReadingProgress(path, callback)
101-
{
102-
path = p.normalize(path);
103-
104-
var readingProgress = storage.getKey('readingProgress');
105-
106-
for(let rpPath in readingProgress)
107-
{
108-
var data = readingProgress[rpPath];
109-
110-
if(typeof data.progress[path] !== 'undefined')
111-
return data;
112-
}
113-
114-
return false;
115-
}
116-
11798
function addImageToDom(sha, path, animation = true)
11899
{
119100
const src = dom.queryAll('img.sha-image-'+sha).setAttribute('src', path);
120101

121102
if(animation)
122103
{
123-
src.addClass('a', 'border');
104+
src.addClass('a', 'active', 'border');
124105
}
125106
else
126107
{
127-
src.addClass('border');
108+
src.addClass('active', 'border');
128109
src.filter('.folder-poster-img').addClass('has-poster');
129110
}
130111
}
@@ -254,7 +235,7 @@ async function readFilesIndexPage(path, mainPath, fromGoBack, notAutomaticBrowsi
254235
};
255236

256237
// Get comic reading progress image
257-
let _readingProgress = storage.get('readingProgress');
238+
let _readingProgress = relative.get('readingProgress');
258239
let readingProgress = _readingProgress[mainPath]?.path ? _readingProgress[mainPath] : false;
259240
let readingProgressCurrentPath = (mainPath != path) ? (_readingProgress[path]?.path ? _readingProgress[path] : false) : false;
260241

@@ -375,7 +356,7 @@ async function loadFilesIndexPage(files, file, animation, path, keepScroll, main
375356
let thumbnails = [];
376357

377358
// Get comic reading progress image
378-
let _readingProgress = storage.get('readingProgress');
359+
let _readingProgress = relative.get('readingProgress');
379360

380361
let readingProgress = _readingProgress[mainPath]?.path ? _readingProgress[mainPath] : false;
381362
let readingProgressCurrentPath = (mainPath != path) ? (_readingProgress[path]?.path ? _readingProgress[path] : false) : false;
@@ -734,15 +715,17 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
734715
let ignore = fileManager.ignoreFilesRegex();
735716

736717
// Get comics in master folders
737-
let masterFolders = storage.get('masterFolders');
718+
let masterFolders = relative.get('masterFolders');
738719

739720
if(!isEmpty(masterFolders))
740721
{
741-
for(let key in masterFolders)
722+
for(let path of masterFolders)
742723
{
743-
if(fs.existsSync(masterFolders[key]) && (!_indexLabel.masterFolder || _indexLabel.masterFolder == masterFolders[key]) && !_indexLabel.server)
724+
path = path;
725+
726+
if(fs.existsSync(path) && (!_indexLabel.masterFolder || _indexLabel.masterFolder == path) && !_indexLabel.server)
744727
{
745-
let file = fileManager.file(masterFolders[key]);
728+
let file = fileManager.file(path);
746729
let files = await file.readDir();
747730
file.destroy();
748731

@@ -856,18 +839,20 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
856839
}
857840

858841
// Get comics in library
859-
let comicsStorage = storage.get('comics');
842+
let comicsStorage = relative.get('comics');
860843

861844
if(!isEmpty(comicsStorage) && !_indexLabel.masterFolder && !_indexLabel.server)
862845
{
863-
for(let key in comicsStorage)
846+
for(const comic of comicsStorage)
864847
{
865-
if(!comicPaths.has(comicsStorage[key].path) && fs.existsSync(comicsStorage[key].path))
848+
const path = comic.path;
849+
850+
if(!comicPaths.has(path) && fs.existsSync(path))
866851
{
867-
comicsStorage[key].name = metadataPathName(comicsStorage[key]);
868-
comics.push(comicsStorage[key]);
852+
comic.name = metadataPathName(comic);
853+
comics.push(comic);
869854

870-
comicPaths.add(comicsStorage[key].path);
855+
comicPaths.add(path);
871856
}
872857
}
873858
}
@@ -878,15 +863,15 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
878863
const labelsPath = [];
879864

880865
// Favorites
881-
const favorites = storage.get('favorites');
866+
const favorites = relative.get('favorites');
882867

883868
for(let path in favorites)
884869
{
885870
labelsPath.push(path);
886871
}
887872

888873
// Labels
889-
const comicLabels = storage.get('comicLabels');
874+
const comicLabels = relative.get('comicLabels');
890875

891876
for(let path in comicLabels)
892877
{
@@ -927,7 +912,7 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
927912
{
928913
if(_indexLabel.favorites)
929914
{
930-
let favorites = storage.get('favorites');
915+
let favorites = relative.get('favorites');
931916
let _comics = [];
932917

933918
for(let i = 0; i < len; i++)
@@ -944,7 +929,7 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
944929
let labels = storage.get('labels') || [];
945930
let label = labels[_indexLabel.index] || false;
946931

947-
let comicLabels = storage.get('comicLabels');
932+
let comicLabels = relative.get('comicLabels');
948933
let _comics = [];
949934

950935
for(let i = 0; i < len; i++)
@@ -967,7 +952,7 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
967952
if(len)
968953
{
969954
// Comic reading progress
970-
let readingProgress = storage.get('readingProgress');
955+
let readingProgress = relative.get('readingProgress');
971956

972957
for(let i = 0; i < len; i++)
973958
{
@@ -1123,21 +1108,22 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
11231108
function loadIndexContentLeft(animation)
11241109
{
11251110
// Master folders
1126-
let masterFolders = storage.get('masterFolders');
1111+
let masterFolders = relative.get('masterFolders');
11271112

1128-
let _masterFolders = [];
1113+
masterFolders = masterFolders.map(function(path, i) {
11291114

1130-
for(let i = 0, len = masterFolders.length; i < len; i++)
1131-
{
1132-
_masterFolders.push({
1115+
path = path;
1116+
1117+
return {
11331118
id: 'master-folder-'+i,
11341119
key: i,
1135-
name: p.basename(masterFolders[i]),
1136-
path: masterFolders[i],
1137-
});
1138-
}
1120+
name: p.basename(path),
1121+
path: path,
1122+
};
1123+
1124+
});
11391125

1140-
_masterFolders.sort(function(a, b){
1126+
masterFolders.sort(function(a, b){
11411127

11421128
if(a.name === b.name)
11431129
return 0;
@@ -1146,7 +1132,7 @@ function loadIndexContentLeft(animation)
11461132

11471133
});
11481134

1149-
handlebarsContext.masterFolders = _masterFolders;
1135+
handlebarsContext.masterFolders = masterFolders;
11501136

11511137
// Labels
11521138
let labels = storage.get('labels');
@@ -2427,7 +2413,7 @@ async function comicContextMenu(path, mainPath, fromIndex = true, fromIndexNotMa
24272413

24282414
if(fromIndex || folder)
24292415
{
2430-
let favorites = storage.get('favorites');
2416+
let favorites = relative.get('favorites');
24312417
let isFavorte = favorites[path] ? true : false;
24322418

24332419
favorite.style.display = 'block';
@@ -2596,6 +2582,7 @@ async function comicContextMenu(path, mainPath, fromIndex = true, fromIndexNotMa
25962582
// Remove the comic from OpenComic
25972583
function removeComic(path, confirm = false, reload = true)
25982584
{
2585+
path = relative.path(path);
25992586
var _comics = [], comics = storage.get('comics');
26002587

26012588
for(let i in comics)

scripts/dom/file-info.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ async function show(path, opds = false)
135135

136136
metadata.size = '<span class="file-info-size">...</span>';
137137

138-
let readingProgress = storage.get('readingProgress');
138+
let readingProgress = relative.get('readingProgress');
139139
readingProgress = readingProgress[path] || false;
140140

141141
if(readingProgress)

scripts/dom/labels.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ function masterFolder(folder, index)
77

88
function setFavorite(path)
99
{
10+
path = relative.path(path);
1011
let favorites = storage.get('favorites');
1112

1213
if(favorites[path])
@@ -162,8 +163,8 @@ function filterList(comics, filter = {favorites: false, labels: false, withoutLa
162163
if(!filter.favorites && !filter.labels && !filter.withoutLabels)
163164
return comics;
164165

165-
const favorites = storage.get('favorites');
166-
const comicLabels = storage.get('comicLabels');
166+
const favorites = relative.get('favorites');
167+
const comicLabels = relative.get('comicLabels');
167168

168169
return comics.filter(function(comic){
169170

@@ -295,9 +296,9 @@ function setLabels(path, save = false)
295296
}
296297
else
297298
{
298-
labelsDialogPath = path;
299+
labelsDialogPath = relative.path(path);
299300

300-
const comicLabels = storage.get('comicLabels');
301+
const comicLabels = relative.get('comicLabels');
301302
const labels = getLabels(comicLabels[path] || []);
302303

303304
handlebarsContext.labels = labels;
@@ -652,7 +653,7 @@ function getName(indexLabel, recentlyOpened)
652653

653654
function has(path, parents = false)
654655
{
655-
const comicLabels = storage.get('comicLabels');
656+
const comicLabels = relative.get('comicLabels');
656657

657658
if(comicLabels[path])
658659
return comicLabels[path];

scripts/migration.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,26 @@ function migrateSeparateOrderOfBrowsingAndReading(data)
374374
return data;
375375
}
376376

377+
function migrateBookmarksPath(data)
378+
{
379+
console.time('Migration: bookmarksPath');
380+
381+
for(const path in data.bookmarks)
382+
{
383+
if(data.bookmarks[path] && data.bookmarks[path].length)
384+
{
385+
for(const bookmark of data.bookmarks[path])
386+
{
387+
bookmark.path = p.relative(path, bookmark.path);
388+
}
389+
}
390+
}
391+
392+
console.timeEnd('Migration: bookmarksPath');
393+
394+
return data;
395+
}
396+
377397
function start(data)
378398
{
379399
let changes = data.config.changes;
@@ -416,6 +436,9 @@ function start(data)
416436
if(changes < 128) // Separate order of browsing and reading
417437
data = migrateSeparateOrderOfBrowsingAndReading(data);
418438

439+
if(changes < 131) // Bookmarks path
440+
data = migrateBookmarksPath(data);
441+
419442
data = opds.addNewDefaultCatalogs(data, changes);
420443

421444
return data;

scripts/opds.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ async function boxes(path = false, mainPath = false)
876876
if(len)
877877
{
878878
// Comic reading progress
879-
let readingProgress = storage.get('readingProgress');
879+
let readingProgress = relative.get('readingProgress');
880880

881881
for(let i = 0; i < len; i++)
882882
{

0 commit comments

Comments
 (0)