From b84a80559a1167b5500fbc5eb4965d3b08b371ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 23 Jan 2015 14:58:17 +0100 Subject: [PATCH] some parameters, new entry form, etc. --- app/config/config.yml | 3 ++ app/config/parameters.yml.dist | 22 +++++++++- app/config/routing.yml | 4 ++ .../Controller/EntryController.php | 42 ++++++++++++++++++ src/WallabagBundle/Entity/Entries.php | 2 + .../Repository/EntriesRepository.php | 42 ++++++++++++++---- .../Resources/views/Entry/new.html.twig | 11 +++++ .../Resources/views/Static/about.html.twig | 43 +++---------------- .../Resources/views/_menu.html.twig | 4 +- 9 files changed, 123 insertions(+), 50 deletions(-) create mode 100644 src/WallabagBundle/Resources/views/Entry/new.html.twig diff --git a/app/config/config.yml b/app/config/config.yml index c6bed7970..455345f46 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -44,6 +44,9 @@ twig: export_epub: %export_epub% export_mobi: %export_mobi% export_pdf: %export_pdf% + version: %app.version% + paypal_url: "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9UBA65LG3FX9Y&lc=gb" + flattr_url: "https://flattr.com/thing/1265480" # Assetic Configuration assetic: diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index 5ccac4922..36e3fe7f2 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist @@ -19,4 +19,24 @@ parameters: # A secret key that's used to generate certain security-related tokens secret: ThisTokenIsNotSoSecretChangeIt - download_pictures: false # if true, pictures will be stored into data/assets for each article \ No newline at end of file + # wallabag misc + app.version: 2.0.0-alpha + + download_pictures: false # if true, pictures will be stored into data/assets for each article + + # Entry view + share_twitter: true + share_mail: true + share_shaarli: true + shaarli_url: http://myshaarli.com + share_diaspora: true + diaspora_url: http://diasporapod.com + flattr: true + carrot: true + show_printlink: true + export_epub: true + export_mobi: true + export_pdf: true + + # List view + items_on_page: 12 \ No newline at end of file diff --git a/app/config/routing.yml b/app/config/routing.yml index a748d532f..d0ece8e30 100644 --- a/app/config/routing.yml +++ b/app/config/routing.yml @@ -1,3 +1,7 @@ app: resource: @WallabagBundle/Controller/ type: annotation + +homepage: + pattern: / + defaults: { _controller: WallabagBundle:Entry:showUnread } \ No newline at end of file diff --git a/src/WallabagBundle/Controller/EntryController.php b/src/WallabagBundle/Controller/EntryController.php index fbbb76aa2..dc1876fac 100644 --- a/src/WallabagBundle/Controller/EntryController.php +++ b/src/WallabagBundle/Controller/EntryController.php @@ -7,9 +7,51 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use WallabagBundle\Repository; use WallabagBundle\Entity\Entries; +use Wallabag\Wallabag\Tools; +use Wallabag\Wallabag\Url; class EntryController extends Controller { + + /** + * @param Request $request + * @Route("/new", name="new_entry") + * @return \Symfony\Component\HttpFoundation\Response + */ + public function addEntryAction(Request $request) + { + $entry = new Entries(); + $entry->setUserId(1); + + $form = $this->createFormBuilder($entry) + ->add('url', 'url') + ->add('save', 'submit') + ->getForm(); + + $form->handleRequest($request); + + if ($form->isValid()) { + + $content = Tools::getPageContent(new Url($entry->getUrl())); + var_dump($content);die; + + $em = $this->getDoctrine()->getEntityManager(); + $em->persist($entry); + $em->flush(); + + $this->get('session')->getFlashBag()->add( + 'notice', + 'Entry saved' + ); + + return $this->redirect($this->generateUrl('homepage')); + } + + return $this->render('WallabagBundle:Entry:new.html.twig', array( + 'form' => $form->createView(), + )); + } + /** * Shows unread entries for current user * diff --git a/src/WallabagBundle/Entity/Entries.php b/src/WallabagBundle/Entity/Entries.php index b364e0c33..5849a2161 100644 --- a/src/WallabagBundle/Entity/Entries.php +++ b/src/WallabagBundle/Entity/Entries.php @@ -3,6 +3,7 @@ namespace WallabagBundle\Entity; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Validator\Constraints as Assert; /** * Entries @@ -31,6 +32,7 @@ class Entries /** * @var string * + * @Assert\NotBlank() * @ORM\Column(name="url", type="text", nullable=true) */ private $url; diff --git a/src/WallabagBundle/Repository/EntriesRepository.php b/src/WallabagBundle/Repository/EntriesRepository.php index c4428a1d2..3eb1733d1 100644 --- a/src/WallabagBundle/Repository/EntriesRepository.php +++ b/src/WallabagBundle/Repository/EntriesRepository.php @@ -8,6 +8,14 @@ use Doctrine\ORM\Tools\Pagination\Paginator; class EntriesRepository extends EntityRepository { + /** + * Retrieves unread entries for a user + * + * @param $userId + * @param $firstResult + * @param int $maxResults + * @return Paginator + */ public function findUnreadByUser($userId, $firstResult, $maxResults = 12) { $qb = $this->createQueryBuilder('e') @@ -18,11 +26,19 @@ class EntriesRepository extends EntityRepository ->andWhere('e.userId =:userId')->setParameter('userId', $userId) ->getQuery(); - $pag = new Paginator($qb); + $paginator = new Paginator($qb); - return $pag; + return $paginator; } + /** + * Retrieves read entries for a user + * + * @param $userId + * @param $firstResult + * @param int $maxResults + * @return Paginator + */ public function findArchiveByUser($userId, $firstResult, $maxResults = 12) { $qb = $this->createQueryBuilder('e') @@ -31,12 +47,21 @@ class EntriesRepository extends EntityRepository ->setMaxResults($maxResults) ->where('e.isRead = 1') ->andWhere('e.userId =:userId')->setParameter('userId', $userId) - ->getQuery() - ->getResult(Query::HYDRATE_ARRAY); + ->getQuery(); - return $qb; + $paginator = new Paginator($qb); + + return $paginator; } + /** + * Retrieves starred entries for a user + * + * @param $userId + * @param $firstResult + * @param int $maxResults + * @return Paginator + */ public function findStarredByUser($userId, $firstResult, $maxResults = 12) { $qb = $this->createQueryBuilder('e') @@ -45,9 +70,10 @@ class EntriesRepository extends EntityRepository ->setMaxResults($maxResults) ->where('e.isFav = 1') ->andWhere('e.userId =:userId')->setParameter('userId', $userId) - ->getQuery() - ->getResult(Query::HYDRATE_ARRAY); + ->getQuery(); - return $qb; + $paginator = new Paginator($qb); + + return $paginator; } } diff --git a/src/WallabagBundle/Resources/views/Entry/new.html.twig b/src/WallabagBundle/Resources/views/Entry/new.html.twig new file mode 100644 index 000000000..78da791f8 --- /dev/null +++ b/src/WallabagBundle/Resources/views/Entry/new.html.twig @@ -0,0 +1,11 @@ +{% extends "WallabagBundle::layout.html.twig" %} + +{% block title %}{% trans %}Save new entry{% endtrans %}{% endblock %} + +{% block menu %} + {% include "WallabagBundle::_menu.html.twig" %} +{% endblock %} + +{% block content %} + {{ form(form) }} +{% endblock %} \ No newline at end of file diff --git a/src/WallabagBundle/Resources/views/Static/about.html.twig b/src/WallabagBundle/Resources/views/Static/about.html.twig index 1a3c927ee..752526e11 100755 --- a/src/WallabagBundle/Resources/views/Static/about.html.twig +++ b/src/WallabagBundle/Resources/views/Static/about.html.twig @@ -14,7 +14,7 @@
{% trans %}Main developer{% endtrans %}
Nicolas Lœuillet{% trans %}website{% endtrans %}
-
{% trans %}Contributors:{% endtrans %}
+
{% trans %}Contributors ♥:{% endtrans %}
{% trans %}on Github{% endtrans %}
{% trans %}Bug reports{% endtrans %}
@@ -24,7 +24,7 @@
MIT
{% trans %}Version{% endtrans %}
-
+
{{ version }}

