]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
some parameters, new entry form, etc.
authorNicolas Lœuillet <nicolas@loeuillet.org>
Fri, 23 Jan 2015 13:58:17 +0000 (14:58 +0100)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Fri, 23 Jan 2015 13:58:17 +0000 (14:58 +0100)
app/config/config.yml
app/config/parameters.yml.dist
app/config/routing.yml
src/WallabagBundle/Controller/EntryController.php
src/WallabagBundle/Entity/Entries.php
src/WallabagBundle/Repository/EntriesRepository.php
src/WallabagBundle/Resources/views/Entry/new.html.twig [new file with mode: 0644]
src/WallabagBundle/Resources/views/Static/about.html.twig
src/WallabagBundle/Resources/views/_menu.html.twig

index c6bed7970c3ba01bfb59d8ad967556ce6cfb3f52..455345f46985671f010558f85716c0b06a2f1bc4 100644 (file)
@@ -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:
index 5ccac49228c684e1fccadfb073e40e18a16854c7..36e3fe7f2a54b1360eb2c0db26e4a12143bb9655 100644 (file)
@@ -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
index a748d532f46ebf0d6eb074e80c5dcf1cbb57d7b4..d0ece8e303c10e6087932162fa1a04b2d9d4b1ff 100644 (file)
@@ -1,3 +1,7 @@
 app:
     resource: @WallabagBundle/Controller/
     type:     annotation
+
+homepage:
+    pattern:   /
+    defaults:  { _controller: WallabagBundle:Entry:showUnread }
\ No newline at end of file
index fbbb76aa2054dbedc06ee391e3ca273c39de03f5..dc1876fac4416652a670599d2a59a46c347d7e22 100644 (file)
@@ -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
      *
index b364e0c334258c0531b97493f6f31d6965df79a7..5849a21612019c0b1d728844f91dea28fc1ab0de 100644 (file)
@@ -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;
index c4428a1d20046e6cf70d1d45c33a020716429cf7..3eb1733d1ebff98cb3ea92c19fa6093155b7f184 100644 (file)
@@ -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();
+
+        $paginator = new Paginator($qb);
 
-        return $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();
+
+        $paginator = new Paginator($qb);
 
-        return $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 (file)
index 0000000..78da791
--- /dev/null
@@ -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
index 1a3c927ee574f366f579ace7ed6e1507820996c8..752526e113339bde79cd40fcd6b38334279f7956 100755 (executable)
@@ -14,7 +14,7 @@
         <dt>{% trans %}Main developer{% endtrans %}</dt>
         <dd><a href="mailto:nicolas@loeuillet.org">Nicolas Lœuillet</a> — <a href="http://cdetc.fr">{% trans %}website{% endtrans %}</a></dd>
 
-        <dt>{% trans %}Contributors:{% endtrans %}</dt>
+        <dt>{% trans %}Contributors ♥:{% endtrans %}</dt>
         <dd><a href="https://github.com/wallabag/wallabag/graphs/contributors">{% trans %}on Github{% endtrans %}</a></dd>
 
         <dt>{% trans %}Bug reports{% endtrans %}</dt>
@@ -24,7 +24,7 @@
         <dd><a href="http://en.wikipedia.org/wiki/MIT_License">MIT</a></dd>
 
         <dt>{% trans %}Version{% endtrans %}</dt>
-        <dd></dd>
+        <dd>{{ version }}</dd>
     </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>
@@ -33,7 +33,7 @@
     
     <dl>
         <dt>{% trans %}Documentation{% endtrans %}</dt>
-        <dd><a href="docs/">Offline documentation</a> and <a href="https://doc.wallabag.org/">online documentation</a> (up to date)</dd>
+        <dd><a href="https://doc.wallabag.org/">Online documentation</a></dd>
         
         <dt>{% trans %}Support{% endtrans %}</dt>
         <dd><a href="http://support.wallabag.org/">http://support.wallabag.org/</a></dd>
     <p>{% trans %}wallabag is free and opensource. You can help us:{% endtrans %}</p>
 
     <dl>
-        <dt><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9UBA65LG3FX9Y&lc=gb">{% trans %}via Paypal{% endtrans %}</a></dt>
+        <dt><a href="{{ paypal_url }}">{% trans %}via Paypal{% endtrans %}</a></dt>
 
-        <dt><a href="https://flattr.com/thing/1265480">{% trans %}via Flattr{% endtrans %}</a></dt>
+        <dt><a href="{{ flattr_url }}">{% trans %}via Flattr{% endtrans %}</a></dt>
     </dl>
-
-    <h2>{% trans %}Credits{% endtrans %}</h2>
-    <dl>
-        <dt>PHP Readability</dt>
-        <dd><a href="https://bitbucket.org/fivefilters/php-readability">https://bitbucket.org/fivefilters/php-readability</a></dd>
-
-        <dt>Full Text RSS</dt>
-        <dd><a href="http://code.fivefilters.org/full-text-rss/src">http://code.fivefilters.org/full-text-rss/src</a></dd>
-
-        <dt>logo by Maylis Agniel</dt>
-        <dd><a href="https://github.com/wallabag/logo">https://github.com/wallabag/logo</a></dd>
-
-        <dt>icons</dt>
-        <dd><a href="http://icomoon.io">http://icomoon.io</a></dd>
-
-        <dt>PHP Simple HTML DOM Parser</dt>
-        <dd><a href="http://simplehtmldom.sourceforge.net/">http://simplehtmldom.sourceforge.net/</a></dd>
-
-        <dt>Session</dt>
-        <dd><a href="https://github.com/tontof/kriss_feed/blob/master/src/class/Session.php">https://github.com/tontof/kriss_feed/blob/master/src/class/Session.php</a></dd>
-
-        <dt>Twig</dt>
-        <dd><a href="http://twig.sensiolabs.org">http://twig.sensiolabs.org</a></dd>
-
-        <dt>Flash messages</dt>
-        <dd><a href="https://github.com/plasticbrain/PHP-Flash-Messages">https://github.com/plasticbrain/PHP-Flash-Messages</a></dd>
-
-        <dt>Pagination</dt>
-        <dd><a href="https://github.com/daveismyname/pagination">https://github.com/daveismyname/pagination</a></dd>
-
-        <dt>PHPePub</dt>
-        <dd><a href="https://github.com/Grandt/PHPePub/">https://github.com/Grandt/PHPePub/</a></dd>
-    </dl> 
 {% endblock %}
index 4c6a0a1b3f97efee022574a3b3fedfb45adbe8fb..419a676b985f31d06a46fb5ba8795e5bde3c3917 100644 (file)
@@ -4,9 +4,7 @@
                 <li><a href="{{ path('starred') }}">{% trans %}favorites{% endtrans %}</a></li>
                 <li><a href="{{ path('archive') }}"}>{% trans %}archive{% endtrans %}</a></li>
                 <li><a href="./?view=tags">{% trans %}tags{% endtrans %}</a></li>
-                <li style="position: relative;"><a href="javascript: void(null);" id="bagit">{% trans %}save a link{% endtrans %}</a>
-                    {% include "WallabagBundle::_save_form.html.twig" %}
-                </li>
+                <li><a href="{{ path('new_entry') }}">{% trans %}save a link{% endtrans %}</a></li>
                 <li style="position: relative;"><a href="javascript: void(null);" id="search">{% trans %}search{% endtrans %}</a>
                     {% include "WallabagBundle::_search_form.html.twig" %}
                 </li>