php_code_coverage: true
php_sim: false
php_cpd: false
+
+checks:
+ php:
+ code_rating: true
form:
resources:
- LexikFormFilterBundle:Form:form_div_layout.html.twig
+
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
},
{
"name": "Jérémy Benoist",
+ "homepage": "http://www.j0k3r.net",
"role": "Developer"
}
],
$client = $this->createClient();
$headers = $this->generateHeaders('admin', 'mypassword');
+ $client->request('GET', '/api/entries', array('star' => 1, 'sort' => 'updated'), array(), $headers);
+
+ $this->assertEquals(200, $client->getResponse()->getStatusCode());
+
+ $content = json_decode($client->getResponse()->getContent(), true);
+
+ $this->assertGreaterThanOrEqual(1, count($content));
+ $this->assertNotEmpty($content['_embedded']['items']);
+ $this->assertGreaterThanOrEqual(1, $content['total']);
+ $this->assertEquals(1, $content['page']);
+ $this->assertGreaterThanOrEqual(1, $content['pages']);
+
+ $this->assertTrue(
+ $client->getResponse()->headers->contains(
+ 'Content-Type',
+ 'application/json'
+ )
+ );
+ }
+
+ public function testGetArchiveEntries()
+ {
+ $client = $this->createClient();
+ $headers = $this->generateHeaders('admin', 'mypassword');
+
$client->request('GET', '/api/entries', array('archive' => 1), array(), $headers);
$this->assertEquals(200, $client->getResponse()->getStatusCode());
));
}
+ /**
+ * Shows all entries for current user.
+ *
+ * @param Request $request
+ * @param int $page
+ *
+ * @Route("/all/list/{page}", name="all", defaults={"page" = "1"})
+ *
+ * @return \Symfony\Component\HttpFoundation\Response
+ */
+ public function showAllAction(Request $request, $page)
+ {
+ return $this->showEntries('all', $request, $page);
+ }
+
/**
* Shows unread entries for current user.
*
*/
public function showUnreadAction(Request $request, $page)
{
- $form = $this->get('form.factory')->create(new EntryFilterType());
-
- $filterBuilder = $this->getDoctrine()
- ->getRepository('WallabagCoreBundle:Entry')
- ->findUnreadByUser($this->getUser()->getId());
-
- if ($request->query->has($form->getName())) {
- // manually bind values from the request
- $form->submit($request->query->get($form->getName()));
-
- // build the query from the given form object
- $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $filterBuilder);
- }
-
- $pagerAdapter = new DoctrineORMAdapter($filterBuilder->getQuery());
- $entries = new Pagerfanta($pagerAdapter);
-
- $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage());
- $entries->setCurrentPage($page);
-
- return $this->render(
- 'WallabagCoreBundle:Entry:entries.html.twig',
- array(
- 'form' => $form->createView(),
- 'entries' => $entries,
- 'currentPage' => $page,
- )
- );
+ return $this->showEntries('unread', $request, $page);
}
/**
*/
public function showArchiveAction(Request $request, $page)
{
- $form = $this->get('form.factory')->create(new EntryFilterType());
-
- $filterBuilder = $this->getDoctrine()
- ->getRepository('WallabagCoreBundle:Entry')
- ->findArchiveByUser($this->getUser()->getId());
-
- if ($request->query->has($form->getName())) {
- // manually bind values from the request
- $form->submit($request->query->get($form->getName()));
-
- // build the query from the given form object
- $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $filterBuilder);
- }
-
- $pagerAdapter = new DoctrineORMAdapter($filterBuilder->getQuery());
- $entries = new Pagerfanta($pagerAdapter);
-
- $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage());
- $entries->setCurrentPage($page);
-
- return $this->render(
- 'WallabagCoreBundle:Entry:entries.html.twig',
- array(
- 'form' => $form->createView(),
- 'entries' => $entries,
- 'currentPage' => $page,
- )
- );
+ return $this->showEntries('archive', $request, $page);
}
/**
*/
public function showStarredAction(Request $request, $page)
{
- $form = $this->get('form.factory')->create(new EntryFilterType());
+ return $this->showEntries('starred', $request, $page);
+ }
+
+ /**
+ * Global method to retrieve entries depending on the given type
+ * It returns the response to be send.
+ *
+ * @param string $type Entries type: unread, starred or archive
+ * @param Request $request
+ * @param int $page
+ *
+ * @return \Symfony\Component\HttpFoundation\Response
+ */
+ private function showEntries($type, Request $request, $page)
+ {
+ $repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entry');
+
+ switch ($type) {
+ case 'starred':
+ $qb = $repository->getBuilderForStarredByUser($this->getUser()->getId());
+ break;
+
+ case 'archive':
+ $qb = $repository->getBuilderForArchiveByUser($this->getUser()->getId());
+ break;
+
+ case 'unread':
+ $qb = $repository->getBuilderForUnreadByUser($this->getUser()->getId());
+ break;
- $filterBuilder = $this->getDoctrine()
- ->getRepository('WallabagCoreBundle:Entry')
- ->findStarredByUser($this->getUser()->getId());
+ case 'all':
+ $qb = $repository->getBuilderForAllByUser($this->getUser()->getId());
+ break;
+
+ default:
+ throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
+ }
+
+ $form = $this->get('form.factory')->create(new EntryFilterType());
if ($request->query->has($form->getName())) {
// manually bind values from the request
$form->submit($request->query->get($form->getName()));
// build the query from the given form object
- $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $filterBuilder);
+ $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $qb);
}
- $pagerAdapter = new DoctrineORMAdapter($filterBuilder->getQuery());
+ $pagerAdapter = new DoctrineORMAdapter($qb->getQuery());
$entries = new Pagerfanta($pagerAdapter);
$entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage());
*/
public function showUnreadAction(User $user)
{
- $qb = $this->getDoctrine()
- ->getRepository('WallabagCoreBundle:Entry')
- ->findUnreadByUser(
- $user->getId()
- );
-
- $pagerAdapter = new DoctrineORMAdapter($qb->getQuery());
- $entries = new Pagerfanta($pagerAdapter);
-
- $perPage = $user->getConfig()->getRssLimit() ?: $this->container->getParameter('rss_limit');
- $entries->setMaxPerPage($perPage);
-
- return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', array(
- 'type' => 'unread',
- 'entries' => $entries,
- ));
+ return $this->showEntries('unread', $user);
}
/**
*/
public function showArchiveAction(User $user)
{
- $qb = $this->getDoctrine()
- ->getRepository('WallabagCoreBundle:Entry')
- ->findArchiveByUser(
- $user->getId()
- );
-
- $pagerAdapter = new DoctrineORMAdapter($qb->getQuery());
- $entries = new Pagerfanta($pagerAdapter);
-
- $perPage = $user->getConfig()->getRssLimit() ?: $this->container->getParameter('rss_limit');
- $entries->setMaxPerPage($perPage);
-
- return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', array(
- 'type' => 'archive',
- 'entries' => $entries,
- ));
+ return $this->showEntries('archive', $user);
}
/**
*/
public function showStarredAction(User $user)
{
- $qb = $this->getDoctrine()
- ->getRepository('WallabagCoreBundle:Entry')
- ->findStarredByUser(
- $user->getId()
- );
+ return $this->showEntries('starred', $user);
+ }
+
+ /**
+ * Global method to retrieve entries depending on the given type
+ * It returns the response to be send.
+ *
+ * @param string $type Entries type: unread, starred or archive
+ * @param User $user
+ *
+ * @return \Symfony\Component\HttpFoundation\Response
+ */
+ private function showEntries($type, User $user)
+ {
+ $repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entry');
+
+ switch ($type) {
+ case 'starred':
+ $qb = $repository->getBuilderForStarredByUser($user->getId());
+ break;
+
+ case 'archive':
+ $qb = $repository->getBuilderForArchiveByUser($user->getId());
+ break;
+
+ case 'unread':
+ $qb = $repository->getBuilderForUnreadByUser($user->getId());
+ break;
+
+ default:
+ throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
+ }
$pagerAdapter = new DoctrineORMAdapter($qb->getQuery());
$entries = new Pagerfanta($pagerAdapter);
$entries->setMaxPerPage($perPage);
return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', array(
- 'type' => 'starred',
+ 'type' => $type,
'entries' => $entries,
));
}
array()
);
}
-
- /**
- * @Route("/", name="homepage")
- */
- public function apiAction()
- {
- return $this->redirect($this->generateUrl('nelmio_api_doc_index'));
- }
}
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Symfony\Component\HttpFoundation\Request;
+use Wallabag\CoreBundle\Form\Type\NewTagType;
+use Wallabag\CoreBundle\Entity\Tag;
+use Wallabag\CoreBundle\Entity\Entry;
class TagController extends Controller
{
+ /**
+ * @param Request $request
+ *
+ * @Route("/new-tag/{entry}", requirements={"entry" = "\d+"}, name="new_tag")
+ *
+ * @return \Symfony\Component\HttpFoundation\Response
+ */
+ public function addTagFormAction(Request $request, Entry $entry)
+ {
+ $tag = new Tag($this->getUser());
+ $form = $this->createForm(new NewTagType(), $tag);
+ $form->handleRequest($request);
+
+ if ($form->isValid()) {
+ $existingTag = $this->getDoctrine()
+ ->getRepository('WallabagCoreBundle:Tag')
+ ->findOneByLabelAndUserId($tag->getLabel(), $this->getUser()->getId());
+
+ $em = $this->getDoctrine()->getManager();
+
+ if (is_null($existingTag)) {
+ $entry->addTag($tag);
+ $em->persist($tag);
+ } else {
+ if (!$existingTag->hasEntry($entry)) {
+ $entry->addTag($existingTag);
+ $em->persist($existingTag);
+ }
+ }
+
+ $em->flush();
+
+ $this->get('session')->getFlashBag()->add(
+ 'notice',
+ 'Tag added'
+ );
+
+ return $this->redirect($this->generateUrl('view', array('id' => $entry->getId())));
+ }
+
+ return $this->render('WallabagCoreBundle:Tag:new_form.html.twig', array(
+ 'form' => $form->createView(),
+ 'entry' => $entry,
+ ));
+ }
+
/**
* Shows tags for current user.
*
use Symfony\Component\Validator\Constraints as Assert;
use Hateoas\Configuration\Annotation as Hateoas;
use JMS\Serializer\Annotation\XmlRoot;
-use Wallabag\CoreBundle\Helper\Tools;
+use Wallabag\CoreBundle\Tools\Utils;
/**
* Entry.
public function setContent($content)
{
$this->content = $content;
- $this->readingTime = Tools::getReadingTime($content);
+ $this->readingTime = Utils::getReadingTime($content);
$this->domainName = parse_url($this->url, PHP_URL_HOST);
return $this;
$this->entries[] = $entry;
}
+ public function hasEntry($entry)
+ {
+ return $this->entries->contains($entry);
+ }
+
/**
* @return User
*/
return $filterQuery->createCondition($expression);
},
- ));
+ ))
+ ->add('isArchived', 'filter_checkbox')
+ ->add('isStarred', 'filter_checkbox');
}
public function getName()
--- /dev/null
+<?php
+
+namespace Wallabag\CoreBundle\Form\Type;
+
+use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolver;
+
+class NewTagType extends AbstractType
+{
+ public function buildForm(FormBuilderInterface $builder, array $options)
+ {
+ $builder
+ ->add('label', 'text', array('required' => true))
+ ->add('save', 'submit')
+ ;
+ }
+
+ public function configureOptions(OptionsResolver $resolver)
+ {
+ $resolver->setDefaults(array(
+ 'data_class' => 'Wallabag\CoreBundle\Entity\Tag',
+ ));
+ }
+
+ public function getName()
+ {
+ return 'tag';
+ }
+}
+++ /dev/null
-<?php
-
-namespace Wallabag\CoreBundle\Helper;
-
-class Entry
-{
-}
+++ /dev/null
-<?php
-
-namespace Wallabag\CoreBundle\Helper;
-
-final class Tools
-{
- /**
- * Download a file (typically, for downloading pictures on web server).
- *
- * @param $url
- *
- * @return bool|mixed|string
- */
- public static function getFile($url)
- {
- $timeout = 15;
- $useragent = 'Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0';
-
- if (in_array('curl', get_loaded_extensions())) {
- # Fetch feed from URL
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, $url);
- curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
- if (!ini_get('open_basedir') && !ini_get('safe_mode')) {
- curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
- }
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_HEADER, false);
-
- # for ssl, do not verified certificate
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($curl, CURLOPT_AUTOREFERER, true);
-
- # FeedBurner requires a proper USER-AGENT...
- curl_setopt($curl, CURL_HTTP_VERSION_1_1, true);
- curl_setopt($curl, CURLOPT_ENCODING, 'gzip, deflate');
- curl_setopt($curl, CURLOPT_USERAGENT, $useragent);
-
- $data = curl_exec($curl);
- $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
- $httpcodeOK = isset($httpcode) and ($httpcode == 200 or $httpcode == 301);
- curl_close($curl);
- } else {
- # create http context and add timeout and user-agent
- $context = stream_context_create(
- array(
- 'http' => array(
- 'timeout' => $timeout,
- 'header' => 'User-Agent: '.$useragent,
- 'follow_location' => true,
- ),
- 'ssl' => array(
- 'verify_peer' => false,
- 'allow_self_signed' => true,
- ),
- )
- );
-
- # only download page lesser than 4MB
- $data = @file_get_contents($url, false, $context, -1, 4000000);
-
- if (isset($http_response_header) and isset($http_response_header[0])) {
- $httpcodeOK = isset($http_response_header) and isset($http_response_header[0]) and ((strpos($http_response_header[0], '200 OK') !== false) or (strpos($http_response_header[0], '301 Moved Permanently') !== false));
- }
- }
-
- # if response is not empty and response is OK
- if (isset($data) and isset($httpcodeOK) and $httpcodeOK) {
- # take charset of page and get it
- preg_match('#<meta .*charset=.*>#Usi', $data, $meta);
-
- # if meta tag is found
- if (!empty($meta[0])) {
- preg_match('#charset="?(.*)"#si', $meta[0], $encoding);
- # if charset is found set it otherwise, set it to utf-8
- $html_charset = (!empty($encoding[1])) ? strtolower($encoding[1]) : 'utf-8';
- if (empty($encoding[1])) {
- $encoding[1] = 'utf-8';
- }
- } else {
- $html_charset = 'utf-8';
- $encoding[1] = '';
- }
-
- # replace charset of url to charset of page
- $data = str_replace('charset='.$encoding[1], 'charset='.$html_charset, $data);
-
- return $data;
- } else {
- return false;
- }
- }
-
- /**
- * Encode a URL by using a salt.
- *
- * @param $string
- *
- * @return string
- */
- public static function encodeString($string)
- {
- return sha1($string.SALT);
- }
-
- public static function generateToken()
- {
- if (ini_get('open_basedir') === '') {
- if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
- // alternative to /dev/urandom for Windows
- $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20);
- } else {
- $token = substr(base64_encode(file_get_contents('/dev/urandom', false, null, 0, 20)), 0, 15);
- }
- } else {
- $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20);
- }
-
- return str_replace('+', '', $token);
- }
-
- /**
- * For a given text, we calculate reading time for an article.
- *
- * @param $text
- *
- * @return float
- */
- public static function getReadingTime($text)
- {
- return floor(str_word_count(strip_tags($text)) / 200);
- }
-}
class EntryRepository extends EntityRepository
{
/**
- * Retrieves unread entries for a user.
+ * Return a query builder to used by other getBuilderFor* method.
*
* @param int $userId
*
* @return QueryBuilder
*/
- public function findUnreadByUser($userId)
+ private function getBuilderByUser($userId)
{
return $this->createQueryBuilder('e')
->leftJoin('e.user', 'u')
- ->where('e.isArchived = false')
- ->andWhere('u.id =:userId')->setParameter('userId', $userId)
- ->orderBy('e.id', 'desc');
+ ->andWhere('u.id = :userId')->setParameter('userId', $userId)
+ ->orderBy('e.id', 'desc')
+ ;
+ }
+
+ /**
+ * Retrieves all entries for a user.
+ *
+ * @param int $userId
+ *
+ * @return QueryBuilder
+ */
+ public function getBuilderForAllByUser($userId)
+ {
+ return $this
+ ->getBuilderByUser($userId)
+ ;
+ }
+
+ /**
+ * Retrieves unread entries for a user.
+ *
+ * @param int $userId
+ *
+ * @return QueryBuilder
+ */
+ public function getBuilderForUnreadByUser($userId)
+ {
+ return $this
+ ->getBuilderByUser($userId)
+ ->andWhere('e.isArchived = false')
+ ;
}
/**
*
* @return QueryBuilder
*/
- public function findArchiveByUser($userId)
+ public function getBuilderForArchiveByUser($userId)
{
- return $this->createQueryBuilder('e')
- ->leftJoin('e.user', 'u')
- ->where('e.isArchived = true')
- ->andWhere('u.id =:userId')->setParameter('userId', $userId)
- ->orderBy('e.id', 'desc');
+ return $this
+ ->getBuilderByUser($userId)
+ ->andWhere('e.isArchived = true')
+ ;
}
/**
*
* @return QueryBuilder
*/
- public function findStarredByUser($userId)
+ public function getBuilderForStarredByUser($userId)
{
- return $this->createQueryBuilder('e')
- ->leftJoin('e.user', 'u')
- ->where('e.isStarred = true')
- ->andWhere('u.id =:userId')->setParameter('userId', $userId)
- ->orderBy('e.id', 'desc');
+ return $this
+ ->getBuilderByUser($userId)
+ ->andWhere('e.isStarred = true')
+ ;
}
/**
return new Pagerfanta($pagerAdapter);
}
+
+ /**
+ * Find a tag by its label and its owner.
+ *
+ * @param string $label
+ * @param int $userId
+ *
+ * @return Tag|null
+ */
+ public function findOneByLabelAndUserId($label, $userId)
+ {
+ return $this->createQueryBuilder('t')
+ ->where('t.label = :label')->setParameter('label', $label)
+ ->andWhere('t.user = :user_id')->setParameter('user_id', $userId)
+ ->getQuery()
+ ->getOneOrNullResult();
+ }
}
-entry:
- resource: "@WallabagCoreBundle/Controller/EntryController.php"
- type: annotation
-
-config:
- resource: "@WallabagCoreBundle/Controller/ConfigController.php"
- type: annotation
{% if entries is empty %}
<div class="messages warning"><p>{% trans %}No articles found.{% endtrans %}</p></div>
{% else %}
- <div><form>{{ form_rest(form) }}<button class="btn waves-effect waves-light" type="submit" id="submit-filter" value="filter">Filter</button></form></div>
+ <div><form action="{{ path('all') }}">{{ form_rest(form) }}<button class="btn waves-effect waves-light" type="submit" id="submit-filter" value="filter">Filter</button></form></div>
{% for entry in entries %}
<div id="entry-{{ entry.id|e }}" class="entry">
<h2><a href="{{ path('view', { 'id': entry.id }) }}">{{ entry.title|raw }}</a></h2>
<h1>{{ entry.title|raw }} <a href="{{ path('edit', { 'id': entry.id }) }}" title="{% trans %}Edit tags{% endtrans %}">✎</a></h1>
</header>
<aside class="tags">
- tags: {% for tag in entry.tags %}<a href="./?view=tag&id={{ tag.id }}">{{ tag.label }}</a> {% endfor %}<a href="./?view=edit-tags&id={{ entry.id }}" title="{% trans %}Edit tags{% endtrans %}">✎</a>
+ {% for tag in entry.tags %}<span class="mdi-action-label-outline">{{ tag.label }}</span>{% endfor %}
+ {{ render(controller( "WallabagCoreBundle:Tag:addTagForm", { 'id': entry.id } )) }}
</aside>
<article>
{{ entry.content | raw }}
{% block title %}{% trans %}About{% endtrans %}{% endblock %}
{% block content %}
- <h2>{% trans %}About wallabag{% endtrans %}</h2>
+ <h2>{% trans %}Who is behind wallabag{% endtrans %}</h2>
<dl>
- <dt>{% trans %}Project website{% endtrans %}</dt>
- <dd><a href="https://www.wallabag.org">https://www.wallabag.org</a></dd>
-
- <dt>{% trans %}Main developer{% endtrans %}</dt>
+ <dt>{% trans %}Developed by{% endtrans %}</dt>
<dd><a href="mailto:nicolas@loeuillet.org">Nicolas Lœuillet</a> — <a href="http://cdetc.fr">{% trans %}website{% endtrans %}</a></dd>
+ <dd>Thomas Citharel — <a href="https://tcit.fr">{% trans %}website{% endtrans %}</a></dd>
+ <dd>Jérémy Benoist — <a href="http://www.j0k3r.net">{% trans %}website{% endtrans %}</a></dd>
- <dt>{% trans %}Contributors ♥:{% endtrans %}</dt>
- <dd><a href="https://github.com/wallabag/wallabag/graphs/contributors">{% trans %}on Github{% endtrans %}</a></dd>
+ <dt>{% trans %}And many others contributors ♥{% endtrans %} <a href="https://github.com/wallabag/wallabag/graphs/contributors">{% trans %}on Github{% endtrans %}</a></dt>
- <dt>{% trans %}Bug reports{% endtrans %}</dt>
- <dd><a href="https://support.wallabag.org">{% trans %}On our support website{% endtrans %}</a> {% trans %}or{% endtrans %} <a href="https://github.com/wallabag/wallabag/issues">{% trans %}on Github{% endtrans %}</a></dd>
+ <dt>{% trans %}Project website{% endtrans %}</dt>
+ <dd><a href="https://www.wallabag.org">https://www.wallabag.org</a></dd>
- <dt>{% trans %}License{% endtrans %}</dt>
- <dd><a href="http://en.wikipedia.org/wiki/MIT_License">MIT</a></dd>
+ <dt>{% trans %}License{% endtrans %}: <a href="http://en.wikipedia.org/wiki/MIT_License">MIT</a></dt>
- <dt>{% trans %}Version{% endtrans %}</dt>
- <dd>{{ version }}</dd>
+ <dt>{% trans %}Version{% endtrans %}: {{ version }}</dt>
</dl>
- <p>{% trans %}wallabag is a read-it-later application: you can save a web page by keeping only content. Elements like ads or menus are deleted.{% endtrans %}</p>
-
<h2>{% trans %}Getting help{% endtrans %}</h2>
<dl>
<dt>{% trans %}Documentation{% endtrans %}</dt>
- <dd><a href="https://doc.wallabag.org/">Online documentation</a></dd>
+ <dd><a href="https://doc.wallabag.org/en">english</a></dd>
+ <dd><a href="https://doc.wallabag.org/fr">français</a></dd>
+ <dd><a href="https://doc.wallabag.org/de">deutsch</a></dd>
- <dt>{% trans %}Support{% endtrans %}</dt>
- <dd><a href="http://support.wallabag.org/">http://support.wallabag.org/</a></dd>
+ <dt>{% trans %}Bug reports{% endtrans %}</dt>
+ <dd><a href="https://support.wallabag.org">{% trans %}On our support website{% endtrans %}</a> {% trans %}or{% endtrans %} <a href="https://github.com/wallabag/wallabag/issues">{% trans %}on Github{% endtrans %}</a></dd>
</dl>
<h2>{% trans %}Helping wallabag{% endtrans %}</h2>
<p>{% trans %}wallabag is free and opensource. You can help us:{% endtrans %}</p>
<dl>
- <dt><a href="{{ paypal_url }}">{% trans %}via Paypal{% endtrans %}</a></dt>
+ <dt>{% trans %}wallabag is free and opensource. You can help us:{% endtrans %}</dt>
+ <dd>by contributing to the project: <a href="https://github.com/wallabag/wallabag/issues/1254">an issue lists all our needs</a></dd>
+ <dd><a href="{{ paypal_url }}">{% trans %}via Paypal{% endtrans %}</a></dd>
- <dt><a href="{{ flattr_url }}">{% trans %}via Flattr{% endtrans %}</a></dt>
+ <dd><a href="{{ flattr_url }}">{% trans %}via Flattr{% endtrans %}</a></dd>
</dl>
{% endblock %}
--- /dev/null
+<form name="tag" method="post" action="{{ path('new_tag', { 'entry': entry.id })}}">
+
+ {% if form_errors(form) %}
+ <span class="black-text">{{ form_errors(form) }}</span>
+ {% endif %}
+
+ {% if form_errors(form.label) %}
+ <span class="black-text">{{ form_errors(form.label) }}</span>
+ {% endif %}
+
+ {{ form_widget(form.label, { 'attr': {'autocomplete': 'off'} }) }}
+ {{ form_widget(form.save, { 'attr': {'class': 'btn waves-effect waves-light'}, 'label': 'add tag' }) }}
+
+ <div class="hidden">{{ form_rest(form) }}</div>
+</form>
<li><a href="{{ path('unread') }}">{% trans %}unread{% endtrans %}</a></li>
<li><a href="{{ path('starred') }}">{% trans %}favorites{% endtrans %}</a></li>
<li><a href="{{ path('archive') }}"}>{% trans %}archive{% endtrans %}</a></li>
+ <li><a href="{{ path('all') }}"}>{% trans %}all{% endtrans %}</a></li>
<li><a href="{{ path ('tag') }}">{% trans %}tags{% endtrans %}</a></li>
<li><a href="{{ path('new') }}">{% trans %}save a link{% endtrans %}</a></li>
<li style="position: relative;"><a href="javascript: void(null);" id="search">{% trans %}search{% endtrans %}</a>
{% trans %}Starred{% endtrans %}
{% elseif currentRoute == 'archive' %}
{% trans %}Archive{% endtrans %}
+ {% elseif currentRoute == 'all' %}
+ {% trans %}Filtered{% endtrans %}
{% else %}
{% trans %}Unread{% endtrans %}
{% endif %}
<!-- Filters -->
<div id="filters" class="side-nav fixed right-aligned">
- <form>
+ <form action="{{ path('all') }}">
<h4 class="center">{% trans %}Filters{% endtrans %}</h1>
<div class="row">
+
+ <div class="col s12">
+ <label>{% trans %}Status{% endtrans %}</label>
+ </div>
+ <div class="input-field col s6">
+ {{ form_widget(form.isArchived) }}
+ <label for="entry_filter_isArchived">{% trans %}Archived{% endtrans %}</label>
+ </div>
+
+ <div class="input-field col s6">
+ {{ form_widget(form.isStarred) }}
+ <label for="entry_filter_isStarred">{% trans %}Starred{% endtrans %}</label>
+ </div>
+
<div class="col s12">
<label>{% trans %}Reading time in minutes{% endtrans %}</label>
</div>
<label for="entry_filter_readingTime_right_number">{% trans %}to{% endtrans %}</label>
</div>
-
<div class="input-field col s6">
{{ form_widget(form.domainName, {'type': 'text', 'attr' : {'placeholder': 'website.com'} }) }}
<label for="entry_filter_domainName">{% trans %}Domain name{% endtrans %}</label>
<a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %} : {{ entry.title|e }}" class="tool link"><span>{{ entry.domainName }}</span></a>
</header>
<aside class="tags">
- tags: {% for tag in entry.tags %}<a href="./?view=tag&id={{ tag.id }}">{{ tag.label }}</a> {% endfor %}<a href="./?view=edit-tags&id={{ entry.id }}" title="{% trans %}Edit tags{% endtrans %}">✎</a>
+ {% for tag in entry.tags %}<span class="mdi-action-label-outline">{{ tag.label }}</span>{% endfor %}
+ {{ render(controller( "WallabagCoreBundle:Tag:addTagForm", { 'id': entry.id } )) }}
</aside>
<article>
{{ entry.content | raw }}
<dt>{% trans %}Developed by{% endtrans %}</dt>
<dd><a href="mailto:nicolas@loeuillet.org">Nicolas Lœuillet</a> — <a href="http://cdetc.fr">{% trans %}website{% endtrans %}</a></dd>
<dd>Thomas Citharel — <a href="https://tcit.fr">{% trans %}website{% endtrans %}</a></dd>
- <dd>Jérémy Besnoit — <a href="http://wildtrip.net">{% trans %}website{% endtrans %}</a></dd>
+ <dd>Jérémy Benoist — <a href="http://www.j0k3r.net">{% trans %}website{% endtrans %}</a></dd>
<dt>{% trans %}And many others contributors ♥{% endtrans %} <a href="https://github.com/wallabag/wallabag/graphs/contributors">{% trans %}on Github{% endtrans %}</a></dt>
<dt>{% trans %}Project website{% endtrans %}</dt>
<dd><a href="https://www.wallabag.org">https://www.wallabag.org</a></dd>
--- /dev/null
+<form name="tag" method="post" action="{{ path('new_tag', { 'entry': entry.id })}}">
+
+ {% if form_errors(form) %}
+ <span class="black-text">{{ form_errors(form) }}</span>
+ {% endif %}
+
+ {% if form_errors(form.label) %}
+ <span class="black-text">{{ form_errors(form.label) }}</span>
+ {% endif %}
+
+ {{ form_widget(form.label, { 'attr': {'autocomplete': 'off'} }) }}
+ {{ form_widget(form.save, { 'attr': {'class': 'btn waves-effect waves-light'}, 'label': 'add tag' }) }}
+
+ <div class="hidden">{{ form_rest(form) }}</div>
+</form>
<li class="bold {% if currentRoute == 'unread' or currentRoute == 'homepage' %}active{% endif %}"><a class="waves-effect" href="{{ path('unread') }}">{% trans %}unread{% endtrans %}</a></li>
<li class="bold {% if currentRoute == 'starred' %}active{% endif %}"><a class="waves-effect" href="{{ path('starred') }}">{% trans %}starred{% endtrans %}</a></li>
<li class="bold {% if currentRoute == 'archive' %}active{% endif %}"><a class="waves-effect" href="{{ path('archive') }}">{% trans %}archive{% endtrans %}</a></li>
+ <li class="bold {% if currentRoute == 'all' %}active{% endif %}"><a class="waves-effect" href="{{ path('all') }}">{% trans %}all{% endtrans %}</a></li>
<li class="bold border-bottom {% if currentRoute == 'tags' %}active{% endif %}"><a class="waves-effect" href="{{ path('tag') }}">{% trans %}tags{% endtrans %}</a></li>
<li class="bold {% if currentRoute == 'config' %}active{% endif %}"><a class="waves-effect" href="{{ path('config') }}">{% trans %}config{% endtrans %}</a></li>
<li class="bold {% if currentRoute == 'howto' %}active{% endif %}"><a class="waves-effect" href="{{ path('howto') }}">{% trans %}howto{% endtrans %}</a></li>
</div>
<div class="input-field nav-panel-buttom">
<ul>
- <li class="bold"><a class="waves-effect" href="{{ path('new') }}" id="nav-btn-add"><i class="mdi-content-add"></i></a></li>
- <li><a class="waves-effect" href="javascript: void(null);" id="nav-btn-search"><i class="mdi-action-search"></i></a>
- <li id="button_filters"><a href="#" data-activates="filters" class="nav-panel-menu button-collapse-right"><i class="mdi-content-filter-list"></i></a></li>
+ <li class="bold"><a title="{% trans %}Add a new entry{% endtrans %}" class="waves-effect" href="{{ path('new') }}" id="nav-btn-add"><i class="mdi-content-add"></i></a></li>
+ <li><a title="{% trans %}Search{% endtrans %}" class="waves-effect" href="javascript: void(null);" id="nav-btn-search"><i class="mdi-action-search"></i></a>
+ <li id="button_filters"><a title="{% trans %}Filter entries{% endtrans %}" href="#" data-activates="filters" class="nav-panel-menu button-collapse-right"><i class="mdi-content-filter-list"></i></a></li>
</ul>
</div>
<form method="get" action="index.php">
$('.button-collapse-right').sideNav({ edge: 'right' });
$('#clear_form_filters').on('click', function(){
$('#filters input').val('');
+ $('#filters :checked').removeAttr('checked');
return false;
});
}
$crawler = $client->submit($form, $data);
- $this->assertCount(4, $crawler->filter('div[class=entry]'));
+ $this->assertCount(5, $crawler->filter('div[class=entry]'));
$data = array(
'entry_filter[createdAt][left_date]' => '01/01/1970',
$crawler = $client->request('GET', 'unread/list'.$parameters);
$this->assertContains($parameters, $client->getResponse()->getContent());
+
+ // reset pagination
+ $crawler = $client->request('GET', '/config');
+ $form = $crawler->filter('button[id=config_save]')->form();
+ $data = array(
+ 'config[items_per_page]' => '12',
+ );
+ $client->submit($form, $data);
}
public function testFilterOnDomainName()
$crawler = $client->submit($form, $data);
$this->assertCount(0, $crawler->filter('div[class=entry]'));
}
+
+ public function testFilterOnStatus()
+ {
+ $this->logInAs('admin');
+ $client = $this->getClient();
+
+ $crawler = $client->request('GET', '/unread/list');
+ $form = $crawler->filter('button[id=submit-filter]')->form();
+ $form['entry_filter[isArchived]']->tick();
+ $form['entry_filter[isStarred]']->untick();
+
+ $crawler = $client->submit($form);
+ $this->assertCount(1, $crawler->filter('div[class=entry]'));
+
+ $form = $crawler->filter('button[id=submit-filter]')->form();
+ $form['entry_filter[isArchived]']->untick();
+ $form['entry_filter[isStarred]']->tick();
+
+ $crawler = $client->submit($form);
+ $this->assertCount(1, $crawler->filter('div[class=entry]'));
+ }
}
$this->assertEquals(200, $client->getResponse()->getStatusCode());
}
+
+ public function testAddTagToEntry()
+ {
+ $this->logInAs('admin');
+ $client = $this->getClient();
+
+ $entry = $client->getContainer()
+ ->get('doctrine.orm.entity_manager')
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->findOneByIsArchived(false);
+
+ $crawler = $client->request('GET', '/view/'.$entry->getId());
+
+ $form = $crawler->filter('button[id=tag_save]')->form();
+
+ $data = array(
+ 'tag[label]' => 'opensource',
+ );
+
+ $client->submit($form, $data);
+ $this->assertEquals(302, $client->getResponse()->getStatusCode());
+
+ $this->assertEquals(1, count($entry->getTags()));
+
+ # tag already exists and already assigned
+ $client->submit($form, $data);
+ $this->assertEquals(302, $client->getResponse()->getStatusCode());
+
+ $newEntry = $client->getContainer()
+ ->get('doctrine.orm.entity_manager')
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->findOneById($entry->getId());
+
+ $this->assertEquals(1, count($newEntry->getTags()));
+
+ # tag already exists but still not assigned to this entry
+ $data = array(
+ 'tag[label]' => 'foo',
+ );
+
+ $client->submit($form, $data);
+ $this->assertEquals(302, $client->getResponse()->getStatusCode());
+
+ $newEntry = $client->getContainer()
+ ->get('doctrine.orm.entity_manager')
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->findOneById($entry->getId());
+
+ $this->assertEquals(2, count($newEntry->getTags()));
+ }
}
// remove character which can broken the url
return str_replace(array('+', '/'), '', $token);
}
+
+ /**
+ * For a given text, we calculate reading time for an article
+ * based on 200 words per minute.
+ *
+ * @param $text
+ *
+ * @return float
+ */
+ public static function getReadingTime($text)
+ {
+ return floor(str_word_count(strip_tags($text)) / 200);
+ }
}