aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xGNUmakefile7
-rw-r--r--app/config/services.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/base.html.twig4
-rw-r--r--src/Wallabag/CoreBundle/Twig/WallabagExtension.php10
-rw-r--r--tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php6
5 files changed, 18 insertions, 10 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 837f7103..d0894dbb 100755
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -17,14 +17,14 @@ help: ## Display this help menu
17clean: ## Clear the application cache 17clean: ## Clear the application cache
18 rm -rf var/cache/* 18 rm -rf var/cache/*
19 19
20install: customcss ## Install wallabag with the latest version 20install: ## Install wallabag with the latest version
21 @./scripts/install.sh $(ENV) 21 @./scripts/install.sh $(ENV)
22 22
23update: ## Update the wallabag installation to the latest version 23update: ## Update the wallabag installation to the latest version
24 @./scripts/update.sh $(ENV) 24 @./scripts/update.sh $(ENV)
25 25
26dev: ENV=dev 26dev: ENV=dev
27dev: build customcss ## Install the latest dev version 27dev: build ## Install the latest dev version
28 @./scripts/dev.sh 28 @./scripts/dev.sh
29 29
30run: ## Run the wallabag built-in server 30run: ## Run the wallabag built-in server
@@ -34,9 +34,6 @@ build: ## Run webpack
34 @npm install 34 @npm install
35 @npm run build:$(ENV) 35 @npm run build:$(ENV)
36 36
37customcss:
38 @touch web/custom.css
39
40prepare: clean ## Prepare database for testsuite 37prepare: clean ## Prepare database for testsuite
41ifdef DB 38ifdef DB
42 cp app/config/tests/parameters_test.$(DB).yml app/config/parameters_test.yml 39 cp app/config/tests/parameters_test.$(DB).yml app/config/parameters_test.yml
diff --git a/app/config/services.yml b/app/config/services.yml
index 25bbe5dc..c2c867cf 100644
--- a/app/config/services.yml
+++ b/app/config/services.yml
@@ -16,6 +16,7 @@ services:
16 - "@security.token_storage" 16 - "@security.token_storage"
17 - "%wallabag_core.cache_lifetime%" 17 - "%wallabag_core.cache_lifetime%"
18 - "@translator" 18 - "@translator"
19 - "%kernel.root_dir%"
19 tags: 20 tags:
20 - { name: twig.extension } 21 - { name: twig.extension }
21 22
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';
diff --git a/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php b/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php
index 39fcec16..db02cb9c 100644
--- a/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php
+++ b/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php
@@ -25,7 +25,7 @@ class WallabagExtensionTest extends TestCase
25 ->disableOriginalConstructor() 25 ->disableOriginalConstructor()
26 ->getMock(); 26 ->getMock();
27 27
28 $extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator); 28 $extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator, '');
29 29
30 $this->assertSame('lemonde.fr', $extension->removeWww('www.lemonde.fr')); 30 $this->assertSame('lemonde.fr', $extension->removeWww('www.lemonde.fr'));
31 $this->assertSame('lemonde.fr', $extension->removeWww('lemonde.fr')); 31 $this->assertSame('lemonde.fr', $extension->removeWww('lemonde.fr'));
@@ -50,7 +50,7 @@ class WallabagExtensionTest extends TestCase
50 ->disableOriginalConstructor() 50 ->disableOriginalConstructor()
51 ->getMock(); 51 ->getMock();
52 52
53 $extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator); 53 $extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator, '');
54 54
55 $this->assertSame('lemonde.fr', $extension->removeScheme('lemonde.fr')); 55 $this->assertSame('lemonde.fr', $extension->removeScheme('lemonde.fr'));
56 $this->assertSame('gist.github.com', $extension->removeScheme('gist.github.com')); 56 $this->assertSame('gist.github.com', $extension->removeScheme('gist.github.com'));
@@ -75,7 +75,7 @@ class WallabagExtensionTest extends TestCase
75 ->disableOriginalConstructor() 75 ->disableOriginalConstructor()
76 ->getMock(); 76 ->getMock();
77 77
78 $extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator); 78 $extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator, '');
79 79
80 $this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('www.lemonde.fr')); 80 $this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('www.lemonde.fr'));
81 $this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('http://lemonde.fr')); 81 $this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('http://lemonde.fr'));