mirror of
https://github.com/flarum/framework.git
synced 2025-05-03 10:04:03 +08:00
Define assets in a more appropriate spot, make extensible
This commit is contained in:
parent
4c42be1362
commit
40715203a5
@ -7,6 +7,7 @@ use Cookie;
|
|||||||
use Config;
|
use Config;
|
||||||
use View;
|
use View;
|
||||||
use DB;
|
use DB;
|
||||||
|
use Flarum\Forum\Events\RenderView;
|
||||||
|
|
||||||
class IndexAction extends BaseAction
|
class IndexAction extends BaseAction
|
||||||
{
|
{
|
||||||
@ -32,14 +33,25 @@ class IndexAction extends BaseAction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return View::make('flarum.forum::index')
|
$view = View::make('flarum.forum::index')
|
||||||
->with('title', Config::get('flarum::forum_title', 'Flarum Demo Forum'))
|
->with('title', Config::get('flarum::forum_title', 'Flarum Demo Forum'))
|
||||||
->with('styles', app('flarum.forum.assetManager')->getCSSFiles())
|
|
||||||
->with('scripts', app('flarum.forum.assetManager')->getJSFiles())
|
|
||||||
->with('config', $config)
|
->with('config', $config)
|
||||||
->with('layout', View::make('flarum.forum::forum'))
|
->with('layout', 'flarum.forum::forum')
|
||||||
->with('data', $data)
|
->with('data', $data)
|
||||||
->with('session', $session)
|
->with('session', $session)
|
||||||
->with('alert', $alert);
|
->with('alert', $alert);
|
||||||
|
|
||||||
|
$assetManager = app('flarum.forum.assetManager');
|
||||||
|
$root = __DIR__.'/../../..';
|
||||||
|
$assetManager->addFile([
|
||||||
|
$root.'/js/forum/dist/app.js',
|
||||||
|
$root.'/less/forum/app.less'
|
||||||
|
]);
|
||||||
|
|
||||||
|
event(new RenderView($view, $assetManager));
|
||||||
|
|
||||||
|
return $view
|
||||||
|
->with('styles', $assetManager->getCSSFiles())
|
||||||
|
->with('scripts', $assetManager->getJSFiles());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
<?php namespace Flarum\Forum\Events;
|
|
||||||
|
|
||||||
class BootForum
|
|
||||||
{
|
|
||||||
public $app;
|
|
||||||
|
|
||||||
public function __construct($app)
|
|
||||||
{
|
|
||||||
$this->app = $app;
|
|
||||||
}
|
|
||||||
}
|
|
14
framework/core/src/Forum/Events/RenderView.php
Normal file
14
framework/core/src/Forum/Events/RenderView.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php namespace Flarum\Forum\Events;
|
||||||
|
|
||||||
|
class RenderView
|
||||||
|
{
|
||||||
|
public $view;
|
||||||
|
|
||||||
|
public $assets;
|
||||||
|
|
||||||
|
public function __construct(&$view, $assets)
|
||||||
|
{
|
||||||
|
$this->view = &$view;
|
||||||
|
$this->assets = $assets;
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use Flarum\Support\AssetManager;
|
use Flarum\Support\AssetManager;
|
||||||
use Flarum\Forum\Events\BootForum;
|
|
||||||
|
|
||||||
class ForumServiceProvider extends ServiceProvider
|
class ForumServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
@ -17,15 +16,6 @@ class ForumServiceProvider extends ServiceProvider
|
|||||||
|
|
||||||
$this->loadViewsFrom($root.'/views', 'flarum.forum');
|
$this->loadViewsFrom($root.'/views', 'flarum.forum');
|
||||||
|
|
||||||
$assetManager = $this->app['flarum.forum.assetManager'];
|
|
||||||
|
|
||||||
$assetManager->addFile([
|
|
||||||
$root.'/js/forum/dist/app.js',
|
|
||||||
$root.'/less/forum/app.less'
|
|
||||||
]);
|
|
||||||
|
|
||||||
event(new BootForum($this->app));
|
|
||||||
|
|
||||||
$this->publishes([
|
$this->publishes([
|
||||||
$root.'/public/fonts' => public_path('flarum/fonts')
|
$root.'/public/fonts' => public_path('flarum/fonts')
|
||||||
]);
|
]);
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
{!! $layout !!}
|
@include($layout)
|
||||||
|
|
||||||
<div id="modal"></div>
|
<div id="modal"></div>
|
||||||
<div id="alerts"></div>
|
<div id="alerts"></div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user