Skip to content

Commit

Permalink
added angular ng:directive generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Jad Joubran committed Aug 14, 2015
1 parent a7e043f commit 2b3b58a
Show file tree
Hide file tree
Showing 16 changed files with 146 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

### v2.7.4
+ New angular/directives folder
+ **artisan ng:directive name** generator

### v2.7.3
+ New demo page for Elixir
+ New demo page: Rest API
Expand Down
11 changes: 6 additions & 5 deletions angular/app/generators/generators.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ <h2>
</md-toolbar>

<section class="language-markup">
<pre><code class="line-numbers language-* language-bash">artisan ng:feature name #New feature inside angular/app/
artisan ng:dialog name #New custom dialog inside angular/dialogs/
artisan ng:service name #New service inside angular/services/
artisan ng:filter name #New filter inside angular/filters/
artisan ng:config name #New config inside angular/config/</code></pre>
<pre><code class="line-numbers language-* language-bash">artisan ng:feature name #New feature inside angular/app/
artisan ng:dialog name #New custom dialog inside angular/dialogs/
artisan ng:directive name #New directive inside angular/directives/
artisan ng:service name #New service inside angular/services/
artisan ng:filter name #New filter inside angular/filters/
artisan ng:config name #New config inside angular/config/</code></pre>
</section>
<div class="PageText">
Do <strong>not</strong> append the words Service, Controller or Ctrl.<br>
Expand Down
Empty file.
17 changes: 17 additions & 0 deletions angular/directives/data_listing/data_listing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(function(){
"use strict";

angular.module('app.directives').directive( 'DataListing', function() {

return {
restrict: 'EA',
templateUrl: 'views/directives/data_listing/data_listing.html',
controller: 'DataListingCtrl',
link: function( $scope, element, $attrs ){
//
}
};

});

})();
Empty file.
8 changes: 8 additions & 0 deletions angular/directives/data_listing/definition.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(function(){
"use strict";

angular.module( 'app.controllers' ).controller( 'DataListingCtrl', function(){
//
});

})();
77 changes: 77 additions & 0 deletions app/Console/Commands/AngularDirective.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use File;

class AngularDirective extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'ng:directive {name}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new directive folder with sample HTML, JS & LESS inside the angular/directives folder.';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$name = $this->argument('name');
$studly_name = studly_case($name);

$html = file_get_contents(__DIR__.'/Stubs/AngularDirective/directive.html.stub');
$js = file_get_contents(__DIR__.'/Stubs/AngularDirective/directive.js.stub');
$definition = file_get_contents(__DIR__.'/Stubs/AngularDirective/definition.js.stub');
$less = file_get_contents(__DIR__.'/Stubs/AngularDirective/directive.less.stub');

$js = str_replace('{{StudlyName}}', $studly_name, $js);
$definition = str_replace('{{StudlyName}}', $studly_name, $definition);
$definition = str_replace('{{name}}', $name, $definition);

$folder = __DIR__.'/../../../angular/directives/'.$name;
if (is_dir($folder)) {
$this->info('Folder already exists');

return false;
}

//create folder
File::makeDirectory($folder, 0775, true);

//create view (.html)
File::put($folder.'/'.$name.'.html', $html);

//create definition (.js)
File::put($folder.'/definition.js', $js);

//create controller (.js)
File::put($folder.'/'.$name.'.js', $definition);

//create less file (.less)
File::put($folder.'/'.$name.'.less', $less);

$this->info('Directive created successfully.');
}
}
17 changes: 17 additions & 0 deletions app/Console/Commands/Stubs/AngularDirective/definition.js.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(function(){
"use strict";

angular.module('app.directives').directive( '{{StudlyName}}', function() {

return {
restrict: 'EA',
templateUrl: 'views/directives/{{name}}/{{name}}.html',
controller: '{{StudlyName}}Ctrl',
link: function( $scope, element, $attrs ){
//
}
};

});

})();
Empty file.
8 changes: 8 additions & 0 deletions app/Console/Commands/Stubs/AngularDirective/directive.js.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(function(){
"use strict";

angular.module( 'app.controllers' ).controller( '{{StudlyName}}Ctrl', function(){
//
});

})();
Empty file.
1 change: 1 addition & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Kernel extends ConsoleKernel
'App\Console\Commands\Inspire',
'App\Console\Commands\AngularFeature',
'App\Console\Commands\AngularDialog',
'App\Console\Commands\AngularDirective',
'App\Console\Commands\AngularService',
'App\Console\Commands\AngularFilter',
'App\Console\Commands\AngularConfig',
Expand Down
2 changes: 1 addition & 1 deletion public/js/app.js

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions public/views/app/generators/generators.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ <h2>
</md-toolbar>

<section class="language-markup">
<pre><code class="line-numbers language-* language-bash">artisan ng:feature name #New feature inside angular/app/
artisan ng:dialog name #New custom dialog inside angular/dialogs/
artisan ng:service name #New service inside angular/services/
artisan ng:filter name #New filter inside angular/filters/
artisan ng:config name #New config inside angular/config/</code></pre>
<pre><code class="line-numbers language-* language-bash">artisan ng:feature name #New feature inside angular/app/
artisan ng:dialog name #New custom dialog inside angular/dialogs/
artisan ng:directive name #New directive inside angular/directives/
artisan ng:service name #New service inside angular/services/
artisan ng:filter name #New filter inside angular/filters/
artisan ng:config name #New config inside angular/config/</code></pre>
</section>
<div class="PageText">
Do <strong>not</strong> append the words Service, Controller or Ctrl.<br>
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ Open a new issue, I'd love to help.
## Planned features


- Make sure that all features have been documented (jshint, jscs)
- Migrate to open source hosting + remove composer.lock properly from pre-commit
- Make sure that all features have been documented
- jwt auth example (with database) + route authentication + documentation page
- Demo pages Design Review
- make gulp --production part of the automated release + remove sourcemaps
Expand Down

0 comments on commit 2b3b58a

Please sign in to comment.