some parameters, new entry form, etc.

This commit is contained in:
Nicolas Lœuillet 2015-01-23 14:58:17 +01:00
parent 163eae0bb1
commit b84a80559a
9 changed files with 123 additions and 50 deletions

View file

@ -44,6 +44,9 @@ twig:
export_epub: %export_epub% export_epub: %export_epub%
export_mobi: %export_mobi% export_mobi: %export_mobi%
export_pdf: %export_pdf% 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 Configuration
assetic: assetic:

View file

@ -19,4 +19,24 @@ parameters:
# A secret key that's used to generate certain security-related tokens # A secret key that's used to generate certain security-related tokens
secret: ThisTokenIsNotSoSecretChangeIt secret: ThisTokenIsNotSoSecretChangeIt
# wallabag misc
app.version: 2.0.0-alpha
download_pictures: false # if true, pictures will be stored into data/assets for each article 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

View file

@ -1,3 +1,7 @@
app: app:
resource: @WallabagBundle/Controller/ resource: @WallabagBundle/Controller/
type: annotation type: annotation
homepage:
pattern: /
defaults: { _controller: WallabagBundle:Entry:showUnread }

View file

@ -7,9 +7,51 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use WallabagBundle\Repository; use WallabagBundle\Repository;
use WallabagBundle\Entity\Entries; use WallabagBundle\Entity\Entries;
use Wallabag\Wallabag\Tools;
use Wallabag\Wallabag\Url;
class EntryController extends Controller 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 * Shows unread entries for current user
* *

View file

@ -3,6 +3,7 @@
namespace WallabagBundle\Entity; namespace WallabagBundle\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/** /**
* Entries * Entries
@ -31,6 +32,7 @@ class Entries
/** /**
* @var string * @var string
* *
* @Assert\NotBlank()
* @ORM\Column(name="url", type="text", nullable=true) * @ORM\Column(name="url", type="text", nullable=true)
*/ */
private $url; private $url;

View file

@ -8,6 +8,14 @@ use Doctrine\ORM\Tools\Pagination\Paginator;
class EntriesRepository extends EntityRepository 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) public function findUnreadByUser($userId, $firstResult, $maxResults = 12)
{ {
$qb = $this->createQueryBuilder('e') $qb = $this->createQueryBuilder('e')
@ -18,11 +26,19 @@ class EntriesRepository extends EntityRepository
->andWhere('e.userId =:userId')->setParameter('userId', $userId) ->andWhere('e.userId =:userId')->setParameter('userId', $userId)
->getQuery(); ->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) public function findArchiveByUser($userId, $firstResult, $maxResults = 12)
{ {
$qb = $this->createQueryBuilder('e') $qb = $this->createQueryBuilder('e')
@ -31,12 +47,21 @@ class EntriesRepository extends EntityRepository
->setMaxResults($maxResults) ->setMaxResults($maxResults)
->where('e.isRead = 1') ->where('e.isRead = 1')
->andWhere('e.userId =:userId')->setParameter('userId', $userId) ->andWhere('e.userId =:userId')->setParameter('userId', $userId)
->getQuery() ->getQuery();
->getResult(Query::HYDRATE_ARRAY);
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) public function findStarredByUser($userId, $firstResult, $maxResults = 12)
{ {
$qb = $this->createQueryBuilder('e') $qb = $this->createQueryBuilder('e')
@ -45,9 +70,10 @@ class EntriesRepository extends EntityRepository
->setMaxResults($maxResults) ->setMaxResults($maxResults)
->where('e.isFav = 1') ->where('e.isFav = 1')
->andWhere('e.userId =:userId')->setParameter('userId', $userId) ->andWhere('e.userId =:userId')->setParameter('userId', $userId)
->getQuery() ->getQuery();
->getResult(Query::HYDRATE_ARRAY);
return $qb; $paginator = new Paginator($qb);
return $paginator;
} }
} }

View file

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

View file

@ -14,7 +14,7 @@
<dt>{% trans %}Main developer{% endtrans %}</dt> <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> <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> <dd><a href="https://github.com/wallabag/wallabag/graphs/contributors">{% trans %}on Github{% endtrans %}</a></dd>
<dt>{% trans %}Bug reports{% endtrans %}</dt> <dt>{% trans %}Bug reports{% endtrans %}</dt>
@ -24,7 +24,7 @@
<dd><a href="http://en.wikipedia.org/wiki/MIT_License">MIT</a></dd> <dd><a href="http://en.wikipedia.org/wiki/MIT_License">MIT</a></dd>
<dt>{% trans %}Version{% endtrans %}</dt> <dt>{% trans %}Version{% endtrans %}</dt>
<dd></dd> <dd>{{ version }}</dd>
</dl> </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> <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> <dl>
<dt>{% trans %}Documentation{% endtrans %}</dt> <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> <dt>{% trans %}Support{% endtrans %}</dt>
<dd><a href="http://support.wallabag.org/">http://support.wallabag.org/</a></dd> <dd><a href="http://support.wallabag.org/">http://support.wallabag.org/</a></dd>
@ -44,41 +44,8 @@
<p>{% trans %}wallabag is free and opensource. You can help us:{% endtrans %}</p> <p>{% trans %}wallabag is free and opensource. You can help us:{% endtrans %}</p>
<dl> <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> </dl>
{% endblock %} {% endblock %}

View file

@ -4,9 +4,7 @@
<li><a href="{{ path('starred') }}">{% trans %}favorites{% 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('archive') }}"}>{% trans %}archive{% endtrans %}</a></li>
<li><a href="./?view=tags">{% trans %}tags{% 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> <li><a href="{{ path('new_entry') }}">{% trans %}save a link{% endtrans %}</a></li>
{% include "WallabagBundle::_save_form.html.twig" %}
</li>
<li style="position: relative;"><a href="javascript: void(null);" id="search">{% trans %}search{% endtrans %}</a> <li style="position: relative;"><a href="javascript: void(null);" id="search">{% trans %}search{% endtrans %}</a>
{% include "WallabagBundle::_search_form.html.twig" %} {% include "WallabagBundle::_search_form.html.twig" %}
</li> </li>