wget lines optional

This commit is contained in:
Ville Rantanen
2022-11-24 12:26:27 +02:00
parent 236d2c4946
commit 739781e162

View File

@@ -22,7 +22,7 @@ try:
except ImportError:
MARKDOWN_AVAILABLE = False
VERSION = "20220217"
VERSION = "20221124"
IMAGE_EXTENSIONS = ["png", "gif", "jpg", "jpeg", "tif", "tiff"]
AUDIO_EXTENSIONS = ["wav", "mp3", "ogg"]
VIDEO_EXTENSIONS = ["mp4", "ogg", "webm"]
@@ -35,6 +35,7 @@ SAFE_OPTS = (
"media",
"includes",
"no_readme",
"no_wget",
"reverse",
)
@@ -68,6 +69,13 @@ def setup():
default=False,
help="Do not show README.md on the page",
)
parser.add_argument(
"--no-wget",
action="store_true",
dest="no_wget",
default=False,
help="Do not show wget download links",
)
parser.add_argument(
"-t",
type=str,
@@ -253,7 +261,8 @@ def generate_index(opts):
f.write(get_pathlink(path, di))
for fi in files:
f.write(get_filelink(path, fi, opts.images, opts.media))
f.write(get_footer(readme))
f.write(get_footer(readme, show_wget=not opts.no_wget))
if not opts.no_wget:
f.write(get_download_lines(files, recursive=opts.recursive))
f.close()
return
@@ -1033,15 +1042,22 @@ function show_wget_magic() {
return header
def get_footer(readme):
return """</tbody></table>{README}
</div>
def get_footer(readme, show_wget=True):
if show_wget:
wget_str = """
<div id=wget_container>
<div id=wget_toggle onclick="show_wget_magic()">wget?</div>
<pre id=wget_magic class=hidden></pre>
</div>
"""
else:
wget_str = ""
return """</tbody></table>{README}
</div>{WGET_STR}
</body></html>""".format(
README=readme
README=readme,
WGET_STR=wget_str
)