diff options
author | Jérémy Benoist <j0k3r@users.noreply.github.com> | 2020-03-28 16:49:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-28 16:49:29 +0100 |
commit | 11079d204d865671524dad0c7f418deef29a8c83 (patch) | |
tree | 103794af0a224c0d0f49b7d06c99cf2ba7c6febe /src | |
parent | d8a40d703e96c10118de025eb5cdcfdd69f26f6a (diff) | |
parent | 33e3eeaec851158289e1a236cfe08a475cc6364a (diff) | |
download | wallabag-11079d204d865671524dad0c7f418deef29a8c83.tar.gz wallabag-11079d204d865671524dad0c7f418deef29a8c83.tar.zst wallabag-11079d204d865671524dad0c7f418deef29a8c83.zip |
Merge pull request #4272 from Simounet/feat/load-custom-css-only-if-exists
Load custom.css only if exists
Diffstat (limited to 'src')
-rw-r--r-- | src/Wallabag/CoreBundle/Resources/views/base.html.twig | 4 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Twig/WallabagExtension.php | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Resources/views/base.html.twig b/src/Wallabag/CoreBundle/Resources/views/base.html.twig index 496b3fb6..2486172d 100644 --- a/src/Wallabag/CoreBundle/Resources/views/base.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/base.html.twig | |||
@@ -44,7 +44,9 @@ | |||
44 | 44 | ||
45 | {% block css %} | 45 | {% block css %} |
46 | {% endblock %} | 46 | {% endblock %} |
47 | <link rel="stylesheet" href="{{ asset('custom.css') }}"> | 47 | {% if asset_file_exists('custom.css') %} |
48 | <link rel="stylesheet" href="{{ asset('custom.css') }}"> | ||
49 | {% endif %} | ||
48 | {% block scripts %} | 50 | {% block scripts %} |
49 | <script src="{{ asset('bundles/fosjsrouting/js/router.js') }}"></script> | 51 | <script src="{{ asset('bundles/fosjsrouting/js/router.js') }}"></script> |
50 | <script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}"></script> | 52 | <script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}"></script> |
diff --git a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php index 02f17f50..47af3c8e 100644 --- a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php +++ b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php | |||
@@ -18,14 +18,16 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface | |||
18 | private $tagRepository; | 18 | private $tagRepository; |
19 | private $lifeTime; | 19 | private $lifeTime; |
20 | private $translator; | 20 | private $translator; |
21 | private $rootDir; | ||
21 | 22 | ||
22 | public function __construct(EntryRepository $entryRepository, TagRepository $tagRepository, TokenStorageInterface $tokenStorage, $lifeTime, TranslatorInterface $translator) | 23 | public function __construct(EntryRepository $entryRepository, TagRepository $tagRepository, TokenStorageInterface $tokenStorage, $lifeTime, TranslatorInterface $translator, string $rootDir) |
23 | { | 24 | { |
24 | $this->entryRepository = $entryRepository; | 25 | $this->entryRepository = $entryRepository; |
25 | $this->tagRepository = $tagRepository; | 26 | $this->tagRepository = $tagRepository; |
26 | $this->tokenStorage = $tokenStorage; | 27 | $this->tokenStorage = $tokenStorage; |
27 | $this->lifeTime = $lifeTime; | 28 | $this->lifeTime = $lifeTime; |
28 | $this->translator = $translator; | 29 | $this->translator = $translator; |
30 | $this->rootDir = $rootDir; | ||
29 | } | 31 | } |
30 | 32 | ||
31 | public function getGlobals() | 33 | public function getGlobals() |
@@ -48,6 +50,7 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface | |||
48 | new TwigFunction('count_entries', [$this, 'countEntries']), | 50 | new TwigFunction('count_entries', [$this, 'countEntries']), |
49 | new TwigFunction('count_tags', [$this, 'countTags']), | 51 | new TwigFunction('count_tags', [$this, 'countTags']), |
50 | new TwigFunction('display_stats', [$this, 'displayStats']), | 52 | new TwigFunction('display_stats', [$this, 'displayStats']), |
53 | new TwigFunction('asset_file_exists', [$this, 'assetFileExists']), | ||
51 | ]; | 54 | ]; |
52 | } | 55 | } |
53 | 56 | ||
@@ -165,6 +168,11 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface | |||
165 | ]); | 168 | ]); |
166 | } | 169 | } |
167 | 170 | ||
171 | public function assetFileExists($name) | ||
172 | { | ||
173 | return file_exists(realpath($this->rootDir . '/../web/' . $name)); | ||
174 | } | ||
175 | |||
168 | public function getName() | 176 | public function getName() |
169 | { | 177 | { |
170 | return 'wallabag_extension'; | 178 | return 'wallabag_extension'; |