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:
@@ -323,6 +323,11 @@ class ImportHtmlTemplates extends Command
|
|||||||
if (str_starts_with($path, 'assets/')) {
|
if (str_starts_with($path, 'assets/')) {
|
||||||
$sourcePath = public_path('html/' . $path);
|
$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)) {
|
if (File::exists($sourcePath)) {
|
||||||
// Dosya adını ve klasörünü belirle
|
// Dosya adını ve klasörünü belirle
|
||||||
$fileName = basename($path);
|
$fileName = basename($path);
|
||||||
@@ -344,7 +349,7 @@ class ImportHtmlTemplates extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dosya bulunamadıysa eski usul devam et
|
// Dosya bulunamadıysa eski usul devam et
|
||||||
return '/html/' . $path;
|
return '/' . $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
|
// 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.
|
// 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('src="assets/', 'src="/assets/', $html);
|
||||||
$html = str_replace('href="assets/', 'href="/html/assets/', $html);
|
$html = str_replace('href="assets/', 'href="/assets/', $html);
|
||||||
$html = str_replace("src='assets/", "src='/html/assets/", $html);
|
$html = str_replace("src='assets/", "src='/assets/", $html);
|
||||||
$html = str_replace("href='assets/", "href='/html/assets/", $html);
|
$html = str_replace("href='assets/", "href='/assets/", $html);
|
||||||
$html = str_replace('url(assets/', 'url(/html/assets/', $html);
|
$html = str_replace('url(assets/', 'url(/assets/', $html);
|
||||||
$html = str_replace('url("assets/', 'url("/html/assets/', $html);
|
$html = str_replace('url("assets/', 'url("/assets/', $html);
|
||||||
$html = str_replace("url('assets/", "url('/html/assets/", $html);
|
$html = str_replace("url('assets/", "url('/assets/", $html);
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -641,6 +641,11 @@ class TemplateService
|
|||||||
if (str_starts_with($value, 'templates/')) {
|
if (str_starts_with($value, 'templates/')) {
|
||||||
return asset('storage/' . $value);
|
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
|
// If it's already using asset() or Storage::url(), assume it's already formatted
|
||||||
// Otherwise, prepend storage/ if it looks like a storage path
|
// Otherwise, prepend storage/ if it looks like a storage path
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ return [
|
|||||||
'column_deleted_at' => 'Deleted At',
|
'column_deleted_at' => 'Deleted At',
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
'action_preview' => 'Preview',
|
||||||
'create' => 'New Section Template',
|
'create' => 'New Section Template',
|
||||||
'edit' => 'Edit Section Template',
|
'edit' => 'Edit Section Template',
|
||||||
'view' => 'View Section Template',
|
'view' => 'View Section Template',
|
||||||
@@ -39,4 +40,3 @@ return [
|
|||||||
'deleted_successfully' => 'Section template deleted successfully.',
|
'deleted_successfully' => 'Section template deleted successfully.',
|
||||||
'restored_successfully' => 'Section template restored successfully.',
|
'restored_successfully' => 'Section template restored successfully.',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ return [
|
|||||||
'column_deleted_at' => 'Silinme',
|
'column_deleted_at' => 'Silinme',
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
'action_preview' => 'Önizleme',
|
||||||
'create' => 'Yeni Section Şablonu',
|
'create' => 'Yeni Section Şablonu',
|
||||||
'edit' => 'Section Şablonunu Düzenle',
|
'edit' => 'Section Şablonunu Düzenle',
|
||||||
'view' => 'Section Şablonunu Görüntüle',
|
'view' => 'Section Şablonunu Görüntüle',
|
||||||
@@ -39,4 +40,3 @@ return [
|
|||||||
'deleted_successfully' => 'Section şablonu başarıyla silindi.',
|
'deleted_successfully' => 'Section şablonu başarıyla silindi.',
|
||||||
'restored_successfully' => 'Section şablonu başarıyla geri yüklendi.',
|
'restored_successfully' => 'Section şablonu başarıyla geri yüklendi.',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user