mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-02-04 03:08:04 +01:00
fix forgotten reader mode script
This commit is contained in:
parent
ac1948eead
commit
2222043b1b
@ -16,6 +16,7 @@
|
||||
<file>sounds/goodresult.wav</file>
|
||||
|
||||
<file>scripts/adblock/adblock-server.js</file>
|
||||
<file>scripts/readability/readabilize-article.js</file>
|
||||
|
||||
<file>graphics/rssguard.ico</file>
|
||||
|
||||
|
10
resources/scripts/readability/readabilize-article.js
Executable file
10
resources/scripts/readability/readabilize-article.js
Executable file
@ -0,0 +1,10 @@
|
||||
var rd = require('@mozilla/readability');
|
||||
var fs = require('fs');
|
||||
var jsd = require('jsdom');
|
||||
var iconvlite = require('iconv-lite');
|
||||
var data = fs.readFileSync(0);
|
||||
var encData = iconvlite.decode(data, "utf-8");
|
||||
var doc = new jsd.JSDOM(encData);
|
||||
|
||||
var article = new rd.Readability(doc.window.document).parse();
|
||||
console.log(article['content']);
|
@ -7,9 +7,14 @@
|
||||
#include "gui/messagebox.h"
|
||||
#include "miscellaneous/application.h"
|
||||
|
||||
#include <QDir>
|
||||
|
||||
#define READABILITY_PACKAGE "@mozilla/readability"
|
||||
#define READABILITY_VERSION "0.4.2"
|
||||
|
||||
#define JSDOM_PACKAGE "jsdom"
|
||||
#define JSDOM_VERSION "19.0.0"
|
||||
|
||||
Readability::Readability(QObject* parent) : QObject{parent}, m_modulesInstalling(false), m_modulesInstalled(false) {
|
||||
connect(qApp->nodejs(), &NodeJs::packageInstalledUpdated, this, &Readability::onPackageReady);
|
||||
connect(qApp->nodejs(), &NodeJs::packageError, this, &Readability::onPackageError);
|
||||
@ -63,9 +68,13 @@ void Readability::onPackageError(const QList<NodeJs::PackageMetadata>& pkgs, con
|
||||
void Readability::makeHtmlReadable(const QString& html, const QString& base_url) {
|
||||
if (!m_modulesInstalled) {
|
||||
try {
|
||||
NodeJs::PackageStatus st = qApp->nodejs()->packageStatus({ QSL(READABILITY_PACKAGE), QSL(READABILITY_VERSION) });
|
||||
NodeJs::PackageStatus stReadability = qApp->nodejs()->packageStatus({ QSL(READABILITY_PACKAGE),
|
||||
QSL(READABILITY_VERSION) });
|
||||
NodeJs::PackageStatus stJsdom = qApp->nodejs()->packageStatus({ QSL(READABILITY_PACKAGE),
|
||||
QSL(READABILITY_VERSION) });
|
||||
|
||||
if (st != NodeJs::PackageStatus::UpToDate) {
|
||||
if (stReadability != NodeJs::PackageStatus::UpToDate ||
|
||||
stJsdom != NodeJs::PackageStatus::UpToDate) {
|
||||
if (!m_modulesInstalling) {
|
||||
// We make sure to update modules.
|
||||
m_modulesInstalling = true;
|
||||
@ -100,13 +109,20 @@ void Readability::makeHtmlReadable(const QString& html, const QString& base_url)
|
||||
}
|
||||
}
|
||||
|
||||
QString temp_script = QDir::toNativeSeparators(IOFactory::getSystemFolder(QStandardPaths::StandardLocation::TempLocation)) +
|
||||
QDir::separator() +
|
||||
QSL("readabilize-article.js");
|
||||
|
||||
if (!IOFactory::copyFile(QSL(":/scripts/readability/readabilize-article.js"), temp_script)) {
|
||||
qWarningNN << LOGSEC_ADBLOCK << "Failed to copy Readability script to TEMP.";
|
||||
}
|
||||
|
||||
QProcess* proc = new QProcess(this);
|
||||
|
||||
connect(proc, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, &Readability::onReadabilityFinished);
|
||||
|
||||
qApp->nodejs()->runScript(proc,
|
||||
QSL("c:\\Projekty\\Moje\\build-rssguard-Desktop_Qt_6_2_3_MSVC2017_64bit-Debug\\"
|
||||
"src\\rssguard\\data4\\node-packages-windows\\article-to-readable.js"),
|
||||
temp_script,
|
||||
{ base_url });
|
||||
|
||||
proc->write(html.toUtf8());
|
||||
|
Loading…
x
Reference in New Issue
Block a user