add new demo symfony files
This commit is contained in:
40
app/templates/blog/_comment_form.html.twig
Normal file
40
app/templates/blog/_comment_form.html.twig
Normal file
@@ -0,0 +1,40 @@
|
||||
{#
|
||||
By default, forms enable client-side validation. This means that you can't
|
||||
test the server-side validation errors from the browser. To temporarily
|
||||
disable this validation, add the 'novalidate' attribute:
|
||||
|
||||
{{ form_start(form, {method: ..., action: ..., attr: {novalidate: 'novalidate'}}) }}
|
||||
#}
|
||||
|
||||
{{ form_start(form, {method: 'POST', action: path('comment_new', {'postSlug': post.slug})}) }}
|
||||
{# instead of displaying form fields one by one, you can also display them
|
||||
all with their default options and styles just by calling to this function:
|
||||
|
||||
{{ form_widget(form) }}
|
||||
#}
|
||||
|
||||
<fieldset>
|
||||
<legend>
|
||||
<i class="fa fa-comment" aria-hidden="true"></i> {{ 'title.add_comment'|trans }}
|
||||
</legend>
|
||||
|
||||
{# Render any global form error (e.g. when a constraint on a public getter method failed) #}
|
||||
{{ form_errors(form) }}
|
||||
|
||||
<div class="form-group {% if not form.content.vars.valid %}has-error{% endif %}">
|
||||
{{ form_label(form.content, 'label.content', {label_attr: {class: 'sr-only'}}) }}
|
||||
|
||||
{# Render any errors for the "content" field (e.g. when a class property constraint failed) #}
|
||||
{{ form_errors(form.content) }}
|
||||
|
||||
{{ form_widget(form.content, {attr: {rows: 10}}) }}
|
||||
{{ form_help(form.content) }}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<button class="btn btn-primary pull-right" type="submit">
|
||||
<i class="fa fa-paper-plane" aria-hidden="true"></i> {{ 'action.publish_comment'|trans }}
|
||||
</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
{{ form_end(form) }}
|
19
app/templates/blog/_delete_post_confirmation.html.twig
Normal file
19
app/templates/blog/_delete_post_confirmation.html.twig
Normal file
@@ -0,0 +1,19 @@
|
||||
{# Bootstrap modal, see https://getbootstrap.com/docs/3.4/javascript/#modals #}
|
||||
<div class="modal fade" id="confirmationModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
<h4>{{ 'delete_post_modal.title'|trans }}</h4>
|
||||
<p>{{ 'delete_post_modal.body'|trans }}</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" id="btnNo" data-dismiss="modal">
|
||||
<i class="fa fa-ban" aria-hidden="true"></i> {{ 'label.cancel'|trans }}
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger" id="btnYes" data-dismiss="modal">
|
||||
<i class="fa fa-trash" aria-hidden="true"></i> {{ 'label.delete_post'|trans }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
12
app/templates/blog/_post_tags.html.twig
Normal file
12
app/templates/blog/_post_tags.html.twig
Normal file
@@ -0,0 +1,12 @@
|
||||
{% if not post.tags.empty %}
|
||||
<p class="post-tags">
|
||||
{% for tag in post.tags %}
|
||||
<a href="{{ path('blog_index', {'tag': tag.name == app.request.query.get('tag') ? null : tag.name}) }}"
|
||||
class="label label-{{ tag.name == app.request.query.get('tag') ? 'success' : 'default' }}"
|
||||
>
|
||||
<i class="fa fa-tag"></i> {{ tag.name }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
5
app/templates/blog/_rss.html.twig
Normal file
5
app/templates/blog/_rss.html.twig
Normal file
@@ -0,0 +1,5 @@
|
||||
<div class="section rss">
|
||||
<a href="{{ path('blog_rss', app.request.query.all) }}">
|
||||
<i class="fa fa-rss" aria-hidden="true"></i> {{ 'menu.rss'|trans }}
|
||||
</a>
|
||||
</div>
|
15
app/templates/blog/about.html.twig
Normal file
15
app/templates/blog/about.html.twig
Normal file
@@ -0,0 +1,15 @@
|
||||
<div class="section about">
|
||||
<div class="well well-lg">
|
||||
<p>
|
||||
{{ 'help.app_description'|trans|raw }}
|
||||
</p>
|
||||
<p>
|
||||
{{ 'help.more_information'|trans|raw }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# it's not mandatory to set the timezone in localizeddate(). This is done to
|
||||
avoid errors when the 'intl' PHP extension is not available and the application
|
||||
is forced to use the limited "intl polyfill", which only supports UTC and GMT #}
|
||||
<!-- Fragment rendered on {{ 'now'|format_datetime('long', 'long', '', 'UTC') }} -->
|
11
app/templates/blog/comment_form_error.html.twig
Normal file
11
app/templates/blog/comment_form_error.html.twig
Normal file
@@ -0,0 +1,11 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body_id 'comment_form_error' %}
|
||||
|
||||
{% block main %}
|
||||
<h1 class="text-danger">{{ 'title.comment_error'|trans }}</h1>
|
||||
|
||||
<div class="well">
|
||||
{{ include('blog/_comment_form.html.twig') }}
|
||||
</div>
|
||||
{% endblock %}
|
59
app/templates/blog/index.html.twig
Normal file
59
app/templates/blog/index.html.twig
Normal file
@@ -0,0 +1,59 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body_id 'blog_index' %}
|
||||
|
||||
{% block main %}
|
||||
{% for post in paginator.results %}
|
||||
<article class="post">
|
||||
<h2>
|
||||
<a href="{{ path('blog_post', {slug: post.slug}) }}">
|
||||
{{ post.title }}
|
||||
</a>
|
||||
</h2>
|
||||
|
||||
<p class="post-metadata">
|
||||
<span class="metadata"><i class="fa fa-calendar"></i> {{ post.publishedAt|format_datetime('long', 'medium', '', 'UTC') }}</span>
|
||||
<span class="metadata"><i class="fa fa-user"></i> {{ post.author.fullName }}</span>
|
||||
</p>
|
||||
|
||||
<p>{{ post.summary }}</p>
|
||||
|
||||
{{ include('blog/_post_tags.html.twig') }}
|
||||
</article>
|
||||
{% else %}
|
||||
<div class="well">{{ 'post.no_posts_found'|trans }}</div>
|
||||
{% endfor %}
|
||||
|
||||
{% if paginator.hasToPaginate %}
|
||||
<div class="navigation text-center">
|
||||
<ul class="pagination">
|
||||
{% if paginator.hasPreviousPage %}
|
||||
<li class="prev"><a href="{{ path('blog_index_paginated', {page: paginator.previousPage, tag: tagName}) }}" rel="previous"><i class="fa fw fa-long-arrow-left"></i> {{ 'paginator.previous'|trans }}</a></li>
|
||||
{% else %}
|
||||
<li class="prev disabled"><span><i class="fa fw fa-arrow-left"></i> {{ 'paginator.previous'|trans }}</span></li>
|
||||
{% endif %}
|
||||
|
||||
{% for i in 1..paginator.lastPage %}
|
||||
{% if i == paginator.currentPage %}
|
||||
<li class="active"><span>{{ i }} <span class="sr-only">{{ 'paginator.current'|trans }}</span></span></li>
|
||||
{% else %}
|
||||
<li><a href="{{ path('blog_index_paginated', {page: i, tag: tagName}) }}">{{ i }}</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if paginator.hasNextPage %}
|
||||
<li class="next"><a href="{{ path('blog_index_paginated', {page: paginator.nextPage, tag: tagName}) }}" rel="next">{{ 'paginator.next'|trans }} <i class="fa fw fa-arrow-right"></i></a></li>
|
||||
{% else %}
|
||||
<li class="next disabled"><span>{{ 'paginator.next'|trans }} <i class="fa fw fa-arrow-right"></i></span></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
{{ parent() }}
|
||||
|
||||
{{ show_source_code(_self) }}
|
||||
{{ include('blog/_rss.html.twig') }}
|
||||
{% endblock %}
|
25
app/templates/blog/index.xml.twig
Normal file
25
app/templates/blog/index.xml.twig
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>{{ 'rss.title'|trans }}</title>
|
||||
<description>{{ 'rss.description'|trans }}</description>
|
||||
<pubDate>{{ 'now'|date('r', timezone='GMT') }}</pubDate>
|
||||
<lastBuildDate>{{ (paginator.results|last).publishedAt|default('now')|date('r', timezone='GMT') }}</lastBuildDate>
|
||||
<link>{{ url('blog_index') }}</link>
|
||||
<language>{{ app.request.locale }}</language>
|
||||
|
||||
{% for post in paginator.results %}
|
||||
<item>
|
||||
<title>{{ post.title }}</title>
|
||||
<description>{{ post.summary }}</description>
|
||||
<link>{{ url('blog_post', {'slug': post.slug}) }}</link>
|
||||
<guid>{{ url('blog_post', {'slug': post.slug}) }}</guid>
|
||||
<pubDate>{{ post.publishedAt|date(format='r', timezone='GMT') }}</pubDate>
|
||||
<author>{{ post.author.email }}</author>
|
||||
{% for tag in post.tags %}
|
||||
<category>{{ tag.name }}</category>
|
||||
{% endfor %}
|
||||
</item>
|
||||
{% endfor %}
|
||||
</channel>
|
||||
</rss>
|
77
app/templates/blog/post_show.html.twig
Normal file
77
app/templates/blog/post_show.html.twig
Normal file
@@ -0,0 +1,77 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body_id 'blog_post_show' %}
|
||||
|
||||
{% block main %}
|
||||
<h1>{{ post.title }}</h1>
|
||||
|
||||
<p class="post-metadata">
|
||||
<span class="metadata"><i class="fa fa-calendar"></i> {{ post.publishedAt|format_datetime('long', 'medium', '', 'UTC') }}</span>
|
||||
<span class="metadata"><i class="fa fa-user"></i> {{ post.author.fullName }}</span>
|
||||
</p>
|
||||
|
||||
{{ post.content|markdown_to_html|sanitize_html }}
|
||||
|
||||
{{ include('blog/_post_tags.html.twig') }}
|
||||
|
||||
<div id="post-add-comment" class="well">
|
||||
{# The 'IS_AUTHENTICATED_FULLY' role ensures that the user has entered
|
||||
their credentials (login + password) during this session. If they
|
||||
are automatically logged via the 'Remember Me' functionality, they won't
|
||||
be able to add a comment.
|
||||
See https://symfony.com/doc/current/security/remember_me.html#forcing-the-user-to-re-authenticate-before-accessing-certain-resources
|
||||
#}
|
||||
{% if is_granted('IS_AUTHENTICATED_FULLY') %}
|
||||
{{ render(controller('App\\Controller\\BlogController::commentForm', {'id': post.id})) }}
|
||||
{% else %}
|
||||
<p>
|
||||
<a class="btn btn-success" href="{{ path('security_login', {'redirect_to': app.request.pathInfo}) }}">
|
||||
<i class="fa fa-sign-in" aria-hidden="true"></i> {{ 'action.sign_in'|trans }}
|
||||
</a>
|
||||
{{ 'post.to_publish_a_comment'|trans }}
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<h3>
|
||||
<i class="fa fa-comments" aria-hidden="true"></i> {{ 'post.num_comments'|trans({ 'count': post.comments|length }) }}
|
||||
</h3>
|
||||
|
||||
{% for comment in post.comments %}
|
||||
<div class="row post-comment">
|
||||
<a name="comment_{{ comment.id }}"></a>
|
||||
<h4 class="col-sm-3">
|
||||
<strong>{{ comment.author.fullName }}</strong> {{ 'post.commented_on'|trans }}
|
||||
{# it's not mandatory to set the timezone in localizeddate(). This is done to
|
||||
avoid errors when the 'intl' PHP extension is not available and the application
|
||||
is forced to use the limited "intl polyfill", which only supports UTC and GMT #}
|
||||
<strong>{{ comment.publishedAt|format_datetime('medium', 'short', '', 'UTC') }}</strong>
|
||||
</h4>
|
||||
<div class="col-sm-9">
|
||||
{{ comment.content|markdown_to_html|sanitize_html }}
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="post-comment">
|
||||
<p>{{ 'post.no_comments'|trans }}</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% if is_granted('edit', post) %}
|
||||
<div class="section">
|
||||
<a class="btn btn-lg btn-block btn-success" href="{{ path('admin_post_edit', {id: post.id}) }}">
|
||||
<i class="fa fa-edit" aria-hidden="true"></i> {{ 'action.edit_post'|trans }}
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{# the parent() function includes the contents defined by the parent template
|
||||
('base.html.twig') for this block ('sidebar'). This is a very convenient way
|
||||
to share common contents in different templates #}
|
||||
{{ parent() }}
|
||||
|
||||
{{ show_source_code(_self) }}
|
||||
{{ include('blog/_rss.html.twig') }}
|
||||
{% endblock %}
|
32
app/templates/blog/search.html.twig
Normal file
32
app/templates/blog/search.html.twig
Normal file
@@ -0,0 +1,32 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block javascripts %}
|
||||
{{ parent() }}
|
||||
{{ encore_entry_script_tags('search') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block body_id 'blog_search' %}
|
||||
|
||||
{% block main %}
|
||||
<form action="{{ path('blog_search') }}" method="get">
|
||||
<div class="form-group">
|
||||
<input name="q"
|
||||
class="form-control search-field"
|
||||
placeholder="{{ 'post.search_for'|trans }}"
|
||||
autocomplete="off"
|
||||
value="{{ query }}"
|
||||
autofocus
|
||||
data-no-results-message="{{ 'post.search_no_results'|trans }}"
|
||||
>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div id="results">
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
{{ parent() }}
|
||||
|
||||
{{ show_source_code(_self) }}
|
||||
{% endblock %}
|
Reference in New Issue
Block a user