mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-22 15:46:30 +00:00
Load custom.css only if exists
This commit is contained in:
parent
62107f50d3
commit
33e3eeaec8
5 changed files with 18 additions and 10 deletions
|
@ -17,14 +17,14 @@ help: ## Display this help menu
|
||||||
clean: ## Clear the application cache
|
clean: ## Clear the application cache
|
||||||
rm -rf var/cache/*
|
rm -rf var/cache/*
|
||||||
|
|
||||||
install: customcss ## Install wallabag with the latest version
|
install: ## Install wallabag with the latest version
|
||||||
@./scripts/install.sh $(ENV)
|
@./scripts/install.sh $(ENV)
|
||||||
|
|
||||||
update: ## Update the wallabag installation to the latest version
|
update: ## Update the wallabag installation to the latest version
|
||||||
@./scripts/update.sh $(ENV)
|
@./scripts/update.sh $(ENV)
|
||||||
|
|
||||||
dev: ENV=dev
|
dev: ENV=dev
|
||||||
dev: build customcss ## Install the latest dev version
|
dev: build ## Install the latest dev version
|
||||||
@./scripts/dev.sh
|
@./scripts/dev.sh
|
||||||
|
|
||||||
run: ## Run the wallabag built-in server
|
run: ## Run the wallabag built-in server
|
||||||
|
@ -34,9 +34,6 @@ build: ## Run webpack
|
||||||
@npm install
|
@npm install
|
||||||
@npm run build:$(ENV)
|
@npm run build:$(ENV)
|
||||||
|
|
||||||
customcss:
|
|
||||||
@touch web/custom.css
|
|
||||||
|
|
||||||
prepare: clean ## Prepare database for testsuite
|
prepare: clean ## Prepare database for testsuite
|
||||||
ifdef DB
|
ifdef DB
|
||||||
cp app/config/tests/parameters_test.$(DB).yml app/config/parameters_test.yml
|
cp app/config/tests/parameters_test.$(DB).yml app/config/parameters_test.yml
|
||||||
|
|
|
@ -16,6 +16,7 @@ services:
|
||||||
- "@security.token_storage"
|
- "@security.token_storage"
|
||||||
- "%wallabag_core.cache_lifetime%"
|
- "%wallabag_core.cache_lifetime%"
|
||||||
- "@translator"
|
- "@translator"
|
||||||
|
- "%kernel.root_dir%"
|
||||||
tags:
|
tags:
|
||||||
- { name: twig.extension }
|
- { name: twig.extension }
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,9 @@
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
<link rel="stylesheet" href="{{ asset('custom.css') }}">
|
{% if asset_file_exists('custom.css') %}
|
||||||
|
<link rel="stylesheet" href="{{ asset('custom.css') }}">
|
||||||
|
{% endif %}
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script src="{{ asset('bundles/fosjsrouting/js/router.js') }}"></script>
|
<script src="{{ asset('bundles/fosjsrouting/js/router.js') }}"></script>
|
||||||
<script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}"></script>
|
<script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}"></script>
|
||||||
|
|
|
@ -18,14 +18,16 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface
|
||||||
private $tagRepository;
|
private $tagRepository;
|
||||||
private $lifeTime;
|
private $lifeTime;
|
||||||
private $translator;
|
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->entryRepository = $entryRepository;
|
||||||
$this->tagRepository = $tagRepository;
|
$this->tagRepository = $tagRepository;
|
||||||
$this->tokenStorage = $tokenStorage;
|
$this->tokenStorage = $tokenStorage;
|
||||||
$this->lifeTime = $lifeTime;
|
$this->lifeTime = $lifeTime;
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
|
$this->rootDir = $rootDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGlobals()
|
public function getGlobals()
|
||||||
|
@ -48,6 +50,7 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface
|
||||||
new TwigFunction('count_entries', [$this, 'countEntries']),
|
new TwigFunction('count_entries', [$this, 'countEntries']),
|
||||||
new TwigFunction('count_tags', [$this, 'countTags']),
|
new TwigFunction('count_tags', [$this, 'countTags']),
|
||||||
new TwigFunction('display_stats', [$this, 'displayStats']),
|
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()
|
public function getName()
|
||||||
{
|
{
|
||||||
return 'wallabag_extension';
|
return 'wallabag_extension';
|
||||||
|
|
|
@ -25,7 +25,7 @@ class WallabagExtensionTest extends TestCase
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator);
|
$extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator, '');
|
||||||
|
|
||||||
$this->assertSame('lemonde.fr', $extension->removeWww('www.lemonde.fr'));
|
$this->assertSame('lemonde.fr', $extension->removeWww('www.lemonde.fr'));
|
||||||
$this->assertSame('lemonde.fr', $extension->removeWww('lemonde.fr'));
|
$this->assertSame('lemonde.fr', $extension->removeWww('lemonde.fr'));
|
||||||
|
@ -50,7 +50,7 @@ class WallabagExtensionTest extends TestCase
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator);
|
$extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator, '');
|
||||||
|
|
||||||
$this->assertSame('lemonde.fr', $extension->removeScheme('lemonde.fr'));
|
$this->assertSame('lemonde.fr', $extension->removeScheme('lemonde.fr'));
|
||||||
$this->assertSame('gist.github.com', $extension->removeScheme('gist.github.com'));
|
$this->assertSame('gist.github.com', $extension->removeScheme('gist.github.com'));
|
||||||
|
@ -75,7 +75,7 @@ class WallabagExtensionTest extends TestCase
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator);
|
$extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator, '');
|
||||||
|
|
||||||
$this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('www.lemonde.fr'));
|
$this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('www.lemonde.fr'));
|
||||||
$this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('http://lemonde.fr'));
|
$this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('http://lemonde.fr'));
|
||||||
|
|
Loading…
Reference in a new issue