summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-05-06 13:05:45 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-05-06 13:05:45 +0300
commitf130d4eaf10a3ef92208bddcddbceec651fdbd6d (patch)
tree3cec719cccbff49fceafbd8cae2ac83822e78b6c /src
parentab70c91fcdb26b6ea0f851af7d975fa4c938dbe1 (diff)
Gempub: Decode URLs, only load cover image
Diffstat (limited to 'src')
-rw-r--r--src/gempub.c6
-rw-r--r--src/gempub.h1
-rw-r--r--src/ui/documentwidget.c3
3 files changed, 8 insertions, 2 deletions
diff --git a/src/gempub.c b/src/gempub.c
index 0f0345dc..aa03d835 100644
--- a/src/gempub.c
+++ b/src/gempub.c
@@ -206,13 +206,17 @@ void close_Gempub(iGempub *d) {
206} 206}
207 207
208void setBaseUrl_Gempub(iGempub *d, const iString *url) { 208void setBaseUrl_Gempub(iGempub *d, const iString *url) {
209 set_String(&d->baseUrl, url); 209 set_String(&d->baseUrl, collect_String(urlDecodeExclude_String(url, "/:")));
210} 210}
211 211
212iBool isOpen_Gempub(const iGempub *d) { 212iBool isOpen_Gempub(const iGempub *d) {
213 return d->arch != NULL; 213 return d->arch != NULL;
214} 214}
215 215
216const iString *coverPageUrl_Gempub(const iGempub *d) {
217 return &d->baseUrl;
218}
219
216const iString *indexPageUrl_Gempub(const iGempub *d) { 220const iString *indexPageUrl_Gempub(const iGempub *d) {
217 iAssert(!isEmpty_String(&d->baseUrl)); 221 iAssert(!isEmpty_String(&d->baseUrl));
218 iString *dir = collect_String(copy_String(&d->baseUrl)); 222 iString *dir = collect_String(copy_String(&d->baseUrl));
diff --git a/src/gempub.h b/src/gempub.h
index fb3c510b..6912bcc9 100644
--- a/src/gempub.h
+++ b/src/gempub.h
@@ -57,6 +57,7 @@ iString * coverPageSource_Gempub (const iGempub *);
57iBool preloadCoverImage_Gempub(const iGempub *, iGmDocument *doc); 57iBool preloadCoverImage_Gempub(const iGempub *, iGmDocument *doc);
58 58
59const iString * property_Gempub (const iGempub *, enum iGempubProperty); 59const iString * property_Gempub (const iGempub *, enum iGempubProperty);
60const iString * coverPageUrl_Gempub (const iGempub *);
60const iString * indexPageUrl_Gempub (const iGempub *); 61const iString * indexPageUrl_Gempub (const iGempub *);
61const iString * navStartLinkUrl_Gempub (const iGempub *); /* for convenience */ 62const iString * navStartLinkUrl_Gempub (const iGempub *); /* for convenience */
62 63
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 5a5a4f84..5d449851 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -1137,7 +1137,8 @@ static void postProcessRequestContent_DocumentWidget_(iDocumentWidget *d) {
1137 } 1137 }
1138 } 1138 }
1139 if (d->sourceGempub) { 1139 if (d->sourceGempub) {
1140 if (preloadCoverImage_Gempub(d->sourceGempub, d->doc)) { 1140 if (equal_String(d->mod.url, coverPageUrl_Gempub(d->sourceGempub)) &&
1141 preloadCoverImage_Gempub(d->sourceGempub, d->doc)) {
1141 redoLayout_GmDocument(d->doc); 1142 redoLayout_GmDocument(d->doc);
1142 updateVisible_DocumentWidget_(d); 1143 updateVisible_DocumentWidget_(d);
1143 invalidate_DocumentWidget_(d); 1144 invalidate_DocumentWidget_(d);