GitLab's annual major release is around the corner. Along with a lot of new and exciting features, there will be a few breaking changes. Learn more here.

Commit 9bd87b7f authored by Matt Marshall's avatar Matt Marshall
Browse files

Updates from upstream

parent 4119799e
......@@ -11,7 +11,7 @@ import frontmatter
import glob
import argparse
WEBSITE_PATH = "./out/website/"
WEBSITE_PATH = "./out/website"
OUT_PATH = "./out"
SRC_PATH = "./src"
......@@ -89,30 +89,6 @@ def buildChapter(chapterNumber, format):
# Run the buildFile command, pass down the chapterNumber to offset properly
buildFile(filename, format, chapterNumber)
# print("Building Chapter {} in {}".format(chapterNumber, format))
# outputPath = "{}/{}/".format(OUT_PATH, format)
#
# # Make the directory for the output if not exists
# subprocess.run(["mkdir", "-p", outputPath])
#
# # Define filename
# filename = "chapter-{}.{}".format(chapterNumber, format)
#
# # define pandoc args
# args = ["pandoc", "src/index.md", "src/chapter-{}.md".format(chapterNumber), "src/bibliography.md" , "--output={}{}".format(outputPath,filename), "-s", "--toc", "--filter=pandoc-citeproc", "--self-contained", "--number-sections"]
#
# # Append the args for offsetting the section number (chapter number minus 1)
# args.append("--number-offset={}".format(int(chapterNumber) - 1))
#
# # Append the pdf args
# if format == "pdf":
# args.append("-t")
# args.append("html5")
#
# # Run the pandoc command
# subprocess.run(args)
#
# print("\tBuilt %s" % outputPath+filename)
# Iterates and builds all individual chapters as separate files.
def buildChapters(format):
......@@ -138,6 +114,8 @@ def buildCoversheet(outputPath):
thesis_title = config['title']
thesis_author = config['author']
thesis_source = config['thesis-source']
build_formats = config['website-build-formats']
download_button_format = config['download-button-format']
# Get the last updated
date = datetime.now()
......@@ -148,7 +126,8 @@ def buildCoversheet(outputPath):
# To find the title the best way forward is to nab the title from the HTML file as that's easier to parse than Markdown
html_file = open('./out/html/thesis.html') # Open the thesis filel it's cheaper to parse the file once and nab the title in the loop
# Open the thesis file, it's cheaper to parse the file once and nab the title in the loop
html_file = open('./out/html/thesis.html')
html_content = html_file.read()
html_file.close()
......@@ -166,7 +145,7 @@ def buildCoversheet(outputPath):
# Write the file
output = open(outputPath + "index.html", "w")
output.write(template.render(thesis_title=thesis_title, thesis_author=thesis_author,last_updated=last_updated, thesis_source=thesis_source, items=items))
output.write(template.render(thesis_title=thesis_title, thesis_author=thesis_author,last_updated=last_updated, thesis_source=thesis_source, items=items, build_formats=build_formats, download_button_format=download_button_format))
output.close()
print("\tCoversheet built under ./out/website/index.html")
......@@ -176,25 +155,30 @@ def buildWebsite():
# Check for and create the folder
subprocess.run(["mkdir", "-p", WEBSITE_PATH])
# Build the various copies of the thesis
buildThesis("html")
buildThesis("odt")
buildThesis("docx")
# Load the config file
config = frontmatter.load('./src/index.md')
# Copy the styles file
copy("./src/styles.css", WEBSITE_PATH)
# Build chapters separately. It's nice to break things up for people.
# First build in HTML for the web, then loop over the format list and build for that
buildThesis("html")
buildChapters("html")
buildChapters("odt")
buildChapters("docx")
buildFile("frontmatter", "html")
dir_util.copy_tree("{}/{}/".format(OUT_PATH, "html"), "{}/{}/".format(WEBSITE_PATH, "html") )
# Copy files (note: is there a better way to do this?)
copy("./src/styles.css", WEBSITE_PATH)
for format in config['website-build-formats']:
# Build the thesis + the individual chapters separately
buildThesis(format)
buildChapters(format)
buildFile("frontmatter", format)
# Move the new files over to the website directory
dir_util.copy_tree("{}/{}/".format(OUT_PATH, format), "{}/{}/".format(WEBSITE_PATH, format) )
dir_util.copy_tree("{}/html/".format(OUT_PATH), WEBSITE_PATH+"html/")
dir_util.copy_tree("{}/odt/".format(OUT_PATH), WEBSITE_PATH+"odt/")
dir_util.copy_tree("{}/docx/".format(OUT_PATH), WEBSITE_PATH+"docx/")
# Generate cover sheet
buildCoversheet(WEBSITE_PATH)
buildCoversheet("{}/".format(WEBSITE_PATH))
# Returns a count of all chapters, used in loops to manipulate chapters dynamically
def getChapterCount():
......
......@@ -12,4 +12,9 @@ link-citations: true
csl: src/harvard-newcastle-university.csl
thesis-source: https://gitlab.com/mrshll1001/thesis
download-button-format: odt
website-build-formats:
- odt
- docx
- epub
---
......@@ -26,7 +26,7 @@
<div class="pure-u-1 pure-u-sm-1">
<div class="download-links margins-top">
<p class="centre">
<a class="pure-button pure-button-primary" href="./html/thesis.html"><i class="fab fa-html5"></i> Read Online</a> <a class="pure-button pure-button-primary" href="./docx/thesis.docx"><i class="fas fa-file-word"></i> Download</a>
<a class="pure-button pure-button-primary" href="./html/thesis.html"><i class="fab fa-html5"></i> Read Online</a> <a class="pure-button pure-button-primary" href="./{{download_button_format}}/thesis.{{download_button_format}}"><i class="fas fa-download"></i> Download</a>
</p>
<p class="centre">
<a href="{{ thesis_source }}" class="pure-button"><i class="fab fa-gitlab"></i> Source</a>
......@@ -44,43 +44,45 @@
</div>
</div>
<div class="pure-g">
<div class="pure-u-1 pure-u-sm-1">
<h2>Quick Note on chapter headings</h2>
<p>I use a hashtag system to try and indicate to myself and others the status of a particular chapter. For example &num;inprogress means I'm working on it at the moment so it'll be a nasty mixture of prose and bullet-pointed notes. The tags will usually be intuitively named, but just in case here are the usual suspects:</p>
<ul>
<li>&num;notes means that the chapter is basically just a brain dump of initial thoughts and shouldn't be read too carefully, or at least critiqued at a conceptual level</li>
<li>&num;inprogress means I'm working on it at the moment. It'll be somewhere between &num;notes and &num;draft</li>
<li>&num;draft means I've drafted the vast majority of the chapter and I'm expecting more in-depth feedback to result in some changes, but the flow and the content is pretty much there.</li>
</ul>
</div>
</div>
<div class="pure-g">
<div class="pure-u-1 pure-u-sm-1">
<div id="table">
<div id="chapter-table">
<table class="pure-table">
<thead>
<tr>
<th>Web</th>
<th>OpenDocument</th>
<th>Word</th>
{% for format in build_formats %}
<th>{{format}}</th>
{% endfor %}
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="./html/thesis.html">Thesis</a>
</td>
{% for format in build_formats %}
<td>
<a href="./odt/thesis.odt">thesis.odt</a>
<a href="./{{format}}/thesis.{{format}}">thesis.{{format}}</a>
</td>
{% endfor %}
</tr>
<tr>
<td>
<a href="./docx/thesis.docx">thesis.docx</a>
<a href="./html/frontmatter.html">Frontmatter</a>
</td>
{% for format in build_formats %}
<td>
<a href="./{{format}}/frontmatter.{{format}}">frontmatter.{{format}}</a>
</td>
{% endfor %}
</tr>
{% for item in items %}
......@@ -89,13 +91,11 @@
<a href="./html/{{item.file}}.html">{{item.title}}</a>
</td>
{% for format in build_formats %}
<td>
<a href="./odt/{{item.file}}.odt">{{item.file}}.odt</a>
</td>
<td>
<a href="./docx/{{item.file}}.docx">{{item.file}}.docx</a>
<a href="./{{format}}/{{item.file}}.{{format}}">{{item.file}}.{{format}}</a>
</td>
{% endfor %}
</tr>
{% endfor %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment