1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-08-01 17:38:38 +00:00

Load custom.css only if exists

This commit is contained in:
Simounet 2020-01-29 22:26:00 +01:00
parent 62107f50d3
commit 33e3eeaec8
No known key found for this signature in database
GPG key ID: 77D3B7DC794EB770
5 changed files with 18 additions and 10 deletions

View file

@ -44,7 +44,9 @@
{% block css %}
{% endblock %}
<link rel="stylesheet" href="{{ asset('custom.css') }}">
{% if asset_file_exists('custom.css') %}
<link rel="stylesheet" href="{{ asset('custom.css') }}">
{% endif %}
{% block scripts %}
<script src="{{ asset('bundles/fosjsrouting/js/router.js') }}"></script>
<script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}"></script>

View file

@ -18,14 +18,16 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface
private $tagRepository;
private $lifeTime;
private $translator;
private $rootDir;
public function __construct(EntryRepository $entryRepository, TagRepository $tagRepository, TokenStorageInterface $tokenStorage, $lifeTime, TranslatorInterface $translator)
public function __construct(EntryRepository $entryRepository, TagRepository $tagRepository, TokenStorageInterface $tokenStorage, $lifeTime, TranslatorInterface $translator, string $rootDir)
{
$this->entryRepository = $entryRepository;
$this->tagRepository = $tagRepository;
$this->tokenStorage = $tokenStorage;
$this->lifeTime = $lifeTime;
$this->translator = $translator;
$this->rootDir = $rootDir;
}
public function getGlobals()
@ -48,6 +50,7 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface
new TwigFunction('count_entries', [$this, 'countEntries']),
new TwigFunction('count_tags', [$this, 'countTags']),
new TwigFunction('display_stats', [$this, 'displayStats']),
new TwigFunction('asset_file_exists', [$this, 'assetFileExists']),
];
}
@ -165,6 +168,11 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface
]);
}
public function assetFileExists($name)
{
return file_exists(realpath($this->rootDir . '/../web/' . $name));
}
public function getName()
{
return 'wallabag_extension';