reveal the wget magic

This commit is contained in:
Ville Rantanen
2022-02-17 14:48:59 +02:00
parent 3af2617ffa
commit 6c3e398a77
2 changed files with 61 additions and 17 deletions

Binary file not shown.

View File

@@ -22,7 +22,7 @@ try:
except ImportError: except ImportError:
MARKDOWN_AVAILABLE = False MARKDOWN_AVAILABLE = False
VERSION = "20211116" VERSION = "20220217"
IMAGE_EXTENSIONS = ["png", "gif", "jpg", "jpeg", "tif", "tiff"] IMAGE_EXTENSIONS = ["png", "gif", "jpg", "jpeg", "tif", "tiff"]
AUDIO_EXTENSIONS = ["wav", "mp3", "ogg"] AUDIO_EXTENSIONS = ["wav", "mp3", "ogg"]
VIDEO_EXTENSIONS = ["mp4", "ogg", "webm"] VIDEO_EXTENSIONS = ["mp4", "ogg", "webm"]
@@ -319,11 +319,15 @@ def get_filelink(path, fname, images=False, media=False):
) )
def get_wget_command():
return 'wget -qO - "$URL" | grep "^#FILE " | cut -c7- | sed "s,^,$URL," | xargs -n1 wget -Nc'
def get_download_lines(files, recursive=False): def get_download_lines(files, recursive=False):
s = "\n<!--\n" s = "\n<!--\n"
for f in files: for f in files:
s += "#FILE %s\n" % (urllib.parse.quote(f),) s += "#FILE %s\n" % (urllib.parse.quote(f),)
s += "#DL-CMD:\n#URL=[insert URL] && wget -qO - $URL | grep '^#FILE ' | cut -c7- | sed \"s,^,$URL,\" | xargs -n1 wget -Nc" s += "#DL-CMD:\n#URL=[insert URL] && " + get_wget_command()
if recursive: if recursive:
s += "x" s += "x"
s += "\n-->\n" s += "\n-->\n"
@@ -503,7 +507,8 @@ def get_readme(path, no_read):
def get_header(opts): def get_header(opts):
opts_str = setup2JSON(opts) opts_str = setup2JSON(opts)
js_code = """ js_code = (
"""
<script type="text/javascript"> <script type="text/javascript">
/* /*
Table sorting script by Joost de Valk, check it out at http://www.joostdevalk.nl/code/sortable-table/. Table sorting script by Joost de Valk, check it out at http://www.joostdevalk.nl/code/sortable-table/.
@@ -825,9 +830,17 @@ function alternate(table) {
} }
} }
} }
function show_wget_magic() {
document.getElementById("wget_magic").innerHTML = 'URL="' + document.URL +'" && ' +
'"""
+ get_wget_command()
+ """';
document.getElementById("wget_magic").classList.toggle("hidden");
window.scrollTo(0,document.body.scrollHeight);
}
</script> </script>
""" """
)
css_style = """ css_style = """
<style> <style>
/* Style modified from: https://css-tricks.com/snippets/php/display-styled-directory-contents/ */ /* Style modified from: https://css-tricks.com/snippets/php/display-styled-directory-contents/ */
@@ -849,6 +862,7 @@ function alternate(table) {
} }
.container { .container {
margin: 20px; margin: 20px;
margin-bottom: 0px;
box-shadow: 0 5px 10px -5px rgba(0,0,0,0.5); box-shadow: 0 5px 10px -5px rgba(0,0,0,0.5);
position: relative; position: relative;
background: #eee; background: #eee;
@@ -950,7 +964,7 @@ function alternate(table) {
} }
table { table {
margin: 0; margin: 0;
width: 800px; width: 800px;monilla yrityksi
} }
td { td {
padding-top: 10px; padding-top: 10px;
@@ -962,6 +976,31 @@ function alternate(table) {
word-break: break-all; word-break: break-all;
} }
} }
#wget_container {
display: inline-block;
margin-left: 20px;
margin-right: 20px;
margin-bottom: 20px;
}
#wget_toggle {
display: inline-block;
cursor: pointer;
background-color: #EB6000;
color: white;
padding: 5px;
box-shadow: 0 5px 10px -5px rgba(0,0,0,0.5);
}
#wget_magic {
white-space: pre-wrap;
word-wrap: break-word;
padding: 20px;
background-color: #eee;
margin: 0px;
box-shadow: 0 5px 10px -5px rgba(0,0,0,0.5);
}
.hidden {
display: none;
}
</style> </style>
""" """
header = ( header = (
@@ -995,7 +1034,12 @@ function alternate(table) {
def get_footer(readme): def get_footer(readme):
return """</tbody></table>{README}</div> return """</tbody></table>{README}
</div>
<div id=wget_container>
<div id=wget_toggle onclick="show_wget_magic()">wget?</div>
<pre id=wget_magic class=hidden></pre>
</div>
</body></html>""".format( </body></html>""".format(
README=readme README=readme
) )