{% 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 %}

@@ -33,7 +33,7 @@
{% trans %}Documentation{% endtrans %}
-
Offline documentation and online documentation (up to date)
+
Online documentation
{% trans %}Support{% endtrans %}
http://support.wallabag.org/
@@ -44,41 +44,8 @@

{% trans %}wallabag is free and opensource. You can help us:{% endtrans %}

-
{% trans %}via Paypal{% endtrans %}
+
{% trans %}via Paypal{% endtrans %}
-
{% trans %}via Flattr{% endtrans %}
+
{% trans %}via Flattr{% endtrans %}
- -

{% trans %}Credits{% endtrans %}

-
-
PHP Readability
-
https://bitbucket.org/fivefilters/php-readability
- -
Full Text RSS
-
http://code.fivefilters.org/full-text-rss/src
- -
logo by Maylis Agniel
-
https://github.com/wallabag/logo
- -
icons
-
http://icomoon.io
- -
PHP Simple HTML DOM Parser
-
http://simplehtmldom.sourceforge.net/
- -
Session
-
https://github.com/tontof/kriss_feed/blob/master/src/class/Session.php
- -
Twig
-
http://twig.sensiolabs.org
- -
Flash messages
-
https://github.com/plasticbrain/PHP-Flash-Messages
- -
Pagination
-
https://github.com/daveismyname/pagination
- -
PHPePub
-
https://github.com/Grandt/PHPePub/
-
{% endblock %} diff --git a/src/WallabagBundle/Resources/views/_menu.html.twig b/src/WallabagBundle/Resources/views/_menu.html.twig index 4c6a0a1b3..419a676b9 100644 --- a/src/WallabagBundle/Resources/views/_menu.html.twig +++ b/src/WallabagBundle/Resources/views/_menu.html.twig @@ -4,9 +4,7 @@
  • {% trans %}favorites{% endtrans %}
  • {% trans %}archive{% endtrans %}
  • {% trans %}tags{% endtrans %}
  • -
  • {% trans %}save a link{% endtrans %} - {% include "WallabagBundle::_save_form.html.twig" %} -
  • +
  • {% trans %}save a link{% endtrans %}
  • {% trans %}search{% endtrans %} {% include "WallabagBundle::_search_form.html.twig" %}