[COMPONENTS][Search] Polished template

[COMPONENTS][Search] Fix event typo
This commit is contained in:
Eliseu Amaro 2021-12-02 16:37:17 +00:00
parent 5cd96669fd
commit f35dbbd8c1
Signed by: eliseuamaro
GPG Key ID: 96DA09D4B97BC2D5
3 changed files with 41 additions and 18 deletions

View File

@ -40,7 +40,7 @@ class Search extends Controller
$actor_qb = DB::createQueryBuilder(); $actor_qb = DB::createQueryBuilder();
$note_qb->select('note')->from('App\Entity\Note', 'note'); $note_qb->select('note')->from('App\Entity\Note', 'note');
$actor_qb->select('actor')->from('App\Entity\Actor', 'actor'); $actor_qb->select('actor')->from('App\Entity\Actor', 'actor');
Event::handle('SeachQueryAddJoins', [&$note_qb, &$actor_qb]); Event::handle('SearchQueryAddJoins', [&$note_qb, &$actor_qb]);
$notes = $actors = []; $notes = $actors = [];
if (!\is_null($note_criteria)) { if (!\is_null($note_criteria)) {
$note_qb->addCriteria($note_criteria); $note_qb->addCriteria($note_criteria);

View File

@ -41,12 +41,13 @@ class Search extends Component
/** /**
* Add the search form to the site header * Add the search form to the site header
* @throws RedirectException
*/ */
public function onAddExtraHeaderForms(Request $request, array &$elements) public function onAddExtraHeaderForms(Request $request, array &$elements)
{ {
$form = Form::create([ $form = Form::create([
['query', TextType::class, [ ['search_tags', TextType::class, [
'attr' => ['placeholder' => _m('Search tags...')], 'attr' => ['placeholder' => _m('Input desired query...')],
]], ]],
[$form_name = 'submit_search', SubmitType::class, [$form_name = 'submit_search', SubmitType::class,
[ [
@ -63,7 +64,7 @@ class Search extends Component
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData(); $data = $form->getData();
throw new RedirectException('search', ['q' => $data['query']]); throw new RedirectException('search', ['q' => $data['search_tags']]);
} }
} }

View File

@ -1,20 +1,42 @@
{% extends 'base.html.twig' %} {% extends 'stdgrid.html.twig' %}
{% import '/cards/note/view.html.twig' as noteView %} {% import '/cards/note/view.html.twig' as noteView %}
{% block title %}{% if page_title is defined %}{{ page_title | trans }}{% endif %}{% endblock %}
{% block stylesheets %}
{{ parent() }}
<link rel="stylesheet" href="{{ asset('assets/default_theme/css/pages/feeds.css') }}" type="text/css">
{% endblock stylesheets %}
{% block body %} {% block body %}
{% for note in notes %} {% if error %}
{% block current_note %} <label class="alert alert-danger">
<div class="section-widget"> {{ error.getMessage() }}
{{ noteView.macro_note(note) }} </label>
</div> {% endif %}
{% endblock current_note %}
{% endfor %}
{% for actor in actors %} {# Backwards compatibility with hAtom 0.1 #}
{% include 'actor/view.html.twig' with {'actor': actor} %} <main class="feed" tabindex="0" role="feed">
{% endfor %} <div class="h-feed hfeed notes">
{% if notes is defined and notes is not empty %}
{% for note in notes %}
{% block current_note %}
<div class="section-widget">
{{ noteView.macro_note(note) }}
<hr tabindex="0" title="{{ 'End of note and replies.' | trans }}">
</div>
{% endblock current_note %}
{% endfor %}
{% else %}
<div id="empty-notes"><h1>{% trans %}No notes here.{% endtrans %}</h1></div>
{% endif %}
</div>
</main>
{{ "Page: " ~ page }} {% for actor in actors %}
{% endblock %} {% include 'actor/view.html.twig' with {'actor': actor} %}
{% endfor %}
{{ "Page: " ~ page }}
{% endblock body %}