Skip to content

Commit

Permalink
Merge pull request #17 from yaapis/dev
Browse files Browse the repository at this point in the history
Theme 4.0
  • Loading branch information
yaapis authored Sep 29, 2019
2 parents b79e2ea + 6462538 commit c92357c
Show file tree
Hide file tree
Showing 20 changed files with 157 additions and 171 deletions.
1 change: 1 addition & 0 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
composer.phar
composer.lock
.DS_Store
.idea
56 changes: 32 additions & 24 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ composer require yaap/theme
Or manually add

~~~json
"yaap/theme": "3.*"
"yaap/theme": "4.*"
~~~


Expand All @@ -30,7 +30,7 @@ php artisan vendor:publish --provider="YAAP\Theme\ThemeServiceProvider"
~~~php
return array(
'path' => base_path('resources/themes'),
'assets_path' => 'assets/themes',
'assets_path' => 'themes',
);
~~~

Expand All @@ -40,7 +40,7 @@ php artisan vendor:publish --provider="YAAP\Theme\ThemeServiceProvider"
~~~php
return array(
'name' => 'default',
'inherit' => null,
'inherit' => null,
);
~~~

Expand All @@ -51,25 +51,24 @@ php artisan vendor:publish --provider="YAAP\Theme\ThemeServiceProvider"
### Structure

