Improve Asset Path Handling and Add Preview Action: Enhanced the ImportHtmlTemplates command to support fallback asset paths for better template import functionality. Updated the TemplateService to handle old asset paths. Added a preview action in the SectionTemplates localization files for improved user experience in template management.

This commit is contained in:
Ümit Tunç
2025-12-27 09:45:10 +03:00
parent f609eb3ec1
commit 537e2769cd
4 changed files with 20 additions and 10 deletions
+13 -8
View File
@@ -323,6 +323,11 @@ class ImportHtmlTemplates extends Command
if (str_starts_with($path, 'assets/')) {
$sourcePath = public_path('html/' . $path);
// Eğer html/assets altında yoksa, ana assets klasörüne bak
if (!File::exists($sourcePath)) {
$sourcePath = public_path($path);
}
if (File::exists($sourcePath)) {
// Dosya adını ve klasörünü belirle
$fileName = basename($path);
@@ -344,7 +349,7 @@ class ImportHtmlTemplates extends Command
}
// Dosya bulunamadıysa eski usul devam et
return '/html/' . $path;
return '/' . $path;
}
return $path;
@@ -361,13 +366,13 @@ class ImportHtmlTemplates extends Command
// CSS içindeki url('assets/...') kısımlarını yakalamak için daha genel bir yaklaşım
// Ancak processNode zaten img taglerini hallettiği için burası sadece kalanlar için.
$html = str_replace('src="assets/', 'src="/html/assets/', $html);
$html = str_replace('href="assets/', 'href="/html/assets/', $html);
$html = str_replace("src='assets/", "src='/html/assets/", $html);
$html = str_replace("href='assets/", "href='/html/assets/", $html);
$html = str_replace('url(assets/', 'url(/html/assets/', $html);
$html = str_replace('url("assets/', 'url("/html/assets/', $html);
$html = str_replace("url('assets/", "url('/html/assets/", $html);
$html = str_replace('src="assets/', 'src="/assets/', $html);
$html = str_replace('href="assets/', 'href="/assets/', $html);
$html = str_replace("src='assets/", "src='/assets/", $html);
$html = str_replace("href='assets/", "href='/assets/", $html);
$html = str_replace('url(assets/', 'url(/assets/', $html);
$html = str_replace('url("assets/', 'url("/assets/', $html);
$html = str_replace("url('assets/", "url('/assets/", $html);
return $html;
}
+5
View File
@@ -641,6 +641,11 @@ class TemplateService
if (str_starts_with($value, 'templates/')) {
return asset('storage/' . $value);
}
// Support for old assets/ path (if import not run)
if (str_starts_with($value, 'assets/')) {
return asset($value);
}
// If it's already using asset() or Storage::url(), assume it's already formatted
// Otherwise, prepend storage/ if it looks like a storage path
+1 -1
View File
@@ -26,6 +26,7 @@ return [
'column_deleted_at' => 'Deleted At',
// Actions
'action_preview' => 'Preview',
'create' => 'New Section Template',
'edit' => 'Edit Section Template',
'view' => 'View Section Template',
@@ -39,4 +40,3 @@ return [
'deleted_successfully' => 'Section template deleted successfully.',
'restored_successfully' => 'Section template restored successfully.',
];
+1 -1
View File
@@ -26,6 +26,7 @@ return [
'column_deleted_at' => 'Silinme',
// Actions
'action_preview' => 'Önizleme',
'create' => 'Yeni Section Şablonu',
'edit' => 'Section Şablonunu Düzenle',
'view' => 'Section Şablonunu Görüntüle',
@@ -39,4 +40,3 @@ return [
'deleted_successfully' => 'Section şablonu başarıyla silindi.',
'restored_successfully' => 'Section şablonu başarıyla geri yüklendi.',
];