simple-photo-gallery 2.0.11-rc.9 → 2.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,78 @@
1
+ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2
+ Upstream-Name: DejaVu fonts
3
+ Upstream-Author: Stepan Roh <src@users.sourceforge.net> (original author),
4
+ see /usr/share/doc/fonts-dejavu-core/AUTHORS for full list
5
+ Source: https://dejavu-fonts.github.io/
6
+
7
+ Files: *
8
+ Copyright: Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved.
9
+ Bitstream Vera is a trademark of Bitstream, Inc.
10
+ DejaVu changes are in public domain.
11
+ License: bitstream-vera
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of the fonts accompanying this license ("Fonts") and associated
14
+ documentation files (the "Font Software"), to reproduce and distribute the
15
+ Font Software, including without limitation the rights to use, copy, merge,
16
+ publish, distribute, and/or sell copies of the Font Software, and to permit
17
+ persons to whom the Font Software is furnished to do so, subject to the
18
+ following conditions:
19
+ .
20
+ The above copyright and trademark notices and this permission notice shall
21
+ be included in all copies of one or more of the Font Software typefaces.
22
+ .
23
+ The Font Software may be modified, altered, or added to, and in particular
24
+ the designs of glyphs or characters in the Fonts may be modified and
25
+ additional glyphs or characters may be added to the Fonts, only if the fonts
26
+ are renamed to names not containing either the words "Bitstream" or the word
27
+ "Vera".
28
+ .
29
+ This License becomes null and void to the extent applicable to Fonts or Font
30
+ Software that has been modified and is distributed under the "Bitstream
31
+ Vera" names.
32
+ .
33
+ The Font Software may be sold as part of a larger software package but no
34
+ copy of one or more of the Font Software typefaces may be sold by itself.
35
+ .
36
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
37
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
38
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
39
+ TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
40
+ FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
41
+ ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
42
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
43
+ THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
44
+ FONT SOFTWARE.
45
+ .
46
+ Except as contained in this notice, the names of Gnome, the Gnome
47
+ Foundation, and Bitstream Inc., shall not be used in advertising or
48
+ otherwise to promote the sale, use or other dealings in this Font Software
49
+ without prior written authorization from the Gnome Foundation or Bitstream
50
+ Inc., respectively. For further information, contact: fonts at gnome dot
51
+ org.
52
+
53
+ Files: debian/*
54
+ Copyright: (C) 2005-2006 Peter Cernak <pce@users.sourceforge.net>
55
+ (C) 2006-2011 Davide Viti <zinosat@tiscali.it>
56
+ (C) 2011-2013 Christian Perrier <bubulle@debian.org>
57
+ (C) 2013 Fabian Greffrath <fabian+debian@greffrath.com>
58
+ License: GPL-2+
59
+ This program is free software; you can redistribute it
60
+ and/or modify it under the terms of the GNU General Public
61
+ License as published by the Free Software Foundation; either
62
+ version 2 of the License, or (at your option) any later
63
+ version.
64
+ .
65
+ This program is distributed in the hope that it will be
66
+ useful, but WITHOUT ANY WARRANTY; without even the implied
67
+ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
68
+ PURPOSE. See the GNU General Public License for more
69
+ details.
70
+ .
71
+ You should have received a copy of the GNU General Public
72
+ License along with this package; if not, write to the Free
73
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor,
74
+ Boston, MA 02110-1301 USA
75
+ .
76
+ On Debian systems, the full text of the GNU General Public
77
+ License version 2 can be found in the file
78
+ /usr/share/common-licenses/GPL-2'.
package/dist/index.cjs CHANGED
@@ -1,13 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- var process3 = require('process');
4
+ var process4 = require('process');
5
5
  var commander = require('commander');
6
6
  var consola = require('consola');
7
7
  var child_process = require('child_process');
8
8
  var fs8 = require('fs');
9
9
  var path7 = require('path');
10
10
  var buffer = require('buffer');
11
+ var url = require('url');
11
12
  var sharp2 = require('sharp');
12
13
  var blurhash = require('blurhash');
13
14
  var common = require('@simple-photo-gallery/common');
@@ -21,7 +22,7 @@ var semverParser = require('semver-parser');
21
22
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
22
23
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
23
24
 
24
- var process3__default = /*#__PURE__*/_interopDefault(process3);
25
+ var process4__default = /*#__PURE__*/_interopDefault(process4);
25
26
  var fs8__default = /*#__PURE__*/_interopDefault(fs8);
