Skip to content

Commit 404cd67

Browse files
committed
vimhelp: Better offline generation capabilities
help.txt now always gets remapped to index.html. It does mean you can't navigate to a "help.txt.html" page anymore, but it makes most static sites happier as you don't have to add manual server logic to remap the root folder listing to a manual `help.txt.html` as most web servers can handle index.html automatically. Also, remove refereces to TomSelect even for online mode, as we want to generate an "online" mode version even for static sitate gneeration just to take advantage of the other features like a better header and light/dark mode switching. Should ideally use another config variable to control this instead of just blanket commenting out.
1 parent 1c8cd07 commit 404cd67

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

vimhelp/scripts/h2h.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,12 @@ def run(args):
123123
content = infile.read_text()
124124
print(f"Processing {infile}...")
125125
html = h2h.to_html(infile.name, content)
126+
if infile.name != "help.txt":
127+
out_filename = f"{infile.name}.html"
128+
else:
129+
out_filename = "index.html"
126130
if args.out_dir is not None:
127-
with (args.out_dir / f"{infile.name}.html").open("w") as f:
131+
with (args.out_dir / out_filename).open("w") as f:
128132
f.write(prelude)
129133
f.write(html)
130134

vimhelp/static/vimhelp-v5.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
// "Go to keyword" entry
44

5+
/*
56
new TomSelect("#vh-select-tag", {
67
maxItems: 1,
78
loadThrottle: 250,
@@ -24,6 +25,7 @@ new TomSelect("#vh-select-tag", {
2425
}
2526
}
2627
});
28+
*/
2729

2830
// Theme switcher
2931

vimhelp/templates/page.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
<!-- {{project.favicon_notice}} -->
99

1010
{% if mode != "offline" %}
11+
{% if project.name != 'MacVim' %}
12+
{# MacVim does not host this on a server and cannot do dynamic queries #}
1113
<link rel="stylesheet" href="{{static_dir}}tom-select-2.2.2.min.css">
1214
<script defer src="{{static_dir}}tom-select-2.2.2.base.min.js"></script>
1315
{% endif %}
16+
{% endif %}
1417

1518
<link rel="stylesheet" href="{{static_dir}}vimhelp-v5.css" type="text/css">
1619
<noscript><link rel="stylesheet" href="{{static_dir}}noscript.css" type="text/css"></noscript>
@@ -61,13 +64,15 @@ <h1>{{project.name}} help files</h1>
6164
{% if mode != "offline" %}
6265
<div class="bar">
6366
<div class="ql">{{sitenavi}}</div>
67+
{% if project.name != "MacVim" %}
6468
<div class="srch" id="go-to-tag">
6569
<select id="vh-select-tag"></select>
6670
</div>
6771
<form class="srch" action="https://duckduckgo.com" method="get" target="_blank" rel="noopener noreferrer">
6872
<input type="hidden" name="sites" value="{{project.vimdoc_site}}">
6973
<input type="search" name="q" id="vh-srch-input" placeholder="Site search">
7074
</form>
75+
{% endif %}
7176
{% if filename != "help.txt" %}
7277
{{theme_switcher}}
7378
{% endif %}

vimhelp/vimhelp/vimh2h.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,11 @@ def add_tags(self, filename, contents):
182182
in_example = True
183183

184184
def do_add_tag(self, filename, tag):
185-
if self._mode == "online" and filename == "help.txt":
186-
htmlfilename = "/"
185+
if filename == "help.txt":
186+
if self._mode == "online":
187+
htmlfilename = "/"
188+
else:
189+
htmlfilename = "index.html"
187190
else:
188191
htmlfilename = filename + ".html"
189192
self._urls[tag] = Link(filename, htmlfilename, tag)
@@ -334,7 +337,7 @@ def to_html(self, filename, contents):
334337
out.append(FAQ_LINE)
335338

336339
static_dir = "/" if self._mode == "online" else ""
337-
helptxt = "./" if self._mode == "online" else "help.txt.html"
340+
helptxt = "./" if self._mode == "online" else "index.html"
338341

339342
return flask.render_template(
340343
"page.html",

0 commit comments

Comments
 (0)