Working on template compatibility

This commit is contained in:
Bob den Otter
2019-01-02 21:23:59 +01:00
parent a7e6d28973
commit d13bbbbdc5
11 changed files with 860 additions and 376 deletions

View File

@@ -23,13 +23,4 @@
{% endif %}
<hr>
{% setcontent pages = "pages" %}
<ul>
{% for page in pages %}
<li><a href="{{ page.link }}">{{ page.title }}</a></li>
{% endfor %}
</ul>
{% endblock main %}

View File

@@ -9,7 +9,7 @@
<div>
{# The next section attempts to fill the panel in the sidebar with the contents of the
'about-us'-block, if it exists. First, attempt to fetch the block with slug 'about-us' #}
{#{% setcontent block = "block/about-us" %}#}
{% setcontent block = "block/about-us" %}
{# check if we have a title. If so, we know we have content to display. Otherwise, we will
output a default text, telling the user to create the 'blocks' in the backend. #}
@@ -23,7 +23,7 @@
{% if content_link or edit_link %}
<p>
{%- if content_link %}
<a href="{{ relative_path(content_link|e) }}">{{ __('general.phrase.read-more') }}</a>
<a href="{{ relative_path(content_link|e) }}">{{ __('general.phrase.read-more') }}</a>
{% endif -%}
{%- if edit_link %}
/ <a href="{{ edit_link }}">{{ __('general.phrase.edit') }}</a>
@@ -53,17 +53,17 @@
{% for ct in config.get('contenttypes') if not ct.viewless|default(false) %}
{#{% setcontent records = ct.slug ~ "/latest/3" %}#}
{% setcontent records = ct.slug ~ "/latest/3" %}
<h5>{{ __('contenttypes.generic.recent', {'%contenttypes%': ct.name}) }}</h5>
<ul>
{% for record in records|default([]) %}
{% for record in records %}
<li><a href="{{ record.link }}">{{ record.title }}</a></li>
{% else %}
<li>{{ __('contenttypes.generic.no-recent', {'%contenttype%': ct.slug}) }}</li>
{% endfor %}
</ul>
{#<p><a href="{{ path('contentlisting', {'contenttypeslug': ct.slug}) }}">{{ __('contenttypes.generic.overview',{'%contenttypes%': ct.name}) }} &raquo;</a></p>#}
<p><a href="{{ path('contentlisting', {'contenttypeslug': ct.slug}) }}">{{ __('contenttypes.generic.overview',{'%contenttypes%': ct.name}) }} &raquo;</a></p>
{% endfor %}

View File

@@ -29,11 +29,11 @@
{{ widgets('main_bottom') }}
{#{{ include('partials/_aside.twig') }}#}
{{ include('partials/_aside.twig') }}
{% endblock body %}
{#{{ include('partials/_footer.twig') }}#}
{{ include('partials/_footer.twig') }}
</body>
</html>

View File

@@ -1,7 +1,8 @@
{# This file is inserted as the 'footer' of each listed record. #}
<p class="meta">
{% if record.editlink() %}
<span class="edit-link"><a href="{{ record.editlink() }}"><strong>Edit</strong></a></span> -
<span class="edit-link"><a href="{{ record.editlink() }}"><strong>{{ __('general.phrase.edit') }}</strong></a></span> -
<span class="edit-link"><a href="{{ record.editlink() }}"><strong>{{ 'general.phrase.edit'|trans }}</strong></a></span> -
{% endif %}
{{ __('general.phrase.written-by-on', {
'%name%': record.user.displayname|default(__('Unknown')),

View File

@@ -10,7 +10,7 @@ use Bolt\Repository\ContentRepository;
use Knp\Menu\FactoryInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Stopwatch\Stopwatch;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
class MenuBuilder
{

View File

@@ -35,7 +35,7 @@ class ListingController extends BaseController
* @throws \Twig_Error_Runtime
* @throws \Twig_Error_Syntax
*/
public function contentListing(ContentRepository $contentRepository, Request $request, string $contenttypeslug): Response
public function listing(ContentRepository $content, Request $request, string $contenttypeslug): Response
{
$page = (int) $request->query->get('page', 1);
@@ -48,4 +48,19 @@ class ListingController extends BaseController
return $this->renderTemplate($templates, ['records' => $records]);
}
/**
* Route alias for Bolt 3 backwards compatibility
* Deprecated since 4.0
*
* @Route(
* "/{contenttypeslug}",
* name="contentlisting",
* requirements={"contenttypeslug"="%bolt.requirement.contenttypes%"},
* methods={"GET"})
*/
public function contentListing(ContentRepository $content, Request $request, string $contenttypeslug): Response
{
return $this->listing($content, $request, $contenttypeslug);
}
}

View File

@@ -34,11 +34,9 @@ class AppExtension extends AbstractExtension
public function getFunctions(): array
{
return [
new TwigFunction('__', [$this, 'dummy'], ['is_safe' => ['html']]),
new TwigFunction('image', [$this, 'dummy'], ['is_safe' => ['html']]),
new TwigFunction('thumbnail', [$this, 'dummy'], ['is_safe' => ['html']]),
new TwigFunction('widgets', [$this, 'dummy'], ['is_safe' => ['html']]),
new TwigFunction('htmllang', [$this, 'dummy'], ['is_safe' => ['html']]),
new TwigFunction('popup', [$this, 'dummy'], ['is_safe' => ['html']]),
];
}

View File

@@ -9,7 +9,7 @@ use Bolt\Entity\Content;
use Bolt\Entity\Field;
use Bolt\Repository\TaxonomyRepository;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

View File

@@ -7,6 +7,7 @@ namespace Bolt\Twig;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Intl\Intl;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Tightenco\Collect\Support\Collection;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
@@ -23,10 +24,14 @@ class LocaleExtension extends AbstractExtension
/** @var UrlGeneratorInterface */
private $urlGenerator;
public function __construct(string $locales, UrlGeneratorInterface $urlGenerator)
/** @var TranslatorInterface */
private $translator;
public function __construct(string $locales, UrlGeneratorInterface $urlGenerator, TranslatorInterface $translator)
{
$this->localeCodes = collect(explode('|', $locales));
$this->urlGenerator = $urlGenerator;
$this->translator = $translator;
}
/**
@@ -38,6 +43,8 @@ class LocaleExtension extends AbstractExtension
$env = ['needs_environment' => true];
return [
new TwigFunction('__', [$this, 'translate'], ['is_safe' => ['html']]),
new TwigFunction('htmllang', [$this, 'dummy'], ['is_safe' => ['html']]),
new TwigFunction('locales', [$this, 'getLocales'], $env),
new TwigFunction('contentlocales', [$this, 'getContentLocales'], $env),
new TwigFunction('locale', [$this, 'getLocale']),
@@ -45,6 +52,16 @@ class LocaleExtension extends AbstractExtension
];
}
public function dummy($input = null)
{
return $input;
}
public function translate(string $id, array $parameters = [], $domain = null, $locale = null): string
{
return $this->translator->trans($id, $parameters, $domain, $locale);
}
public function getLocale($localeCode)
{
return $this->localeInfo($localeCode);

File diff suppressed because it is too large Load Diff

View File

@@ -1,50 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="en" target-language="en" datatype="plaintext" original="file.ext">
<header>
<tool tool-id="symfony" tool-name="Symfony"/>
</header>
<body>
<trans-unit id="TG1D5NO" resname="post.blank_summary">
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0" srcLang="en" trgLang="en">
<file id="validators.en">
<unit id="TG1D5NO" name="post.blank_summary">
<notes>
<note priority="1">obsolete</note>
</notes>
<segment>
<source>post.blank_summary</source>
<target>Give your post a summary!</target>
</segment>
</unit>
<unit id="BZOzjk." name="post.blank_content">
<notes>
<note priority="1">obsolete</note>
</trans-unit>
<trans-unit id="BZOzjk." resname="post.blank_content">
</notes>
<segment>
<source>post.blank_content</source>
<target>Your post should have some content!</target>
</segment>
</unit>
<unit id="S6M.YWY" name="post.too_short_content">
<notes>
<note priority="1">obsolete</note>
</trans-unit>
<trans-unit id="S6M.YWY" resname="post.too_short_content">
</notes>
<segment>
<source>post.too_short_content</source>
<target>Post content is too short ({{ limit }} characters minimum)</target>
</segment>
</unit>
<unit id="niM7JYj" name="post.too_many_tags">
<notes>
<note priority="1">obsolete</note>
</trans-unit>
<trans-unit id="niM7JYj" resname="post.too_many_tags">
</notes>
<segment>
<source>post.too_many_tags</source>
<target>Too many tags (add {{ limit }} tags or less)</target>
</segment>
</unit>
<unit id="ARUoKOV" name="comment.blank">
<notes>
<note priority="1">obsolete</note>
</trans-unit>
<trans-unit id="ARUoKOV" resname="comment.blank">
</notes>
<segment>
<source>comment.blank</source>
<target>Please don't leave your comment blank!</target>
</segment>
</unit>
<unit id="J.L_ppQ" name="comment.too_short">
<notes>
<note priority="1">obsolete</note>
</trans-unit>
<trans-unit id="J.L_ppQ" resname="comment.too_short">
</notes>
<segment>
<source>comment.too_short</source>
<target>Comment is too short ({{ limit }} characters minimum)</target>
</segment>
</unit>
<unit id=".bkQKXb" name="comment.too_long">
<notes>
<note priority="1">obsolete</note>
</trans-unit>
<trans-unit id=".bkQKXb" resname="comment.too_long">
</notes>
<segment>
<source>comment.too_long</source>
<target>Comment is too long ({{ limit }} characters maximum)</target>
</segment>
</unit>
<unit id="cTT8h4_" name="comment.is_spam">
<notes>
<note priority="1">obsolete</note>
</trans-unit>
<trans-unit id="cTT8h4_" resname="comment.is_spam">
</notes>
<segment>
<source>comment.is_spam</source>
<target>The content of this comment is considered spam.</target>
<note priority="1">obsolete</note>
</trans-unit>
</body>
</segment>
</unit>
</file>
</xliff>