-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildSite.ps1
88 lines (70 loc) · 3.77 KB
/
buildSite.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
$Years = Get-ChildItem -Path "www/albums/" -Directory | Sort-Object $_.Name -Descending
$Albums = Get-ChildItem -Path "www/albums/" -Directory -Recurse | Sort-Object $_.Parent -Descending
$AlbumTemplate = Get-Content -Path "templates/album.html" -Raw
$HomeTemplate = Get-Content -Path "templates/home.html" -Raw
$ImageRootUri = "https://mansonphotography.azureedge.net/images"
foreach ($Year in $Years) {
$Albums = Get-Content -Path "$($Year.FullName)/albums.json" | ConvertFrom-Json
foreach ($Album in $Albums) {
$ImagesConfig = Join-Path $Year.FullName $Album.Name "images.json"
if ((Test-Path $ImagesConfig) -ne $true) {
Write-Host "[$($Album.Name)]: Missing images.json, skipping.."
continue
}
else {
$Images = (Get-Content -Path $ImagesConfig | ConvertFrom-Json).Images
}
$GalleryItems = ""
foreach ($Image in $Images) {
$Extension = ($Image.Name).Split('.')[-1]
$ThumbnailFile = ($Image.Name).Split('.')[0] + "-thumb." + $Extension
$GalleryItemBlock = @"
<a class="gallery-item"
data-src="$($ImageRootUri)/$($Year.Name)/$($Album.Name)/$($Image.Name)"
data-sub-html="$($Image.CameraModel) @ $($Image.FStop) | $($Image.ExposureTime) | $($Image.FocalLength) | $($Image.IsoSpeed)">
<img class="img-responsive"
src="$($ImageRootUri)/$($Year.Name)/$($Album.Name)/$($ThumbnailFile)" />
</a>
"@
$GalleryItems = $GalleryItems + $GalleryItemBlock
}
# Replace Tokens
$HTML = $AlbumTemplate
$HTML = $HTML -replace ('##TITLE##', "$($Album.Title) - Cory Manson Photography")
$HTML = $HTML -replace ('##GALLERYITEMS##', $GalleryItems)
$HTML | Out-File -FilePath (Join-Path $Year.FullName $Album.Name "index.html") -Force
$HomeItemBlock = @"
<div class="isotope-item iso-height-1">
<!-- Begin gallery list item -->
<div class="gallery-list-item">
<!-- Begin gallery list item image -->
<div class="gl-item-image-wrap">
<!-- Begin gallery list item image inner -->
<a href="/albums/$($Year.Name)/$($Album.Name)" class="gl-item-image-inner">
<div class="gl-item-image bg-image"
style="background-image: url($($ImageRootUri)/$($Year.Name)/$($Album.Name)/cover.jpg); background-position: 50% 50%">
</div>
<span class="gl-item-image-zoom"></span>
</a>
<!-- End gallery list item image inner -->
</div>
<!-- End gallery list item image -->
<!-- Begin gallery list item info -->
<div class="gl-item-info">
<div class="gl-item-caption">
<h2 class="gl-item-title"><a href="/albums/$($Year.Name)/$($Album.Name)">$($Album.Title)</a></h2>
<span class="gl-item-category">$($Year.Name) - $($Album.Category)</span>
</div>
</div>
<!-- End gallery list item info -->
</div>
<!-- End gallery list item -->
</div>
<!-- End isotope item -->
"@
$HomeItems = $HomeItems + $HomeItemBlock
}
}
$HTML = $HomeTemplate
$HTML = $HTML -replace ('##GALLERIES##', $HomeItems)
$HTML | Out-File -FilePath "www/index.html" -Force