summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Haag <jonas@lophus.org>2017-01-26 21:24:35 +0100
committerJonas Haag <jonas@lophus.org>2017-01-27 01:36:10 +0100
commitfd0ee00949c9aad3140d5d850864ae43fb9ea40a (patch)
tree9ff34d32d7959110e4e4fc430609d5433dee6d0b
parent8ce586f773fbf253ed2496b4a7f9723b95f60ae1 (diff)
Some minor fixes
-rw-r--r--klaus/__init__.py1
-rw-r--r--klaus/highlighting.py2
-rw-r--r--klaus/templates/index.html1
-rw-r--r--klaus/utils.py4
-rw-r--r--klaus/views.py9
5 files changed, 10 insertions, 7 deletions
diff --git a/klaus/__init__.py b/klaus/__init__.py
index 91db708..ecd8795 100644
--- a/klaus/__init__.py
+++ b/klaus/__init__.py
@@ -60,7 +60,6 @@ class Klaus(flask.Flask):
('patch', '/<repo>/commit/<rev>.diff'),
('patch', '/<repo>/commit/<rev>.patch'),
('index', '/<repo>/'),
- ('history', '/<repo>/history'),
('history', '/<repo>/tree/<rev>/'),
('history', '/<repo>/tree/<rev>/<path:path>'),
('download', '/<repo>/tarball/<rev>/'),
diff --git a/klaus/highlighting.py b/klaus/highlighting.py
index c427c11..471dabd 100644
--- a/klaus/highlighting.py
+++ b/klaus/highlighting.py
@@ -74,7 +74,7 @@ class KlausPythonFormatter(KlausDefaultFormatter):
)
-def pygmentize(code, filename, render_markup, ctags=None, ctags_baseurl=None):
+def highlight_or_render(code, filename, render_markup=True, ctags=None, ctags_baseurl=None):
"""Render code using Pygments, markup (markdown, rst, ...) using the
corresponding renderer, if available.
diff --git a/klaus/templates/index.html b/klaus/templates/index.html
index 6d71ee7..0f26caa 100644
--- a/klaus/templates/index.html
+++ b/klaus/templates/index.html
@@ -17,6 +17,7 @@
{{ rendered_code }}
{% endif %}
{% endautoescape %}
+<hr>
{% endif %}
{% include 'history.inc.html' %}
diff --git a/klaus/utils.py b/klaus/utils.py
index 783ea8b..d6b96ba 100644
--- a/klaus/utils.py
+++ b/klaus/utils.py
@@ -238,10 +238,10 @@ def guess_git_revision():
"""
git_dir = os.path.join(os.path.dirname(__file__), '..', '.git')
try:
- return check_output(
+ return force_unicode(check_output(
['git', 'log', '--format=%h', '-n', '1'],
cwd=git_dir
- ).strip()
+ ).strip())
except OSError:
# Either the git executable couldn't be found in the OS's PATH
# or no ".git" directory exists, i.e. this is no "bleeding-edge" installation.
diff --git a/klaus/views.py b/klaus/views.py
index 80831d2..cff75ca 100644
--- a/klaus/views.py
+++ b/klaus/views.py
@@ -19,7 +19,7 @@ else:
CTAGS_CACHE = ctagscache.CTagsCache()
from klaus import markup
-from klaus.highlighting import pygmentize
+from klaus.highlighting import highlight_or_render
from klaus.utils import parent_directory, subpaths, force_unicode, guess_is_binary, \
guess_is_image, replace_dupes
@@ -232,7 +232,10 @@ class IndexView(TreeViewMixin, BaseRepoView):
else:
self.context.update({
'is_markup': markup.can_render(readme_filename),
- 'rendered_code': markup.render(readme_filename, readme_data),
+ 'rendered_code': highlight_or_render(
+ force_unicode(readme_data),
+ force_unicode(readme_filename),
+ ),
})
@@ -269,7 +272,7 @@ class BaseFileView(TreeViewMixin, BaseBlobView):
else:
ctags_args = {}
- return pygmentize(
+ return highlight_or_render(
force_unicode(self.context['blob_or_tree'].data),
self.context['filename'],
render_markup,