diff --git a/src/data/document.py b/src/data/document.py index d066958..ceba343 100644 --- a/src/data/document.py +++ b/src/data/document.py @@ -62,18 +62,13 @@ class Document: cmd.append(['git', 'pull']) # build the HTML version - cmd.append(['sphinx-build', '-M', 'html', self.doc_path + "/repo/source", self.doc_path + "/build"]) + cmd.append(['make', 'html', 'BUILDDIR=../build']) # build the PDF version - cmd.append(['sphinx-build', '-M', 'weasyprint', self.doc_path + '/repo/source', self.doc_path + '/build']) - cmd.append(['weasyprint', self.doc_path + '/build/weasyprint/index.html', self.doc_path + '/build/weasyprint/index.pdf', '-s', self.doc_path + '/repo/source/css/print-theme.css']) - cmd.append(['sh', '-c', current_app.config['DATA_ROOT_DIR'] + '/../pdftoc-to-latex "' + self.doc_path + '/build/weasyprint/index.pdf" > "' + self.doc_path + '/build/weasyprint/toc.tex"']) - cmd.append(['sh', '-c', 'pdflatex -interaction nonstopmode -output-directory="' + self.doc_path + '/build/weasyprint" "' + self.doc_path + '/build/weasyprint/toc.tex" || echo OK']) - cmd.append(['pdftk', 'A=' + self.doc_path + '/build/weasyprint/index.pdf', 'B=' + self.doc_path + '/build/weasyprint/toc.pdf', 'cat', 'A1', 'B', 'A2-end', 'output', self.doc_path + '/build/weasyprint/vheliotech.pdf']) - #cmd.append(['rm', self.doc_path + '/build/weasyprint/index.pdf', self.doc_path + '/build/weasyprint/toc.tex', self.doc_path + '/build/weasyprint/toc.pdf', self.doc_path + '/build/weasyprint/GuidedemontageVheliotech.pdf']) + cmd.append(['make', 'pdf', 'BUILDDIR=../build']) # Copy the generated PDF file to the HTML directory, so that it is accessible for download by users - cmd.append(['cp', self.doc_path + '/build/weasyprint/vheliotech.pdf', self.doc_path + '/build/html/guide-de-montage-vheliotech.pdf']) + cmd.append(['cp', self.doc_path + '/build/weasyprint/vheliotech.pdf', self.doc_path + '/build/html/' + self.doc_name + '.pdf']) task = ProcessTask(cmd, cwd = self.doc_path + "/repo") task.start() @@ -98,6 +93,9 @@ class Document: def get_url(self): return "/doc/" + self.encoded_origin + "/" + sanitize_name(self.doc_name)+'/'+sanitize_name(self.branch) + "/index.html" + def get_pdf_url(self): + return "/doc/" + self.encoded_origin + "/" + sanitize_name(self.doc_name)+'/'+sanitize_name(self.branch) + "/" + self.doc_name + ".pdf" + def get_api_key(self): with open(self.doc_path + "/apikey") as f: return f.read().replace('\n', '') @@ -151,8 +149,8 @@ class Document: cmd = [] cmd.append(['git', 'init', '--initial-branch=' + branch]) cmd.append(['git', 'remote', 'add', '-f', 'origin', repo]) - cmd.append(['git', 'sparse-checkout', 'init']) - cmd.append(['git', 'sparse-checkout', 'set', source_dir]) + #cmd.append(['git', 'sparse-checkout', 'init']) + #cmd.append(['git', 'sparse-checkout', 'set', source_dir]) cmd.append(['git', 'pull', 'origin', branch]) cmd.append(['git', 'branch', '--set-upstream-to=origin/' + branch, branch]) diff --git a/src/templates/admin/document/manage.html b/src/templates/admin/document/manage.html index de367ae..6906f5f 100644 --- a/src/templates/admin/document/manage.html +++ b/src/templates/admin/document/manage.html @@ -5,7 +5,8 @@ {% block content %}
URL permettant de déclencher la compilation : {{ url_for('api_document.build', origin = doc.encoded_origin, doc_name = doc.doc_name, branch = doc.branch, apikey = doc.get_api_key(), _external = True) }}
- Consulter