|
|
|
@ -8,7 +8,6 @@ A single photo/video could exist in multiple albums
|
|
|
|
|
|
|
|
|
|
const _ = require('lodash')
|
|
|
|
|
const path = require('path')
|
|
|
|
|
const url = require('url')
|
|
|
|
|
const slugify = require('slugify')
|
|
|
|
|
var index = 0
|
|
|
|
|
|
|
|
|
@ -60,7 +59,7 @@ Album.prototype.finalize = function (options, parent) {
|
|
|
|
|
this.basename = parent.basename + '-' + this.basename
|
|
|
|
|
}
|
|
|
|
|
this.path = path.join(albumsOutputFolder, this.basename + '.html')
|
|
|
|
|
this.url = url.resolve(albumsOutputFolder + '/', this.basename + '.html')
|
|
|
|
|
this.url = this.getUrl(albumsOutputFolder, this.basename + '.html')
|
|
|
|
|
this.depth = parent.depth + 1
|
|
|
|
|
}
|
|
|
|
|
// path to the optional ZIP file
|
|
|
|
@ -111,6 +110,18 @@ Album.prototype.calculateSummary = function () {
|
|
|
|
|
this.summary = _.compact(items).join(', ')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Album.prototype.getUrl = function (albumsOutputFolder, documentPath) {
|
|
|
|
|
// Encode characters like ?, # and space, however, undo the encoding for slashes.
|
|
|
|
|
// This is needed to support albums and files with these URI-unfriendly characters.
|
|
|
|
|
// See https://github.com/thumbsup/thumbsup/issues/234
|
|
|
|
|
let url = encodeURIComponent(albumsOutputFolder + '/' + documentPath).replace(/%2F/g, '/')
|
|
|
|
|
// Shorten the url if it starts with './'
|
|
|
|
|
if (url.startsWith('./')) {
|
|
|
|
|
url = url.slice(2)
|
|
|
|
|
}
|
|
|
|
|
return url
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Album.prototype.sort = function (options) {
|
|
|
|
|
const sortAlbumsBy = getItemOrLast(options.sortAlbumsBy, this.depth)
|
|
|
|
|
const sortAlbumsDirection = getItemOrLast(options.sortAlbumsDirection, this.depth)
|
|
|
|
|