26
27
  var path7__default = /*#__PURE__*/_interopDefault(path7);
27
28
  var sharp2__default = /*#__PURE__*/_interopDefault(sharp2);
@@ -91,7 +92,33 @@ async function generateBlurHash(imagePath, componentX = 4, componentY = 3) {
91
92
  }
92
93
 
93
94
  // src/modules/build/utils/index.ts
94
- path7__default.default.dirname(new URL((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname);
95
+ var __dirname$1 = path7__default.default.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
96
+ var SOCIAL_CARD_FONT_RELATIVE_PATH = path7__default.default.join("assets", "fonts", "dejavu", "DejaVuSans-Bold.ttf");
97
+ var socialCardFontBase64;
98
+ function resolveFromCurrentDir(...segments) {
99
+ return path7__default.default.resolve(__dirname$1, ...segments);
100
+ }
101
+ function findSocialCardFontPath() {
102
+ const fontCandidates = [
103
+ resolveFromCurrentDir("../../../../", SOCIAL_CARD_FONT_RELATIVE_PATH),
104
+ path7__default.default.resolve(__dirname$1, "../", SOCIAL_CARD_FONT_RELATIVE_PATH),
105
+ path7__default.default.resolve(process4__default.default.cwd(), SOCIAL_CARD_FONT_RELATIVE_PATH)
106
+ ];
107
+ for (const candidate of fontCandidates) {
108
+ if (fs8__default.default.existsSync(candidate)) {
109
+ return candidate;
110
+ }
111
+ }
112
+ throw new Error("Social media card font file not found");
113
+ }
114
+ function getSocialCardFontBase64() {
115
+ if (socialCardFontBase64) {
116
+ return socialCardFontBase64;
117
+ }
118
+ const fontPath = findSocialCardFontPath();
119
+ socialCardFontBase64 = fs8__default.default.readFileSync(fontPath).toString("base64");
120
+ return socialCardFontBase64;
121
+ }
95
122
  async function createGallerySocialMediaCardImage(headerPhotoPath, title, ouputPath, ui) {
96
123
  ui?.start(`Creating social media card image`);
97
124
  const headerBasename = path7__default.default.basename(headerPhotoPath, path7__default.default.extname(headerPhotoPath));
@@ -103,11 +130,18 @@ async function createGallerySocialMediaCardImage(headerPhotoPath, title, ouputPa
103
130
  const resizedImageBuffer = await image.resize(1200, 631, { fit: "cover" }).jpeg({ quality: 90 }).toBuffer();
104
131
  const outputPath = ouputPath;
105
132
  await sharp2__default.default(resizedImageBuffer).toFile(outputPath);
133
+ const fontBase64 = getSocialCardFontBase64();
106
134
  const svgText = `
107
135
  <svg width="1200" height="631" xmlns="http://www.w3.org/2000/svg">
108
136
  <defs>
109
137
  <style>
110
- .title { font-family: Arial, sans-serif; font-size: 96px; font-weight: bold; fill: white; stroke: black; stroke-width: 5; paint-order: stroke; text-anchor: middle; }
138
+ @font-face {
139
+ font-family: 'DejaVu Sans';
140
+ src: url('data:font/ttf;base64,${fontBase64}') format('truetype');
141
+ font-weight: 700;
142
+ font-style: normal;
143
+ }
144
+ .title { font-family: 'DejaVu Sans', Arial, sans-serif; font-size: 96px; font-weight: bold; fill: white; stroke: black; stroke-width: 5; paint-order: stroke; text-anchor: middle; }
111
145
  </style>
112
146
  </defs>
113
147
  <text x="600" y="250" class="title">${title}</text>
@@ -371,7 +405,7 @@ async function getGallerySettingsFromUser(galleryName, defaultImage, ui) {
371
405
  });
372
406
  return { title, description, url, headerImage };
373
407
  }
374
- async function createGalleryJson(mediaFiles, galleryJsonPath, scanPath, subGalleries = [], useDefaultSettings, ui) {
408
+ async function createGalleryJson(mediaFiles, galleryJsonPath, scanPath, subGalleries = [], useDefaultSettings, ctaBanner, ui) {
375
409
  const galleryDir = path7__default.default.dirname(galleryJsonPath);
376
410
  const isSameLocation = path7__default.default.relative(scanPath, path7__default.default.join(galleryDir, "..")) === "";
377
411
  const mediaBasePath = isSameLocation ? void 0 : scanPath;
@@ -393,7 +427,8 @@ async function createGalleryJson(mediaFiles, galleryJsonPath, scanPath, subGalle
393
427
  subGalleries: {
394
428
  title: "Sub Galleries",
395
429
  galleries: relativeSubGalleries
396
- }
430
+ },
431
+ ...ctaBanner !== void 0 && { ctaBanner }
397
432
  };
398
433
  if (!useDefaultSettings) {
399
434
  galleryData = {
@@ -417,7 +452,7 @@ async function galleryExists(outputPath) {
417
452
  return false;
418
453
  }
419
454
  }
420
- async function processDirectory(scanPath, outputPath, recursive, useDefaultSettings, force, ui) {
455
+ async function processDirectory(scanPath, outputPath, recursive, useDefaultSettings, force, ctaBanner, ui) {
421
456
  ui.start(`Scanning ${scanPath}`);
422
457
  let totalFiles = 0;
423
458
  let totalGalleries = 1;
@@ -432,6 +467,7 @@ async function processDirectory(scanPath, outputPath, recursive, useDefaultSetti
432
467
  recursive,
433
468
  useDefaultSettings,
434
469
  force,
470
+ ctaBanner,
435
471
  ui
436
472
  );
437
473
  totalFiles += result2.totalFiles;
@@ -457,7 +493,7 @@ async function processDirectory(scanPath, outputPath, recursive, useDefaultSetti
457
493
  }
458
494
  try {
459
495
  await fs8.promises.mkdir(galleryPath, { recursive: true });
460
- await createGalleryJson(mediaFiles, galleryJsonPath, scanPath, subGalleries, useDefaultSettings, ui);
496
+ await createGalleryJson(mediaFiles, galleryJsonPath, scanPath, subGalleries, useDefaultSettings, ctaBanner, ui);
461
497
  ui.success(
462
498
  `Create gallery with ${mediaFiles.length} files and ${subGalleries.length} subgalleries at: ${galleryJsonPath}`
463
499
  );
@@ -481,7 +517,15 @@ async function init(options, ui) {
481
517
  try {
482
518
  const scanPath = path7__default.default.resolve(options.photos);
483
519
  const outputPath = options.gallery ? path7__default.default.resolve(options.gallery) : scanPath;
484
- const result = await processDirectory(scanPath, outputPath, options.recursive, options.default, options.force, ui);
520
+ const result = await processDirectory(
521
+ scanPath,
522
+ outputPath,
523
+ options.recursive,
524
+ options.default,
525
+ options.force,
526
+ options.ctaBanner,
527
+ ui
528
+ );
485
529
  ui.box(
486
530
  `Created ${result.totalGalleries} ${result.totalGalleries === 1 ? "gallery" : "galleries"} with ${result.totalFiles} media ${result.totalFiles === 1 ? "file" : "files"}`
487
531
  );
@@ -675,6 +719,12 @@ async function processMediaFile(mediaFile, mediaBasePath, thumbnailsPath, thumbn
675
719
  if (updatedMediaFile.thumbnail) {
676
720
  updatedMediaFile.thumbnail.path = path7__default.default.basename(thumbnailPath);
677
721
  updatedMediaFile.thumbnail.pathRetina = path7__default.default.basename(thumbnailPathRetina);
722
+ if (mediaFile.thumbnail?.baseUrl) {
723
+ updatedMediaFile.thumbnail.baseUrl = mediaFile.thumbnail.baseUrl;
724
+ }
725
+ }
726
+ if (mediaFile.url) {
727
+ updatedMediaFile.url = mediaFile.url;
678
728
  }
679
729
  return updatedMediaFile;
680
730
  } catch (error) {
@@ -838,8 +888,8 @@ async function buildGallery(galleryDir, templateDir, scan, shouldCreateThumbnail
838
888
  }
839
889
  ui.debug("Building gallery from template");
840
890
  try {
841
- process3__default.default.env.GALLERY_JSON_PATH = galleryJsonPath;
842
- process3__default.default.env.GALLERY_OUTPUT_DIR = path7__default.default.join(galleryDir, "gallery");
891
+ process4__default.default.env.GALLERY_JSON_PATH = galleryJsonPath;
892
+ process4__default.default.env.GALLERY_OUTPUT_DIR = path7__default.default.join(galleryDir, "gallery");
843
893
  child_process.execSync("npx astro build", { cwd: templateDir, stdio: ui.level === consola.LogLevels.debug ? "inherit" : "ignore" });
844
894
  } catch (error) {
845
895
  ui.error(`Build failed for ${galleryDir}`);
@@ -963,7 +1013,7 @@ var ApiTelemetryClient = class {
963
1013
  axios__default.default.post(this.endpoint, event, {
964
1014
  headers: {
965
1015
  "content-type": "application/json",
966
- "user-agent": `simple-photo-gallery/${event.packageVersion} (${process3__default.default.platform}; ${process3__default.default.arch})`
1016
+ "user-agent": `simple-photo-gallery/${event.packageVersion} (${process4__default.default.platform}; ${process4__default.default.arch})`
967
1017
  }
968
1018
  });
969
1019
  } catch {
@@ -973,7 +1023,7 @@ var ApiTelemetryClient = class {
973
1023
  var ConsoleTelemetryClient = class {
974
1024
  async record(event) {
975
1025
  const serialized = JSON.stringify(event, null, 2);
976
- process3.stdout.write(`TELEMETRY EVENT: ${serialized}
1026
+ process4.stdout.write(`TELEMETRY EVENT: ${serialized}
977
1027
  `);
978
1028
  }
979
1029
  };
@@ -1000,11 +1050,11 @@ var TelemetryService = class {
1000
1050
  if (override) {
1001
1051
  return override === "1";
1002
1052
  }
1003
- if (process3__default.default.env.CI || process3__default.default.env.DO_NOT_TRACK) {
1053
+ if (process4__default.default.env.CI || process4__default.default.env.DO_NOT_TRACK) {
1004
1054
  return false;
1005
1055
  }
1006
- if (process3__default.default.env.SPG_TELEMETRY) {
1007
- return process3__default.default.env.SPG_TELEMETRY === "1";
1056
+ if (process4__default.default.env.SPG_TELEMETRY) {
1057
+ return process4__default.default.env.SPG_TELEMETRY === "1";
1008
1058
  }
1009
1059
  const stored = this.getStoredPreference();
1010
1060
  if (stored === void 0) {
@@ -1046,7 +1096,7 @@ var TelemetryService = class {
1046
1096
  durationMs: now - startedAt,
1047
1097
  packageName: this.packageName,
1048
1098
  packageVersion: this.packageVersion,
1049
- nodeVersion: process3__default.default.version,
1099
+ nodeVersion: process4__default.default.version,
1050
1100
  osPlatform: os__default.default.platform(),
1051
1101
  osRelease: os__default.default.release(),
1052
1102
  osArch: os__default.default.arch(),
@@ -1080,7 +1130,7 @@ var TelemetryService = class {
1080
1130
  /** Returns the telemetry client. */
1081
1131
  getClient() {
1082
1132
  if (!this.client) {
1083
- switch (process3__default.default.env.SPG_TELEMETRY_PROVIDER) {
1133
+ switch (process4__default.default.env.SPG_TELEMETRY_PROVIDER) {
1084
1134
  case "none": {
1085
1135
  this.client = void 0;
1086
1136
  break;
@@ -1172,7 +1222,7 @@ async function waitForUpdateCheck(checkPromise) {
1172
1222
  // package.json
1173
1223
  var package_default = {
1174
1224
  name: "simple-photo-gallery",
1175
- version: "2.0.11-rc.9"};
1225
+ version: "2.0.11"};
1176
1226
 
1177
1227
  // src/index.ts
1178
1228
  var program = new commander.Command();
@@ -1214,7 +1264,7 @@ function withCommandContext(handler) {
1214
1264
  } catch (error) {
1215
1265
  ui.debug(error);
1216
1266
  errorInfo = error instanceof Error ? { name: error.name, message: error.message } : { name: "UnknownError", message: String(error) };
1217
- process3__default.default.exitCode = 1;
1267
+ process4__default.default.exitCode = 1;
1218
1268
  }
1219
1269
  const updateInfo = await waitForUpdateCheck(updateCheckPromise);
1220
1270
  if (updateInfo) {
@@ -1236,14 +1286,14 @@ function withCommandContext(handler) {
1236
1286
  program.command("init").description("Initialize a gallery by scaning a folder for images and videos").option(
1237
1287
  "-p, --photos <path>",
1238
1288
  "Path to the folder where the photos are stored. Default: current working directory",
1239
- process3__default.default.cwd()
1289
+ process4__default.default.cwd()
1240
1290
  ).option(
1241
1291
  "-g, --gallery <path>",
1242
1292
  "Path to the directory where the gallery will be initialized. Default: same directory as the photos folder"
1243
- ).option("-r, --recursive", "Recursively create galleries from all photos subdirectories", false).option("-d, --default", "Use default gallery settings instead of asking the user", false).option("-f, --force", "Force override existing galleries without asking", false).action(withCommandContext((options, ui) => init(options, ui)));
1244
- program.command("thumbnails").description("Create thumbnails for all media files in the gallery").option("-g, --gallery <path>", "Path to the directory of the gallery. Default: current working directory", process3__default.default.cwd()).option("-r, --recursive", "Scan subdirectories recursively", false).action(withCommandContext((options, ui) => thumbnails(options, ui)));
1245
- program.command("build").description("Build the HTML gallery in the specified directory").option("-g, --gallery <path>", "Path to the directory of the gallery. Default: current working directory", process3__default.default.cwd()).option("-r, --recursive", "Scan subdirectories recursively", false).option("-b, --base-url <url>", "Base URL where the photos are hosted").option("-t, --thumbs-base-url <url>", "Base URL where the thumbnails are hosted").option("--no-thumbnails", "Skip creating thumbnails when building the gallery", true).option("--no-scan", "Do not scan for new photos when building the gallery", true).action(withCommandContext((options, ui) => build(options, ui)));
1246
- program.command("clean").description("Remove all gallery files and folders (index.html, gallery/)").option("-g, --gallery <path>", "Path to the directory of the gallery. Default: current working directory", process3__default.default.cwd()).option("-r, --recursive", "Clean subdirectories recursively", false).action(withCommandContext((options, ui) => clean(options, ui)));
1293
+ ).option("-r, --recursive", "Recursively create galleries from all photos subdirectories", false).option("-d, --default", "Use default gallery settings instead of asking the user", false).option("-f, --force", "Force override existing galleries without asking", false).option("--cta-banner", "Add a Simple Photo Gallery call-to-action banner to the end of the gallery", false).action(withCommandContext((options, ui) => init(options, ui)));
1294
+ program.command("thumbnails").description("Create thumbnails for all media files in the gallery").option("-g, --gallery <path>", "Path to the directory of the gallery. Default: current working directory", process4__default.default.cwd()).option("-r, --recursive", "Scan subdirectories recursively", false).action(withCommandContext((options, ui) => thumbnails(options, ui)));
1295
+ program.command("build").description("Build the HTML gallery in the specified directory").option("-g, --gallery <path>", "Path to the directory of the gallery. Default: current working directory", process4__default.default.cwd()).option("-r, --recursive", "Scan subdirectories recursively", false).option("-b, --base-url <url>", "Base URL where the photos are hosted").option("-t, --thumbs-base-url <url>", "Base URL where the thumbnails are hosted").option("--no-thumbnails", "Skip creating thumbnails when building the gallery", true).option("--no-scan", "Do not scan for new photos when building the gallery", true).action(withCommandContext((options, ui) => build(options, ui)));
1296
+ program.command("clean").description("Remove all gallery files and folders (index.html, gallery/)").option("-g, --gallery <path>", "Path to the directory of the gallery. Default: current working directory", process4__default.default.cwd()).option("-r, --recursive", "Clean subdirectories recursively", false).action(withCommandContext((options, ui) => clean(options, ui)));
1247
1297
  program.command("telemetry").description("Manage anonymous telemetry preferences. Use 1 to enable, 0 to disable, or no argument to check status").option("-s, --state <state>", "Enable (1) or disable (0) telemetry", parseTelemetryOption).action(withCommandContext((options, ui) => telemetry(options, ui, telemetryService)));
1248
1298
  program.parse();
1249
1299
  //# sourceMappingURL=index.cjs.map