Skip to content

Commit

Permalink
🚧 Fix theme config: make theme
Browse files Browse the repository at this point in the history
  • Loading branch information
juzaweb committed Jun 23, 2021
1 parent 57b7f37 commit 0dd6631
Show file tree
Hide file tree
Showing 21 changed files with 44 additions and 310 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"files": [
"src/Core/Helpers/helpers.php",
"src/Plugin/helpers.php",
"src/Installer/Helpers/functions.php"
"src/Installer/Helpers/functions.php",
"src/Theme/Helpers/helpers.php"
]
},
"extra": {
Expand Down
174 changes: 0 additions & 174 deletions src/FileManager/config/filemanager2.php

This file was deleted.

File renamed without changes.
63 changes: 38 additions & 25 deletions src/Theme/Console/ThemeGeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ThemeGeneratorCommand extends Command
*
* @var string
*/
protected $signature = 'theme:make {name?}';
protected $signature = 'theme:make {name}';

/**
* The console command description.
Expand Down Expand Up @@ -87,18 +87,8 @@ public function __construct(Repository $config, File $files)
*/
public function handle()
{
$this->themePath = $this->config->get('theme.theme_path');
$this->themePath = $this->config->get('mymo.theme.path');
$this->theme['name'] = strtolower($this->argument('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 !!!');

return;
}
}

$this->init();
}

Expand All @@ -116,15 +106,11 @@ protected function init()
exit();
}

$this->consoleAsk();

$this->themeFolders = $this->config->get('theme.folders');
$this->themeStubPath = $this->config->get('theme.stubs.path');

$themeStubFiles = $this->config->get('theme.stubs.files');
$themeStubFiles['theme'] = $this->config->get('theme.config.name');
$themeStubFiles['changelog'] = $this->config->get('theme.config.changelog');

$this->themeFolders = $this->getThemeFolders();
$this->themeStubPath = $this->getThemeStubPath();
$themeStubFiles = $this->getThemeStubFiles();
$themeStubFiles['theme'] = 'theme.json';
$themeStubFiles['changelog'] = 'changelog.yml';
$this->makeDir($createdThemePath);

foreach ($this->themeFolders as $key => $folder) {
Expand All @@ -144,7 +130,6 @@ protected function init()
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'] ? '' : Str::title($this->theme['description']);

Expand Down Expand Up @@ -179,7 +164,7 @@ public function createStubs($themeStubFiles, $createdThemePath)
} elseif ($filename == 'css' || $filename == 'js') {
$this->theme[$filename] = ltrim(
$storePath,
rtrim($this->config->get('theme.folders.assets'), '/').'/'
rtrim('assets', '/').'/'
);
}
$themeStubFile = $this->themeStubPath.'/'.$filename.'.stub';
Expand Down Expand Up @@ -208,12 +193,12 @@ protected function makeDir($directory)
* @param string $storePath
*
* @return void
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
protected function makeFile($file, $storePath)
{
if ($this->files->exists($file)) {
$content = $this->replaceStubs($this->files->get($file));

$this->files->put($storePath, $content);
}
}
Expand Down Expand Up @@ -249,7 +234,35 @@ protected function replaceStubs($contents)
];

$replaceContents = str_replace($mainString, $replaceString, $contents);

return $replaceContents;
}

protected function getThemeStubPath()
{
return __DIR__ . '/../../../stubs/theme';
}

protected function getThemeStubFiles()
{
return [
'css' => 'assets/css/app.css',
'layout' => 'views/layouts/master.blade.php',
'page' => 'views/welcome.blade.php',
'lang' => 'lang/en/content.php',
];
}

protected function getThemeFolders()
{
return [
'assets' => 'assets',
'views' => 'views',
'lang' => 'lang',
'lang/en' => 'lang/en',
'css' => 'assets/css',
'js' => 'assets/js',
'img' => 'assets/images',
'layouts' => 'views/layouts',
];
}
}
2 changes: 1 addition & 1 deletion src/Theme/Exceptions/ThemeNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class ThemeNotFoundException extends NotFoundHttpException
{
public function __construct($themeName)
{
parent::__construct("Theme [ $themeName ] not found! Maybe you're missing a ".config('theme.config.name').' file.');
parent::__construct("Theme [{$themeName}] not found! Maybe you're missing a ".config('theme.config.name').' file.');
}
}
2 changes: 1 addition & 1 deletion src/Theme/Managers/Theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Mymo\Theme\Managers;

use Noodlehaus\Config;
use Illuminate\Config\Repository;
use Illuminate\Container\Container;
use Illuminate\Contracts\Translation\Translator;
use Illuminate\View\ViewFinderInterface;
use Noodlehaus\Config;
use Mymo\Theme\Contracts\ThemeContract;
use Mymo\Theme\Exceptions\ThemeNotFoundException;

Expand Down
24 changes: 0 additions & 24 deletions src/Theme/Middleware/RouteMiddleware.php

This file was deleted.

23 changes: 0 additions & 23 deletions src/Theme/Middleware/WebMiddleware.php

This file was deleted.

Loading

0 comments on commit 0dd6631

Please sign in to comment.