aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorSimounet <contact@simounet.net>2020-01-29 22:26:00 +0100
committerSimounet <contact@simounet.net>2020-02-07 13:21:48 +0100
commit33e3eeaec851158289e1a236cfe08a475cc6364a (patch)
tree0cb4c3b64622bfcc818026d667ee3b286644bd19 /src
parent62107f50d3b43039a635dcaecce317ef0299ee1f (diff)
downloadwallabag-33e3eeaec851158289e1a236cfe08a475cc6364a.tar.gz
wallabag-33e3eeaec851158289e1a236cfe08a475cc6364a.tar.zst
wallabag-33e3eeaec851158289e1a236cfe08a475cc6364a.zip
Load custom.css only if exists
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/base.html.twig4
-rw-r--r--src/Wallabag/CoreBundle/Twig/WallabagExtension.php10
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';