Commit 2f0cedd2 authored by Jonathan Marten's avatar Jonathan Marten Committed by Stefano Crocco
Browse files

Start to restore the web archiving plugin

This reverts commit 6e876efb.
parent 8b8df797
......@@ -8,6 +8,7 @@ add_subdirectory( kimgalleryplugin )
add_subdirectory( dirfilter )
add_subdirectory( uachanger )
add_subdirectory( babelfish )
add_subdirectory( webarchiver )
if (Qt5TextToSpeech_FOUND)
add_subdirectory(ttsplugin)
......
add_definitions(-DTRANSLATION_DOMAIN=\"webarchiver\")
find_package(KF5 REQUIRED COMPONENTS CoreAddons Parts)
########### next target ###############
set(webarchiverplugin_PART_SRCS plugin_webarchiver.cpp)
add_library(webarchiverplugin MODULE ${webarchiverplugin_PART_SRCS})
target_include_directories(webarchiverplugin PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/logging)
target_link_libraries(webarchiverplugin webarchiverdebug KF5::Parts Qt5::Core Qt5::Widgets)
########### install files ###############
install(TARGETS webarchiverplugin DESTINATION ${KDE_INSTALL_PLUGINDIR})
set(plugin_FILES plugin_webarchiver.rc plugin_webarchiver.desktop)
install(FILES ${plugin_FILES} DESTINATION ${KDE_INSTALL_DATADIR}/khtml/kpartplugins)
install(FILES ${plugin_FILES} DESTINATION ${KDE_INSTALL_DATADIR}/kwebkitpart/kpartplugins)
install(FILES ${plugin_FILES} DESTINATION ${KDE_INSTALL_DATADIR}/webenginepart/kpartplugins)
ecm_install_icons(
ICONS 16-actions-webarchiver.png 22-actions-webarchiver.png
DESTINATION ${KDE_INSTALL_ICONDIR}
THEME hicolor
)
########### subdirectories ###############
add_subdirectory(logging)
add_subdirectory(app)
add_subdirectory(thumbnailer)
#! /bin/sh
$EXTRACTRC *.rc app/*.kcfg >> rc.cpp
$XGETTEXT *.cpp */*.cpp -o $podir/webarchiver.pot
add_definitions(-DTRANSLATION_DOMAIN=\"webarchiver\")
find_package(KF5 REQUIRED COMPONENTS I18n Crash KIO Archive XmlGui TextWidgets)
########### next target ###############
set(kcreatewebarchive_SRCS main.cpp archivedialog.cpp)
kconfig_add_kcfg_files(kcreatewebarchive_SRCS settings.kcfgc)
add_executable(kcreatewebarchive ${kcreatewebarchive_SRCS})
target_include_directories(kcreatewebarchive PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/.)
target_link_libraries(kcreatewebarchive
webarchiverdebug
KF5::I18n
KF5::XmlGui
KF5::TextWidgets
KF5::Crash
KF5::KIOCore KF5::KIOWidgets KF5::KIOFileWidgets
KF5::Archive
Qt5::Core Qt5::Widgets)
########### install files ###############
install(TARGETS kcreatewebarchive ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES settings.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR} RENAME kcreatewebarchive.kcfg)
This diff is collapsed.
/*
Copyright (C) 2003 Antonio Larrosa <larrosa@kde.org>
Copyright (C) 2008 Matthias Grimrath <maps4711@gmx.de>
Copyright (C) 2020 Jonathan Marten <jjm@keelhaul.me.uk>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, see
<http://www.gnu.org/licenses/>.
*/
#ifndef ARCHIVEDIALOG_H
#define ARCHIVEDIALOG_H
#include <kmainwindow.h>
#include <qurl.h>
#include <qprocess.h>
#include <qpointer.h>
#include <kmessagewidget.h>
class QDialogButtonBox;
class QComboBox;
class QCheckBox;
class QPushButton;
class QTemporaryDir;
class QTemporaryFile;
class KUrlRequester;
class KJob;
class KPluralHandlingSpinBox;
class ArchiveDialog : public KMainWindow
{
Q_OBJECT
public:
ArchiveDialog(const QUrl &url, QWidget *parent = nullptr);
~ArchiveDialog() override;
protected:
void saveSettings();
void readSettings();
bool queryClose() override;
protected slots:
void slotArchiveTypeChanged(int idx);
void slotMessageLinkActivated(const QString &link);
private slots:
void slotCreateButtonClicked();
void slotCheckedDestination(KJob *job);
void slotDeletedOldDestination(KJob *job);
void slotProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
void slotCopiedArchive(KJob *job);
void slotFinishedArchive(KJob *job);
private:
void cleanup();
void startDownloadProcess();
void finishArchive();
void setGuiEnabled(bool on);
void showMessage(const QString &text, KMessageWidget::MessageType type = KMessageWidget::Information);
void showMessageAndCleanup(const QString &text, KMessageWidget::MessageType type = KMessageWidget::Information);
private:
QDialogButtonBox *m_buttonBox;
QPushButton *m_archiveButton;
QPushButton *m_cancelButton;
QWidget *m_guiWidget;
KMessageWidget *m_messageWidget;
KUrlRequester *m_pageUrlReq;
KUrlRequester *m_saveUrlReq;
QComboBox *m_typeCombo;
KPluralHandlingSpinBox *m_waitTimeSpinbox;
QCheckBox *m_noProxyCheck;
QCheckBox *m_randomWaitCheck;
QCheckBox *m_fixExtensionsCheck;
QCheckBox *m_runInTerminalCheck;
QCheckBox *m_closeWhenFinishedCheck;
QUrl m_saveUrl;
QString m_saveType;
QString m_wgetProgram;
QTemporaryDir *m_tempDir;
QTemporaryFile *m_tempFile;
QPointer<QProcess> m_archiveProcess;
};
#endif // ARCHIVEDIALOG_H
/* This file is part of Webarchiver
*
* Copyright (C) 2020 Jonathan Marten <jjm@keelhaul.me.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this program; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
**/
#include <qapplication.h>
#include <qcommandlineparser.h>
#include <qurl.h>
#include <qicon.h>
#include <kaboutdata.h>
#include <klocalizedstring.h>
#include <kcrash.h>
#include "archivedialog.h"
#include "webarchiverdebug.h"
int main(int argc,char *argv[])
{
KAboutData aboutData("kcreatwebearchive", // componentName
i18n("Web Archiver"), // displayName
i18n("0.0.1"), // version
i18n("Archive a web page"),
KAboutLicense::GPL_V3,
i18n("Copyright (c) 2020 Jonathan Marten"),
"", // otherText
"", // homePageAddress
""); // bugsEmailAddress
aboutData.addAuthor(i18n("Jonathan Marten"),
"",
"jjm@keelhaul.me.uk",
"http://www.keelhaul.me.uk");
QApplication app(argc, argv);
KAboutData::setApplicationData(aboutData);
app.setWindowIcon(QIcon::fromTheme("webarchiver"));
KCrash::setDrKonqiEnabled(true);
QCommandLineParser parser;
parser.setApplicationDescription(aboutData.shortDescription());
parser.addPositionalArgument("url", i18n("URL of the web page to archive"), i18n("url"));
aboutData.setupCommandLine(&parser);
parser.process(app);
aboutData.processCommandLine(&parser);
QUrl url;
QStringList args = parser.positionalArguments();
if (!args.isEmpty())
{
if (args.count()>1)
{
qCWarning(WEBARCHIVERPLUGIN_LOG) << "Only one URL argument is accepted";
}
url = QUrl::fromUserInput(args.first());
if (!url.isValid())
{
qCCritical(WEBARCHIVERPLUGIN_LOG) << "Invalid URL argument";
std::exit(EXIT_FAILURE);
}
}
ArchiveDialog *ad = new ArchiveDialog(url);
ad->show();
return (app.exec());
}
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<group name="Options">
<entry name="WaitTime" type="UInt">
<label>Wait time:</label>
<tooltip>The wait time between item requests, to reduce web server load</tooltip>
<min>0</min>
<max>60</max>
<default>1</default>
</entry>
<entry name="NoProxy" type="Bool">
<label>Do not use proxy</label>
<tooltip>Do not use the system proxy settings to fetch the web page</tooltip>
<default>false</default>
</entry>
<entry name="RandomWait" type="Bool">
<label>Randomise wait time</label>
<tooltip>Vary the wait time between requests, to confuse server log analysis</tooltip>
<default>false</default>
</entry>
<entry name="FixExtensions" type="Bool">
<label>Save in standard web archive format</label>
<tooltip>&lt;p&gt;Save downloaded files all in a single directory, with file name extensions suitable for local browsing.
For example, the main HTML page will always be called "index.html" and a remote .php page will be saved with the standard .html extension.&lt;/p&gt;
&lt;p&gt;Leave this option turned on to produce a standard web archive (.war) file.&lt;/p&gt;
&lt;p&gt;If this option is turned off, then the files will be saved exactly as downloaded.
This means that they may be in subdirectories reflecting the structure of the original web site, and extensions will not be adjusted.
Note that the download may not work correctly if the original URL refers to a directory but does not end with a slash.&lt;/p&gt;
</tooltip>
<default>true</default>
</entry>
<entry name="RunInTerminal" type="Bool">
<label>Run in terminal</label>
<tooltip>&lt;p&gt;Run the download process in a terminal window. Close the terminal window when the download has finished.&lt;/p&gt;
&lt;p&gt;If this option is turned off then the download will run in the background. Its progress output should appear in the session log file.&lt;/p&gt;
</tooltip>
<default>false</default>
</entry>
<entry name="CloseWhenFinished" type="Bool">
<label>Close when finished</label>
<tooltip>Close this window when the download has finished successfully</tooltip>
<default>false</default>
</entry>
<entry name="ArchiveType" type="String">
<label>Archive &amp;type:</label>
<tooltip>The type of web archive to save</tooltip>
<default>application/x-webarchive</default>
</entry>
</group>
</kcfg>
File=settings.kcfg
ClassName=Settings
Singleton=true
ItemAccessors=true
Mutators=true
SetUserTexts=true
find_package(Qt5 REQUIRED COMPONENTS Core)
########### next target ###############
set(webarchiverplugin_DEBUG_SRCS "")
ecm_qt_declare_logging_category(webarchiverplugin_DEBUG_SRCS HEADER webarchiverdebug.h IDENTIFIER WEBARCHIVERPLUGIN_LOG CATEGORY_NAME org.kde.konqueror.webarchiver)
add_library(webarchiverdebug STATIC ${webarchiverplugin_DEBUG_SRCS})
target_link_libraries(webarchiverdebug Qt5::Core)
/* This file is part of Webarchiver
*
* Copyright (C) 2001 Andreas Schlapbach <schlpbch@iam.unibe.ch>
* Copyright (C) 2020 Jonathan Marten <jjm@keelhaul.me.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this program; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
**/
#include "plugin_webarchiver.h"
#include <qicon.h>
#include <qurl.h>
#include <qstandardpaths.h>
#include <qprocess.h>
#include <klocalizedstring.h>
#include <kpluginfactory.h>
#include <kactioncollection.h>
#include <kmessagebox.h>
#include <kparts/readonlypart.h>
#include "webarchiverdebug.h"
K_PLUGIN_FACTORY(PluginWebArchiverFactory, registerPlugin<PluginWebArchiver>();)
PluginWebArchiver::PluginWebArchiver(QObject *parent, const QVariantList &args)
: Plugin(parent)
{
QAction *a = actionCollection()->addAction(QStringLiteral("archivepage"));
a->setText(i18n("Archive Web Page..."));
a->setIcon(QIcon::fromTheme(QStringLiteral("webarchiver")));
connect(a, &QAction::triggered, this, &PluginWebArchiver::slotSaveToArchive);
}
void PluginWebArchiver::slotSaveToArchive()
{
KParts::ReadOnlyPart *part = qobject_cast<KParts::ReadOnlyPart *>(parent());
if (part==nullptr) return;
const QUrl pageUrl = part->url();
if (!pageUrl.isValid()) return;
const QString helper = QStandardPaths::findExecutable("kcreatewebarchive");
if (helper.isEmpty())
{
KMessageBox::error(part->widget(),
xi18nc("@info", "Cannot find the <command>kcreatewebarchive</command> executable,<nl/>check the plugin and helper installation."),
i18n("Cannot Create Web Archive"));
return;
}
qCDebug(WEBARCHIVERPLUGIN_LOG) << "Executing" << helper;
QProcess::startDetached(helper, (QStringList() << pageUrl.url()));
}
#include "plugin_webarchiver.moc"
[Desktop Entry]
X-KDE-Library=webarchiver
X-KDE-PluginInfo-Author=Andreas Schlapbach
X-KDE-PluginInfo-Email=schlpbch@iam.unibe.ch
X-KDE-PluginInfo-Name=webarchiver
X-KDE-PluginInfo-Version=3.3
X-KDE-PluginInfo-Website=
X-KDE-PluginInfo-Category=Tools
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
Name=Web Archiver
Name[ar]=مؤرشف الويب
Name[ast]=Archivador web
Name[bg]=Архивиране на страници
Name[bs]=Veb arhivar
Name[ca]=Arxivador de webs
Name[ca@valencia]=Arxivador de webs
Name[cs]=Webový archivátor
Name[da]=Webarkivering
Name[de]=Web-Archivierung
Name[el]=Αρχειοθέτης ιστοσελίδας
Name[en_GB]=Web Archiver
Name[es]=Archivador web
Name[et]=Veebiarhiveerija
Name[eu]=Web artxibatzailea
Name[fi]=Web-arkistoija
Name[fr]=Archiveur Web
Name[ga]=Cartlannaí Gréasáin
Name[gl]=Arquivador web
Name[he]=ארכיוני רשת
Name[hne]=वेब आर्काइवर
Name[hr]=Arhiviranje weba
Name[hu]=Webarchiváló
Name[ia]=Archivator web
Name[id]=Pengarsip Web
Name[is]=Vefsíðusafnari
Name[it]=Archiviatore web
Name[ja]=ウェブアーカイバ
Name[kk]=Веб-архивтеуіш
Name[km]=កម្មវិធី​ទុក​បណ្ដាញ​ជា​​​ប័ណ្ណសារ
Name[ko]=웹 보관 도구
Name[ku]=Arşîvgerê Torê
Name[lt]=Žiniatinklių puslapių archyvavimo priemonė
Name[lv]=Tīmekļa arhivators
Name[mr]=वेब संग्रहकर्ता
Name[ms]=Pengarkib Web
Name[nb]=Vevarkivar
Name[nds]=Nettarchiv-Maker
Name[nl]=Webarchiveerder
Name[nn]=Nettsidearkivering
Name[oc]=Web
Name[pa]=ਵੈਬ ਅਕਾਇਵਰ
Name[pl]=Archiwizator sieciowy
Name[pt]=Arquivos Web
Name[pt_BR]=Arquivador de páginas da Internet
Name[ro]=Arhivator web
Name[ru]=Архиватор веб-страниц
Name[sk]=Webový archivátor
Name[sl]=Spletni pakirnik
Name[sr]=Веб архивар
Name[sr@ijekavian]=Веб архивар
Name[sr@ijekavianlatin]=Veb arhivar
Name[sr@latin]=Veb arhivar
Name[sv]=Webbarkiverare
Name[tg]=Бойгони интернетӣ
Name[th]=เครื่องมือสร้างแฟ้มจัดเก็บหน้าเว็บ
Name[tr]=Web Arşivleyici
Name[ug]=تور ئارخىپى
Name[uk]=Вебархіватор
Name[wa]=Årtchiveu d' waibe
Name[x-test]=xxWeb Archiverxx
Name[zh_CN]=Web 存档
Name[zh_TW]=網頁歸檔器
Comment=Creates archives of websites
Comment[ar]=ينشئ أرشيفات لمواقع الويب
Comment[ast]=Crea archivos de sitios web
Comment[bg]=Създаване на архиви на сайтове
Comment[bs]=Pravi arhive veb sajtova
Comment[ca]=Crea arxius de llocs web
Comment[ca@valencia]=Crea arxius de llocs web
Comment[cs]=Vytvoří archiv z webových stránek
Comment[da]=Kan arkivere websider
Comment[de]=Erstellt ein Archiv von Webseiten
Comment[el]=Δημιουργεί αρχειοθήκες από ιστοσελίδες
Comment[en_GB]=Creates archives of websites
Comment[es]=Crea archivos de sitios web
Comment[et]=Võimaldab luua veebilehekülgede arhiive
Comment[eu]=Webguneen artxiboak sortzen ditu
Comment[fi]=Luo arkistoja verkkosivuista
Comment[fr]=Crée des archives de sites Web
Comment[ga]=Cruthaigh cartlann de shuímh Ghréasáin
Comment[gl]=Crea arquivos de páxinas web
Comment[he]=יוצר ארכיבים של אתרי אינטרנט
Comment[hne]=वेबसाइट मन के अभिलेखागार बनाथे
Comment[hr]=Stvara arhive web stranica
Comment[hu]=Weboldalak archívumának készítése
Comment[ia]=Il crea archivos de sitos web
Comment[id]=Menciptakan arsip situs web
Comment[is]=Býr til safnskrár með vefsvæðum
Comment[it]=Crea archivi di siti web
Comment[ja]=ウェブサイトのアーカイブを作成します
Comment[kk]=Вебсайттарының архивін құру
Comment[km]=បង្កើត​ប័ណ្ណសារ​តំបន់​បណ្ដាញ
Comment[ko]=웹 사이트의 보관 파일 만들기
Comment[ku]=Arşîvên malperan diafirîne
Comment[lt]=Sukuria archyvus iš žiniatinklio puslapių
Comment[lv]=Izveido tīmekļa lapu arhīvus
Comment[mr]=वेबसाइटचा संग्रह तयार करतो
Comment[nb]=Lager arkiver av nettsteder
Comment[nds]=Stellt Archiven ut Nettsieden op
Comment[nl]=Maakt archieven van websites aan
Comment[nn]=Lag arkiv av nettsider
Comment[pa]=ਵੈੱਬ ਸਾਈਟਾਂ ਦਾ ਅਕਾਇਵ ਬਣਾਓ
Comment[pl]=Tworzy archiwa dla stron internetowych
Comment[pt]=Cria arquivos de páginas web
Comment[pt_BR]=Cria arquivos de páginas da Internet
Comment[ro]=Crează arhive ale siturilor web
Comment[ru]=Создаёт архивы с содержимым веб-сайтов
Comment[sk]=Vytvorí archív z webových stránok
Comment[sl]=Ustvari arhive spletnih strani
Comment[sr]=Прави архиве веб сајтова
Comment[sr@ijekavian]=Прави архиве веб сајтова
Comment[sr@ijekavianlatin]=Pravi arhive veb sajtova
Comment[sr@latin]=Pravi arhive veb sajtova
Comment[sv]=Skapar arkiv av webbplatser
Comment[tg]=Бойгонии саҳифаҳои интернетро эҷод мекунад
Comment[th]=สร้างแฟ้มจัดเก็บหน้าเว็บต่าง ๆ
Comment[tr]=Sitelerin arşivlerini oluşturur
Comment[ug]=تور بېكەتنىڭ ئارخىپىنى قۇرىدۇ
Comment[uk]=Створює архіви вебсайтів
Comment[wa]=Ahive des årtchives des waibes
Comment[x-test]=xxCreates archives of websitesxx
Comment[zh_CN]=创建网站的归档
Comment[zh_TW]=建立網站的歸檔
Icon=webarchiver
X-KDE-ParentApp=konqueror
DocPath=konq-plugins/webarchiver/index.html
/* This file is part of Webarchiver
* Copyright (C) 2001 by Andreas Schlapbach <schlpbch@iam.unibe.ch>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this program; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
**/
#ifndef PLUGIN_WEBARCHIVER_H
#define PLUGIN_WEBARCHIVER_H
#include <kparts/plugin.h>
class PluginWebArchiver : public KParts::Plugin
{
Q_OBJECT
public:
PluginWebArchiver(QObject *parent, const QVariantList &args);
~PluginWebArchiver() override = default;
protected slots:
void slotSaveToArchive();
};
#endif
<!DOCTYPE gui SYSTEM "kpartgui.dtd">
<gui name="webarchiver" library="webarchiverplugin" version="2" translationDomain="webarchiver">
<MenuBar>
<Menu name="tools"><text>&amp;Tools</text>
<Action name="archivepage"/>
</Menu>
</MenuBar>
<ToolBar name="extraToolBar"><text>Extra Toolbar</text>
<Action name="archivepage"/>
</ToolBar>
</gui>