=== modified file 'lava_scheduler_app/static/lava_scheduler_app/css/logfile.css'
@@ -24,3 +24,13 @@
border-width: medium;
}
+.line
+{
+ line-height: 18px;
+ white-space: nowrap;
+}
+
+div:target
+{
+ background-color: rgb(255, 128, 128);
+}
=== modified file 'lava_scheduler_app/templates/lava_scheduler_app/job_log_file.html'
@@ -6,6 +6,7 @@
{% endblock %}
{% block content %}
+{% load linenumbers %}
<h2>Dispatcher log file - {{ job.id }} </h1>
<a href="{% url lava.scheduler.job.log_file.plain job.pk %}">Download as text file</a>
@@ -15,7 +16,7 @@
{% if section.0 == 'console' and section.1 > 20 and not forloop.last %}
<a href="#entry{{ forloop.counter }}">skip {{ section.1 }} lines to next log entry →</a>
{% endif %}
-<pre class="log_{{ section.0 }}">{{ section.2 }}</pre>
+{% linenumbers section.2 forloop.counter0 section.0 %}
{% endfor %}
{% if job.status == job.RUNNING %}
<img id="progress" src="{{ STATIC_URL }}lava_scheduler_app/images/ajax-progress.gif"/>
=== added directory 'lava_scheduler_app/templatetags'
=== added file 'lava_scheduler_app/templatetags/__init__.py'
=== added file 'lava_scheduler_app/templatetags/linenumbers.py'
@@ -0,0 +1,45 @@
+from django import template
+from django.db.models import fields
+from django.utils.html import escape
+from django.utils.safestring import mark_safe
+
+register = template.Library()
+
+class LineNumbers(template.Node):
+ def __init__(self, text, prefix, style):
+ self.text = template.Variable(text)
+ self.prefix = template.Variable(prefix)
+ self.style = template.Variable(style)
+
+ def render(self, context):
+ text = self.text.resolve(context)
+ prefix = self.prefix.resolve(context)
+ style = self.style.resolve(context)
+ ret = "<table><tr><td>"
+ for i in range(0, len(text.splitlines())):
+ name = "L_%s_%s" % (prefix, i)
+ display = "Section %s.%s" % (prefix, i)
+ ret += "<div class=\"line\"><a name=\"%s\"></a> \
+ <a href=\"#%s\">%s</a></div>" % (name, name, display)
+
+ ret += "</td><td class=\"code\"><div class=\"containter\"> \
+ <pre class=\"log_%s\">" % (style)
+
+ for index, line in enumerate(text.splitlines()):
+ ret += "<div id=\"L_%s_%s\" class=\"line\"> %s</div>" % \
+ (prefix,
+ index,
+ mark_safe(escape(line).encode('ascii', 'xmlcharrefreplace')))
+
+ ret += "</pre></div></td><tr></table>"
+
+ return ret
+
+@register.tag('linenumbers')
+def do_linenumbers(parser, token):
+ try:
+ tag_name, text, prefix, style = token.split_contents()
+ except ValueError:
+ raise template.TemplateSyntaxError("%r tag requires 3 arguments" % \
+ token.contents.split()[0])
+ return LineNumbers(text, prefix, style)