diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-06-16 06:58:22 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-06-16 14:09:21 -0700 |
commit | 226e9a7e85ef1cf148daa61a54039ebfa060f4cb (patch) | |
tree | ffbba2fae0944c919d18581d133d6e58591222b5 /export-html.cpp | |
parent | 0692e2403600090cf92efed375136c3d256f71ac (diff) | |
download | subsurface-226e9a7e85ef1cf148daa61a54039ebfa060f4cb.tar.gz |
Implement a standalone HTML exporter
This is mostly a proof of concept right now; it shows that it is possible
to create a headless server application that exports a git repository
based data file as html.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'export-html.cpp')
-rw-r--r-- | export-html.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/export-html.cpp b/export-html.cpp new file mode 100644 index 000000000..041c52807 --- /dev/null +++ b/export-html.cpp @@ -0,0 +1,55 @@ +/* Dirk Hohndel, 2015 */ + +#include <QString> +#include <QCommandLineParser> +#include <QDebug> + +#include "qt-gui.h" +#include "dive.h" +#include "save-html.h" +#include "stdio.h" +#include "git2.h" +#include "subsurfacestartup.h" +#include "divelogexportlogic.h" + +QTranslator *qtTranslator, *ssrfTranslator; + +int main(int argc, char **argv) +{ + QApplication *application = init_qt(&argc, &argv); + git_libgit2_init(); + setup_system_prefs(); + prefs = default_prefs; + init_qt_late(); + + QCommandLineParser parser; + QCommandLineOption sourceDirectoryOption(QStringList() << "s" << "source", + "Read git repository from <directory>", + "directory"); + parser.addOption(sourceDirectoryOption); + QCommandLineOption outputDirectoryOption(QStringList() << "u" << "output", + "Write HTML files into <directory>", + "directory"); + parser.addOption(outputDirectoryOption); + + parser.process(*application); + + QString source = parser.value(sourceDirectoryOption); + QString output = parser.value(outputDirectoryOption); + + if (source.isEmpty() || output.isEmpty()) { + qDebug() << "need --source and --output"; + exit(1); + } + qDebug() << source << output; + fprintf(stderr, "parse_file returned %d\n", parse_file(qPrintable(source))); + + struct htmlExportSetting hes; + hes.themeFile = "sand.css"; + hes.exportPhotos = true; + hes.selectedOnly = false; + hes.listOnly = false; + hes.yearlyStatistics = true; + exportHtmlInitLogic(output, &hes); + exit(0); +} |