aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorctucx <leah@antifa.jetzt>2020-06-16 23:19:15 +0200
committerctucx <leah@antifa.jetzt>2020-06-16 23:19:15 +0200
commitfbe7a7ee76f741f8dcf6ca53bb06ff513e7d600b (patch)
tree790379e58c2ccb97fc7e55cf7d5f57b6ab60f52f
parentcc91219b0a45a034f35c9e510fb384a9abda0d99 (diff)
downloadgallery-fbe7a7ee76f741f8dcf6ca53bb06ff513e7d600b.tar.gz
gallery-fbe7a7ee76f741f8dcf6ca53bb06ff513e7d600b.tar.bz2
gallery-fbe7a7ee76f741f8dcf6ca53bb06ff513e7d600b.zip
removes stuff that was deleted
-rw-r--r--src/assets/album.html4
-rw-r--r--src/assets/picture.html16
-rw-r--r--src/gallery.nim40
3 files changed, 45 insertions, 15 deletions
diff --git a/src/assets/album.html b/src/assets/album.html
index 3334560..001ba91 100644
--- a/src/assets/album.html
+++ b/src/assets/album.html
@@ -114,8 +114,8 @@
{{/hasSubalbums}}
{{#pictures}}
- <a href="{{name}}/" class="photo">
- <img src="./thumbnails/{{name}}.png" alt="Photo thumbnail" width="{{ThumbThumbMaxWidth}}" height="{{ThumbThumbMaxHeight}}">
+ <a href="{{name}}.html" class="photo">
+ <img src="thumbnails/{{name}}.png" alt="Photo thumbnail" width="{{ThumbThumbMaxWidth}}" height="{{ThumbThumbMaxHeight}}">
<span class="overlay">
<h1>{{name}}</h1>
<!--<p><span title="Camera Date"><svg class="iconic "><use xlink:href="/iconic.svg#camera-slr"></use></svg></span></p>-->
diff --git a/src/assets/picture.html b/src/assets/picture.html
index 6f3058f..e8b1bc9 100644
--- a/src/assets/picture.html
+++ b/src/assets/picture.html
@@ -13,7 +13,7 @@
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
- <meta property="og:image" content="../medium/{{name}}.jpg" />
+ <meta property="og:image" content="medium/{{filename}}" />
<link type="text/css" rel="stylesheet" href="/style.css">
<link rel="shortcut icon" href="favicon.ico">
@@ -24,7 +24,7 @@
<a class="header-title">{{name}}<svg class="iconic "><use xlink:href="/iconic.svg#caret-bottom"></use></svg></a>
{{#SiteShowOrigBtn}}
- <a class="button" href="/originals{{orig}}" title="Download"><svg class="iconic"><use xlink:href="/iconic.svg#cloud-download"></use></svg></a>
+ <a class="button" href="{{orig}}" title="Download"><svg class="iconic"><use xlink:href="/iconic.svg#cloud-download"></use></svg></a>
{{/SiteShowOrigBtn}}
<a class="header-divider"></a>
@@ -140,11 +140,11 @@
</header>
<div id="imageview" class="fadeIn full" style="display: block;">
- <img id="image" class="" src="../medium/{{name}}.jpg">
+ <img id="image" class="" src="medium/{{filename}}">
{{#hasPrev}}
<div class="arrow_wrapper arrow_wrapper--previous">
- <a id="previous" href="../{{prev_name}}" style="background-image: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)), url(&quot;../thumbnails/{{prev_name}}.png&quot;);">
+ <a id="previous" href="{{prev_name}}.html" style="background-image: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)), url(&quot;thumbnails/{{prev_name}}.png&quot;);">
<svg class="iconic "><use xlink:href="/iconic.svg#caret-left"></use></svg>
</a>
</div>
@@ -152,7 +152,7 @@
{{#hasNext}}
<div class="arrow_wrapper arrow_wrapper--next">
- <a id="next" href="../{{next_name}}" style="background-image: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)), url(&quot;../thumbnails/{{next_name}}.png&quot;);">
+ <a id="next" href="{{next_name}}.html" style="background-image: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)), url(&quot;thumbnails/{{next_name}}.png&quot;);">
<svg class="iconic "><use xlink:href="/iconic.svg#caret-right"></use></svg>
</a>
</div>
@@ -163,9 +163,9 @@
<script type="text/javascript">
window.onload=getExif;
window.onkeyup = function(e) {
- if (e.keyCode == 27) window.location = "..";
- if (e.keyCode == 39) window.location = "../{{next_name}}";
- if (e.keyCode == 37) window.location = "../{{prev_name}}";
+ if (e.keyCode == 27) window.location = "./";
+ if (e.keyCode == 39) window.location = "./{{next_name}}.html";
+ if (e.keyCode == 37) window.location = "./{{prev_name}}.html";
if (e.keyCode == 32) document.getElementById("toggle").checked = true;
}
diff --git a/src/gallery.nim b/src/gallery.nim
index 1dc42f0..cbbb045 100644
--- a/src/gallery.nim
+++ b/src/gallery.nim
@@ -21,6 +21,7 @@ type
name*: string
path*: string
filename*: string
+ filetype*: string
desc*: Option[string]
size*: BiggestInt
@@ -61,6 +62,7 @@ proc createPicture(path: string): Picture =
result.name = name
result.path = dir
result.filename = lastPathPart(path)
+ result.filetype = ext.replace(".", "")
result.size = getFileSize(path)
@@ -96,6 +98,32 @@ proc placeAssets(targetDir: string, enableJS: bool) =
if enableJS: writeFile(joinPath(targetDir, "exif.js"), asset_exif_js)
+proc removeOrphans (sourceDir: string, targetDir: string) =
+ #Albums
+ for element in walkDir(targetDir):
+ if element.kind != pcDir: continue
+
+ var targetDir = targetDir
+ normalizePath(targetDir)
+ var dirname = element.path.replace(targetDir & "/", "")
+
+ if dirname == "thumbnails": continue
+ if dirname == "medium": continue
+
+ if not dirExists(joinPath(sourceDir, dirname)):
+ removeDir(joinPath(targetDir, dirname))
+
+ #Photos
+ for element in walkDir(joinPath(targetDir, "medium")):
+ let (dir, name, ext) = splitFile(element.path)
+ let filename = name & ext
+
+ if not fileExists(joinPath(sourceDir, filename)):
+ removeFile(joinPath(targetDir, name & ".html"))
+ removeFile(joinPath(targetDir, "medium", filename))
+ removeFile(joinPath(targetDir, "thumbnails", name & ".png"))
+
+
proc generateWebsite(sourceDir: string, targetDir: string, album: Album, config: JsonNode) =
echo "============"
echo "Create Album:" & album.name
@@ -123,6 +151,8 @@ proc generateWebsite(sourceDir: string, targetDir: string, album: Album, config:
for subalbum in album.subalbums:
generateWebsite(sourceDir, joinPath(targetDir, subalbum.name), subalbum, config)
+ removeOrphans(joinPath(sourceDir, subalbum.name), joinPath(targetDir, subalbum.name))
+
var thumbnail1 = "/no_images.svg"
var thumbnail2 = "/no_images.svg"
@@ -143,11 +173,10 @@ proc generateWebsite(sourceDir: string, targetDir: string, album: Album, config:
})
for index, picture in album.pictures:
- discard existsOrCreateDir(joinPath(targetDir, picture.name))
-
var pictureTemplateContext = mergeJson(%* {
"name": picture.name,
- "orig": picture.path.replace(sourceDir, "") & "/" & picture.filename,
+ "orig": joinPath("/originals", picture.path.replace(sourceDir, ""), picture.filename),
+ "filename": picture.filename,
"description": "-",
"hasPrev": false,
"hasNext": false,
@@ -166,13 +195,13 @@ proc generateWebsite(sourceDir: string, targetDir: string, album: Album, config:
echo "Generate picture page: " & picture.name
- writeFile(joinPath(targetDir, picture.name, "index.html"), render(asset_picture_html, pictureTemplateContext))
+ writeFile(joinPath(targetDir, picture.name & ".html"), render(asset_picture_html, pictureTemplateContext))
if not fileExists(targetDir & "/thumbnails/" & picture.name & ".png"):
smallThumbnails.add("/usr/bin/env mogrify -strip -quality " & $config["ThumbThumbQuality"].getInt & " -format png -path " & quoteShell(joinPath(targetDir, "thumbnails")) & " -thumbnail " & $config["ThumbThumbMaxWidth"].getInt & "x" & $config["ThumbThumbMaxHeight"].getInt & "^ -gravity center -extent " & $config["ThumbThumbMaxWidth"].getInt & "x" & $config["ThumbThumbMaxHeight"].getInt & " " & quoteShell(joinPath(picture.path, picture.filename)))
if not fileExists(targetDir & "/medium/" & picture.name & ".jpg"):
- mediumThumbnails.add("/usr/bin/env mogrify -format jpg -path " & quoteShell(joinPath(targetDir, "medium")) & " -resize " & $config["ThumbMediumMaxWidth"].getInt & "x\\> " & quoteShell(joinPath(picture.path, picture.filename)))
+ mediumThumbnails.add("/usr/bin/env mogrify -format " & picture.filetype & " -path " & quoteShell(joinPath(targetDir, "medium")) & " -resize " & $config["ThumbMediumMaxWidth"].getInt & "x\\> " & quoteShell(joinPath(picture.path, picture.filename)))
templateContext["pictures"].add(%* {
"name": picture.name,
@@ -187,6 +216,7 @@ proc generateWebsite(sourceDir: string, targetDir: string, album: Album, config:
echo "Generate album page!\n"
writeFile(joinPath(targetDir, "index.html"), render(asset_album_html, templateContext))
+ removeOrphans(sourceDir, targetDir)
proc main =