Add controller, views and translations for ignore origin instance rules

Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
This commit is contained in:
Kevin Decherf 2019-08-27 00:03:30 +02:00
parent b22eb27623
commit 7408a6cb68
26 changed files with 673 additions and 4 deletions

View file

@ -79,4 +79,5 @@ security:
- { path: ^/annotations, roles: ROLE_USER } - { path: ^/annotations, roles: ROLE_USER }
- { path: ^/2fa, role: IS_AUTHENTICATED_2FA_IN_PROGRESS } - { path: ^/2fa, role: IS_AUTHENTICATED_2FA_IN_PROGRESS }
- { path: ^/users, roles: ROLE_SUPER_ADMIN } - { path: ^/users, roles: ROLE_SUPER_ADMIN }
- { path: ^/ignore-origin-instance-rules, roles: ROLE_SUPER_ADMIN }
- { path: ^/, roles: ROLE_USER } - { path: ^/, roles: ROLE_USER }

View file

@ -0,0 +1,138 @@
<?php
namespace Wallabag\CoreBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule;
/**
* IgnoreOriginInstanceRuleController controller.
*
* @Route("/ignore-origin-instance-rules")
*/
class IgnoreOriginInstanceRuleController extends Controller
{
/**
* Lists all IgnoreOriginInstanceRule entities.
*
* @Route("/", name="ignore_origin_instance_rules_index", methods={"GET"})
*/
public function indexAction()
{
$rules = $this->get('wallabag_core.ignore_origin_instance_rule_repository')->findAll();
return $this->render('WallabagCoreBundle:IgnoreOriginInstanceRule:index.html.twig', [
'rules' => $rules,
]);
}
/**
* Creates a new ignore origin instance rule entity.
*
* @Route("/new", name="ignore_origin_instance_rules_new", methods={"GET", "POST"})
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function newAction(Request $request)
{
$ignoreOriginInstanceRule = new IgnoreOriginInstanceRule();
$form = $this->createForm('Wallabag\CoreBundle\Form\Type\IgnoreOriginInstanceRuleType', $ignoreOriginInstanceRule);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($ignoreOriginInstanceRule);
$em->flush();
$this->get('session')->getFlashBag()->add(
'notice',
$this->get('translator')->trans('flashes.ignore_origin_instance_rule.notice.added')
);
return $this->redirectToRoute('ignore_origin_instance_rules_index');
}
return $this->render('WallabagCoreBundle:IgnoreOriginInstanceRule:new.html.twig', [
'rule' => $ignoreOriginInstanceRule,
'form' => $form->createView(),
]);
}
/**
* Displays a form to edit an existing ignore origin instance rule entity.
*
* @Route("/{id}/edit", name="ignore_origin_instance_rules_edit", methods={"GET", "POST"})
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function editAction(Request $request, IgnoreOriginInstanceRule $ignoreOriginInstanceRule)
{
$deleteForm = $this->createDeleteForm($ignoreOriginInstanceRule);
$editForm = $this->createForm('Wallabag\CoreBundle\Form\Type\IgnoreOriginInstanceRuleType', $ignoreOriginInstanceRule);
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($ignoreOriginInstanceRule);
$em->flush();
$this->get('session')->getFlashBag()->add(
'notice',
$this->get('translator')->trans('flashes.ignore_origin_instance_rule.notice.updated')
);
return $this->redirectToRoute('ignore_origin_instance_rules_index');
}
return $this->render('WallabagCoreBundle:IgnoreOriginInstanceRule:edit.html.twig', [
'rule' => $ignoreOriginInstanceRule,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
]);
}
/**
* Deletes a site credential entity.
*
* @Route("/{id}", name="ignore_origin_instance_rules_delete", methods={"DELETE"})
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
public function deleteAction(Request $request, IgnoreOriginInstanceRule $ignoreOriginInstanceRule)
{
$form = $this->createDeleteForm($ignoreOriginInstanceRule);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->get('session')->getFlashBag()->add(
'notice',
$this->get('translator')->trans('flashes.ignore_origin_instance_rule.notice.deleted')
);
$em = $this->getDoctrine()->getManager();
$em->remove($ignoreOriginInstanceRule);
$em->flush();
}
return $this->redirectToRoute('ignore_origin_instance_rules_index');
}
/**
* Creates a form to delete a ignore origin instance rule entity.
*
* @param IgnoreOriginInstanceRule $ignoreOriginInstanceRule The ignore origin instance rule entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createDeleteForm(IgnoreOriginInstanceRule $ignoreOriginInstanceRule)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('ignore_origin_instance_rules_delete', ['id' => $ignoreOriginInstanceRule->getId()]))
->setMethod('DELETE')
->getForm()
;
}
}

View file

@ -0,0 +1,37 @@
<?php
namespace Wallabag\CoreBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class IgnoreOriginInstanceRuleType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('rule', TextType::class, [
'required' => true,
'label' => 'config.form_rules.rule_label',
])
->add('save', SubmitType::class, [
'label' => 'config.form.save',
])
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => 'Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule',
]);
}
public function getBlockPrefix()
{
return 'ignore_origin_instance_rule';
}
}

View file

@ -33,6 +33,7 @@ menu:
back_to_unread: 'Tilbage til de ulæste artikler' back_to_unread: 'Tilbage til de ulæste artikler'
# users_management: 'Users management' # users_management: 'Users management'
# site_credentials: 'Site credentials' # site_credentials: 'Site credentials'
# ignore_origin_instance_rules: 'Global ignore origin rules'
# quickstart: "Quickstart" # quickstart: "Quickstart"
top: top:
add_new_entry: 'Tilføj ny artikel' add_new_entry: 'Tilføj ny artikel'
@ -661,3 +662,8 @@ flashes:
# added: 'Site credential for "%host%" added' # added: 'Site credential for "%host%" added'
# updated: 'Site credential for "%host%" updated' # updated: 'Site credential for "%host%" updated'
# deleted: 'Site credential for "%host%" deleted' # deleted: 'Site credential for "%host%" deleted'
ignore_origin_instance_rule:
notice:
# added: 'Global ignore origin rule added'
# updated: 'Global ignore origin rule updated'
# deleted: 'Global ignore origin rule deleted'

View file

@ -33,6 +33,7 @@ menu:
back_to_unread: 'Zurück zu ungelesenen Artikeln' back_to_unread: 'Zurück zu ungelesenen Artikeln'
users_management: 'Benutzerverwaltung' users_management: 'Benutzerverwaltung'
site_credentials: 'Zugangsdaten' site_credentials: 'Zugangsdaten'
# ignore_origin_instance_rules: 'Global ignore origin rules'
quickstart: "Schnelleinstieg" quickstart: "Schnelleinstieg"
top: top:
add_new_entry: 'Neuen Artikel hinzufügen' add_new_entry: 'Neuen Artikel hinzufügen'
@ -661,3 +662,8 @@ flashes:
added: 'Zugangsdaten für "%host%" hinzugefügt' added: 'Zugangsdaten für "%host%" hinzugefügt'
updated: 'Zugangsdaten für "%host%" aktualisiert' updated: 'Zugangsdaten für "%host%" aktualisiert'
deleted: 'Zugangsdaten für "%host%" gelöscht' deleted: 'Zugangsdaten für "%host%" gelöscht'
ignore_origin_instance_rule:
notice:
# added: 'Global ignore origin rule added'
# updated: 'Global ignore origin rule updated'
# deleted: 'Global ignore origin rule deleted'

View file

@ -33,6 +33,7 @@ menu:
back_to_unread: 'Back to unread articles' back_to_unread: 'Back to unread articles'
users_management: 'Users management' users_management: 'Users management'
site_credentials: 'Site credentials' site_credentials: 'Site credentials'
ignore_origin_instance_rules: 'Global ignore origin rules'
quickstart: "Quickstart" quickstart: "Quickstart"
top: top:
add_new_entry: 'Add a new entry' add_new_entry: 'Add a new entry'
@ -595,6 +596,24 @@ site_credential:
delete_confirm: Are you sure? delete_confirm: Are you sure?
back_to_list: Back to list back_to_list: Back to list
ignore_origin_instance_rule:
page_title: Global ignore origin rules
new_ignore_origin_instance_rule: Create a global ignore origin rule
edit_ignore_origin_instance_rule: Edit an existing ignore origin rule
description: "Here you can manage the global ignore origin rules used to ignore some patterns of origin url."
list:
actions: Actions
edit_action: Edit
yes: Yes
no: No
create_new_one: Create a new global ignore origin rule
form:
rule_label: Rule
save: Save
delete: Delete
delete_confirm: Are you sure?
back_to_list: Back to list
error: error:
page_title: An error occurred page_title: An error occurred
@ -661,3 +680,8 @@ flashes:
added: 'Site credential for "%host%" added' added: 'Site credential for "%host%" added'
updated: 'Site credential for "%host%" updated' updated: 'Site credential for "%host%" updated'
deleted: 'Site credential for "%host%" deleted' deleted: 'Site credential for "%host%" deleted'
ignore_origin_instance_rule:
notice:
added: 'Global ignore origin rule added'
updated: 'Global ignore origin rule updated'
deleted: 'Global ignore origin rule deleted'

View file

@ -33,6 +33,7 @@ menu:
back_to_unread: 'Volver a los artículos sin leer' back_to_unread: 'Volver a los artículos sin leer'
users_management: 'Configuración de usuarios' users_management: 'Configuración de usuarios'
site_credentials: 'Credenciales del sitio' site_credentials: 'Credenciales del sitio'
# ignore_origin_instance_rules: 'Global ignore origin rules'
quickstart: "Inicio rápido" quickstart: "Inicio rápido"
top: top:
add_new_entry: 'Añadir un nuevo artículo' add_new_entry: 'Añadir un nuevo artículo'
@ -661,3 +662,8 @@ flashes:
added: 'Credenciales del sitio añadidas para "%host%"' added: 'Credenciales del sitio añadidas para "%host%"'
updated: 'Credenciales del sitio actualizadas para "%host%"' updated: 'Credenciales del sitio actualizadas para "%host%"'
deleted: 'Credenciales del sitio eliminadas para "%host%"' deleted: 'Credenciales del sitio eliminadas para "%host%"'
ignore_origin_instance_rule:
notice:
# added: 'Global ignore origin rule added'
# updated: 'Global ignore origin rule updated'
# deleted: 'Global ignore origin rule deleted'

View file

@ -33,6 +33,7 @@ menu:
back_to_unread: 'بازگشت به خوانده‌نشده‌ها' back_to_unread: 'بازگشت به خوانده‌نشده‌ها'
# users_management: 'Users management' # users_management: 'Users management'
# site_credentials: 'Site credentials' # site_credentials: 'Site credentials'
# ignore_origin_instance_rules: 'Global ignore origin rules'
quickstart: "Quickstart" quickstart: "Quickstart"
top: top:
add_new_entry: 'افزودن مقالهٔ تازه' add_new_entry: 'افزودن مقالهٔ تازه'
@ -661,3 +662,8 @@ flashes:
# added: 'Site credential for "%host%" added' # added: 'Site credential for "%host%" added'
# updated: 'Site credential for "%host%" updated' # updated: 'Site credential for "%host%" updated'
# deleted: 'Site credential for "%host%" deleted' # deleted: 'Site credential for "%host%" deleted'
ignore_origin_instance_rule:
notice:
# added: 'Global ignore origin rule added'
# updated: 'Global ignore origin rule updated'
# deleted: 'Global ignore origin rule deleted'

View file

@ -33,6 +33,7 @@ menu:
back_to_unread: "Retour aux articles non lus" back_to_unread: "Retour aux articles non lus"
users_management: "Gestion des utilisateurs" users_management: "Gestion des utilisateurs"
site_credentials: 'Accès aux sites' site_credentials: 'Accès aux sites'
ignore_origin_instance_rules: "Règles globales d'omission d'origine"
quickstart: "Pour bien débuter" quickstart: "Pour bien débuter"
top: top:
add_new_entry: "Sauvegarder un nouvel article" add_new_entry: "Sauvegarder un nouvel article"
@ -619,11 +620,8 @@ flashes:
otp_disabled: "Authentification à double-facteur désactivée" otp_disabled: "Authentification à double-facteur désactivée"
tagging_rules_imported: Règles bien importées tagging_rules_imported: Règles bien importées
tagging_rules_not_imported: Impossible d'importer les règles tagging_rules_not_imported: Impossible d'importer les règles
<<<<<<< HEAD
=======
ignore_origin_rules_deleted: "Règle d'omission d'origine supprimée" ignore_origin_rules_deleted: "Règle d'omission d'origine supprimée"
ignore_origin_rules_updated: "Règle d'omission d'origine mise à jour" ignore_origin_rules_updated: "Règle d'omission d'origine mise à jour"
>>>>>>> 4c595340... fixup! Add new Ignore Origin rules tab, update ConfigController
entry: entry:
notice: notice:
entry_already_saved: "Article déjà sauvegardé le %date%" entry_already_saved: "Article déjà sauvegardé le %date%"

View file

@ -33,6 +33,7 @@ menu:
back_to_unread: 'Torna ai contenuti non letti' back_to_unread: 'Torna ai contenuti non letti'
users_management: 'Gestione utenti' users_management: 'Gestione utenti'
site_credentials: 'Credenziali sito' site_credentials: 'Credenziali sito'
# ignore_origin_instance_rules: 'Global ignore origin rules'
quickstart: "Introduzione" quickstart: "Introduzione"
top: top:
add_new_entry: 'Aggiungi un nuovo contenuto' add_new_entry: 'Aggiungi un nuovo contenuto'
@ -661,3 +662,8 @@ flashes:
# added: 'Site credential for "%host%" added' # added: 'Site credential for "%host%" added'
# updated: 'Site credential for "%host%" updated' # updated: 'Site credential for "%host%" updated'
# deleted: 'Site credential for "%host%" deleted' # deleted: 'Site credential for "%host%" deleted'
ignore_origin_instance_rule:
notice:
# added: 'Global ignore origin rule added'
# updated: 'Global ignore origin rule updated'
# deleted: 'Global ignore origin rule deleted'

View file

@ -33,6 +33,7 @@ menu:
back_to_unread: 'Tornar als articles pas legits' back_to_unread: 'Tornar als articles pas legits'
users_management: 'Gestion dels utilizaires' users_management: 'Gestion dels utilizaires'
site_credentials: 'Identificants del site' site_credentials: 'Identificants del site'
# ignore_origin_instance_rules: 'Global ignore origin rules'
quickstart: "Per ben començar" quickstart: "Per ben començar"
top: top:
add_new_entry: 'Enregistrar un novèl article' add_new_entry: 'Enregistrar un novèl article'
@ -661,3 +662,8 @@ flashes:
added: 'Identificant per "%host%" ajustat' added: 'Identificant per "%host%" ajustat'
updated: 'Identificant per "%host%" mes a jorn' updated: 'Identificant per "%host%" mes a jorn'
deleted: 'Identificant per "%host%" suprimit' deleted: 'Identificant per "%host%" suprimit'
ignore_origin_instance_rule:
notice:
# added: 'Global ignore origin rule added'
# updated: 'Global ignore origin rule updated'
# deleted: 'Global ignore origin rule deleted'

View file

@ -33,6 +33,7 @@ menu:
back_to_unread: 'Powrót do nieprzeczytanych artykułów' back_to_unread: 'Powrót do nieprzeczytanych artykułów'
users_management: 'Zarządzanie użytkownikami' users_management: 'Zarządzanie użytkownikami'
site_credentials: 'Poświadczenia strony' site_credentials: 'Poświadczenia strony'
# ignore_origin_instance_rules: 'Global ignore origin rules'
quickstart: "Szybki start" quickstart: "Szybki start"
top: top:
add_new_entry: 'Dodaj nowy wpis' add_new_entry: 'Dodaj nowy wpis'
@ -661,3 +662,8 @@ flashes:
added: 'Poświadczenie dla "%host%" dodane' added: 'Poświadczenie dla "%host%" dodane'
updated: 'Poświadczenie dla "%host%" zaktualizowane' updated: 'Poświadczenie dla "%host%" zaktualizowane'
deleted: 'Poświadczenie dla "%host%" usuniętę' deleted: 'Poświadczenie dla "%host%" usuniętę'
ignore_origin_instance_rule:
notice:
# added: 'Global ignore origin rule added'
# updated: 'Global ignore origin rule updated'
# deleted: 'Global ignore origin rule deleted'

View file

@ -33,6 +33,7 @@ menu:
back_to_unread: 'Voltar para os artigos não lidos' back_to_unread: 'Voltar para os artigos não lidos'
users_management: 'Gestão de Usuários' users_management: 'Gestão de Usuários'
site_credentials: 'Credenciais do site' site_credentials: 'Credenciais do site'
# ignore_origin_instance_rules: 'Global ignore origin rules'
quickstart: "Começo Rápido" quickstart: "Começo Rápido"
top: top:
add_new_entry: 'Adicionar um novo artigo' add_new_entry: 'Adicionar um novo artigo'
@ -658,3 +659,8 @@ flashes:
added: 'Credencial do site para "%host%" foi adicionada' added: 'Credencial do site para "%host%" foi adicionada'
updated: 'Credencial do site pa "%host%" atualizada' updated: 'Credencial do site pa "%host%" atualizada'
deleted: 'Credencial do site pa "%host%" removida' deleted: 'Credencial do site pa "%host%" removida'
ignore_origin_instance_rule:
notice:
# added: 'Global ignore origin rule added'
# updated: 'Global ignore origin rule updated'
# deleted: 'Global ignore origin rule deleted'

View file

@ -33,6 +33,7 @@ menu:
back_to_unread: 'Înapoi la articolele necitite' back_to_unread: 'Înapoi la articolele necitite'
# users_management: 'Users management' # users_management: 'Users management'
# site_credentials: 'Site credentials' # site_credentials: 'Site credentials'
# ignore_origin_instance_rules: 'Global ignore origin rules'
# quickstart: "Quickstart" # quickstart: "Quickstart"
top: top:
add_new_entry: 'Introdu un nou articol' add_new_entry: 'Introdu un nou articol'
@ -660,3 +661,8 @@ flashes:
# added: 'Site credential for "%host%" added' # added: 'Site credential for "%host%" added'
# updated: 'Site credential for "%host%" updated' # updated: 'Site credential for "%host%" updated'
# deleted: 'Site credential for "%host%" deleted' # deleted: 'Site credential for "%host%" deleted'
ignore_origin_instance_rule:
notice:
# added: 'Global ignore origin rule added'
# updated: 'Global ignore origin rule updated'
# deleted: 'Global ignore origin rule deleted'

View file

@ -33,6 +33,7 @@ menu:
back_to_unread: 'Назад к непрочитанным записям' back_to_unread: 'Назад к непрочитанным записям'
users_management: 'Управление пользователями' users_management: 'Управление пользователями'
site_credentials: 'Site credentials' site_credentials: 'Site credentials'
# ignore_origin_instance_rules: 'Global ignore origin rules'
quickstart: "Быстрый старт" quickstart: "Быстрый старт"
top: top:
add_new_entry: 'Добавить новую запись' add_new_entry: 'Добавить новую запись'
@ -660,3 +661,8 @@ flashes:
# added: 'Site credential for "%host%" added' # added: 'Site credential for "%host%" added'
# updated: 'Site credential for "%host%" updated' # updated: 'Site credential for "%host%" updated'
# deleted: 'Site credential for "%host%" deleted' # deleted: 'Site credential for "%host%" deleted'
ignore_origin_instance_rule:
notice:
# added: 'Global ignore origin rule added'
# updated: 'Global ignore origin rule updated'
# deleted: 'Global ignore origin rule deleted'

View file

@ -33,6 +33,7 @@ menu:
back_to_unread: 'กลับไปยังรายการที่ไม่ได้อ่าน' back_to_unread: 'กลับไปยังรายการที่ไม่ได้อ่าน'
users_management: 'การจัดการผู้ใช้' users_management: 'การจัดการผู้ใช้'
site_credentials: 'การรับรองไซต์' site_credentials: 'การรับรองไซต์'
# ignore_origin_instance_rules: 'Global ignore origin rules'
quickstart: "เริ่มแบบด่วน" quickstart: "เริ่มแบบด่วน"
top: top:
add_new_entry: 'เพิ่มรายการใหม่' add_new_entry: 'เพิ่มรายการใหม่'
@ -660,3 +661,8 @@ flashes:
added: 'ไซต์ข้อมูลประจำตัวสำหรับ "%host%" ที่ทำการเพิ่ม' added: 'ไซต์ข้อมูลประจำตัวสำหรับ "%host%" ที่ทำการเพิ่ม'
updated: 'ไซต์ข้อมูลประจำตัวสำหรับ "%host%" ที่ทำการอัปเดต' updated: 'ไซต์ข้อมูลประจำตัวสำหรับ "%host%" ที่ทำการอัปเดต'
deleted: 'ไซต์ข้อมูลประจำตัวสำหรับ "%host%" ที่ทำการลบ' deleted: 'ไซต์ข้อมูลประจำตัวสำหรับ "%host%" ที่ทำการลบ'
ignore_origin_instance_rule:
notice:
# added: 'Global ignore origin rule added'
# updated: 'Global ignore origin rule updated'
# deleted: 'Global ignore origin rule deleted'

View file

@ -33,6 +33,7 @@ menu:
back_to_unread: 'Okunmayan makalelere geri dön' back_to_unread: 'Okunmayan makalelere geri dön'
# users_management: 'Users management' # users_management: 'Users management'
# site_credentials: 'Site credentials' # site_credentials: 'Site credentials'
# ignore_origin_instance_rules: 'Global ignore origin rules'
quickstart: "Hızlı başlangıç" quickstart: "Hızlı başlangıç"
top: top:
add_new_entry: 'Yeni bir makale ekle' add_new_entry: 'Yeni bir makale ekle'
@ -660,3 +661,8 @@ flashes:
# added: 'Site credential for "%host%" added' # added: 'Site credential for "%host%" added'
# updated: 'Site credential for "%host%" updated' # updated: 'Site credential for "%host%" updated'
# deleted: 'Site credential for "%host%" deleted' # deleted: 'Site credential for "%host%" deleted'
ignore_origin_instance_rule:
notice:
# added: 'Global ignore origin rule added'
# updated: 'Global ignore origin rule updated'
# deleted: 'Global ignore origin rule deleted'

View file

@ -0,0 +1,44 @@
{% extends "WallabagCoreBundle::layout.html.twig" %}
{% block title %}{{ 'ignore_origin_instance_rule.page_title'|trans }}{% endblock %}
{% block content %}
<div class="row">
<div class="col s12">
<div class="card-panel">
<div class="row">
<div class="input-field col s12">
<h4>{{ 'ignore_origin_instance_rule.edit_ignore_origin_instance_rule'|trans }}</h4>
<div id="set6" class="col s12">
{{ form_start(edit_form) }}
{{ form_errors(edit_form) }}
<div class="row">
<div class="input-field col s12">
{{ form_label(edit_form.rule) }}
{{ form_errors(edit_form.rule) }}
{{ form_widget(edit_form.rule) }}
</div>
</div>
<br/>
{{ form_widget(edit_form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }}
{{ form_widget(edit_form._token) }}
</form>
<p>
{{ form_start(delete_form) }}
<button onclick="return confirm('{{ 'ignore_origin_instance_rule.form.delete_confirm'|trans|escape('js') }}')" type="submit" class="btn waves-effect waves-light red">{{ 'ignore_origin_instance_rule.form.delete'|trans }}</button>
{{ form_end(delete_form) }}
</p>
<p><a class="waves-effect waves-light btn blue-grey" href="{{ path('ignore_origin_instance_rules_index') }}">{{ 'ignore_origin_instance_rule.form.back_to_list'|trans }}</a></p>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -0,0 +1,42 @@
{% extends "WallabagCoreBundle::layout.html.twig" %}
{% block title %}{{ 'ignore_origin_instance_rule.page_title'|trans }}{% endblock %}
{% block content %}
<div class="row">
<div class="col s12">
<div class="card-panel">
<div class="row">
<div class="input-field col s12">
<p class="help">{{ 'ignore_origin_instance_rule.description'|trans|raw }}</p>
<table class="bordered">
<thead>
<tr>
<th>{{ 'ignore_origin_instance_rule.form.rule_label'|trans }}</th>
<th>{{ 'ignore_origin_instance_rule.list.actions'|trans }}</th>
</tr>
</thead>
<tbody>
{% for rule in rules %}
<tr>
<td>{{ rule.rule }}</td>
<td>
<a href="{{ path('ignore_origin_instance_rules_edit', { 'id': rule.id }) }}">{{ 'ignore_origin_instance_rule.list.edit_action'|trans }}</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<br />
<p>
<a href="{{ path('ignore_origin_instance_rules_new') }}" class="waves-effect waves-light btn">{{ 'ignore_origin_instance_rule.list.create_new_one'|trans }}</a>
</p>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -0,0 +1,37 @@
{% extends "WallabagCoreBundle::layout.html.twig" %}
{% block title %}{{ 'ignore_origin_instance_rule.page_title'|trans }}{% endblock %}
{% block content %}
<div class="row">
<div class="col s12">
<div class="card-panel">
<div class="row">
<div class="input-field col s12">
<h4>{{ 'ignore_origin_instance_rule.new_ignore_origin_instance_rule'|trans }}</h4>
<div id="set6" class="col s12">
{{ form_start(form) }}
{{ form_errors(form) }}
<div class="row">
<div class="input-field col s12">
{{ form_label(form.rule) }}
{{ form_errors(form.rule) }}
{{ form_widget(form.rule) }}
</div>
</div>
{{ form_widget(form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }}
{{ form_rest(form) }}
</form>
<p><a class="waves-effect waves-light btn blue-grey" href="{{ path('ignore_origin_instance_rules_index') }}">{{ 'ignore_origin_instance_rule.form.back_to_list'|trans }}</a></p>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -45,6 +45,7 @@
{% if is_granted('ROLE_SUPER_ADMIN') %} {% if is_granted('ROLE_SUPER_ADMIN') %}
<li class="menu users"><a href="{{ path('user_index') }}">{{ 'menu.left.users_management'|trans }}</a></li> <li class="menu users"><a href="{{ path('user_index') }}">{{ 'menu.left.users_management'|trans }}</a></li>
<li class="menu internal"><a href="{{ path('craue_config_settings_modify') }}">{{ 'menu.left.internal_settings'|trans }}</a></li> <li class="menu internal"><a href="{{ path('craue_config_settings_modify') }}">{{ 'menu.left.internal_settings'|trans }}</a></li>
<li class="menu ignore"><a href="{{ path('ignore_origin_instance_rules_index') }}">{{ 'menu.left.ignore_origin_instance_rules'|trans }}</a></li>
{% endif %} {% endif %}
<li class="menu import"><a href="{{ path('import') }}">{{ 'menu.left.import'|trans }}</a></li> <li class="menu import"><a href="{{ path('import') }}">{{ 'menu.left.import'|trans }}</a></li>
<li class="menu howto"><a href="{{ path('howto') }}">{{ 'menu.left.howto'|trans }}</a></li> <li class="menu howto"><a href="{{ path('howto') }}">{{ 'menu.left.howto'|trans }}</a></li>

View file

@ -0,0 +1,44 @@
{% extends "WallabagCoreBundle::layout.html.twig" %}
{% block title %}{{ 'ignore_origin_instance_rule.page_title'|trans }}{% endblock %}
{% block content %}
<div class="row">
<div class="col s12">
<div class="card-panel">
<div class="row">
<div class="input-field col s12">
<h4>{{ 'ignore_origin_instance_rule.edit_ignore_origin_instance_rule'|trans }}</h4>
<div id="set6" class="col s12">
{{ form_start(edit_form) }}
{{ form_errors(edit_form) }}
<div class="row">
<div class="input-field col s12">
{{ form_label(edit_form.rule) }}
{{ form_errors(edit_form.rule) }}
{{ form_widget(edit_form.rule) }}
</div>
</div>
<br/>
{{ form_widget(edit_form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }}
{{ form_widget(edit_form._token) }}
</form>
<p>
{{ form_start(delete_form) }}
<button onclick="return confirm('{{ 'ignore_origin_instance_rule.form.delete_confirm'|trans|escape('js') }}')" type="submit" class="btn waves-effect waves-light red">{{ 'ignore_origin_instance_rule.form.delete'|trans }}</button>
{{ form_end(delete_form) }}
</p>
<p><a class="waves-effect waves-light btn blue-grey" href="{{ path('ignore_origin_instance_rules_index') }}">{{ 'ignore_origin_instance_rule.form.back_to_list'|trans }}</a></p>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -0,0 +1,42 @@
{% extends "WallabagCoreBundle::layout.html.twig" %}
{% block title %}{{ 'ignore_origin_instance_rule.page_title'|trans }}{% endblock %}
{% block content %}
<div class="row">
<div class="col s12">
<div class="card-panel">
<div class="row">
<div class="input-field col s12">
<p class="help">{{ 'ignore_origin_instance_rule.description'|trans|raw }}</p>
<table class="bordered">
<thead>
<tr>
<th>{{ 'ignore_origin_instance_rule.form.rule_label'|trans }}</th>
<th>{{ 'ignore_origin_instance_rule.list.actions'|trans }}</th>
</tr>
</thead>
<tbody>
{% for rule in rules %}
<tr>
<td>{{ rule.rule }}</td>
<td>
<a href="{{ path('ignore_origin_instance_rules_edit', { 'id': rule.id }) }}">{{ 'ignore_origin_instance_rule.list.edit_action'|trans }}</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<br />
<p>
<a href="{{ path('ignore_origin_instance_rules_new') }}" class="waves-effect waves-light btn">{{ 'ignore_origin_instance_rule.list.create_new_one'|trans }}</a>
</p>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -0,0 +1,37 @@
{% extends "WallabagCoreBundle::layout.html.twig" %}
{% block title %}{{ 'ignore_origin_instance_rule.page_title'|trans }}{% endblock %}
{% block content %}
<div class="row">
<div class="col s12">
<div class="card-panel">
<div class="row">
<div class="input-field col s12">
<h4>{{ 'ignore_origin_instance_rule.new_ignore_origin_instance_rule'|trans }}</h4>
<div id="set6" class="col s12">
{{ form_start(form) }}
{{ form_errors(form) }}
<div class="row">
<div class="input-field col s12">
{{ form_label(form.rule) }}
{{ form_errors(form.rule) }}
{{ form_widget(form.rule) }}
</div>
</div>
{{ form_widget(form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }}
{{ form_rest(form) }}
</form>
<p><a class="waves-effect waves-light btn blue-grey" href="{{ path('ignore_origin_instance_rules_index') }}">{{ 'ignore_origin_instance_rule.form.back_to_list'|trans }}</a></p>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -78,9 +78,13 @@
<a class="waves-effect" href="{{ path('user_index') }}">{{ 'menu.left.users_management'|trans }}</a> <a class="waves-effect" href="{{ path('user_index') }}">{{ 'menu.left.users_management'|trans }}</a>
</li> </li>
<li class="bold border-bottom {% if currentRoute == 'craue_config_settings_modify' %}active{% endif %}"> <li class="bold {% if currentRoute == 'craue_config_settings_modify' %}active{% endif %}">
<a class="waves-effect" href="{{ path('craue_config_settings_modify') }}">{{ 'menu.left.internal_settings'|trans }}</a> <a class="waves-effect" href="{{ path('craue_config_settings_modify') }}">{{ 'menu.left.internal_settings'|trans }}</a>
</li> </li>
<li class="bold border-bottom {% if currentRoute == 'ignore_origin_instance_rules_index' %}active{% endif %}">
<a class="waves-effect" href="{{ path('ignore_origin_instance_rules_index') }}">{{ 'menu.left.ignore_origin_instance_rules'|trans }}</a>
</li>
{% endif %} {% endif %}
<li class="bold {% if currentRoute == 'import' %}active{% endif %}"> <li class="bold {% if currentRoute == 'import' %}active{% endif %}">
<a class="waves-effect" href="{{ path('import') }}">{{ 'menu.left.import'|trans }}</a> <a class="waves-effect" href="{{ path('import') }}">{{ 'menu.left.import'|trans }}</a>

View file

@ -0,0 +1,148 @@
<?php
namespace Tests\Wallabag\CoreBundle\Controller;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
class IgnoreOriginInstanceRuleControllerTest extends WallabagCoreTestCase
{
public function testListIgnoreOriginInstanceRule()
{
$this->logInAs('admin');
$client = $this->getClient();
$crawler = $client->request('GET', '/ignore-origin-instance-rules/');
$this->assertSame(200, $client->getResponse()->getStatusCode());
$body = $crawler->filter('body')->extract(['_text'])[0];
$this->assertContains('ignore_origin_instance_rule.description', $body);
$this->assertContains('ignore_origin_instance_rule.list.create_new_one', $body);
}
public function testIgnoreOriginInstanceRuleCreationEditionDeletion()
{
$this->logInAs('admin');
$client = $this->getClient();
// Creation
$crawler = $client->request('GET', '/ignore-origin-instance-rules/new');
$this->assertSame(200, $client->getResponse()->getStatusCode());
$body = $crawler->filter('body')->extract(['_text'])[0];
$this->assertContains('ignore_origin_instance_rule.new_ignore_origin_instance_rule', $body);
$this->assertContains('ignore_origin_instance_rule.form.back_to_list', $body);
$form = $crawler->filter('button[id=ignore_origin_instance_rule_save]')->form();
$data = [
'ignore_origin_instance_rule[rule]' => 'host = "foo.example.com"',
];
$client->submit($form, $data);
$this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$this->assertContains('flashes.ignore_origin_instance_rule.notice.added', $crawler->filter('body')->extract(['_text'])[0]);
// Edition
$editLink = $crawler->filter('div[id=content] table a')->last()->link();
$crawler = $client->click($editLink);
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertContains('foo.example.com', $crawler->filter('form[name=ignore_origin_instance_rule] input[type=text]')->extract(['value'])[0]);
$body = $crawler->filter('body')->extract(['_text'])[0];
$this->assertContains('ignore_origin_instance_rule.edit_ignore_origin_instance_rule', $body);
$this->assertContains('ignore_origin_instance_rule.form.back_to_list', $body);
$form = $crawler->filter('button[id=ignore_origin_instance_rule_save]')->form();
$data = [
'ignore_origin_instance_rule[rule]' => 'host = "bar.example.com"',
];
$client->submit($form, $data);
$this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$this->assertContains('flashes.ignore_origin_instance_rule.notice.updated', $crawler->filter('body')->extract(['_text'])[0]);
$editLink = $crawler->filter('div[id=content] table a')->last()->link();
$crawler = $client->click($editLink);
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertContains('bar.example.com', $crawler->filter('form[name=ignore_origin_instance_rule] input[type=text]')->extract(['value'])[0]);
$deleteForm = $crawler->filter('body')->selectButton('ignore_origin_instance_rule.form.delete')->form();
$client->submit($deleteForm, []);
$this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$this->assertContains('flashes.ignore_origin_instance_rule.notice.deleted', $crawler->filter('body')->extract(['_text'])[0]);
}
public function dataForIgnoreOriginInstanceRuleCreationFail()
{
return [
[
[
'ignore_origin_instance_rule[rule]' => 'foo = "bar"',
],
[
'The variable',
'does not exist.',
],
],
[
[
'ignore_origin_instance_rule[rule]' => '_all != "none"',
],
[
'The operator',
'does not exist.',
],
],
];
}
/**
* @dataProvider dataForIgnoreOriginInstanceRuleCreationFail
*/
public function testIgnoreOriginInstanceRuleCreationFail($data, $messages)
{
$this->logInAs('admin');
$client = $this->getClient();
$crawler = $client->request('GET', '/ignore-origin-instance-rules/new');
$this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=ignore_origin_instance_rule_save]')->form();
$crawler = $client->submit($form, $data);
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
foreach ($messages as $message) {
$this->assertContains($message, $body[0]);
}
}
}