summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Server/Reports/reports/templates/config_items/index.html5
-rw-r--r--src/lib/Server/Reports/reports/templatetags/syntax_coloring.py25
2 files changed, 29 insertions, 1 deletions
diff --git a/src/lib/Server/Reports/reports/templates/config_items/index.html b/src/lib/Server/Reports/reports/templates/config_items/index.html
index 952172715..b6e4957a4 100644
--- a/src/lib/Server/Reports/reports/templates/config_items/index.html
+++ b/src/lib/Server/Reports/reports/templates/config_items/index.html
@@ -1,6 +1,9 @@
+{% load syntax_coloring %}
+
{% extends "base.html" %}
{% block extra_header_info %}
+<link rel="stylesheet" type="text/css" href="/site_media/syntax-coloring.css" />
<script type="text/javascript" src="/site_media/CalendarPopup.js"></script>
<script language="JavaScript">var cal = new CalendarPopup();</script>
{% endblock%}
@@ -41,7 +44,7 @@
{% endif %}{% if not item.reason.current_exists %}
<tr><td align="right"><b>Existance: </b></td><td colspan=2>This item does not currently exist on the host but is specified to exist in the configuration.</td></tr>
{% endif %}{% if item.reason.current_diff %}
-<tr><td align="right"><b>Unified Diff: </b></td><td colspan=2><pre>{{item.reason.current_diff}}</pre></td></tr>
+<tr><td align="right"><b>Unified Diff: </b></td><td colspan=2><pre>{{item.reason.current_diff|syntaxhilight:"diff"}}</pre></td></tr>
{% endif %}
</table></center>
<hr/>
diff --git a/src/lib/Server/Reports/reports/templatetags/syntax_coloring.py b/src/lib/Server/Reports/reports/templatetags/syntax_coloring.py
new file mode 100644
index 000000000..14827b3c6
--- /dev/null
+++ b/src/lib/Server/Reports/reports/templatetags/syntax_coloring.py
@@ -0,0 +1,25 @@
+from django import template
+
+try:
+ from pygments import highlight
+ from pygments.lexers import get_lexer_by_name
+ from pygments.formatters import HtmlFormatter
+ colorize = True
+except:
+ colorize = False
+
+register = template.Library()
+
+def syntaxhilight(value, arg="diff"):
+ '''Returns a syntax-hilighted version of Code; requires code and language arguments'''
+ lexer = get_lexer_by_name(arg)
+ if colorize:
+ try:
+ return highlight(value, lexer, HtmlFormatter())
+ except:
+ return value
+ else:
+ return value
+
+
+register.filter('syntaxhilight', syntaxhilight)