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:
MARKDOWN_AVAILABLE = False
VERSION = "20211116"
VERSION = "20220217"
IMAGE_EXTENSIONS = ["png", "gif", "jpg", "jpeg", "tif", "tiff"]
AUDIO_EXTENSIONS = ["wav", "mp3", "ogg"]
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):
s = "\n<!--\n"
for f in files:
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:
s += "x"
s += "\n-->\n"
@@ -503,7 +507,8 @@ def get_readme(path, no_read):
def get_header(opts):
opts_str = setup2JSON(opts)
js_code = """
js_code = (
"""
<script type="text/javascript">
/*
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>
"""
)
css_style = """
<style>
/* Style modified from: https://css-tricks.com/snippets/php/display-styled-directory-contents/ */
@@ -849,6 +862,7 @@ function alternate(table) {
}
.container {
margin: 20px;
margin-bottom: 0px;
box-shadow: 0 5px 10px -5px rgba(0,0,0,0.5);
position: relative;
background: #eee;
@@ -916,24 +930,24 @@ function alternate(table) {
color: #222;
}
.right {
text-align: right;
text-align: right;
}
.bytes {
font-size: xx-small;
font-size: xx-small;
}
.image {
max-width: 90%;
max-width: 90%;
}
.audio {
width: 90%;
padding-left: 5px;
width: 90%;
padding-left: 5px;
}
.video {
width: 320;
height: 240;
width: 320;
height: 240;
}
.container pre {
margin: 10px 10px 10px 10px;
margin: 10px 10px 10px 10px;
}
.readme {
padding: 0;
@@ -944,13 +958,13 @@ function alternate(table) {
}
@media only screen and (max-width: 600px) {
.container {
margin: 0;
min-width: 800px;
display: block;
margin: 0;
min-width: 800px;
display: block;
}
table {
margin: 0;
width: 800px;
width: 800px;monilla yrityksi
}
td {
padding-top: 10px;
@@ -962,6 +976,31 @@ function alternate(table) {
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>
"""
header = (
@@ -995,7 +1034,12 @@ function alternate(table) {
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(
README=readme
)