1
0
mirror of https://github.com/flarum/core.git synced 2025-07-30 21:20:24 +02:00

Frontend refactor (#1471)

Refactor Frontend + Asset code

- Use Laravel's Filesystem component for asset IO, meaning theoretically
  assets should be storable on S3 etc.

- More reliable checking for asset recompilation when debug mode is on,
  so you don't have to constantly delete the compiled assets to force
  a recompile. Should also fix issues with locale JS files being
  recompiled with the same name and cached.

- Remove JavaScript minification, because it will be done by Webpack
  (exception is for the TextFormatter JS).

- Add support for JS sourcemaps.

- Separate frontend view and assets completely. This is an important
  distinction because frontend assets are compiled independent of a
  request, whereas putting together a view depends on a request.

- Bind frontend view/asset factory instances to the container (in
  service providers) rather than subclassing. Asset and content
  populators can be added to these factories – these are simply objects
  that populate the asset compilers or the view with information.

- Add RouteHandlerFactory functions that make it easy to hook up a
  frontend controller with a frontend instance ± some content.

- Remove the need for "nojs"

- Fix cache:clear command

- Recompile assets when settings/enabled extensions change
This commit is contained in:
Toby Zerner
2018-06-30 12:31:12 +09:30
committed by GitHub
parent 0f5ddc1c43
commit 0e73785498
73 changed files with 2846 additions and 2176 deletions

View File

@@ -1,63 +1,40 @@
<!doctype html>
<html dir="{{ $direction }}" lang="{{ $language }}">
<head>
<meta charset="utf-8">
<title>{{ $title }}</title>
<meta name="description" content="{{ $description }}">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
<meta name="theme-color" content="{{ array_get($forum, 'attributes.themePrimaryColor') }}">
@if (! $allowJs)
<meta name="robots" content="noindex" />
@endif
<head>
<meta charset="utf-8">
<title>{{ $title }}</title>
@foreach ($cssUrls as $url)
<link rel="stylesheet" href="{{ $url }}">
@endforeach
{!! $head !!}
</head>
@if ($faviconUrl = array_get($forum, 'attributes.faviconUrl'))
<link href="{{ $faviconUrl }}" rel="shortcut icon">
@endif
<body>
{!! $layout !!}
{!! $head !!}
</head>
<div id="modal"></div>
<div id="alerts"></div>
<body>
{!! $layout !!}
<script>
document.getElementById('flarum-loading').style.display = 'block';
var flarum = {extensions: {}};
</script>
<div id="modal"></div>
<div id="alerts"></div>
{!! $js !!}
@if ($allowJs)
<script>
document.getElementById('flarum-loading').style.display = 'block';
var flarum = {extensions: {}};
</script>
<script>
document.getElementById('flarum-loading').style.display = 'none';
@foreach ($jsUrls as $url)
<script src="{{ $url }}"></script>
@endforeach
try {
flarum.core.app.load(@json($payload));
flarum.core.app.bootExtensions(flarum.extensions);
flarum.core.app.boot();
} catch (e) {
var error = document.getElementById('flarum-loading-error');
error.innerHTML += document.getElementById('flarum-content').textContent;
error.style.display = 'block';
throw e;
}
</script>
<script>
document.getElementById('flarum-loading').style.display = 'none';
@if (! $debug)
try {
@endif
flarum.core.app.load(@json($payload));
flarum.core.app.bootExtensions(flarum.extensions);
flarum.core.app.boot();
@if (! $debug)
} catch (e) {
window.location += (window.location.search ? '&' : '?') + 'nojs=1';
throw e;
}
@endif
</script>
@else
<script>
window.history.replaceState(null, null, window.location.toString().replace(/([&?]nojs=1$|nojs=1&)/, ''));
</script>
@endif
{!! $foot !!}
</body>
{!! $foot !!}
</body>
</html>