Skip to content

Commit

Permalink
Reserve Photos
Browse files Browse the repository at this point in the history
  • Loading branch information
kristofzerbe committed Nov 29, 2024
1 parent 51c3aca commit b0cd3c3
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ XXX/
HexoCommand*
photos_original/
lemmy-test.rest
'--'/
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ static_dir: static
photo_dir: photos
pool_dir: pool
shed_dir: shed
reserve_dir: reserve
public_dir: docs
archive_dir: archives
tag_dir: archives/tags
Expand Down
38 changes: 37 additions & 1 deletion scripts/events/on-generateBefore-get-dynamic-photos.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ hexo.on('generateBefore', function() {
let pHero = getHeroPhoto();
let pPool = getPoolPhotos();
let pShed = getShedPhotos();
let pReserve = getReservePhotos();
let pPostPages = getPostAndPagePhotos();
let pDrafts = getDraftPagePhotos();
let pDynamic = getDynamicPagePhotos();
let pAnything = getAnythingPagePhotos();
let pNotes = getNotesPhotos();

let photos = [...pHero, ...pPool, ...pShed, ...pPostPages, ...pDrafts, ...pDynamic, ...pAnything, ...pNotes]
let photos = [...pHero, ...pPool, ...pReserve, ...pShed, ...pPostPages, ...pDrafts, ...pDynamic, ...pAnything, ...pNotes]
.filter(p => (p.name)) //filter out all without photo name
.sort((a, b) => a.key.localeCompare(b.key));

Expand Down Expand Up @@ -190,6 +191,41 @@ function getPoolPhotos() {

/** ================================================================================= */

function getReservePhotos() {
const config = hexo.config;

var reserveDir = path.join(_rootDir, config.static_dir, config.reserve_dir);

let reserve = fs.readdirSync(reserveDir)
.filter(entry => fs.statSync(path.join(reserveDir, entry)).isDirectory())
.map(entry => ({ key: entry, status: "reserve", file: null }));

reserve.forEach(entry => {

let metaFile = path.join(reserveDir, entry.key, "meta.json");
let metaCreationDate, meta;
if (fs.existsSync(metaFile)) {
metaCreationDate = fs.statSync(metaFile).birthtime;
meta = JSON.parse(fs.readFileSync(metaFile));
}

entry.file = entry.key + ".jpg";
entry.route = entry.key; //meta?.custom.name || entry.key;
entry.name = entry.meta?.ObjectName || entry.key;
entry.article = null;
entry.pathMobile = "/" + path.join(config.reserve_dir, entry.key, "mobile.jpg").replace(/\134/g,"/");
entry.pathTablet = "/" + path.join(config.reserve_dir, entry.key, "tablet.jpg").replace(/\134/g,"/");
entry.pathNormal = "/" + path.join(config.reserve_dir, entry.key, "normal.jpg").replace(/\134/g,"/");
entry.date = metaCreationDate;
entry.meta = meta;
});

log.info("-> " + magenta(reserve.length) + " reserve photos");
return reserve;
}

/** ================================================================================= */

function getShedPhotos() {
const config = hexo.config;

Expand Down
2 changes: 1 addition & 1 deletion source/_dynamic/photos-map.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ photograph:
name: Photographers Mosaic
keepOutOverview: true
date: 2021-08-24 15:56:00
updated: 2024-11-17 17:19:33
updated: 2024-11-29 14:51:01
---

Most of the images listed in the collection (and some more out of the shed) contain geo-localisations in the form of GPS coordinates in their metadata. These **{% photo.count %} photos** are pinned on this map.
Expand Down
2 changes: 1 addition & 1 deletion source/_dynamic/photos.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ photograph:
file: $20-08-Mallorca-7627.jpg
name: Photographers Mosaic
date: 2021-08-24 15:56:00
updated: 2024-11-17 17:19:33
updated: 2024-11-29 14:51:01
---

<div><img src="/images/cc-free-culture.png" class="float-element" style="width:5rem;" /></div>
Expand Down

0 comments on commit b0cd3c3

Please sign in to comment.