Skip to content

Commit

Permalink
Merge pull request #41 from jpagny/fix-bug
Browse files Browse the repository at this point in the history
Fix symlink, title_case bugs
  • Loading branch information
Shipu authored May 9, 2020
2 parents 42ffe52 + 2ff1ad9 commit ebf7b1d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
20 changes: 12 additions & 8 deletions src/Console/ThemeGeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Config\Repository;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem as File;
use Illuminate\Support\Str;

class ThemeGeneratorCommand extends Command
{
Expand Down Expand Up @@ -89,10 +90,11 @@ public function handle()
$this->themePath = $this->config->get('theme.theme_path');
$this->theme['name'] = strtolower($this->argument('name'));

if(empty($this->theme['name'])) {
if (empty($this->theme['name'])) {
$this->theme['name'] = $this->ask('What is your theme name?');
if(empty($this->theme['name'])) {
$this->error("Theme is not Generated, Theme name required !!!");
if (empty($this->theme['name'])) {
$this->error('Theme is not Generated, Theme name required !!!');

return;
}
}
Expand All @@ -101,7 +103,7 @@ public function handle()
}

/**
* Theme Initialize
* Theme Initialize.
*
* @return void
*/
Expand Down Expand Up @@ -143,10 +145,10 @@ public function consoleAsk()
$this->theme['title'] = $this->ask('What is theme title?');

$this->theme['description'] = $this->ask('What is theme description?', false);
$this->theme['description'] = !$this->theme['description'] ? '' : title_case($this->theme['description']);
$this->theme['description'] = !$this->theme['description'] ? '' : Str::title($this->theme['description']);

$this->theme['author'] = $this->ask('What is theme author name?', false);
$this->theme['author'] = !$this->theme['author'] ? '' : title_case($this->theme['author']);
$this->theme['author'] = !$this->theme['author'] ? '' : Str::title($this->theme['author']);

$this->theme['version'] = $this->ask('What is theme version?', false);
$this->theme['version'] = !$this->theme['version'] ? '1.0.0' : $this->theme['version'];
Expand Down Expand Up @@ -174,8 +176,10 @@ public function createStubs($themeStubFiles, $createdThemePath)
} elseif ($filename == 'theme') {
$filename = pathinfo($storePath, PATHINFO_EXTENSION);
} elseif ($filename == 'css' || $filename == 'js') {
$this->theme[$filename] = ltrim($storePath,
rtrim($this->config->get('theme.folders.assets'), '/').'/');
$this->theme[$filename] = ltrim(
$storePath,
rtrim($this->config->get('theme.folders.assets'), '/').'/'
);
}
$themeStubFile = $this->themeStubPath.'/'.$filename.'.stub';
$this->makeFile($themeStubFile, $createdThemePath.'/'.$storePath);
Expand Down
10 changes: 5 additions & 5 deletions src/Managers/Theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,17 @@ public function getFullPath($path)

$themeInfo = $this->getThemeInfo($themeName);

if ( $this->config[ 'theme.symlink' ] ) {
$themePath = 'Themes'. DIRECTORY_SEPARATOR . $themeName . DIRECTORY_SEPARATOR;
if ($this->config['theme.symlink']) {
$themePath = str_replace(base_path('public').DIRECTORY_SEPARATOR, '', $this->config['theme.symlink_path']).DIRECTORY_SEPARATOR.$themeName.DIRECTORY_SEPARATOR;
} else {
$themePath = str_replace(base_path('public') . DIRECTORY_SEPARATOR, '', $themeInfo->get('path')) . DIRECTORY_SEPARATOR;
$themePath = str_replace(base_path('public').DIRECTORY_SEPARATOR, '', $themeInfo->get('path')).DIRECTORY_SEPARATOR;
}

$assetPath = $this->config['theme.folders.assets'].DIRECTORY_SEPARATOR;
$fullPath = $themePath.$assetPath.$path;

if (!file_exists($fullPath) && $themeInfo->has('parent') && !empty($themeInfo->get('parent'))) {
$themePath = str_replace(base_path().DIRECTORY_SEPARATOR, '', $this->getThemeInfo($themeInfo->get('parent'))->get('path') ).DIRECTORY_SEPARATOR;
$themePath = str_replace(base_path().DIRECTORY_SEPARATOR, '', $this->getThemeInfo($themeInfo->get('parent'))->get('path')).DIRECTORY_SEPARATOR;
$fullPath = $themePath.$assetPath.$path;

return $fullPath;
Expand All @@ -226,7 +226,7 @@ public function getFullPath($path)
* Get the current theme path to a versioned Mix file.
*
* @param string $path
* @param string $manifestDirectory
* @param string $manifestDirectory
*
* @return \Illuminate\Support\HtmlString|string
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Providers/ThemevelServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ThemevelServiceProvider extends ServiceProvider
*/
public function boot()
{
if (!File::exists(public_path('Themes')) && config('theme.symlink') && File::exists(config('theme.theme_path'))) {
if (!File::exists(public_path('Themes')) && !File::exists(config('theme.symlink_path')) && config('theme.symlink') && File::exists(config('theme.theme_path'))) {
App::make('files')->link(config('theme.theme_path'), config('theme.symlink_path', public_path('Themes')));
}
}
Expand Down

0 comments on commit ebf7b1d

Please sign in to comment.