```
├── resources/
└── themes/
├── default/
| ├── layouts/
├── partials/
├── views/
| └── hello.blade.php
└── config.php
└── admin/
├── themes/
├── default/
| ├── assets/
├── lang/
├── layouts/
├── partials/
├── views/
| └── hello.blade.php
└── config.php
└── admin/
├── views/
| ├── emails/
| | └── notify.blade.php
| └── hello.blade.php
|
└── lang/
├── public/assets/
├── public/
└── themes/
└── default/
├── css/
Expand All @@ -86,6 +85,12 @@ The first time you have to create theme "default" structure, using the artisan c
php artisan theme:create default
~~~

In order to seed webpack.mix.js with custom rules add --with-mix option

~~~bash
php artisan theme:create default --with-mix
~~~

To delete an existing theme, use the command:

~~~bash
Expand All @@ -99,8 +104,11 @@ Theme::init($name)
~~~

This will add to views find path:
* resources/themes/{$name}
* resources/themes/{$name}/views
* themes/{$name}
* themes/{$name}/views

Lang files will be added as well:
* themes/{$name}/lang

### Making view

Expand All @@ -110,15 +118,15 @@ View::make('emails.notify');
~~~

### Assets
Assets can be nested too.
Asset url can be automatically with version.
Use laravel mix for assets.

~~~css
<link rel="stylesheet" href="{{ Theme::asset('css/styles.css', null, true) }}"/>
<link rel="stylesheet" href="{{ Theme::asset('css/ie.css', null, 'v1') }}"/>
<link rel="stylesheet" href="{{ mix('/themes/default/css/app.min.css') }}"/>
~~~

The first one will get version from `filemtime`, the second one - from params
~~~js
<script type="text/javascript" src="{{ mix('/themes/default/js/app.min.js') }}"></script>
~~~


###Blade templates
Expand Down Expand Up @@ -151,4 +159,4 @@ We will be happy to work with you! Other [work we’ve done](https://hexide-digi
Stay up to date with the latest Vuestic news! Follow us on [LinkedIn](https://www.linkedin.com/company/hexide-digital) or [Facebook](https://www.facebook.com/hexide.digital)

## License
[MIT](https://github.com/epicmaxco/vuestic-admin/blob/master/LICENSE) license.
[MIT](https://github.com/epicmaxco/vuestic-admin/blob/master/LICENSE) license.
6 changes: 3 additions & 3 deletions src/YAAP/Theme/Commands/ThemeDestroyCommand.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function handle()
*/
protected function getPath($path)
{
$rootPath = $this->config->get('theme::path', base_path('resources/themes'));
$rootPath = $this->config->get('theme::path', base_path('themes'));

return $rootPath.'/'.strtolower($this->getTheme()).'/' . $path;
}
Expand All @@ -104,7 +104,7 @@ protected function getPath($path)
*/
protected function getAssetsPath($path, $absolute = true)
{
$rootPath = $this->config->get('theme::assets_path', 'assets/themes');
$rootPath = $this->config->get('theme::assets_path', 'themes');

if ($absolute)
$rootPath = public_path($rootPath);
Expand Down Expand Up @@ -134,4 +134,4 @@ protected function getArguments()
);
}

}
}
59 changes: 47 additions & 12 deletions src/YAAP/Theme/Commands/ThemeGeneratorCommand.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class ThemeGeneratorCommand extends Command {
*
* @var string
*/
protected $name = 'theme:create';

protected $signature = 'theme:create
{name : A name of the new theme}
{--with-mix : Seed webpack.mix.js with themes specific}';

/**
* The console command description.
Expand Down Expand Up @@ -76,27 +79,59 @@ public function handle()
$this->makeDir($this->getPath($container['partial']));
$this->makeDir($this->getPath($container['view']));

$this->makeFile($container['layout'].'/master.blade.php', $this->getTemplate('layout.blade'));
$this->makeFile($container['partial'].'/header.blade.php', $this->getTemplate('header.blade'));
$this->makeFile($container['partial'].'/footer.blade.php', $this->getTemplate('footer.blade'));
$this->makeFile($container['view'].'/hello.blade.php', $this->getTemplate('view.blade'));

$this->makeFile($container['layout'].'/master.blade.php', $this->getTemplate('layout.blade.php'));
$this->makeFile($container['partial'].'/header.blade.php', $this->getTemplate('header.blade.php'));
$this->makeFile($container['partial'].'/footer.blade.php', $this->getTemplate('footer.blade.php'));
$this->makeFile($container['view'].'/hello.blade.php', $this->getTemplate('view.blade.php'));


//lang
$this->makeDir($this->getPath($container['lang']));
$this->makeDir($this->getPath($container['lang'].'/en'));
$this->makeFile($container['lang'].'/en/labels.php', $this->getTemplate('lang.php'));

// frontend sources
$this->makeDir($this->getPath($container['assets']));
//sass
$this->makeDir($this->getPath($container['assets'].'/sass'));
$this->makeFile($container['assets'].'/sass/_variables.scss', $this->getTemplate('_variables.scss'));
$this->makeFile($container['assets'].'/sass/app.scss', $this->getTemplate('app.scss'));

//js
$this->makeDir($this->getPath($container['assets'].'/js'));
$this->makeFile($container['assets'].'/js/app.js', $this->getTemplate('app.js'));

// img
$this->makeDir($this->getPath($container['assets'].'/img'));
$this->makeFile($container['assets'].'/img/favicon.png', $this->getTemplate('favicon.png'));

//assets
// fonts
$this->makeDir($this->getPath($container['assets'].'/fonts'));

//public assets
$this->makeDir($this->getAssetsPath('css'));
$this->makeAssetsFile('css/.gitkeep', '');
$this->makeAssetsFile('css/styles.css', $this->getTemplate('styles.css'));

$this->makeDir($this->getAssetsPath('js'));
$this->makeAssetsFile('js/.gitkeep', '');

$this->makeDir($this->getAssetsPath('img'));
$this->makeAssetsFile('img/.gitkeep', '');

$this->makeDir($this->getAssetsPath('fonts'));
$this->makeAssetsFile('fonts/.gitkeep', '');


// Generate inside config.
$this->makeFile('config.php', $this->getTemplate('config', ['%theme_name%' => $this->getTheme()]));
$this->makeFile('config.php', $this->getTemplate('config.php', ['%theme_name%' => $this->getTheme()]));

// mix
$withMix = $this->option('with-mix');
if ($withMix) {
$this->info('Seeding webpack.mix.js');
$this->files->append(base_path('webpack.mix.js'), $this->getTemplate('mix.js', ['%theme_name%' => $this->getTheme()]));
}

$this->info('Theme "'.$this->getTheme().'" has been created.');
}
Expand Down Expand Up @@ -154,7 +189,7 @@ protected function makeAssetsFile($file, $template = null)
*/
protected function getPath($path)
{
$rootPath = $this->config->get('theme.path', base_path('resources/themes'));
$rootPath = $this->config->get('theme.path', base_path('themes'));

return $rootPath.'/'.strtolower($this->getTheme()).'/' . $path;
}
Expand All @@ -168,7 +203,7 @@ protected function getPath($path)
*/
protected function getAssetsPath($path, $absolute = true)
{
$rootPath = $this->config->get('theme.assets_path', 'assets/themes');
$rootPath = $this->config->get('theme.assets_path', 'themes');

if ($absolute)
$rootPath = public_path($rootPath);
Expand Down Expand Up @@ -196,7 +231,7 @@ protected function getTheme()
protected function getTemplate($template, $replacements = array())
{

$path = realpath(__DIR__ . '/../templates/' . $template . '.txt');
$path = realpath(__DIR__ . '/../templates/' . $template);

$content = $this->files->get($path);

Expand All @@ -220,4 +255,4 @@ protected function getArguments()
}


}
}
Loading

0 comments on commit c92357c

Please sign in to comment.