mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-08 08:37:38 +03:00
Compare commits
3 Commits
328f78365d
...
7ba522ed9e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ba522ed9e | ||
|
|
9572fc3fb2 | ||
|
|
f67c544e16 |
@ -153,7 +153,7 @@ Click **File Manager** to access file management features.
|
|||||||
|
|
||||||
1. Click the **+ Add** button in the top-right corner
|
1. Click the **+ Add** button in the top-right corner
|
||||||
2. Select **New Folder** from the dropdown menu
|
2. Select **New Folder** from the dropdown menu
|
||||||
3. Enter a folder name (letters, numbers, underscores, and hyphens only)
|
3. Enter a folder name (must not contain characters \" * : < > ? / \\ | and must not be . or ..)
|
||||||
4. Click **Create Folder**
|
4. Click **Create Folder**
|
||||||
|
|
||||||
This is useful for organizing your ebooks by genre, author, or series.
|
This is useful for organizing your ebooks by genre, author, or series.
|
||||||
|
|||||||
@ -79,7 +79,8 @@ bool RecentBooksStore::loadFromFile() {
|
|||||||
serialization::readString(inputFile, path);
|
serialization::readString(inputFile, path);
|
||||||
// Title and author will be empty, they will be filled when the book is
|
// Title and author will be empty, they will be filled when the book is
|
||||||
// opened again
|
// opened again
|
||||||
recentBooks.push_back({path, "", "", ""});
|
std::string fileName = path.substr(path.rfind('/') + 1);
|
||||||
|
recentBooks.push_back({path, fileName, "", "-"});
|
||||||
}
|
}
|
||||||
} else if (version == 2) {
|
} else if (version == 2) {
|
||||||
// Old version, just read paths, titles and authors
|
// Old version, just read paths, titles and authors
|
||||||
@ -94,7 +95,7 @@ bool RecentBooksStore::loadFromFile() {
|
|||||||
serialization::readString(inputFile, author);
|
serialization::readString(inputFile, author);
|
||||||
// Title and author will be empty, they will be filled when the book is
|
// Title and author will be empty, they will be filled when the book is
|
||||||
// opened again
|
// opened again
|
||||||
recentBooks.push_back({path, title, author, ""});
|
recentBooks.push_back({path, title, author, "-"});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Serial.printf("[%lu] [RBS] Deserialization failed: Unknown version %u\n", millis(), version);
|
Serial.printf("[%lu] [RBS] Deserialization failed: Unknown version %u\n", millis(), version);
|
||||||
|
|||||||
@ -44,8 +44,11 @@ void HomeActivity::loadRecentBooks(int maxBooks, int coverHeight) {
|
|||||||
const auto& books = RECENT_BOOKS.getBooks();
|
const auto& books = RECENT_BOOKS.getBooks();
|
||||||
recentBooks.reserve(std::min(static_cast<int>(books.size()), maxBooks));
|
recentBooks.reserve(std::min(static_cast<int>(books.size()), maxBooks));
|
||||||
|
|
||||||
|
bool mustReloadRecents = false; // We're migrating from an older version of recent books
|
||||||
int progress = 0;
|
int progress = 0;
|
||||||
for (const RecentBook& book : books) {
|
for (const RecentBook& book : books) {
|
||||||
|
bool mustLoadCover = false;
|
||||||
|
|
||||||
// Limit to maximum number of recent books
|
// Limit to maximum number of recent books
|
||||||
if (recentBooks.size() >= maxBooks) {
|
if (recentBooks.size() >= maxBooks) {
|
||||||
break;
|
break;
|
||||||
@ -56,9 +59,16 @@ void HomeActivity::loadRecentBooks(int maxBooks, int coverHeight) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!book.coverBmpPath.empty()) {
|
if (book.coverBmpPath == "-") {
|
||||||
|
mustReloadRecents = true;
|
||||||
|
} else {
|
||||||
std::string coverPath = UITheme::getCoverThumbPath(book.coverBmpPath, coverHeight);
|
std::string coverPath = UITheme::getCoverThumbPath(book.coverBmpPath, coverHeight);
|
||||||
if (!SdMan.exists(coverPath.c_str())) {
|
if (!SdMan.exists(coverPath.c_str())) {
|
||||||
|
mustLoadCover = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mustReloadRecents || mustLoadCover) {
|
||||||
std::string lastBookFileName = "";
|
std::string lastBookFileName = "";
|
||||||
const size_t lastSlash = book.path.find_last_of('/');
|
const size_t lastSlash = book.path.find_last_of('/');
|
||||||
if (lastSlash != std::string::npos) {
|
if (lastSlash != std::string::npos) {
|
||||||
@ -77,8 +87,14 @@ void HomeActivity::loadRecentBooks(int maxBooks, int coverHeight) {
|
|||||||
showingLoading = true;
|
showingLoading = true;
|
||||||
popupRect = GUI.drawPopup(renderer, "Loading...");
|
popupRect = GUI.drawPopup(renderer, "Loading...");
|
||||||
}
|
}
|
||||||
GUI.fillPopupProgress(renderer, popupRect, progress * 30);
|
GUI.fillPopupProgress(renderer, popupRect, progress * (100 / maxBooks));
|
||||||
epub.generateThumbBmp(coverHeight);
|
epub.generateThumbBmp(coverHeight);
|
||||||
|
|
||||||
|
if (mustReloadRecents) {
|
||||||
|
// Update recent book entry with title/author/cover path
|
||||||
|
RECENT_BOOKS.addBook(book.path, epub.getTitle(), epub.getAuthor(), epub.getThumbBmpPath());
|
||||||
|
recentBooks.push_back({book.path, epub.getTitle(), epub.getAuthor(), epub.getThumbBmpPath()});
|
||||||
|
}
|
||||||
} else if (StringUtils::checkFileExtension(lastBookFileName, ".xtch") ||
|
} else if (StringUtils::checkFileExtension(lastBookFileName, ".xtch") ||
|
||||||
StringUtils::checkFileExtension(lastBookFileName, ".xtc")) {
|
StringUtils::checkFileExtension(lastBookFileName, ".xtc")) {
|
||||||
// Handle XTC file
|
// Handle XTC file
|
||||||
@ -89,18 +105,24 @@ void HomeActivity::loadRecentBooks(int maxBooks, int coverHeight) {
|
|||||||
showingLoading = true;
|
showingLoading = true;
|
||||||
popupRect = GUI.drawPopup(renderer, "Loading...");
|
popupRect = GUI.drawPopup(renderer, "Loading...");
|
||||||
}
|
}
|
||||||
GUI.fillPopupProgress(renderer, popupRect, progress * 30);
|
GUI.fillPopupProgress(renderer, popupRect, progress * (100 / maxBooks));
|
||||||
xtc.generateThumbBmp(coverHeight);
|
xtc.generateThumbBmp(coverHeight);
|
||||||
|
|
||||||
|
if (mustReloadRecents) {
|
||||||
|
// Update recent book entry with title/author/cover path
|
||||||
|
RECENT_BOOKS.addBook(book.path, xtc.getTitle(), xtc.getAuthor(), xtc.getThumbBmpPath());
|
||||||
|
recentBooks.push_back({book.path, xtc.getTitle(), xtc.getAuthor(), xtc.getThumbBmpPath()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mustReloadRecents) {
|
||||||
recentBooks.push_back(book);
|
recentBooks.push_back(book);
|
||||||
|
}
|
||||||
progress++;
|
progress++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.printf("Recent books loaded: %d\n", recentBooks.size());
|
|
||||||
recentsLoaded = true;
|
recentsLoaded = true;
|
||||||
recentsLoading = false;
|
recentsLoading = false;
|
||||||
updateRequired = true;
|
updateRequired = true;
|
||||||
|
|||||||
@ -58,9 +58,11 @@ void TxtReaderActivity::onEnter() {
|
|||||||
txt->setupCacheDir();
|
txt->setupCacheDir();
|
||||||
|
|
||||||
// Save current txt as last opened file and add to recent books
|
// Save current txt as last opened file and add to recent books
|
||||||
APP_STATE.openEpubPath = txt->getPath();
|
auto filePath = txt->getPath();
|
||||||
|
auto fileName = filePath.substr(filePath.rfind('/') + 1);
|
||||||
|
APP_STATE.openEpubPath = filePath;
|
||||||
APP_STATE.saveToFile();
|
APP_STATE.saveToFile();
|
||||||
RECENT_BOOKS.addBook(txt->getPath(), "", "", "");
|
RECENT_BOOKS.addBook(filePath, fileName, "", "");
|
||||||
|
|
||||||
// Trigger first update
|
// Trigger first update
|
||||||
updateRequired = true;
|
updateRequired = true;
|
||||||
|
|||||||
@ -1146,10 +1146,10 @@ function retryAllFailedUploads() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate folder name (no special characters except underscore and hyphen)
|
// Validate folder name
|
||||||
const validName = /^[a-zA-Z0-9_\-]+$/.test(folderName);
|
const validName = /^(?!\.{1,2}$)[^"*:<>?\/\\|]+$/.test(folderName);
|
||||||
if (!validName) {
|
if (!validName) {
|
||||||
alert('Folder name can only contain letters, numbers, underscores, and hyphens.');
|
alert('Folder name cannot contain \" * : < > ? / \\ | and must not be . or ..');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user