mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									0692e24036
								
							
						
					
					
						commit
						226e9a7e85
					
				
					 2 changed files with 59 additions and 0 deletions
				
			
		| 
						 | 
					@ -444,6 +444,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
 | 
				
			||||||
	add_dependencies(${SUBSURFACE_TARGET} generate_qtconf)
 | 
						add_dependencies(${SUBSURFACE_TARGET} generate_qtconf)
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# build an automated html exporter
 | 
				
			||||||
 | 
					add_executable(export-html EXCLUDE_FROM_ALL export-html.cpp qt-init.cpp qthelper.cpp ${SUBSURFACE_RESOURCES})
 | 
				
			||||||
 | 
					target_link_libraries(export-html subsurface_corelib ${SUBSURFACE_LINK_LIBRARIES})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# QTest based tests
 | 
					# QTest based tests
 | 
				
			||||||
macro(TEST NAME FILE)
 | 
					macro(TEST NAME FILE)
 | 
				
			||||||
	add_executable(${NAME} EXCLUDE_FROM_ALL tests/${FILE} ${SUBSURFACE_RESOURCES})
 | 
						add_executable(${NAME} EXCLUDE_FROM_ALL tests/${FILE} ${SUBSURFACE_RESOURCES})
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										55
									
								
								export-html.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								export-html.cpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -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);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue