Skip to content

Commit

Permalink
Some updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Arbeit authored and Arbeit committed Feb 10, 2018
1 parent 6cae562 commit 8ffe6ce
Show file tree
Hide file tree
Showing 18 changed files with 6,492 additions and 4,600 deletions.
Binary file modified .DS_Store
Binary file not shown.
24 changes: 22 additions & 2 deletions src/Book.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ public function bundles()
}
public function bundle($type)
{
return $this->bundles()->where('type', $type);
return $this->bundles()->where('type', $type);
}
public function bundleSingle($type)
{
return $this->bundles()->where('type', $type)->first();
return $this->bundles()->where('type', $type)->first();
}


Expand Down Expand Up @@ -114,6 +114,26 @@ public function content()
return $HTMLContent;
}

public function getContentAttribute()
{
$uri = static::$storageName . '/' . $this->loc . '/main.md';
if ( !Storage::disk('ibook')->exists($uri) ) {
return null;
}
$content = Storage::disk('ibook')->get($uri);
$extra = new ParsedownExtra();
$HTMLContent = $extra->text($content);
return $HTMLContent;
}
public function getContentRawAttribute()
{
$uri = static::$storageName . '/' . $this->loc . '/main.md';
if ( !Storage::disk('ibook')->exists($uri) ) {
return null;
}
return Storage::disk('ibook')->get($uri);
}

/* 💛❤️ Further development!
public function __call($name, $arguments = null)
{
Expand Down
32 changes: 16 additions & 16 deletions src/Console/stubs/controller.stub
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ use App\DummyModelClass;
class DummyClass extends BookController
{
public $type = 'DummyModelVariable';
public $class = DummyModelClass::class;
public $roles = [];
public $bundleTypes = [];
public function store(Request $request)
{
// add your validation
$request->validate([]);
// REQUIRED :: add what inputs to accept from the user ...
public $class = DummyModelClass::class;
public $roles = [];
public $bundleTypes = [];
public function store(Request $request)
{
// add your validation
$request->validate([]);
// REQUIRED :: add what inputs to accept from the user ...
$values = $request->only([]);

$DummyModelVariable = new $this->class;
Expand All @@ -30,17 +30,17 @@ class DummyClass extends BookController
$DummyModelVariable->save();

return response()->backend($DummyModelVariable);
}
public function update(Request $request, DummyModelClass $DummyModelVariable)
{
// REQUIRED :: add what inputs to accept from the user ...
}
public function update(Request $request, $id)
{
// REQUIRED :: add what inputs to accept from the user ...
$values = $request->only([]);
$DummyModelVariable = $this->class::find($id);
$DummyModelVariable->revise($values);

$DummyModelVariable->save();

return response()->backend($DummyModelVariable);
}
}
}
44 changes: 22 additions & 22 deletions src/Console/stubs/create.stub
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ use Illuminate\Database\Migrations\Migration;

class DummyClass extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('DummyTable', function (Blueprint $table) {
$table->increments('id');
$table->string('loc')->nullable();
$table->timestamps();
});
}
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('DummyTable', function (Blueprint $table) {
$table->increments('id');
$table->string('loc')->nullable();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('DummyTable');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('DummyTable');
}
}
8 changes: 4 additions & 4 deletions src/Console/stubs/model.stub
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use LILPLP\IBA\Book as Book;

class DummyClass extends Book
{
//
public static $dimensions = ['title', 'subtitle', 'slug', 'description', 'thumbnail', 'timestamp'];
public static $groupings = ['keywords', 'people', 'bundles'];
public static $storageName = "DummyClass";
//
public static $dimensions = ['title', 'subtitle', 'slug', 'description', 'thumbnail', 'timestamp'];
public static $groupings = ['keywords', 'people', 'bundles'];
public static $storageName = "DummyModelVariable";
}
2 changes: 0 additions & 2 deletions src/Http/Controllers/AnalogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ public function index()
$books = [];
foreach ($this->books as $key => $book)
{

$request = Request::create('iba/analog/' . $book . '/dashboard/', 'GET');
$response = Route::dispatch($request);
$books[$key] = json_decode($response->content());
// redirect('iba/analog/' . $book . '/dashboard/')->getOriginalContent();
}
return view('iba::index', compact('books'));
}
Expand Down
11 changes: 7 additions & 4 deletions src/Http/Controllers/BookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,20 @@ public function __construct()

public function dashboard()
{
$r['name'] = $this->type;
$r['count'] = $this->class::count();
// $r['size'] = 0;
$r['size'] = $this->get_dir_size();
return $r;
$r['name'] = $this->type;
$r['size'] = $this->get_dir_size();
return $r;
}

private function get_dir_size()
{
$dir_size = 0;
$dir = storage_path() . "/ibook/" . $this->class::$storageName . "/";
if ( !is_dir($dir) )
{
return "no directory";
}
foreach( File::allFiles($dir) as $file)
{
$dir_size += $file->getSize();
Expand Down
5 changes: 4 additions & 1 deletion src/IBAServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class IBAServiceProvider extends Provider
*/
public function boot()
{
$this->app->make('Illuminate\Contracts\Http\Kernel')->pushMiddleware('Illuminate\Session\Middleware\StartSession');

$this->publishes([
__DIR__.'/config/iba.php' => config_path('iba.php'),
]);
Expand Down Expand Up @@ -99,7 +101,8 @@ public function boot()
// $view->with('peoples', People::select('id', 'name')->get()->pluck('id', 'name'));
});




}

