diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cfeda1cd0..dfbbdfd81 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,10 +25,9 @@ jobs: steps: - name: Install dependencies - shell: bash - run: | - ARCHIVE_NAME=deps2_focal_native_dyn_kiwix-desktop.tar.xz - wget -O- http://tmp.kiwix.org/ci/${ARCHIVE_NAME} | tar -xJ -C ${{env.HOME}} + uses: kiwix/kiwix-build/actions/dl_deps_archive@main + with: + target_platform: native_dyn - name: Retrieve source code uses: actions/checkout@v3 diff --git a/src/main.cpp b/src/main.cpp index b98c54d81..ec975d724 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,6 +22,7 @@ int main(int argc, char *argv[]) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) QWebEngineUrlScheme scheme("zim"); + scheme.setSyntax(QWebEngineUrlScheme::Syntax::Host); QWebEngineUrlScheme::registerScheme(scheme); #endif KiwixApp a(argc, argv); diff --git a/src/urlschemehandler.cpp b/src/urlschemehandler.cpp index 956c8840e..fd9ee3ada 100644 --- a/src/urlschemehandler.cpp +++ b/src/urlschemehandler.cpp @@ -48,12 +48,14 @@ UrlSchemeHandler::handleContentRequest(QWebEngineUrlRequestJob *request) return; } try { + qInfo() << "Getting " << QString::fromStdString(url) << "from" << zim_id; auto entry = getEntryFromPath(*archive, url); auto item = entry.getItem(true); if (entry.isRedirect()) { auto path = QString("/") + QString::fromStdString(item.getPath()); qurl.setPath(path); request->redirect(qurl); + qInfo() << "-> Redirecting to" << path; return; } @@ -62,8 +64,10 @@ UrlSchemeHandler::handleContentRequest(QWebEngineUrlRequestJob *request) mimeType = mimeType.split(';')[0]; connect(request, &QObject::destroyed, buffer, &QObject::deleteLater); request->reply(mimeType, buffer); + qInfo() << "-> Reply with" << mimeType; } catch (zim::EntryNotFound&) { request->fail(QWebEngineUrlRequestJob::UrlNotFound); + qInfo() << "-> Not found"; } } diff --git a/src/webpage.cpp b/src/webpage.cpp index 8824710de..fc058c13d 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -14,11 +14,35 @@ WebPage::WebPage(QObject *parent) : action(QWebEnginePage::Reload)->setVisible(false); } -bool WebPage::acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType /*type*/, bool /*isMainFrame*/) +bool WebPage::acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame) { + qInfo() << "Requesting" << url; + qInfo() << "Navigation type :" << type << "MainFrame:" << isMainFrame; + if (url.scheme() != "zim") { QDesktopServices::openUrl(url); + qInfo() << "=> False"; return false; } + qInfo() << "=> True"; return true; } + + +void WebPage::javaScriptConsoleMessage(QWebEnginePage::JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID) { + auto info = qInfo(); + switch (level) { + case QWebEnginePage::InfoMessageLevel: + info << "INFO"; + break; + case QWebEnginePage::WarningMessageLevel: + info << "WARN"; + break; + case QWebEnginePage::ErrorMessageLevel: + info << "ERRO"; + break; + } + + info << "in" << sourceID << " at line" << lineNumber; + info << ":" << message; +} diff --git a/src/webpage.h b/src/webpage.h index c8e64a3f1..a29cca1e0 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -10,6 +10,7 @@ class WebPage : public QWebEnginePage protected: bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame); + void javaScriptConsoleMessage(QWebEnginePage::JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID) override; }; #endif // WEBPAGE_H