This repository has been archived by the owner on Oct 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 205
/
search.html
152 lines (142 loc) · 5.18 KB
/
search.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
{% extends "layout.html" %}
{% block title %}{{ query }} - DXR Search{% endblock %}
{% block tip -%}
{%- if error -%}
<b>{{ error }}</b>
{%- else -%}
Query executed in {{"%.3f"|format(time)}}s
{%- endif -%}
{%- endblock %}
{% set state_offset = offset + results|length %}
{% set state_limit = limit %}
{% set state_eof = results|length < limit %}
{% block head %}
<script src="{{ wwwroot }}/static/panel.js"></script>
<script src="{{ wwwroot }}/static/advanced-search.js"></script>
{% if error %}
<script>
window.addEventListener('load', function(){
// Write a the error message to search tip
dxr.setErrorTip("{{ error }}");
});
</script>
{% endif %}
{% endblock %}
{# Enable panel #}
{% set panel = True %}
{% block panel_title %}Advanced Search{% endblock %}
{% block panel %}
<form id="advanced-search">
<div class="section">
<label for="substring-search">Text search</label>
<input type="text" name="substring-search"
placeholder='Substring, "phrases"'
style="background-image: url('{{ wwwroot }}/static/icons/search.png');">
<br>
<label for="regexp-search">regexp:</label>
<input type="text" name="regexp-search"
data-param="regexp" placeholder='/(f|s)?printf/'
style="background-image: url('{{ wwwroot }}/static/icons/regexp-search.png');">
<br>
</div>
<div class="section">
<h1>Case Insensitive Substring Matching</h1>
<label for="path">path:</label>
<input type="text" name="path"
data-param="path" placeholder="Path substring"
style="background-image: url('{{ wwwroot }}/static/icons/path_search.png');">
<br>
<label for="type">type:</label>
<input type="text" name="type"
data-param="type" placeholder="Type name"
style="background-image: url('{{ wwwroot }}/static/icons/type.png');">
<br>
<label for="type-ref">type-ref:</label>
<input type="text" name="type-ref"
data-param="type-ref" placeholder="Type name"
style="background-image: url('{{ wwwroot }}/static/icons/reference.png');">
<br>
<label for="function">function:</label>
<input type="text" name="function"
data-param="function" placeholder="Function name"
style="background-image: url('{{ wwwroot }}/static/icons/method.png');">
<br>
<label for="function-ref">function-ref:</label>
<input type="text" name="function-ref"
data-param="function-ref" placeholder="Function reference"
style="background-image: url('{{ wwwroot }}/static/icons/reference.png');">
<br>
<label for="macro">macro:</label>
<input type="text" name="macro"
data-param="macro" placeholder="Macro name"
style="background-image: url('{{ wwwroot }}/static/icons/macro.png');">
<br>
<label for="warning">warning:</label>
<input type="text" name="warning"
data-param="warning" placeholder=""unused variable""
style="background-image: url('{{ wwwroot }}/static/icons/search_warning.png');">
</div>
<div class="section">
<h1>Case Insensitive Suffix Matching</h1>
<label for="ext">ext:</label>
<input type="text" name="ext" data-param="ext" placeholder=".cpp"
style="background-image: url('{{ wwwroot }}/static/icons/path_search.png');">
</div>
<input type="submit" value="Search">
</form>
{% endblock %}
{# When updating results remember to update it in search.js too! #}
{% block content %}
{% for icon, path, lines in results %}
<div class="result">
<div class="path" style="background-image: url({{ wwwroot }}/static/icons/{{ icon }}.png);">
{%- set folders = path.split('/') -%}
{%- for folder in folders -%}
<a href="{{ wwwroot }}/{{ tree }}/source/{{ "/".join(folders[0:loop.index]) }}"
{% if not loop.last %}
data-path="{{ "/".join(folders[0:loop.index]) }}/"
{% endif %}
>{{ folder }}
{%- if not loop.last -%} / {%- endif -%}
</a>
{%- endfor -%}
</div>
{% for number, line in lines %}
<a class="snippet" href="{{ wwwroot }}/{{ tree }}/source/{{ path }}#l{{ number }}">
<div class="line-numbers">
<pre><span class="ln">{{ number }}</span></pre>
</div>
<div class="file-lines"><pre><code>{{ line|safe }}</code></pre></div>
</a>
{%- endfor %}
</div>
{% else %}
<div id="no-results">
<img src="{{ wwwroot }}/static/garbage.svg"
style="padding-top: 50px; width: 400px;">
<div style="font-family: sans-serif; font-size: 4em;">
Sorry, no results!
</div>
</div>
{% endfor %}
{% endblock %}
{% block foot %}
{# We don't show next link if there's no more results,
# and show prev link if offset != 0. Note that these links will
# only be available to non-javascript users. #}
{% set search_url = wwwroot
+ '/search?tree=' + tree
+ '&q=' + quoted_query + '&redirect=false' %}
{% set prev = offset - results|length %}
{% set next = offset + results|length %}
<div id="result-page-switch">
{% if prev >= 0%}
<a style="float: left;"
href="{{ search_url }}&offset={{ prev }}&limit={{ limit }}">Prev page</a>
{% endif %}
{% if results|length >= limit %}
<a style="float: right;"
href="{{ search_url }}&offset={{ next }}&limit={{ limit }}">Next page</a>
{% endif %}
</div>
{% endblock %}