diff --git a/infra/deploy/build.sh b/infra/deploy/build.sh index 1499df7..669b063 100644 --- a/infra/deploy/build.sh +++ b/infra/deploy/build.sh @@ -13,5 +13,8 @@ pnpm astro build echo "[build] rsync -> $STAGING" mkdir -p "$STAGING" rsync -a --delete "$REPO_DIR/dist/" "$STAGING/" +# 原图仓独立同步(不进 git/dist):/photos-originals/ 供图库"查看原图/下载" +ORIG="$HOME/docker_apps/blog/photos-originals" +if [ -d "$ORIG" ]; then rsync -a "$ORIG/" "$STAGING/photos-originals/"; fi printf 'built at %s\n' "$(date -Is)" > "$STAGING/.build-stamp" echo "[build] done: $(find "$STAGING" -name '*.html' | wc -l) html files" diff --git a/scripts/migrate/photos_migrate.py b/scripts/migrate/photos_migrate.py index be3fad8..3e7d3b9 100644 --- a/scripts/migrate/photos_migrate.py +++ b/scripts/migrate/photos_migrate.py @@ -61,9 +61,11 @@ def main() -> int: fname = unquote(url.rsplit("/", 1)[1]) slug = slugify(spec.get("displayName") or fname) data = urllib.request.urlopen(BASE + url, timeout=60).read() - # 入仓前压到长边 2400/q86:原图总计 196M(单张最大 28M)会永久膨胀 - # 公开仓历史并撞死 nginx 100M 推送上限;原图已随 Phase 0 备份归档, - # 站内展示由 sharp 出 srcset,2400px 足够 lightbox 全屏 + # 原图双留档:仓外 originals store(构建时独立 rsync,服务"查看原图/ + # 下载")+ Phase 0 备份 tar;git 仓只进压缩版(196M 事故教训) + STORE = Path.home() / "docker_apps/blog/photos-originals" + STORE.mkdir(parents=True, exist_ok=True) + (STORE / f"{slug}.jpg").write_bytes(data) (OUT / f"{slug}.jpg").write_bytes(compress(data)) (OUT / f"{slug}.json").write_text(json.dumps({ diff --git a/scripts/photos_ingest.py b/scripts/photos_ingest.py index dd86e3f..36337ff 100644 --- a/scripts/photos_ingest.py +++ b/scripts/photos_ingest.py @@ -27,6 +27,11 @@ def main() -> int: if size < SKIP_BELOW_BYTES: skipped += 1 continue + STORE = Path.home() / "docker_apps/blog/photos-originals" + STORE.mkdir(parents=True, exist_ok=True) + # 压缩覆写仓内文件前原件先进 store(幂等:store 已有同名则跳过) + if not (STORE / jpg.name).exists(): + (STORE / jpg.name).write_bytes(jpg.read_bytes()) img = Image.open(jpg) # EXIF 显式保留:重存默认剥离会抽走图库参数条的构建期数据源 exif = img.info.get("exif") diff --git a/src/pages/gallery/index.astro b/src/pages/gallery/index.astro index 52cb16e..74ece9d 100644 --- a/src/pages/gallery/index.astro +++ b/src/pages/gallery/index.astro @@ -47,6 +47,8 @@ const cards = await Promise.all( image: photo.data.image, exif: formatExif(photo.data.exif), fullSrc: full.src, + // 原图走仓外 store(构建时独立 rsync 到 /photos-originals/),git 不背 196M + original: `/photos-originals/${photo.id}.jpg`, w, h, s3: spanFor(w, h, 3), @@ -84,6 +86,7 @@ const first = cards[0]; data-title={card.title} data-exif={card.exif} data-full={card.fullSrc} + data-original={card.original} aria-label={`查看大图:${card.title}${card.exif ? `(${card.exif})` : ''}`} > {first?.title} {first?.exif} + + 原图 + 下载 +