/**
Expand Down
27 changes: 22 additions & 5 deletions src/Leaf.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
use Illuminate\Support\Facades\Storage;
use Illuminate\Http\Request;

use Illuminate\Support\Facades\Auth;
use App\Http\Middleware\EncryptCookies;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Illuminate\Session\Middleware\StartSession;

use ParsedownExtra;

use Symfony\Component\Yaml\Yaml;
Expand Down Expand Up @@ -68,6 +73,7 @@ public function cssStandards($content)
public function render($file, $disk = 'seed')
{
$leaf = $this->retriveMetas($file, $disk);
$this->check_status($leaf);
$rawContent = Storage::disk($disk)->get($file);
$leaf['slug'] = $this->slug;

Expand Down Expand Up @@ -123,15 +129,26 @@ public function display() {
if ( array_key_exists('style', $leaf) )
{
$blade_file = 'leaf.' . $leaf['style'];

if ( $leaf['style'] != 'index' ) {
return $this->leafReturn($blade_file, compact('leaf', 'base', 'menu'), '200');
}
return $this->leafReturn('iba::leaf', compact('leaf', 'base', 'menu'), '200'); /// to be changed later !!!
return $this->leafReturn($blade_file, compact('leaf', 'base', 'menu'), '200');
}
return $this->leafReturn('iba::leaf', compact('leaf', 'base', 'menu'), '200');
}

public function check_status($leaf)
{
if (array_key_exists('status', $leaf))
{
if ($leaf['status'] == 'protected')
{
// $router->aliasMiddleware('auth.user', \Path\To\Your\Middleware\custom_auth::class);
if (!Auth::check()) {
return abort(403, 'Unauthorized action.');
}
}
}

}

public function leafReturn($view, $function)
{
if ( !request()->wantsJson() )
Expand Down
12 changes: 12 additions & 0 deletions src/Production/BookProduction.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,19 @@ public function revise($values)
{
$this->reviseDimensions($values);
$this->reviseGroupings($values);
$this->reviseContent($values);
$this->save();
}

public function reviseContent($values)
{
if ( !empty(static::$storageName) )
{
$fileUri = static::$storageName . '/' . $this->id . '/main.md';
Storage::disk('ibook')->put($fileUri, $values['content']);
$this->loc = $this->id;
$this->save();
}
}

}
49 changes: 25 additions & 24 deletions src/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.1",
"font-awesome": "^4.7.0",
"jquery": "^3.2.1",
"laravel-mix": "^0.8.9",
"lodash": "^4.17.4"
Expand All @@ -23,8 +22,7 @@
"jquery-smooth-scroll": "^2.2.0",
"microplugin": "0.0.3",
"moment": "^2.20.1",
"plp-css-base": "^1.0.3",
"plp-css-elements": "^1.2.8",
"plp-css-app": "1.0.3",
"purecss": "^0.6.2",
"sifter": "^0.5.3",
"sticky-kit": "^1.1.3",
Expand Down
Loading

0 comments on commit 8ffe6ce

Please sign in to comment.