]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
migrating legacy to symfony
authorNicolas Lœuillet <nicolas@loeuillet.org>
Thu, 22 Jan 2015 16:18:56 +0000 (17:18 +0100)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Thu, 22 Jan 2015 16:18:56 +0000 (17:18 +0100)
31 files changed:
app/config/config.yml
app/config/parameters.yml.dist
src/Wallabag/Wallabag/Database.php
src/WallabagBundle/Controller/DefaultController.php [deleted file]
src/WallabagBundle/Controller/EntryController.php [new file with mode: 0644]
src/WallabagBundle/DependencyInjection/WallabagExtension.php [new file with mode: 0644]
src/WallabagBundle/Entity/Config.php [new file with mode: 0644]
src/WallabagBundle/Entity/Config.php~ [new file with mode: 0644]
src/WallabagBundle/Entity/Entries.php [new file with mode: 0644]
src/WallabagBundle/Entity/Entries.php~ [new file with mode: 0644]
src/WallabagBundle/Entity/Entry.php~ [new file with mode: 0644]
src/WallabagBundle/Entity/Tags.php [new file with mode: 0644]
src/WallabagBundle/Entity/Tags.php~ [new file with mode: 0644]
src/WallabagBundle/Entity/TagsEntries.php [new file with mode: 0644]
src/WallabagBundle/Entity/TagsEntries.php~ [new file with mode: 0644]
src/WallabagBundle/Entity/Users.php [new file with mode: 0644]
src/WallabagBundle/Entity/Users.php~ [new file with mode: 0644]
src/WallabagBundle/Entity/UsersConfig.php [new file with mode: 0644]
src/WallabagBundle/Entity/UsersConfig.php~ [new file with mode: 0644]
src/WallabagBundle/Repository/EntriesRepository.php [new file with mode: 0644]
src/WallabagBundle/Resources/config/routing.yml [new file with mode: 0644]
src/WallabagBundle/Resources/config/services.xml [new file with mode: 0644]
src/WallabagBundle/Resources/views/Entry/entries.html.twig [new file with mode: 0644]
src/WallabagBundle/Resources/views/_bookmarklet.html.twig [new file with mode: 0644]
src/WallabagBundle/Resources/views/_footer.html.twig [new file with mode: 0644]
src/WallabagBundle/Resources/views/_head.html.twig [new file with mode: 0755]
src/WallabagBundle/Resources/views/_messages.html.twig [new file with mode: 0644]
src/WallabagBundle/Resources/views/_top.html.twig [new file with mode: 0755]
src/WallabagBundle/Resources/views/layout.html.twig [new file with mode: 0644]
src/WallabagBundle/Tests/Controller/DefaultControllerTest.php
src/WallabagBundle/Twig/Extension/WallabagExtension.php [new file with mode: 0644]

index 25f6647196219b43f03d8a75160d476cc2c22a79..ca7fb467d1716423f6823c3e7c2d83d6aa611b92 100644 (file)
@@ -58,7 +58,7 @@ doctrine:
         #     e.g. database_path: "%kernel.root_dir%/data/data.db3"
         #   2. Uncomment database_path in parameters.yml.dist
         #   3. Uncomment next line:
-        #     path:     "%database_path%"
+        path:     "%database_path%"
 
     orm:
         auto_generate_proxy_classes: "%kernel.debug%"
index 26a23f54079d4c4895cdf09dba126c2f04ba7df0..5ccac49228c684e1fccadfb073e40e18a16854c7 100644 (file)
@@ -7,7 +7,7 @@ parameters:
     database_user:     root
     database_password: ~
     # You should uncomment this if you want use pdo_sqlite
-    # database_path: "%kernel.root_dir%/data.db3"
+    database_path: "%kernel.root_dir%/data/db/poche.sqlite"
 
     mailer_transport:  smtp
     mailer_host:       127.0.0.1
index fa13291019bc15b4709281b0e807fb5a621e3675..47fa99aa8957cb10b2050e93c40614c47561e590 100755 (executable)
@@ -11,6 +11,7 @@
 namespace Wallabag\Wallabag;
 
 use \PDO;
