Skip to content

Commit

Permalink
Add back to top button (#101)
Browse files Browse the repository at this point in the history
* Add back to top button

* Minor changes

* Add gitignore

* Hide button in printed documents

* Add missing local changes

* Align th text to the left again
  • Loading branch information
mathiascode authored and bearbin committed Sep 5, 2019
1 parent 4822fa8 commit 9821968
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
9 changes: 8 additions & 1 deletion generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
def main():
# First off, load all of the data from disk into memory.
template = load_template()
css = load_css()
sections = load_sections()
# Run through the sections and linkify.
for s in sections:
Expand All @@ -37,7 +38,8 @@ def main():
head_title = title
# Write the actual content.
with open(os.path.join(output_directory, "index.html"), "w") as f:
f.write(template.safe_substitute(content=content,
f.write(template.safe_substitute(css=css,
content=content,
timestamp=timestamp,
title=title,
head_title=head_title,
Expand All @@ -50,6 +52,11 @@ def load_template():
# Read all of the data from the file and return it.
return string.Template(template_file.read())

def load_css():
with open(os.path.join(input_directory, "style.css"), "r") as css_file:
# Read all of the data from the file and return it.
return css_file.read()

def load_sections():
# First, define an empty dictionary to contain the section data.
# This dictionary will consist of keys of section names, with values of
Expand Down
24 changes: 22 additions & 2 deletions static/css/style.css → style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
<title>${head_title}</title>
<meta name="description" content="This is the Cuberite User's Manual. It is intended as a guide on how to operate the basics of Cuberite, as well as an introduction to some advanced features.">
<link rel="canonical" href="https://book.cuberite.org/">
<link rel="stylesheet" href="css/style.css">
<style>
${css}
</style>
</head>
<body>
<a class="return-link" href="https://cuberite.org/">&lt;- Return to Cuberite.org</a>
<a name="top" class="return-link" href="https://cuberite.org/">&lt;- Return to Cuberite.org</a>
<h1>${title}</h1>
<p>Updated on ${timestamp}, Commit: <a href="https://github.com/cuberite/users-manual/commit/${commit_id}">${commit_id}</a></p>
${content}
<a class="top-button" href="#top">^</a>
<noscript>
<img class="hidden" src="https://analytics.cuberite.org/piwik.php?idsite=2&amp;rec=1" alt=""/>
</noscript>
Expand Down

0 comments on commit 9821968

Please sign in to comment.