⚡️ Precompile markdown & remove changelog

We already have Github's releases with all the changes, we don't need to
keep everything twice.

Instead of the changelog included in the about dialog there's now a link
to the release list, that should suffice.

Implements #3342
This commit is contained in:
Gina Häußge committed 2019-11-20 15:35:44 +01:00
1 parent d8c3063813
commit b7e0e89bb4
10 files changed
+49 -1303

No files matched your search

+3 -1282
View File
File diff suppressed because it is too large. Load diff
+25 -13
View File
@@ -17,6 +17,11 @@ import setuptools
# we test against 2.7, 3.6 and 3.7, so that's what we'll mark as supported
PYTHON_REQUIRES = ">=2.7.9, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4"
# Requirements for setup.py
SETUP_REQUIRES = [
"markdown>=3.1,<3.2",
]
# Requirements for our application
INSTALL_REQUIRES = [
# the following dependencies are non trivial to update since later versions introduce backwards incompatible
@@ -80,7 +85,7 @@ INSTALL_REQUIRES_OSX = [
EXTRA_REQUIRES = dict(
# Dependencies for developing OctoPrint
develop=[
# Testing dependencies
# Testing dependencies - SEE ALSO tox.ini
"mock>=3.0.5,<4",
"pytest==4.6.6",
"pytest-doctest-custom>=1.0.0,<1.1",
@@ -133,14 +138,14 @@ def read_file_contents(path):
with codecs.open(path, encoding="utf-8") as f:
return f.read()
def data_copy_build_py_factory(files, baseclass):
class data_copy_build_py(baseclass):
def md_to_html_build_py_factory(files, baseclass):
class md_to_html_build_py(baseclass):
files = dict()
def run(self):
import shutil
print("RUNNING md_to_html_build_py")
if not self.dry_run:
for directory, files in self.__class__.files.items():
for directory, files in self.files.items():
target_dir = os.path.join(self.build_lib, directory)
self.mkpath(target_dir)
@@ -148,16 +153,22 @@ def data_copy_build_py_factory(files, baseclass):
if isinstance(entry, tuple):
if len(entry) != 2:
continue
source, dest = entry
source, dest = entry[0], os.path.join(target_dir, entry[1])
else:
source = dest = entry
shutil.copy(source, os.path.join(target_dir, dest))
source = entry
dest = os.path.join(target_dir, source + ".html")
print("Rendering markdown from {} to {}".format(source, dest))
from markdown import markdownFromFile
markdownFromFile(input=source,
output=dest,
encoding="utf-8")
baseclass.run(self)
return type(data_copy_build_py)(data_copy_build_py.__name__,
(data_copy_build_py,),
dict(files=files))
return type(md_to_html_build_py)(md_to_html_build_py.__name__,
(md_to_html_build_py,),
dict(files=files))
def get_cmdclass():
cmdclass = versioneer.get_cmdclass()
@@ -171,10 +182,9 @@ def get_cmdclass():
bundled_dir = os.path.join("src", "octoprint", "translations")
cmdclass.update(octoprint_setuptools.get_babel_commandclasses(pot_file=pot_file, output_dir=translation_dir, pack_name_prefix="OctoPrint-i18n-", pack_path_prefix="", bundled_dir=bundled_dir))
cmdclass["build_py"] = data_copy_build_py_factory({
cmdclass["build_py"] = md_to_html_build_py_factory({
"octoprint/templates/_data": [
"AUTHORS.md",
"CHANGELOG.md",
"SUPPORTERS.md",
"THIRDPARTYLICENSES.md",
]
@@ -193,6 +203,7 @@ def params():
long_description_content_type = "text/markdown"
python_requires = PYTHON_REQUIRES
setup_requires = SETUP_REQUIRES
install_requires = INSTALL_REQUIRES
extras_require = EXTRA_REQUIRES
dependency_links = DEPENDENCY_LINKS
@@ -217,6 +228,7 @@ def params():
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: JavaScript",
"Topic :: Printing",
+5 -3
View File
@@ -1131,10 +1131,12 @@ class Server(object):
loaders = [app.jinja_loader, filesystem_loader]
if octoprint.util.is_running_from_source():
from markdown import markdown
root = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../.."))
allowed = ["AUTHORS.md", "CHANGELOG.md", "SUPPORTERS.md", "THIRDPARTYLICENSES.md"]
files = {"_data/" + name: os.path.join(root, name) for name in allowed}
loaders.append(octoprint.util.jinja.SelectedFilesLoader(files))
allowed = ["AUTHORS.md", "SUPPORTERS.md", "THIRDPARTYLICENSES.md"]
files = {"_data/" + name + ".html": os.path.join(root, name) for name in allowed}
loaders.append(octoprint.util.jinja.SelectedFilesWithConversionLoader(files, conversion=markdown))
jinja_loader = jinja2.ChoiceLoader(loaders)
app.jinja_loader = jinja_loader
-1
View File
@@ -643,7 +643,6 @@ def fetch_template_data(refresh=False):
license=("OctoPrint License", dict(template="dialogs/about/license.jinja2", _div="about_license", custom_bindings=False)),
thirdparty=("Third Party Licenses", dict(template="dialogs/about/thirdparty.jinja2", _div="about_thirdparty", custom_bindings=False)),
authors=("Authors", dict(template="dialogs/about/authors.jinja2", _div="about_authors", custom_bindings=False)),
changelog=("Changelog", dict(template="dialogs/about/changelog.jinja2", _div="about_changelog", custom_bindings=False)),
supporters=("Supporters", dict(template="dialogs/about/supporters.jinja2", _div="about_sponsors", custom_bindings=False))
)
@@ -10,6 +10,7 @@
<li><i class="fa-li fa fa-question-circle"></i> FAQ: <a href="https://faq.octoprint.org" target="_blank" rel="noreferrer noopener">faq.octoprint.org</a></li>
<li><i class="fa-li fa fa-book"></i> Documentation: <a href="http://docs.octoprint.org" target="_blank" rel="noreferrer noopener">docs.octoprint.org</a></li>
<li><i class="fa-li fa fa-github"></i> Source Code: <a href="https://github.com/foosel/OctoPrint" target="_blank" rel="noreferrer noopener">github.com/foosel/OctoPrint</a></li>
<li><i class="fa-li fa fa-code-fork"></i> Changelog: <a href="https://github.com/foosel/OctoPrint/releases" target="_blank" rel="noreferrer noopener">github.com/foosel/OctoPrint/releases</a></li>
</ul>
<p>
@@ -1 +1 @@
{% filter externalize_links %}{% filter markdown %}{% filter offset_markdown_headers(2) %}{% include "_data/AUTHORS.md" ignore missing %}{% endfilter %}{% endfilter %}{% endfilter %}
{% filter externalize_links %}{% filter offset_html_headers(2) %}{% include "_data/AUTHORS.md.html" ignore missing %}{% endfilter %}{% endfilter %}
@@ -1 +0,0 @@
{% filter externalize_links %}{% filter markdown %}{% filter offset_markdown_headers(2) %}{% include "_data/CHANGELOG.md" ignore missing %}{% endfilter %}{% endfilter %}{% endfilter %}
@@ -1 +1 @@
{% filter externalize_links %}{% filter markdown %}{% filter offset_markdown_headers(2) %}{% include "_data/SUPPORTERS.md" ignore missing %}{% endfilter %}{% endfilter %}{% endfilter %}
{% filter externalize_links %}{% filter offset_html_headers(2) %}{% include "_data/SUPPORTERS.md.html" ignore missing %}{% endfilter %}{% endfilter %}
@@ -1 +1 @@
{% filter externalize_links %}{% filter markdown %}{% filter offset_markdown_headers(2) %}{% include "_data/THIRDPARTYLICENSES.md" ignore missing %}{% endfilter %}{% endfilter %}{% endfilter %}
{% filter externalize_links %}{% filter offset_html_headers(2) %}{% include "_data/THIRDPARTYLICENSES.md.html" ignore missing %}{% endfilter %}{% endfilter %}
+12
View File
@@ -94,6 +94,18 @@ class SelectedFilesLoader(BaseLoader):
return self.files.keys()
class SelectedFilesWithConversionLoader(SelectedFilesLoader):
def __init__(self, files, encoding="utf-8", conversion=None):
SelectedFilesLoader.__init__(self, files, encoding=encoding)
self.conversion = conversion
def get_source(self, environment, template):
contents = SelectedFilesLoader.get_source(self, environment, template)
if callable(self.conversion):
contents = self.conversion(contents[0]), contents[1], contents[2]
return contents
def get_all_template_paths(loader):
def walk_folder(folder):
files = []