Skip to content

Commit 8ea0554

Browse files
authored
Merge branch 'dev' into remotebuzzer/chroma-capture
2 parents d744c70 + 63c2b24 commit 8ea0554

File tree

7 files changed

+82
-27
lines changed

7 files changed

+82
-27
lines changed

admin/generator/index.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@
236236
justify-content: center;
237237
}
238238
</style>
239+
<style id="fontselectedStyle"></style>
239240
<div class="w-full flex items-center justify-center flex-col">
240241
<div class="w-full max-w-[1500px] rounded-lg p-4 md:p-8 bg-white flex flex-col shadow-xl place-items-center relative">
241242
<div class="w-full text-center flex flex-col items-center justify-center text-2xl font-bold text-brand-1 mb-2">
@@ -722,7 +723,7 @@
722723
<div id="collage_frame" class="absolute h-full w-full">
723724
<img class="h-full w-full hidden" src="" alt="Choose the frame">
724725
</div>
725-
<div id="collage_text" class="absolute h-full">
726+
<div id="collage_text" class="absolute h-full font-selected">
726727
<div class='relative'>
727728
<div class='absolute whitespace-nowrap origin-top-left text-line-1 leading-none'></div>
728729
<div class='absolute whitespace-nowrap origin-top-left text-line-2 leading-none'></div>

