From 0d1762f16b68d2e263b5343fb013117e086b3bef Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 18 Feb 2020 09:35:28 -0500 Subject: [PATCH] blob view: add rendered markdown view --- gitsrht/blueprints/repo.py | 5 ++++- gitsrht/templates/blob.html | 28 ++++++++++++++++++++++++++++ scss/main.scss | 11 +++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/gitsrht/blueprints/repo.py b/gitsrht/blueprints/repo.py index 22bf4c4..73c2488 100644 --- a/gitsrht/blueprints/repo.py +++ b/gitsrht/blueprints/repo.py @@ -218,11 +218,14 @@ def tree(owner, repo, ref, path): data = blob.data.decode() except: data = '[unable to decode]' + markdown = not blob.is_binary and entry.name.endswith(".md") + force_source = "view-source" in request.args return render_template("blob.html", view="blob", owner=owner, repo=repo, ref=ref, path=path, entry=entry, blob=blob, data=data, commit=commit, highlight_file=_highlight_file, - editorconfig=editorconfig) + editorconfig=editorconfig, + markdown=markdown, force_source=force_source) tree = git_repo.get(entry.id) if not tree: diff --git a/gitsrht/templates/blob.html b/gitsrht/templates/blob.html index 4b0d7e1..c307dd6 100644 --- a/gitsrht/templates/blob.html +++ b/gitsrht/templates/blob.html @@ -59,12 +59,39 @@ pre, body { {% endif %} +{% if markdown %} +
+ +
+{% endif %} +{% if markdown and not force_source %} +
+{% else %}
+{% endif %} {# This row has some weird styles going on. This prevents the page from scrolling horizontally #}
+ {% if markdown and not force_source %} +
+ {{ data | extended_md }} +
+ {% else %} {% if not blob.is_binary %}
{% for i in range(
@@ -97,6 +124,7 @@ pre, body {
       
{% endif %} + {% endif %}
{% endblock %} diff --git a/scss/main.scss b/scss/main.scss index 503d704..cb76329 100644 --- a/scss/main.scss +++ b/scss/main.scss @@ -303,3 +303,14 @@ img { } } } + +.markdown-nav { + padding-left: 0; + padding-right: 0; + + .nav-tabs { + padding-left: 0; + margin-bottom: 0; + border-left: 1rem #ddd solid; + } +} -- 2.38.4