sync newer images, LoRA page update

This commit is contained in:
2026-07-07 21:35:17 -07:00
parent ffe0377f4c
commit 48ab1db956
4 changed files with 212 additions and 134 deletions

File diff suppressed because one or more lines are too long

View File

@@ -329,7 +329,7 @@ def generate_html(loras, sources=None):
rest = sorted_tags[8:] rest = sorted_tags[8:]
has_rest = len(rest) > 0 has_rest = len(rest) > 0
top8_html = ", ".join( top8_html = "".join(
f"<span class=\"tg\"><code>{_e(t)}</code> <span class=\"c\">({c}x)</span></span>" f"<span class=\"tg\"><code>{_e(t)}</code> <span class=\"c\">({c}x)</span></span>"
for t, c in top8 for t, c in top8
) )
@@ -339,7 +339,7 @@ def generate_html(loras, sources=None):
more_id = "m_" + html_id() more_id = "m_" + html_id()
more_count = sum(c for _, c in rest) more_count = sum(c for _, c in rest)
rest_html = " <span class=\"ml\" onclick=\"t('" + more_id + "',this)\" data-n=\"" + str(more_count) + "\">" + str(more_count) + " more&hellip;</span>" rest_html = " <span class=\"ml\" onclick=\"t('" + more_id + "',this)\" data-n=\"" + str(more_count) + "\">" + str(more_count) + " more&hellip;</span>"
rest_list = ", ".join( rest_list = "".join(
f"<span class=\"tg\"><code>{_e(t)}</code> <span class=\"c\">({c}x)</span></span>" f"<span class=\"tg\"><code>{_e(t)}</code> <span class=\"c\">({c}x)</span></span>"
for t, c in rest for t, c in rest
) )
@@ -393,7 +393,7 @@ td{{padding:7px 10px;border-bottom:1px solid #21262d;vertical-align:top;word-bre
tr:hover td{{background:#161b22}} tr:hover td{{background:#161b22}}
.fn{{color:#58a6ff;font-weight:500;white-space:nowrap}} .fn{{color:#58a6ff;font-weight:500;white-space:nowrap}}
.tl,.bm{{color:#8b949e}} .tl,.bm{{color:#8b949e}}
.tr code{{background:#1f2937;padding:1px 5px;border-radius:3px;font-size:0.78rem;color:#f0c674;white-space:nowrap}} .tr code{{background:#1f2937;padding:1px 5px;border-radius:3px;font-size:0.78rem;color:#f0c674;word-break:break-word}}
.c{{color:#8b949e;font-size:0.72rem;margin-right:3px}} .c{{color:#8b949e;font-size:0.72rem;margin-right:3px}}
.n{{color:#484f58;font-style:italic}} .n{{color:#484f58;font-style:italic}}
.ml{{color:#58a6ff;cursor:pointer;font-size:0.78rem;text-decoration:none;border-bottom:1px dotted #58a6ff}} .ml{{color:#58a6ff;cursor:pointer;font-size:0.78rem;text-decoration:none;border-bottom:1px dotted #58a6ff}}
@@ -401,7 +401,7 @@ tr:hover td{{background:#161b22}}
.ht{{display:none}} .ht{{display:none}}
.dr td{{background:#161b22;padding:10px 14px;border-bottom:2px solid #30363d}} .dr td{{background:#161b22;padding:10px 14px;border-bottom:2px solid #30363d}}
.dr code{{background:#1f2937;padding:1px 5px;border-radius:3px;font-size:0.78rem;color:#f0c674}} .dr code{{background:#1f2937;padding:1px 5px;border-radius:3px;font-size:0.78rem;color:#f0c674}}
.tg{{white-space:nowrap;display:inline-block;margin:1px 0}} .tg{{display:inline-block;margin:1px 6px 1px 0}}
mark.hl{{background:#264f78;color:#f0f6fc;border-radius:2px;padding:0 2px}} mark.hl{{background:#264f78;color:#f0f6fc;border-radius:2px;padding:0 2px}}
.sr a{{color:#58a6ff;text-decoration:none;font-size:0.78rem}} .sr a{{color:#58a6ff;text-decoration:none;font-size:0.78rem}}
.c0{{width:24%}}.c1{{width:8%}}.c2{{width:12%}}.c3{{width:48%}}.c4{{width:8%}} .c0{{width:24%}}.c1{{width:8%}}.c2{{width:12%}}.c3{{width:48%}}.c4{{width:8%}}

9
push-newer-pics Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
#
# push-newer-pics — Wrapper for sync-newer-images with default paths.
# Syncs ~/Pictures → ~/mnt/mini.nas/miniShare1/Pictures
#
# Usage: push-newer-pics [--help]
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
exec "${SCRIPT_DIR}/sync-newer-images" "$HOME/mnt/mini.nas/miniShare1/Pictures" "$HOME/Pictures"

69
sync-newer-images Executable file
View File

@@ -0,0 +1,69 @@
#!/bin/bash
#
# sync-newer-images — For each top-level image in SRC, find any matching
# filename recursively under DEST and copy over it if SRC is newer.
# Works on Linux and macOS (bash 3.2+ compatible).
usage() {
cat <<'EOF'
Usage: sync-newer-images [options] <destination> <source>
For each top-level image in source, find any matching filename recursively
under destination and copy over it if the source file is newer.
Arguments:
destination Path to copy TO
source Path to copy FROM
Options:
-h, --help Show this help message and exit
EOF
exit 0
}
for arg in "$@"; do
case "$arg" in
-h|--help) usage ;;
esac
done
if [ $# -lt 2 ]; then
echo "Error: destination and source are required" >&2
echo "Usage: sync-newer-images <destination> <source>" >&2
exit 1
fi
DEST="$1"
SRC="$2"
if [ ! -d "$DEST" ]; then
echo "Error: destination '$DEST' is not a directory" >&2
exit 1
fi
if [ ! -d "$SRC" ]; then
echo "Error: source '$SRC' is not a directory" >&2
exit 1
fi
copied=0
for srcfile in "$SRC"/*; do
[ -f "$srcfile" ] || continue
ext="${srcfile##*.}"
case "$(echo "$ext" | tr '[:upper:]' '[:lower:]')" in
jpg|jpeg|png|gif|heic|webp|bmp|tiff|tif) ;;
*) continue ;;
esac
filename="${srcfile##*/}"
while IFS= read -r destfile; do
if [ -f "$destfile" ] && [ "$srcfile" -nt "$destfile" ]; then
cp -v "$srcfile" "$destfile"
copied=$((copied + 1))
fi
done < <(find "$DEST" -type f -name "$filename" 2>/dev/null)
done
echo "Copied ${copied} newer image(s) from ${SRC} into ${DEST}"