mirror of
https://github.com/searxng/searxng.git
synced 2025-12-22 19:50:00 +00:00
This patch adds GitHub Code Search [1] engine to allow querying the codebases. Template code.html is changed to allow passthrough of strip and highlighting options. Engine Searchcode is adjusted to pass filename and not rely on hardcoded extensions. GitHub search code API does not return the exact code line indices, this implementation assigns the code arbitrary numbers starting from 1 (effectively relabeling the code). The API allows for unauth calls, and the default engine settings default to that, although the calls are heavily rate limited. The 'text' lexer is the default pygments lexer when parsing fails. [1] https://docs.github.com/en/rest/search/search?apiVersion=2022-11-28#search-code Co-authored-by: Markus Heiser <markus.heiser@darmarIT.de>
33 lines
960 B
HTML
33 lines
960 B
HTML
{% from 'simple/macros.html' import result_header, result_sub_header, result_sub_footer, result_footer with context %}
|
|
|
|
{{ result_header(result, favicons, image_proxify) -}}
|
|
{{- result_sub_header(result) -}}
|
|
|
|
{%- if result.content -%}
|
|
<p class="content">
|
|
{{- result.content|safe -}}
|
|
</p>
|
|
{%- endif -%}
|
|
{%- if result.repository -%}
|
|
<p class="content">{{- '' -}}
|
|
{{ _('repo') }}: {{- ' ' -}}
|
|
<a href="{{ result.repository|safe }}"{{- ' ' -}}
|
|
{% if results_on_new_tab %}
|
|
target="_blank" {{- ' ' -}}
|
|
rel="noopener noreferrer"
|
|
{%- else -%}
|
|
rel="noreferrer"
|
|
{%- endif -%}
|
|
>
|
|
{{- result.repository -}}
|
|
</a>{{- '' -}}
|
|
</p>
|
|
{%- endif -%}
|
|
|
|
<div dir="ltr" class="codelines">
|
|
{{- result.codelines|code_highlighter(result.code_language, result.hl_lines, result.strip_whitespace, result.strip_new_lines)|safe -}}
|
|
</div>
|
|
|
|
{{- result_sub_footer(result) -}}
|
|
{{- result_footer(result) -}}
|