assets/js/admin/fontSelect.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// eslint-disable-next-line no-unused-vars
2-
function adminFontSelect(element, path) {
2+
function adminFontSelect(element, path, fontclass) {
33
const parent = element.closest('.adminFontSelection');
44
const origin = element.dataset.origin;
55
const src = element.src;
@@ -10,6 +10,7 @@ function adminFontSelect(element, path) {
1010
previewElement.src = src;
1111
textElement.textContent = origin;
1212
inputElement.value = origin;
13+
inputElement.setAttribute('data-fontclass', fontclass);
1314

1415
const event = new Event('change');
1516
inputElement.dispatchEvent(event);

assets/js/admin/generator.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ function loadCurrentConfig() {
103103
//text
104104
$('input[name=\'text_enabled\'][data-trigger=\'general\']').prop('checked', text_enabled);
105105
$('input[name=\'text_font_family\']').val(font_family);
106-
let fClass = $('input[name=\'text_font_family\']').data('fontclass');
106+
$('input[name=\'text_font_family\']')[0].setAttribute('data-fontclass', 'font-selected');
107107
$('#fontselectedStyle').html(
108-
`@font-face{font-family:"fontselected";src:url(${font_family}) format("truetype");} .${fClass}{font-family:"fontselected",Verdena,Tahoma;}`
108+
`@font-face{font-family:"fontselected";src:url(${font_family}) format("truetype");} .font-selected{font-family:"fontselected",Verdena,Tahoma;}`
109109
);
110110
$('input[name=\'text_font_color\']').attr('value', font_color);
111111
$('input[name=\'text_font_size\']').attr('value', font_size);
@@ -157,7 +157,7 @@ function changeGeneralSetting() {
157157
const c_show_background = $('input[name=\'show-background\'][data-trigger=\'general\']').is(':checked');
158158

159159
const c_text_enabled = $('input[name=\'text_enabled\'][data-trigger=\'general\']').is(':checked');
160-
let c_text_font = $('input[name=\'text_font_family\']').data('fontclass');
160+
let c_text_font = $('input[name=\'text_font_family\']')[0].getAttribute('data-fontclass');
161161
let c_text_font_unique_id = $('input[name=\'text_font_family\']').data('unique-id');
162162
let c_text_font_value = $('input[name=\'text_font_family\']').val();
163163
const c_font_color = $('input[name=\'text_font_color\']').val();
@@ -217,15 +217,15 @@ function changeGeneralSetting() {
217217
left: adjusted_tl + 'px'
218218
});
219219
if (c_text_font_value.startsWith('http')) {
220-
c_text_font = `customfont-${c_text_font_unique_id}`;
220+
c_text_font = `font-${c_text_font_unique_id}`;
221221
$('#fontselectedStyle').html(
222222
`@font-face{font-family:"fontselected";src:url(${c_text_font_value}) format("truetype");} .${c_text_font}{font-family:"fontselected",Verdena,Tahoma;}`
223223
);
224224
}
225225
collageTextDOM.removeClass((index, classes) =>
226226
classes
227227
.split(' ')
228-
.filter((cName) => cName.startsWith('customfont'))
228+
.filter((cName) => cName.startsWith('font-'))
229229
.join(' ')
230230
);
231231
collageTextDOM.addClass(c_text_font);

assets/js/sync-to-drive.js

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ if (process.platform === 'win32') {
2525

2626
class SyncToDrive {
2727
constructor() {
28+
this.validateRsync();
2829
this.config = this.fetchConfig();
2930
if (!this.config.synctodrive.enabled) {
3031
error('Sync to drive is disabled.');
@@ -47,6 +48,15 @@ class SyncToDrive {
4748
this.start();
4849
}
4950

51+
validateRsync() {
52+
try {
53+
execSync('command -v rsync', { stdio: 'ignore' });
54+
} catch (err) {
55+
log(err.message);
56+
error('Error: rsync is not installed. Please install it and try again.');
57+
}
58+
}
59+
5060
start() {
5161
try {
5262
const device = this.findDevice(this.driveName);
@@ -82,31 +92,51 @@ class SyncToDrive {
8292
throw new Error('Folder ' + this.source + ' does not exist!');
8393
}
8494

85-
log('Starting sync to USB drive ...');
86-
const distinationPath = path.join(device.mountpoint, this.destination);
87-
if (!fs.existsSync(distinationPath)) {
88-
log('Creating target directory' + distinationPath);
89-
fs.mkdirSync(distinationPath, { recursive: true });
95+
if (!device.mountpoint) {
96+
throw new Error('Error: USB device is not properly mounted.');
9097
}
9198

92-
log('Source data folder ' + this.source);
93-
log('Syncing to drive ' + device.path + ' -> ' + distinationPath);
99+
const destinationPath = path.join(device.mountpoint, this.destination);
100+
if (!fs.existsSync(destinationPath)) {
101+
log(`Creating target directory ${destinationPath}`);
102+
try {
103+
fs.mkdirSync(destinationPath, { recursive: true });
104+
} catch (err) {
105+
throw new Error(`Error: Failed to create directory ${destinationPath} - ${err.message}`);
106+
}
107+
}
108+
109+
if (!this.isWritable(destinationPath)) {
110+
throw new Error(`Error: Destination ${destinationPath} is not writable.`);
111+
}
94112

95113
const command = [
96114
'rsync',
97115
'-a',
98-
'--delete-before',
99116
'-b',
117+
'--delete-before',
100118
'--backup-dir=' + path.join(device.mountpoint, 'deleted'),
101119
'--ignore-existing',
102-
'--include=\'*.\'{jpg,chk,gif,mp4}',
120+
'--include=\'*.{jpg,chk,gif,mp4}\'',
103121
'--include=\'*/\'',
104122
'--exclude=\'*\'',
105123
'--prune-empty-dirs',
106124
this.source,
107-
path.join(device.mountpoint, this.destination)
125+
destinationPath
108126
].join(' ');
109-
log('Executing command "' + command + '"');
127+
128+
log('Validating rsync command...');
129+
try {
130+
execSync(command + ' --dry-run', { stdio: 'ignore' });
131+
// eslint-disable-next-line no-unused-vars
132+
} catch (err) {
133+
throw new Error('Error: Rsync validation failed. Check permissions and paths.');
134+
}
135+
136+
log('Starting sync to USB drive ...');
137+
log('Source data folder ' + this.source);
138+
log('Syncing to drive ' + device.path + ' -> ' + destinationPath);
139+
log(`Executing command: "${command}"`);
110140

111141
this.rsyncProcess = spawn(command, {
112142
shell: '/bin/bash'
@@ -118,8 +148,7 @@ class SyncToDrive {
118148
});
119149
this.rsyncProcess.on('exit', () => {
120150
this.rsyncProcess = null;
121-
log('Sync finished');
122-
log('Next run in ' + this.intervalInSeconds + 's');
151+
log('Sync finished. Next run in ' + this.intervalInSeconds + 's');
123152
setTimeout(() => {
124153
this.start();
125154
}, this.intervalInMilliseconds);
@@ -228,6 +257,16 @@ class SyncToDrive {
228257
this.stop();
229258
}
230259

260+
isWritable(directory) {
261+
try {
262+
fs.accessSync(directory, fs.constants.W_OK);
263+
return true;
264+
// eslint-disable-next-line no-unused-vars
265+
} catch (err) {
266+
return false;
267+
}
268+
}
269+
231270
fetchConfig() {
232271
try {
233272
const cmd = 'bin/photobooth photobooth:config:list json';

assets/sass/tailwind.admin.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@use '../../node_modules/tailwindcss';
22
@config "../../config/tailwind.admin.config.mjs";
3+
@custom-variant hover (&:hover);
34

45
body {
56
width: 100%;

chroma/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
?>
3232
<body class="gallery-mode--overlay ">
3333

34-
<?php include PathUtility::getAbsolutePath('template/components/preview.php'); ?>
3534
<?php include PathUtility::getAbsolutePath('template/components/chroma.canvas.php'); ?>
35+
<?php include PathUtility::getAbsolutePath('template/components/preview.php'); ?>
3636

3737
<div class="stage stage--chroma rotarygroup" data-stage="start">
3838
<div class="stage-inner">

src/Utility/AdminInput.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,13 @@ public static function renderFontSelect(array $setting, string $label): string
347347
$languageService = LanguageService::getInstance();
348348
$fonts = '';
349349

350+
$attributes = '';
351+
if (isset($setting['attributes'])) {
352+
foreach ($setting['attributes'] as $key => $prop) {
353+
$attributes .= $key . '="' . $prop . '" ';
354+
}
355+
}
356+
350357
if (isset($setting['paths']) && is_array($setting['paths'])) {
351358
$pathIndex = 0;
352359
foreach ($setting['paths'] as $path) {
@@ -355,6 +362,7 @@ public static function renderFontSelect(array $setting, string $label): string
355362
<h2 class="font-bold">' . PathUtility::getPublicPath($path) . '</h2>
356363
</div>
357364
';
365+
$fontClassName = 'font-' . $pathIndex;
358366
try {
359367
$files = FontUtility::getFontsFromPath($path, false);
360368
$files = array_map(fn ($file): string => PathUtility::getPublicPath($file), $files);
@@ -365,14 +373,18 @@ public static function renderFontSelect(array $setting, string $label): string
365373
</div>
366374
';
367375
}
368-
foreach ($files as $file) {
376+
$fontIndex = 0;
377+
foreach ($files as $name => $path) {
378+
$fontClassName .= '-' . $fontIndex;
369379
$imageAttributes = [
370-
'onClick' => 'adminFontSelect(this, "' . $setting['name'] . '");',
371-
'data-origin' => $file,
372-
'title' => $file,
373-
'class' => 'w-full h-full left-0 top-0 absolute object-contain cursor-pointer'
380+
'onClick' => 'adminFontSelect(this, "' . $setting['name'] . '", "' . $fontClassName . '");',
381+
'data-origin' => $path,
382+
'title' => $name,
383+
'class' => 'w-full h-full left-0 top-0 absolute object-contain cursor-pointer',
374384
];
375-
$fonts .= '<div class="w-full relative h-0 pb-2/3">' . FontUtility::getFontPreviewImage(fontPath: $file, attributes: $imageAttributes) . '</div>';
385+
$fonts .= '<style>.' . $fontClassName . ' {font-family:"' . $name . '"}</style>';
386+
$fonts .= '<div class="w-full relative h-0 pb-2/3">' . FontUtility::getFontPreviewImage(fontPath: $path, attributes: $imageAttributes) . '</div>';
387+
$fontIndex++;
376388
}
377389
} catch (\Exception $e) {
378390
$fonts .= '
@@ -428,6 +440,7 @@ public static function renderFontSelect(array $setting, string $label): string
428440
class="w-full h-10 border-2 border-solid border-gray-300 focus:border-brand-1 rounded-md px-3 mt-auto"
429441
name="' . $setting['name'] . '"
430442
value="' . $setting['value'] . '"
443+
' . $attributes . '
431444
/>
432445
</div>
433446
';

0 commit comments

Comments
 (0)