asset moving for themes fixed, settings save patch

When testing themes, the script wasn't moving all assets that were in
subdirectories of the theme css folder, so that's been fixed so it moves
everything when testing a theme and rendering the site

there was also an issue with saving settings options because the script
was referencing email data that was no longer being provided from the
front end, so it was erroring out trying to save it. those references
have been removed so it's smooth sailing
This commit is contained in:
ro 2024-06-25 15:33:42 -06:00
parent 7d78476870
commit 37120efe18
No known key found for this signature in database
GPG key ID: 29B551CDBD4D3B50
6 changed files with 45 additions and 33 deletions

View file

@ -55,3 +55,22 @@ function randomString(int $length)
return $string; return $string;
} }
function delete_directory($dirPath)
{
if (is_dir($dirPath)) {
$objects = new DirectoryIterator($dirPath);
foreach ($objects as $object) {
if (!$object->isDot()) {
if ($object->isDir()) {
delete_directory($object->getPathname());
} else {
unlink($object->getPathname());
}
}
}
rmdir($dirPath);
} else {
throw new Exception(__FUNCTION__ . '(dirPath): dirPath is not a directory!');
}
}

View file

@ -56,8 +56,9 @@ class ThemeController extends Controller
$view == 'index' ? $view == 'index' ?
$template = $currentTheme . '.index' : $template = $currentTheme . '.index' :
$template = $currentTheme . '.page'; $template = $currentTheme . '.page';
$page = $this->pages->getById('F4429D34-25E7-4CA9-9B0A-742810277505'); //TODO: Get rid of hard link page IDS
$pageData = $this->sort->page($page); $page = $this->pages->getById('F791DED9-0359-4662-8976-4C474803D2C6');
$pageData = $this->sort->page($page);
break; break;
case "tags": case "tags":
$template = $currentTheme . '.tags'; $template = $currentTheme . '.tags';
@ -69,8 +70,8 @@ class ThemeController extends Controller
$pageData = $this->sort->archive(); $pageData = $this->sort->archive();
break; break;
default: default:
$template = $currentTheme . '.' . $view; $template = $currentTheme . '.index';
$page = $this->pages->getById('F4429D34-25E7-4CA9-9B0A-742810277505'); $page = $this->pages->getById('F791DED9-0359-4662-8976-4C474803D2C6');
$pageData = $this->sort->page($page); $pageData = $this->sort->page($page);
} }
if ($this->member::status()) { if ($this->member::status()) {

View file

@ -54,10 +54,12 @@ class MemberRepository implements MemberRepositoryInterface
public function update($member) public function update($member)
{ {
$index = findIndex($this->folks, ['id' => $member->id]); $index = findIndex($this->folks, ['id' => $member->id]);
$this->folks[$index]['handle'] = $member->handle; $this->folks[$index]['handle'] = $member->handle;
$this->folks[$index]['email'] = $member->email; $this->folks[$index]['email'] = $member->email;
$this->folks[$index]['avatar'] = $member->avatar; if (isset($member->avatar)) {
$this->folks[$index]['avatar'] = $member->avatar;
}
$this->folks[$index]['updated'] = Carbon::now(); $this->folks[$index]['updated'] = Carbon::now();
//save new folks file //save new folks file
$this->docs::writeSettings($this->folks, env('FOLKS_PATH')); $this->docs::writeSettings($this->folks, env('FOLKS_PATH'));

View file

@ -60,7 +60,6 @@ class AssetService
} else { } else {
//image is already there, so chill //image is already there, so chill
} }
//print $file->getFilename() . "\n";
} }
//clear test theme css and script directories //clear test theme css and script directories
$styles = glob($cssPath . '*'); // get all file names $styles = glob($cssPath . '*'); // get all file names
@ -85,6 +84,13 @@ class AssetService
if (is_file($file)) { if (is_file($file)) {
$path = explode('/', $file); $path = explode('/', $file);
copy($file, $cssPath . $path[6]); copy($file, $cssPath . $path[6]);
} else {
// if there is a type/font folder, move it
$typePath = explode('/', $file);
if (is_dir($cssPath . $typePath[6])) {
delete_directory($cssPath . $typePath[6]);
}
rename($file, $cssPath . $typePath[6]);
} }
} }
$newjs = glob('../content/themes/' . $this->currentTheme . '/assets/scripts/*'); $newjs = glob('../content/themes/' . $this->currentTheme . '/assets/scripts/*');

View file

@ -122,13 +122,9 @@ class SettingsService
$settings['global']['externalAPI'] = $data->global->externalAPI; $settings['global']['externalAPI'] = $data->global->externalAPI;
$settings['global']['dynamicRender'] = $data->global->dynamicRender; $settings['global']['dynamicRender'] = $data->global->dynamicRender;
//TODO: This is for to be created MemberServices //$settings['email']['active'] = $data->email->active;
//Member::updateData('handle', $data['member']['handle']); //$settings['email']['smtp'] = $data->email->smtp;
//Member::updateData('email', $data['member']['email']); //$settings['email']['mailgun'] = $data->email->mailgun;
$settings['email']['active'] = $data->email->active;
$settings['email']['smtp'] = $data->email->smtp;
$settings['email']['mailgun'] = $data->email->mailgun;
return $this->docs::writeSettings($settings); return $this->docs::writeSettings($settings);
} }

View file

@ -21,11 +21,11 @@ export default class SettingsActions {
.replace(/"/g, ''); .replace(/"/g, '');
let selected = ''; let selected = '';
let selects = document.querySelectorAll('.theme-select'); let selects = document.querySelectorAll('.theme-select');
let smtpDomain = document.getElementById('smtp-domain').value; //let smtpDomain = document.getElementById('smtp-domain').value;
let smtpEmail = document.getElementById('smtp-email').value; //let smtpEmail = document.getElementById('smtp-email').value;
let smtpPass = document.getElementById('smtp-pass').value; //let smtpPass = document.getElementById('smtp-pass').value;
let mgDomain = document.getElementById('mg-domain').value; //let mgDomain = document.getElementById('mg-domain').value;
let mgKey = document.getElementById('mg-key').value; //let mgKey = document.getElementById('mg-key').value;
let mailActive = ''; let mailActive = '';
let mailOptions = document.querySelectorAll('.mail-option'); let mailOptions = document.querySelectorAll('.mail-option');
let apiStatus = document let apiStatus = document
@ -60,18 +60,6 @@ export default class SettingsActions {
handle: handle, handle: handle,
email: email, email: email,
id: memberID id: memberID
},
email: {
active: mailActive,
smtp: {
domain: smtpDomain,
email: smtpEmail,
password: smtpPass
},
mailgun: {
domain: mgDomain,
key: mgKey
}
} }
}; };
return new Promise(function (resolve) { return new Promise(function (resolve) {