source: subsurface/export-html.cpp

Last change on this file was f6cd21c, checked in by Dirk Hohndel <dirk@…>, 3 months ago

Finish removal of informational_prefs

And make export-html build again.

Signed-off-by: Dirk Hohndel <dirk@…>

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/* Dirk Hohndel, 2015 */
2
3#include <QString>
4#include <QCommandLineParser>
5#include <QApplication>
6#include <QDebug>
7
8#include "core/qt-gui.h"
9#include "core/qthelper.h"
10#include "core/dive.h"
11#include "core/save-html.h"
12#include <stdio.h>
13#include "git2.h"
14#include "core/subsurfacestartup.h"
15#include "core/divelogexportlogic.h"
16#include "core/windowtitleupdate.h"
17#include "core/statistics.h"
18
19int main(int argc, char **argv)
20{
21        QApplication *application = new QApplication(argc, argv);
22        git_libgit2_init();
23        copy_prefs(&default_prefs, &prefs);
24        init_qt_late();
25
26        QCommandLineParser parser;
27        QCommandLineOption sourceDirectoryOption(QStringList() << "s" << "source",
28                                                 "Read git repository from <directory>",
29                                                 "directory");
30        parser.addOption(sourceDirectoryOption);
31        QCommandLineOption outputDirectoryOption(QStringList() << "u" << "output",
32                                                 "Write HTML files into <directory>",
33                                                 "directory");
34        parser.addOption(outputDirectoryOption);
35
36        parser.process(*application);
37
38        QString source = parser.value(sourceDirectoryOption);
39        QString output = parser.value(outputDirectoryOption);
40
41        if (source.isEmpty() || output.isEmpty()) {
42                qDebug() << "need --source and --output";
43                exit(1);
44        }
45        WindowTitleUpdate *wtu = new WindowTitleUpdate();
46        int ret = parse_file(qPrintable(source));
47        if (ret) {
48                fprintf(stderr, "parse_file returned %d\n", ret);
49                exit(1);
50        }
51
52        // this should have set up the informational preferences - let's grab
53        // the units from there
54
55        prefs.unit_system = git_prefs.unit_system;
56        prefs.units = git_prefs.units;
57
58        // populate the statistics
59        struct dive *d = get_dive(0);
60        struct dive *pd;
61        if (d) {
62                process_all_dives(d, &pd);
63        }
64
65        // now set up the export settings to create the HTML export
66        struct htmlExportSetting hes;
67        hes.themeFile = "sand.css";
68        hes.exportPhotos = true;
69        hes.selectedOnly = false;
70        hes.listOnly = false;
71        hes.yearlyStatistics = true;
72        hes.subsurfaceNumbers = true;
73        exportHtmlInitLogic(output, hes);
74        exit(0);
75}
Note: See TracBrowser for help on using the repository browser.