+use WallabagBundle\Entity;
 
 class Database {
 
diff --git a/src/WallabagBundle/Controller/DefaultController.php b/src/WallabagBundle/Controller/DefaultController.php
deleted file mode 100644 (file)
index 1030b7a..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-
-namespace WallabagBundle\Controller;
-
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
-
-class DefaultController extends Controller
-{
-    /**
-     * @Route("/app/index", name="homepage")
-     */
-    public function indexAction()
-    {
-        return $this->render('default/index.html.twig');
-    }
-}
diff --git a/src/WallabagBundle/Controller/EntryController.php b/src/WallabagBundle/Controller/EntryController.php
new file mode 100644 (file)
index 0000000..0c0c156
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+
+namespace WallabagBundle\Controller;
+
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use WallabagBundle\Repository;
+
+class EntryController extends Controller
+{
+    /**
+     * @Route("/unread", name="unread")
+     */
+    public function unreadAction()
+    {
+        $repository = $this->getDoctrine()->getRepository('WallabagBundle:Entries');
+        $entries = $repository->findUnreadByUser(1);
+
+        return $this->render(
+            'WallabagBundle:Entry:entries.html.twig',
+            array('entries' => $entries)
+        );
+
+    }
+}
diff --git a/src/WallabagBundle/DependencyInjection/WallabagExtension.php b/src/WallabagBundle/DependencyInjection/WallabagExtension.php
new file mode 100644 (file)
index 0000000..cfdb21f
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+
+namespace WallabagBundle\DependencyInjection;
+
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Symfony\Component\HttpKernel\DependencyInjection\Extension;
+use Symfony\Component\Config\FileLocator;
+
+class WallabagExtension extends Extension
+{
+    public function load(array $configs, ContainerBuilder $container)
+    {
+        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
+        $loader->load('services.xml');
+    }
+
+    public function getAlias()
+    {
+        return 'wallabag';
+    }
+}
diff --git a/src/WallabagBundle/Entity/Config.php b/src/WallabagBundle/Entity/Config.php
new file mode 100644 (file)
index 0000000..8b692ce
--- /dev/null
@@ -0,0 +1,95 @@
+<?php
+
+namespace WallabagBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Config
+ *
+ * @ORM\Table(name="config")
+ * @ORM\Entity
+ */
+class Config
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer", nullable=false)
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="IDENTITY")
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="name", type="string", nullable=true)
+     */
+    private $name;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="value", type="blob", nullable=true)
+     */
+    private $value;
+
+
+
+    /**
+     * Get id
+     *
+     * @return integer 
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set name
+     *
+     * @param string $name
+     * @return Config
+     */
+    public function setName($name)
+    {
+        $this->name = $name;
+
+        return $this;
+    }
+
+    /**
+     * Get name
+     *
+     * @return string 
+     */
+    public function getName()
+    {
+        return $this->name;
+    }
+
+    /**
+     * Set value
+     *
+     * @param string $value
+     * @return Config
+     */
+    public function setValue($value)
+    {
+        $this->value = $value;
+
+        return $this;
+    }
+
+    /**
+     * Get value
+     *
+     * @return string 
+     */
+    public function getValue()
+    {
+        return $this->value;
+    }
+}
diff --git a/src/WallabagBundle/Entity/Config.php~ b/src/WallabagBundle/Entity/Config.php~
new file mode 100644 (file)
index 0000000..8b692ce
--- /dev/null
@@ -0,0 +1,95 @@
+<?php
+
+namespace WallabagBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Config
+ *
+ * @ORM\Table(name="config")
+ * @ORM\Entity
+ */
+class Config
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer", nullable=false)
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="IDENTITY")
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="name", type="string", nullable=true)
+     */
+    private $name;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="value", type="blob", nullable=true)
+     */
+    private $value;
+
+
+
+    /**
+     * Get id
+     *
+     * @return integer 
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set name
+     *
+     * @param string $name
+     * @return Config
+     */
+    public function setName($name)
+    {
+        $this->name = $name;
+
+        return $this;
+    }
+
+    /**
+     * Get name
+     *
+     * @return string 
+     */
+    public function getName()
+    {
+        return $this->name;
+    }
+
+    /**
+     * Set value
+     *
+     * @param string $value
+     * @return Config
+     */
+    public function setValue($value)
+    {
+        $this->value = $value;
+
+        return $this;
+    }
+
+    /**
+     * Get value
+     *
+     * @return string 
+     */
+    public function getValue()
+    {
+        return $this->value;
+    }
+}
diff --git a/src/WallabagBundle/Entity/Entries.php b/src/WallabagBundle/Entity/Entries.php
new file mode 100644 (file)
index 0000000..69c6be0
--- /dev/null
@@ -0,0 +1,215 @@
+<?php
+
+namespace WallabagBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Entries
+ *
+ * @ORM\Entity(repositoryClass="WallabagBundle\Repository\EntriesRepository")
+ * @ORM\Table(name="entries")
+ */
+class Entries
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer", nullable=true)
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="IDENTITY")
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="title", type="text", nullable=true)
+     */
+    private $title;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="url", type="text", nullable=true)
+     */
+    private $url;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="is_read", type="decimal", precision=10, scale=0, nullable=true)
+     */
+    private $isRead = '0';
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="is_fav", type="decimal", precision=10, scale=0, nullable=true)
+     */
+    private $isFav = '0';
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="content", type="text", nullable=true)
+     */
+    private $content;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="user_id", type="decimal", precision=10, scale=0, nullable=true)
+     */
+    private $userId;
+
+
+
+    /**
+     * Get id
+     *
+     * @return integer 
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set title
+     *
+     * @param string $title
+     * @return Entries
+     */
+    public function setTitle($title)
+    {
+        $this->title = $title;
+
+        return $this;
+    }
+
+    /**
+     * Get title
+     *
+     * @return string 
+     */
+    public function getTitle()
+    {
+        return $this->title;
+    }
+
+    /**
+     * Set url
+     *
+     * @param string $url
+     * @return Entries
+     */
+    public function setUrl($url)
+    {
+        $this->url = $url;
+
+        return $this;
+    }
+
+    /**
+     * Get url
+     *
+     * @return string 
+     */
+    public function getUrl()
+    {
+        return $this->url;
+    }
+
+    /**
+     * Set isRead
+     *
+     * @param string $isRead
+     * @return Entries
+     */
+    public function setIsRead($isRead)
+    {
+        $this->isRead = $isRead;
+
+        return $this;
+    }
+
+    /**
+     * Get isRead
+     *
+     * @return string 
+     */
+    public function getIsRead()
+    {
+        return $this->isRead;
+    }
+
+    /**
+     * Set isFav
+     *
+     * @param string $isFav
+     * @return Entries
+     */
+    public function setIsFav($isFav)
+    {
+        $this->isFav = $isFav;
+
+        return $this;
+    }
+
+    /**
+     * Get isFav
+     *
+     * @return string 
+     */
+    public function getIsFav()
+    {
+        return $this->isFav;
+    }
+
+    /**
+     * Set content
+     *
+     * @param string $content
+     * @return Entries
+     */
+    public function setContent($content)
+    {
+        $this->content = $content;
+
+        return $this;
+    }
+
+    /**
+     * Get content
+     *
+     * @return string 
+     */
+    public function getContent()
+    {
+        return $this->content;
+    }
+
+    /**
+     * Set userId
+     *
+     * @param string $userId
+     * @return Entries
+     */
+    public function setUserId($userId)
+    {
+        $this->userId = $userId;
+
+        return $this;
+    }
+
+    /**
+     * Get userId
+     *
+     * @return string 
+     */
+    public function getUserId()
+    {
+        return $this->userId;
+    }
+}
diff --git a/src/WallabagBundle/Entity/Entries.php~ b/src/WallabagBundle/Entity/Entries.php~
new file mode 100644 (file)
index 0000000..69c6be0
--- /dev/null
@@ -0,0 +1,215 @@
+<?php
+
+namespace WallabagBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Entries
+ *
+ * @ORM\Entity(repositoryClass="WallabagBundle\Repository\EntriesRepository")
+ * @ORM\Table(name="entries")
+ */
+class Entries
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer", nullable=true)
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="IDENTITY")
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="title", type="text", nullable=true)
+     */
+    private $title;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="url", type="text", nullable=true)
+     */
+    private $url;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="is_read", type="decimal", precision=10, scale=0, nullable=true)
+     */
+    private $isRead = '0';
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="is_fav", type="decimal", precision=10, scale=0, nullable=true)
+     */
+    private $isFav = '0';
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="content", type="text", nullable=true)
+     */
+    private $content;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="user_id", type="decimal", precision=10, scale=0, nullable=true)
+     */
+    private $userId;
+
+
+
+    /**
+     * Get id
+     *
+     * @return integer 
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set title
+     *
+     * @param string $title
+     * @return Entries
+     */
+    public function setTitle($title)
+    {
+        $this->title = $title;
+
+        return $this;
+    }
+
+    /**
+     * Get title
+     *
+     * @return string 
+     */
+    public function getTitle()
+    {
+        return $this->title;
+    }
+
+    /**
+     * Set url
+     *
+     * @param string $url
+     * @return Entries
+     */
+    public function setUrl($url)
+    {
+        $this->url = $url;
+
+        return $this;
+    }
+
+    /**
+     * Get url
+     *
+     * @return string 
+     */
+    public function getUrl()
+    {
+        return $this->url;
+    }
+
+    /**
+     * Set isRead
+     *
+     * @param string $isRead
+     * @return Entries
+     */
+    public function setIsRead($isRead)
+    {
+        $this->isRead = $isRead;
+
+        return $this;
+    }
+
+    /**
+     * Get isRead
+     *
+     * @return string 
+     */
+    public function getIsRead()
+    {
+        return $this->isRead;
+    }
+
+    /**
+     * Set isFav
+     *
+     * @param string $isFav
+     * @return Entries
+     */
+    public function setIsFav($isFav)
+    {
+        $this->isFav = $isFav;
+
+        return $this;
+    }
+
+    /**
+     * Get isFav
+     *
+     * @return string 
+     */
+    public function getIsFav()
+    {
+        return $this->isFav;
+    }
+
+    /**
+     * Set content
+     *
+     * @param string $content
+     * @return Entries
+     */
+    public function setContent($content)
+    {
+        $this->content = $content;
+
+        return $this;
+    }
+
+    /**
+     * Get content
+     *
+     * @return string 
+     */
+    public function getContent()
+    {
+        return $this->content;
+    }
+
+    /**
+     * Set userId
+     *
+     * @param string $userId
+     * @return Entries
+     */
+    public function setUserId($userId)
+    {
+        $this->userId = $userId;
+
+        return $this;
+    }
+
+    /**
+     * Get userId
+     *
+     * @return string 
+     */
+    public function getUserId()
+    {
+        return $this->userId;
+    }
+}
diff --git a/src/WallabagBundle/Entity/Entry.php~ b/src/WallabagBundle/Entity/Entry.php~
new file mode 100644 (file)
index 0000000..ebcdf53
--- /dev/null
@@ -0,0 +1,74 @@
+<?php
+
+namespace WallabagBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Entry
+ *
+ * @ORM\Table(name="Entry")
+ * @ORM\Entity
+ */
+class Entry
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer", nullable=false)
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="IDENTITY")
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="title", type="string", length=255, nullable=false)
+     */
+    private $title;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="url", type="text", nullable=false)
+     */
+    private $url;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="content", type="text", nullable=false)
+     */
+    private $content;
+
+    /**
+     * @var boolean
+     *
+     * @ORM\Column(name="is_read", type="boolean", nullable=false)
+     */
+    private $isRead;
+
+    /**
+     * @var boolean
+     *
+     * @ORM\Column(name="is_fav", type="boolean", nullable=false)
+     */
+    private $isFav;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="created_at", type="datetime", nullable=false)
+     */
+    private $createdAt;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="edited_at", type="datetime", nullable=false)
+     */
+    private $editedAt;
+
+
+}
diff --git a/src/WallabagBundle/Entity/Tags.php b/src/WallabagBundle/Entity/Tags.php
new file mode 100644 (file)
index 0000000..c0c78ee
--- /dev/null
@@ -0,0 +1,65 @@
+<?php
+
+namespace WallabagBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Tags
+ *
+ * @ORM\Table(name="tags")
+ * @ORM\Entity
+ */
+class Tags
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer", nullable=false)
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="IDENTITY")
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="value", type="text", nullable=true)
+     */
+    private $value;
+
+
+
+    /**
+     * Get id
+     *
+     * @return integer 
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set value
+     *
+     * @param string $value
+     * @return Tags
+     */
+    public function setValue($value)
+    {
+        $this->value = $value;
+
+        return $this;
+    }
+
+    /**
+     * Get value
+     *
+     * @return string 
+     */
+    public function getValue()
+    {
+        return $this->value;
+    }
+}
diff --git a/src/WallabagBundle/Entity/Tags.php~ b/src/WallabagBundle/Entity/Tags.php~
new file mode 100644 (file)
index 0000000..c0c78ee
--- /dev/null
@@ -0,0 +1,65 @@
+<?php
+
+namespace WallabagBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Tags
+ *
+ * @ORM\Table(name="tags")
+ * @ORM\Entity
+ */
+class Tags
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer", nullable=false)
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="IDENTITY")
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="value", type="text", nullable=true)
+     */
+    private $value;
+
+
+
+    /**
+     * Get id
+     *
+     * @return integer 
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set value
+     *
+     * @param string $value
+     * @return Tags
+     */
+    public function setValue($value)
+    {
+        $this->value = $value;
+
+        return $this;
+    }
+
+    /**
+     * Get value
+     *
+     * @return string 
+     */
+    public function getValue()
+    {
+        return $this->value;
+    }
+}
diff --git a/src/WallabagBundle/Entity/TagsEntries.php b/src/WallabagBundle/Entity/TagsEntries.php
new file mode 100644 (file)
index 0000000..448c54f
--- /dev/null
@@ -0,0 +1,95 @@
+<?php
+
+namespace WallabagBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * TagsEntries
+ *
+ * @ORM\Table(name="tags_entries")
+ * @ORM\Entity
+ */
+class TagsEntries
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer", nullable=false)
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="IDENTITY")
+     */
+    private $id;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="entry_id", type="integer", nullable=true)
+     */
+    private $entryId;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="tag_id", type="integer", nullable=true)
+     */
+    private $tagId;
+
+
+
+    /**
+     * Get id
+     *
+     * @return integer 
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set entryId
+     *
+     * @param integer $entryId
+     * @return TagsEntries
+     */
+    public function setEntryId($entryId)
+    {
+        $this->entryId = $entryId;
+
+        return $this;
+    }
+
+    /**
+     * Get entryId
+     *
+     * @return integer 
+     */
+    public function getEntryId()
+    {
+        return $this->entryId;
+    }
+
+    /**
+     * Set tagId
+     *
+     * @param integer $tagId
+     * @return TagsEntries
+     */
+    public function setTagId($tagId)
+    {
+        $this->tagId = $tagId;
+
+        return $this;
+    }
+
+    /**
+     * Get tagId
+     *
+     * @return integer 
+     */
+    public function getTagId()
+    {
+        return $this->tagId;
+    }
+}
diff --git a/src/WallabagBundle/Entity/TagsEntries.php~ b/src/WallabagBundle/Entity/TagsEntries.php~
new file mode 100644 (file)
index 0000000..448c54f
--- /dev/null
@@ -0,0 +1,95 @@
+<?php
+
+namespace WallabagBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * TagsEntries
+ *
+ * @ORM\Table(name="tags_entries")
+ * @ORM\Entity
+ */
+class TagsEntries
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer", nullable=false)
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="IDENTITY")
+     */
+    private $id;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="entry_id", type="integer", nullable=true)
+     */
+    private $entryId;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="tag_id", type="integer", nullable=true)
+     */
+    private $tagId;
+
+
+
+    /**
+     * Get id
+     *
+     * @return integer 
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set entryId
+     *
+     * @param integer $entryId
+     * @return TagsEntries
+     */
+    public function setEntryId($entryId)
+    {
+        $this->entryId = $entryId;
+
+        return $this;
+    }
+
+    /**
+     * Get entryId
+     *
+     * @return integer 
+     */
+    public function getEntryId()
+    {
+        return $this->entryId;
+    }
+
+    /**
+     * Set tagId
+     *
+     * @param integer $tagId
+     * @return TagsEntries
+     */
+    public function setTagId($tagId)
+    {
+        $this->tagId = $tagId;
+
+        return $this;
+    }
+
+    /**
+     * Get tagId
+     *
+     * @return integer 
+     */
+    public function getTagId()
+    {
+        return $this->tagId;
+    }
+}
diff --git a/src/WallabagBundle/Entity/Users.php b/src/WallabagBundle/Entity/Users.php
new file mode 100644 (file)
index 0000000..a48f224
--- /dev/null
@@ -0,0 +1,155 @@
+<?php
+
+namespace WallabagBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Users
+ *
+ * @ORM\Table(name="users")
+ * @ORM\Entity
+ */
+class Users
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer", nullable=true)
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="IDENTITY")
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="username", type="text", nullable=true)
+     */
+    private $username;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="password", type="text", nullable=true)
+     */
+    private $password;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="name", type="text", nullable=true)
+     */
+    private $name;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="email", type="text", nullable=true)
+     */
+    private $email;
+
+
+
+    /**
+     * Get id
+     *
+     * @return integer 
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set username
+     *
+     * @param string $username
+     * @return Users
+     */
+    public function setUsername($username)
+    {
+        $this->username = $username;
+
+        return $this;
+    }
+
+    /**
+     * Get username
+     *
+     * @return string 
+     */
+    public function getUsername()
+    {
+        return $this->username;
+    }
+
+    /**
+     * Set password
+     *
+     * @param string $password
+     * @return Users
+     */
+    public function setPassword($password)
+    {
+        $this->password = $password;
+
+        return $this;
+    }
+
+    /**
+     * Get password
+     *
+     * @return string 
+     */
+    public function getPassword()
+    {
+        return $this->password;
+    }
+
+    /**
+     * Set name
+     *
+     * @param string $name
+     * @return Users
+     */
+    public function setName($name)
+    {
+        $this->name = $name;
+
+        return $this;
+    }
+
+    /**
+     * Get name
+     *
+     * @return string 
+     */
+    public function getName()
+    {
+        return $this->name;
+    }
+
+    /**
+     * Set email
+     *
+     * @param string $email
+     * @return Users
+     */
+    public function setEmail($email)
+    {
+        $this->email = $email;
+
+        return $this;
+    }
+
+    /**
+     * Get email
+     *
+     * @return string 
+     */
+    public function getEmail()
+    {
+        return $this->email;
+    }
+}
diff --git a/src/WallabagBundle/Entity/Users.php~ b/src/WallabagBundle/Entity/Users.php~
new file mode 100644 (file)
index 0000000..a48f224
--- /dev/null
@@ -0,0 +1,155 @@
+<?php
+
+namespace WallabagBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Users
+ *
+ * @ORM\Table(name="users")
+ * @ORM\Entity
+ */
+class Users
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer", nullable=true)
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="IDENTITY")
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="username", type="text", nullable=true)
+     */
+    private $username;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="password", type="text", nullable=true)
+     */
+    private $password;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="name", type="text", nullable=true)
+     */
+    private $name;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="email", type="text", nullable=true)
+     */
+    private $email;
+
+
+
+    /**
+     * Get id
+     *
+     * @return integer 
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set username
+     *
+     * @param string $username
+     * @return Users
+     */
+    public function setUsername($username)
+    {
+        $this->username = $username;
+
+        return $this;
+    }
+
+    /**
+     * Get username
+     *
+     * @return string 
+     */
+    public function getUsername()
+    {
+        return $this->username;
+    }
+
+    /**
+     * Set password
+     *
+     * @param string $password
+     * @return Users
+     */
+    public function setPassword($password)
+    {
+        $this->password = $password;
+
+        return $this;
+    }
+
+    /**
+     * Get password
+     *
+     * @return string 
+     */
+    public function getPassword()
+    {
+        return $this->password;
+    }
+
+    /**
+     * Set name
+     *
+     * @param string $name
+     * @return Users
+     */
+    public function setName($name)
+    {
+        $this->name = $name;
+
+        return $this;
+    }
+
+    /**
+     * Get name
+     *
+     * @return string 
+     */
+    public function getName()
+    {
+        return $this->name;
+    }
+
+    /**
+     * Set email
+     *
+     * @param string $email
+     * @return Users
+     */
+    public function setEmail($email)
+    {
+        $this->email = $email;
+
+        return $this;
+    }
+
+    /**
+     * Get email
+     *
+     * @return string 
+     */
+    public function getEmail()
+    {
+        return $this->email;
+    }
+}
diff --git a/src/WallabagBundle/Entity/UsersConfig.php b/src/WallabagBundle/Entity/UsersConfig.php
new file mode 100644 (file)
index 0000000..8af283c
--- /dev/null
@@ -0,0 +1,125 @@
+<?php
+
+namespace WallabagBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * UsersConfig
+ *
+ * @ORM\Table(name="users_config")
+ * @ORM\Entity
+ */
+class UsersConfig
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer", nullable=true)
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="IDENTITY")
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="user_id", type="decimal", precision=10, scale=0, nullable=true)
+     */
+    private $userId;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="name", type="text", nullable=true)
+     */
+    private $name;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="value", type="text", nullable=true)
+     */
+    private $value;
+
+
+
+    /**
+     * Get id
+     *
+     * @return integer 
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set userId
+     *
+     * @param string $userId
+     * @return UsersConfig
+     */
+    public function setUserId($userId)
+    {
+        $this->userId = $userId;
+
+        return $this;
+    }
+
+    /**
+     * Get userId
+     *
+     * @return string 
+     */
+    public function getUserId()
+    {
+        return $this->userId;
+    }
+
+    /**
+     * Set name
+     *
+     * @param string $name
+     * @return UsersConfig
+     */
+    public function setName($name)
+    {
+        $this->name = $name;
+
+        return $this;
+    }
+
+    /**
+     * Get name
+     *
+     * @return string 
+     */
+    public function getName()
+    {
+        return $this->name;
+    }
+
+    /**
+     * Set value
+     *
+     * @param string $value
+     * @return UsersConfig
+     */
+    public function setValue($value)
+    {
+        $this->value = $value;
+
+        return $this;
+    }
+
+    /**
+     * Get value
+     *
+     * @return string 
+     */
+    public function getValue()
+    {
+        return $this->value;
+    }
+}
diff --git a/src/WallabagBundle/Entity/UsersConfig.php~ b/src/WallabagBundle/Entity/UsersConfig.php~
new file mode 100644 (file)
index 0000000..8af283c
--- /dev/null
@@ -0,0 +1,125 @@
+<?php
+
+namespace WallabagBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * UsersConfig
+ *
+ * @ORM\Table(name="users_config")
+ * @ORM\Entity
+ */
+class UsersConfig
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer", nullable=true)
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="IDENTITY")
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="user_id", type="decimal", precision=10, scale=0, nullable=true)
+     */
+    private $userId;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="name", type="text", nullable=true)
+     */
+    private $name;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="value", type="text", nullable=true)
+     */
+    private $value;
+
+
+
+    /**
+     * Get id
+     *
+     * @return integer 
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set userId
+     *
+     * @param string $userId
+     * @return UsersConfig
+     */
+    public function setUserId($userId)
+    {
+        $this->userId = $userId;
+
+        return $this;
+    }
+
+    /**
+     * Get userId
+     *
+     * @return string 
+     */
+    public function getUserId()
+    {
+        return $this->userId;
+    }
+
+    /**
+     * Set name
+     *
+     * @param string $name
+     * @return UsersConfig
+     */
+    public function setName($name)
+    {
+        $this->name = $name;
+
+        return $this;
+    }
+
+    /**
+     * Get name
+     *
+     * @return string 
+     */
+    public function getName()
+    {
+        return $this->name;
+    }
+
+    /**
+     * Set value
+     *
+     * @param string $value
+     * @return UsersConfig
+     */
+    public function setValue($value)
+    {
+        $this->value = $value;
+
+        return $this;
+    }
+
+    /**
+     * Get value
+     *
+     * @return string 
+     */
+    public function getValue()
+    {
+        return $this->value;
+    }
+}
diff --git a/src/WallabagBundle/Repository/EntriesRepository.php b/src/WallabagBundle/Repository/EntriesRepository.php
new file mode 100644 (file)
index 0000000..4c13c9c
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+
+namespace WallabagBundle\Repository;
+
+use Doctrine\ORM\Query;
+use Doctrine\ORM\EntityRepository;
+
+/**
+ * EntriesRepository
+ *
+ * This class was generated by the Doctrine ORM. Add your own custom
+ * repository methods below.
+ */
+class EntriesRepository extends EntityRepository
+{
+  /*  public function findUnreadByUser($userId)
+    {
+        return $this->createQueryBuilder('e')
+            ->where('e.is_read = 0')
+            ->andWhere('e.user_id = :userId')
+            ->setParameter('userId', $userId)
+            ->getQuery();
+    }*/
+    public function findUnreadByUser($userId)
+    {
+        $qb = $this->createQueryBuilder('e')
+            ->select('e')
+            ->where('e.isRead = 0')
+            ->andWhere('e.userId =:userId')->setParameter('userId', $userId)
+            ->getQuery()
+            ->getResult(Query::HYDRATE_ARRAY);
+
+        return $qb;
+    }
+}
diff --git a/src/WallabagBundle/Resources/config/routing.yml b/src/WallabagBundle/Resources/config/routing.yml
new file mode 100644 (file)
index 0000000..ad79b1f
--- /dev/null
@@ -0,0 +1,3 @@
+_wllbg:
+    resource: "@WallabagBundle/Controller/EntryController.php"
+    type:     annotation
diff --git a/src/WallabagBundle/Resources/config/services.xml b/src/WallabagBundle/Resources/config/services.xml
new file mode 100644 (file)
index 0000000..02d8264
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" ?>
+
+<container xmlns="http://symfony.com/schema/dic/services"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
+
+    <services>
+        <service id="wallabag.twig.extension.wallabag_extension" class="WallabagBundle\Twig\Extension\WallabagExtension">
+            <tag name="twig.extension" />
+        </service>
+    </services>
+</container>
diff --git a/src/WallabagBundle/Resources/views/Entry/entries.html.twig b/src/WallabagBundle/Resources/views/Entry/entries.html.twig
new file mode 100644 (file)
index 0000000..f4d7a7a
--- /dev/null
@@ -0,0 +1,26 @@
+{% extends "WallabagBundle::layout.html.twig" %}
+
+{% block title "Unread" %}
+
+{% block content_header '' %}
+
+{% block content %}
+    {% for entry in entries %}
+        <div id="entry-{{ entry.id|e }}" class="entrie">
+            <h2><a href="index.php?view=view&amp;id={{ entry.id|e }}">{{ entry.title|raw }}</a></h2>
+            {% if entry.content| readingTime > 0 %}
+                <div class="estimatedTime"><span class="tool reading-time">{% trans %}estimated reading time :{% endtrans %} {{ entry.content| readingTime }} min</span></div>
+            {% else %}
+                <div class="estimatedTime"><span class="tool reading-time">{% trans %}estimated reading time :{% endtrans %} <small class="inferieur">&lt;</small> 1 min</span></div>
+            {% endif %}
+
+            <ul class="tools links">
+                <li><a title="{% trans %}Toggle mark as read{% endtrans %}" class="tool icon-check icon {% if entry.isRead == 0 %}archive-off{% else %}archive{% endif %}" href="./?action=toggle_archive&amp;id={{ entry.id|e }}"><span>{% trans %}Toggle mark as read{% endtrans %}</span></a></li>
+                <li><a title="{% trans %}toggle favorite{% endtrans %}" class="tool icon-star icon {% if entry.isFav == 0 %}fav-off{% else %}fav{% endif %}" href="./?action=toggle_fav&amp;id={{ entry.id|e }}"><span>{% trans %}toggle favorite{% endtrans %}</span></a></li>
+                <li><a title="{% trans %}delete{% endtrans %}" class="tool delete icon-trash icon" href="./?action=delete&amp;id={{ entry.id|e }}"><span>{% trans %}delete{% endtrans %}</span></a></li>
+                <li><a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %} : {{ entry.title|e }}" class="tool link icon-link icon"><span>{{ entry.url | e | domainName }}</span></a></li>
+            </ul>
+            <p>{{ entry.content|striptags|slice(0, 300) }}...</p>
+        </div>
+    {% endfor %}
+{% endblock %}
diff --git a/src/WallabagBundle/Resources/views/_bookmarklet.html.twig b/src/WallabagBundle/Resources/views/_bookmarklet.html.twig
new file mode 100644 (file)
index 0000000..d432909
--- /dev/null
@@ -0,0 +1,3 @@
+        <script type="text/javascript">
+          top["bookmarklet-url@wallabag.org"]=""+"<!DOCTYPE html>"+"<html>"+"<head>"+"<title>bag it!</title>"+'<link rel="icon" href="tpl/img/favicon.ico" />'+"</head>"+"<body>"+"<script>"+"window.onload=function(){"+"window.setTimeout(function(){"+"history.back();"+"},250);"+"};"+"</scr"+"ipt>"+"</body>"+"</html>"
+        </script>
\ No newline at end of file
diff --git a/src/WallabagBundle/Resources/views/_footer.html.twig b/src/WallabagBundle/Resources/views/_footer.html.twig
new file mode 100644 (file)
index 0000000..c897a97
--- /dev/null
@@ -0,0 +1,3 @@
+        <footer class="w600p center mt3 mb3 smaller txtright">
+            <p>{% trans %}powered by{% endtrans %} <a href="http://wallabag.org">wallabag</a></p>
+        </footer>
\ No newline at end of file
diff --git a/src/WallabagBundle/Resources/views/_head.html.twig b/src/WallabagBundle/Resources/views/_head.html.twig
new file mode 100755 (executable)
index 0000000..7ef79a2
--- /dev/null
@@ -0,0 +1,40 @@
+        <link rel="apple-touch-icon" type="image/png" href="{{ asset('themes/_global/img/appicon/apple-touch-icon-152.png') }}" sizes="152x152">
+        <link rel="icon" type="image/png" href="{{ asset('themes/_global/img/appicon/apple-touch-icon-152.png') }}" sizes="152x152">
+
+        <link rel="apple-touch-icon" type="image/png" href="{{ asset('themes/_global/img/appicon/apple-touch-icon-144.png') }}" sizes="144x144">
+        <link rel="icon" type="image/png" href="{{ asset('themes/_global/img/appicon/apple-touch-icon-144.png') }}" sizes="144x144">
+
+        <link rel="apple-touch-icon" type="image/png" href="{{ asset('themes/_global/img/appicon/apple-touch-icon-120.png') }}" sizes="120x120">
+        <link rel="icon" type="image/png" href="{{ asset('themes/_global/img/appicon/apple-touch-icon-120.png') }}" sizes="120x120">
+
+        <link rel="apple-touch-icon" type="image/png" href="{{ asset('themes/_global/img/appicon/apple-touch-icon-114.png') }}" sizes="114x114">
+        <link rel="icon" type="image/png" href="{{ asset('themes/_global/img/appicon/apple-touch-icon-114.png') }}" sizes="114x114">
+
+        <link rel="apple-touch-icon" type="image/png" href="{{ asset('themes/_global/img/appicon/apple-touch-icon-76.png') }}" sizes="76x76">
+        <link rel="icon" type="image/png" href="{{ asset('themes/_global/img/appicon/apple-touch-icon-76.png') }}" sizes="76x76">
+
+        <link rel="apple-touch-icon" type="image/png" href="{{ asset('themes/_global/img/appicon/apple-touch-icon-72.png') }}" sizes="72x72">
+        <link rel="icon" type="image/png" href="{{ asset('themes/_global/img/appicon/apple-touch-icon-72.png') }}" sizes="72x72">
+
+        <link rel="apple-touch-icon" type="image/png" href="{{ asset('themes/_global/img/appicon/apple-touch-icon-57.png') }}" sizes="57x57">
+        <link rel="icon" type="image/png" href="{{ asset('themes/_global/img/appicon/apple-touch-icon-57.png') }}" sizes="57x57">
+
+        <link rel="apple-touch-icon" type="image/png" href="{{ asset('themes/_global/img/appicon/apple-touch-icon.png') }}">
+        <link rel="icon" type="image/png" href="{{ asset('themes/_global/img/appicon/apple-touch-icon.png') }}">
+
+        <link rel="shortcut icon" type="image/x-icon" href="{{ asset('themes/_global/img/appicon/favicon.ico') }}">
+
+        <link rel="stylesheet" href="{{ asset('themes/baggy/css/ratatouille.css') }}" media="all">
+        <link rel="stylesheet" href="{{ asset('themes/baggy/css/font.css') }}" media="all">
+        <link rel="stylesheet" href="{{ asset('themes/baggy/css/main.css') }}" media="all">
+        <link rel="stylesheet" href="{{ asset('themes/baggy/css/messages.css') }}" media="all">
+        <link rel="stylesheet" href="{{ asset('themes/baggy/css/print.css') }}" media="print">
+
+        <script src="{{ asset('themes/_global/js/jquery-2.0.3.min.js') }}"></script>
+        <script src="{{ asset('themes/_global/js/autoClose.js') }}"></script>
+        <script src="{{ asset('themes/baggy/js/jquery.cookie.js') }}"></script>
+        <script src="{{ asset('themes/baggy/js/init.js') }}"></script>
+        <script src="{{ asset('themes/_global/js/saveLink.js') }}"></script>
+        <script src="{{ asset('themes/_global/js/popupForm.js') }}"></script>
+        <script src="{{ asset('themes/baggy/js/closeMessage.js') }}"></script>
+
diff --git a/src/WallabagBundle/Resources/views/_messages.html.twig b/src/WallabagBundle/Resources/views/_messages.html.twig
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/WallabagBundle/Resources/views/_top.html.twig b/src/WallabagBundle/Resources/views/_top.html.twig
new file mode 100755 (executable)
index 0000000..576df80
--- /dev/null
@@ -0,0 +1,6 @@
+        <header class="w600p center mbm">
+            <h1>
+                {% block logo %}<img width="100" height="100" src="{{ asset('themes/baggy/img/logo-other_themes.png') }}" alt="wallabag logo" />{% endblock %}
+
+            </h1>
+        </header>
diff --git a/src/WallabagBundle/Resources/views/layout.html.twig b/src/WallabagBundle/Resources/views/layout.html.twig
new file mode 100644 (file)
index 0000000..4a3f0f5
--- /dev/null
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<!--[if lte IE 6]><html class="no-js ie6 ie67 ie678" lang="en"><![endif]-->
+<!--[if lte IE 7]><html class="no-js ie7 ie67 ie678" lang="en"><![endif]-->
+<!--[if IE 8]><html class="no-js ie8 ie678" lang="en"><![endif]-->
+<!--[if gt IE 8]><html class="no-js" lang="en"><![endif]-->
+<html lang="en">
+<head>
+    <meta name="viewport" content="initial-scale=1.0">
+    <meta charset="utf-8">
+    <!--[if IE]>
+    <meta http-equiv="X-UA-Compatible" content="IE=10">
+    <![endif]-->
+    <title>{% block title %}{% endblock %} - wallabag</title>
+    {% include "WallabagBundle::_head.html.twig" %}
+    {% include "WallabagBundle::_bookmarklet.html.twig" %}
+</head>
+<body>
+{% include "WallabagBundle::_top.html.twig" %}
+<div id="main">
+    {% block menu %}{% endblock %}
+    {% block precontent %}{% endblock %}
+    {% block messages %}
+        {% include "WallabagBundle::_messages.html.twig" %}
+    {% endblock %}
+    <div id="content" class="w600p center">
+        {% block content %}{% endblock %}
+    </div>
+</div>
+{% include "WallabagBundle::_footer.html.twig" %}
+</body>
+</html>
\ No newline at end of file
index e902243893db8ddf97b9edaa1d06b981105a8e2d..64b389bbe6e33423ef4fbf4d482bee773aba11bb 100644 (file)
@@ -4,7 +4,7 @@ namespace WallabagBundle\Tests\Controller;
 
 use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
 
-class DefaultControllerTest extends WebTestCase
+class EntryControllerTest extends WebTestCase
 {
     public function testIndex()
     {
diff --git a/src/WallabagBundle/Twig/Extension/WallabagExtension.php b/src/WallabagBundle/Twig/Extension/WallabagExtension.php
new file mode 100644 (file)
index 0000000..741fb19
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+
+namespace WallabagBundle\Twig\Extension;
+
+class WallabagExtension extends \Twig_Extension
+{
+    public function getFilters()
+    {
+        return array(
+            new \Twig_SimpleFilter('readingTime', array($this, 'getReadingTime')),
+            new \Twig_SimpleFilter('domainName', array($this, 'getDomainName')),
+        );
+    }
+
+    /**
+     * Returns the domain name for a URL
+     *
+     * @param $url
+     * @return string
+     */
+    public static function getDomainName($url)
+    {
+        return parse_url($url, PHP_URL_HOST);
+    }
+
+    /**
+     * 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);
+    }
+
+    public function getName()
+    {
+        return 'wallabag_extension';
+    }
+}
\ No newline at end of file