Move to fontawesome webfonts

Added cache busting
This commit is contained in:
Sergio Brighenti 2019-09-06 14:26:41 +02:00
parent 111f220629
commit 9294c3382b
9 changed files with 51 additions and 37 deletions

View file

@ -1,3 +1,8 @@
## v2.6.2
+ Use the font awesome web font for better performances.
+ Changed background default color.
+ Added method for cache busting when updating/change theme.
## v2.6.1
+ Fixed bad redirects on the web installer (#62).
+ Fixed login page with dark themes.

View file

@ -57,7 +57,7 @@ module.exports = function (grunt) {
{
expand: true,
cwd: 'node_modules/@fortawesome/fontawesome-free',
src: ['js/all.min.js'],
src: ['css/all.min.css', 'webfonts/**/*'],
dest: 'static/fontawesome'
},
{

View file

@ -29,16 +29,13 @@ class ThemeController extends Controller
public function applyTheme(Request $request, Response $response): Response
{
if (!is_writable('static/bootstrap/css/bootstrap.min.css')) {
if (!is_writable(BASE_DIR . 'static/bootstrap/css/bootstrap.min.css')) {
$this->session->alert(lang('cannot_write_file'), 'danger');
return redirect($response, 'system');
}
file_put_contents('static/bootstrap/css/bootstrap.min.css', file_get_contents($request->getParam('css')));
return redirect($response, 'system')
->withAddedHeader('Cache-Control', 'no-cache, no-store, must-revalidate')
->withAddedHeader('Pragma', 'no-cache')
->withAddedHeader('Expire', 'Mon, 26 Jul 1997 05:00:00 GMT');
file_put_contents(BASE_DIR . 'static/bootstrap/css/bootstrap.min.css', file_get_contents($request->getParam('css')));
return redirect($response, 'system');
}
}

View file

@ -102,6 +102,18 @@ if (!function_exists('redirect')) {
}
}
if (!function_exists('asset')) {
/**
* Get the asset link with timestamp
* @param string $path
* @return string
*/
function asset(string $path): string
{
return urlFor($path, '?' . filemtime(realpath(BASE_DIR . $path)));
}
}
if (!function_exists('urlFor')) {
/**
* Generate the app url given a path

View file

@ -92,7 +92,6 @@ if (file_exists(__DIR__ . '/../install')) {
removeDirectory(__DIR__ . '/../install');
}
include __DIR__ . '/clean';
echo 'If you are upgrading from a previous version, please run a "php bin\clean".' . PHP_EOL;
echo 'Done.' . PHP_EOL;
exit(0);

View file

@ -155,6 +155,7 @@ $container['view'] = function ($container) use (&$config) {
$view->getEnvironment()->addFunction(new TwigFunction('route', 'route'));
$view->getEnvironment()->addFunction(new TwigFunction('lang', 'lang'));
$view->getEnvironment()->addFunction(new TwigFunction('urlFor', 'urlFor'));
$view->getEnvironment()->addFunction(new TwigFunction('asset', 'asset'));
$view->getEnvironment()->addFunction(new TwigFunction('mime2font', 'mime2font'));
$view->getEnvironment()->addFunction(new TwigFunction('queryParams', 'queryParams'));
return $view;

View file

@ -1,6 +1,6 @@
{
"name": "sergix44/xbackbone",
"version": "2.6.1",
"version": "2.6.2",
"description": "A lightweight ShareX PHP backend",
"type": "project",
"require": {

16
composer.lock generated
View file

@ -4,20 +4,20 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "b00b4789eb0530c6eb3a5280dae29c86",
"content-hash": "12e49250d00781ff06391038f1cd356a",
"packages": [
{
"name": "aws/aws-sdk-php",
"version": "3.110.7",
"version": "3.110.10",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "57d9dd171a5afe0b48ce44f05be2d8875c2f7b34"
"reference": "705fc1ffe05747e6789b19480764ebcd06995911"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/57d9dd171a5afe0b48ce44f05be2d8875c2f7b34",
"reference": "57d9dd171a5afe0b48ce44f05be2d8875c2f7b34",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/705fc1ffe05747e6789b19480764ebcd06995911",
"reference": "705fc1ffe05747e6789b19480764ebcd06995911",
"shasum": ""
},
"require": {
@ -87,7 +87,7 @@
"s3",
"sdk"
],
"time": "2019-08-30T18:07:59+00:00"
"time": "2019-09-05T18:11:21+00:00"
},
{
"name": "container-interop/container-interop",
@ -1535,9 +1535,9 @@
"authors": [
{
"name": "Alex Vanderbist",
"role": "Developer",
"email": "alex.vanderbist@gmail.com",
"homepage": "https://spatie.be",
"role": "Developer"
"homepage": "https://spatie.be"
}
],
"description": "Flysystem Adapter for the Dropbox v2 API",

View file

@ -7,20 +7,21 @@
<meta name="description" content="XBackBone File Manager">
<link rel="shortcut icon" href="{{ urlFor('/favicon.ico') }}" type="image/x-icon">
<link rel="icon" href="{{ urlFor('/favicon.ico') }}" type="image/x-icon">
<link rel="preload" href="{{ urlFor('/static/bootstrap/css/bootstrap.min.css') }}" as="style">
<link rel="preload" href="{{ urlFor('/static/app/app.css') }}" as="style">
<link rel="preload" href="{{ urlFor('/static/jquery/jquery.min.js') }}" as="script">
<link rel="preload" href="{{ urlFor('/static/bootstrap/js/bootstrap.bundle.min.js') }}" as="script">
<link rel="preload" href="{{ urlFor('/static/fontawesome/js/all.min.js') }}" as="script">
<link rel="preload" href="{{ urlFor('/static/app/app.js') }}" as="script">
<link href="{{ urlFor('/static/bootstrap/css/bootstrap.min.css') }}" rel="stylesheet">
<link href="{{ urlFor('/static/highlightjs/styles/monokai.css') }}" rel="stylesheet">
<link href="{{ urlFor('/static/videojs/video-js.min.css') }}" rel="stylesheet">
<link href="{{ urlFor('/static/app/app.css') }}" rel="stylesheet">
<link rel="preload" href="{{ asset('/static/bootstrap/css/bootstrap.min.css') }}" as="style">
<link rel="preload" href="{{ asset('/static/fontawesome/css/all.min.css') }}" as="script">
<link rel="preload" href="{{ asset('/static/app/app.css') }}" as="style">
<link rel="preload" href="{{ asset('/static/jquery/jquery.min.js') }}" as="script">
<link rel="preload" href="{{ asset('/static/bootstrap/js/bootstrap.bundle.min.js') }}" as="script">
<link rel="preload" href="{{ asset('/static/app/app.js') }}" as="script">
<link href="{{ asset('/static/bootstrap/css/bootstrap.min.css') }}" rel="stylesheet">
<link href="{{ asset('/static/fontawesome/css/all.min.css') }}" rel="stylesheet">
<link href="{{ asset('/static/highlightjs/styles/monokai.css') }}" rel="stylesheet">
<link href="{{ asset('/static/videojs/video-js.min.css') }}" rel="stylesheet">
<link href="{{ asset('/static/app/app.css') }}" rel="stylesheet">
<script>window.AppConfig = {'base_url': '{{ config.base_url }}', 'lang': {'publish': '{{ lang('publish') }}', 'hide': '{{ lang('hide') }}'}}</script>
{% block head %}{% endblock %}
</head>
<body>
<body class="bg-light">
{% block content %}{% endblock %}
{% block footer %}
<div class="container-fluid footer" style="display: none; font-size: 0.8rem">
@ -29,13 +30,12 @@
</div>
</div>
{% endblock %}
<script src="{{ urlFor('/static/jquery/jquery.min.js') }}"></script>
<script src="{{ urlFor('/static/bootstrap/js/bootstrap.bundle.min.js') }}"></script>
<script src="{{ urlFor('/static/fontawesome/js/all.min.js') }}"></script>
<script src="{{ urlFor('/static/highlightjs/highlight.pack.min.js') }}"></script>
<script src="{{ urlFor('/static/clipboardjs/clipboard.min.js') }}"></script>
<script src="{{ urlFor('/static/videojs/video.min.js') }}"></script>
<script src="{{ urlFor('/static/app/app.js') }}"></script>
<script src="{{ asset('/static/jquery/jquery.min.js') }}"></script>
<script src="{{ asset('/static/bootstrap/js/bootstrap.bundle.min.js') }}"></script>
<script src="{{ asset('/static/highlightjs/highlight.pack.min.js') }}"></script>
<script src="{{ asset('/static/clipboardjs/clipboard.min.js') }}"></script>
<script src="{{ asset('/static/videojs/video.min.js') }}"></script>
<script src="{{ asset('/static/app/app.js') }}"></script>
<script>hljs.initHighlightingOnLoad();</script>
</body>
</html>