[debug_toolbar/helpers] add a helper to generate a link to source file from filepath/line draft
authorLaurent Peuch <cortex@worlddomination.be>
Tue, 08 Oct 2019 23:17:44 +0200
changeset 13441 955a46b4cc17
parent 13440 5c0e63747174
child 13442 88dc32884083
[debug_toolbar/helpers] add a helper to generate a link to source file from filepath/line
cubicweb/pyramid/debug_source_code.py
--- a/cubicweb/pyramid/debug_source_code.py	Thu Oct 03 22:16:53 2019 +0200
+++ b/cubicweb/pyramid/debug_source_code.py	Tue Oct 08 23:17:44 2019 +0200
@@ -66,6 +66,15 @@
     )
 
 
+def source_code_url_simple(file_path, line):
+    FILES_WHITE_LIST.add(file_path)
+
+    line_anchor = max(0, line - 10)
+
+    return '<a href="../%s?file=%s&line=%s#line-%s" target="_blank">&lt;&gt;</a>' % (
+        DEBUG_DISPLAY_SOURCE_CODE_PATH, file_path, line, line_anchor
+    )
+
 def source_code_url_in_stack(stack):
     new_stack = []