aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2015-09-20 22:37:27 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2015-09-22 20:52:13 +0200
commit98f0929f168a336079456f65b6ca41e84b22efff (patch)
tree64d354d41c4188d4544c1841607225aad8e7233c /src
parentdb96045a0ae96cfe67bc98d49596fde31c9124fc (diff)
downloadwallabag-98f0929f168a336079456f65b6ca41e84b22efff.tar.gz
wallabag-98f0929f168a336079456f65b6ca41e84b22efff.tar.zst
wallabag-98f0929f168a336079456f65b6ca41e84b22efff.zip
Handle entry in language
Fix #1333
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php31
-rw-r--r--src/Wallabag/CoreBundle/Entity/User.php5
-rw-r--r--src/Wallabag/CoreBundle/Helper/ContentProxy.php1
-rw-r--r--src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php24
4 files changed, 56 insertions, 5 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index e684c9b1..7108889e 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -95,6 +95,13 @@ class Entry
95 private $mimetype; 95 private $mimetype;
96 96
97 /** 97 /**
98 * @var string
99 *
100 * @ORM\Column(name="language", type="text", nullable=true)
101 */
102 private $language;
103
104 /**
98 * @var int 105 * @var int
99 * 106 *
100 * @ORM\Column(name="reading_time", type="integer", nullable=true) 107 * @ORM\Column(name="reading_time", type="integer", nullable=true)
@@ -450,4 +457,28 @@ class Entry
450 { 457 {
451 return $this->previewPicture; 458 return $this->previewPicture;
452 } 459 }
460
461 /**
462 * Set language.
463 *
464 * @param string $language
465 *
466 * @return Entry
467 */
468 public function setLanguage($language)
469 {
470 $this->language = $language;
471
472 return $this;
473 }
474
475 /**
476 * Get language.
477 *
478 * @return string
479 */
480 public function getLanguage()
481 {
482 return $this->language;
483 }
453} 484}
diff --git a/src/Wallabag/CoreBundle/Entity/User.php b/src/Wallabag/CoreBundle/Entity/User.php
index eeae331e..a6002352 100644
--- a/src/Wallabag/CoreBundle/Entity/User.php
+++ b/src/Wallabag/CoreBundle/Entity/User.php
@@ -7,7 +7,6 @@ use Doctrine\ORM\Mapping as ORM;
7use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; 7use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
8use Symfony\Component\Security\Core\User\UserInterface; 8use Symfony\Component\Security\Core\User\UserInterface;
9use Symfony\Component\Security\Core\User\AdvancedUserInterface; 9use Symfony\Component\Security\Core\User\AdvancedUserInterface;
10use Symfony\Component\Validator\Constraints as Assert;
11use JMS\Serializer\Annotation\ExclusionPolicy; 10use JMS\Serializer\Annotation\ExclusionPolicy;
12use JMS\Serializer\Annotation\Expose; 11use JMS\Serializer\Annotation\Expose;
13use FOS\UserBundle\Model\User as BaseUser; 12use FOS\UserBundle\Model\User as BaseUser;
@@ -74,8 +73,8 @@ class User extends BaseUser implements AdvancedUserInterface, \Serializable
74 public function __construct() 73 public function __construct()
75 { 74 {
76 parent::__construct(); 75 parent::__construct();
77 $this->entries = new ArrayCollection(); 76 $this->entries = new ArrayCollection();
78 $this->tags = new ArrayCollection(); 77 $this->tags = new ArrayCollection();
79 } 78 }
80 79
81 /** 80 /**
diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
index 4565d8e7..3de8828f 100644
--- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php
+++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
@@ -49,6 +49,7 @@ class ContentProxy
49 $entry->setUrl($content['url'] ?: $url); 49 $entry->setUrl($content['url'] ?: $url);
50 $entry->setTitle($title); 50 $entry->setTitle($title);
51 $entry->setContent($html); 51 $entry->setContent($html);
52 $entry->setLanguage($content['language']);
52 $entry->setMimetype($content['content_type']); 53 $entry->setMimetype($content['content_type']);
53 54
54 if (isset($content['open_graph']['og_image'])) { 55 if (isset($content['open_graph']['og_image'])) {
diff --git a/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php b/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php
index 71a004ff..30065d6b 100644
--- a/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php
@@ -18,7 +18,13 @@ class ContentProxyTest extends KernelTestCase
18 18
19 $graby->expects($this->any()) 19 $graby->expects($this->any())
20 ->method('fetchContent') 20 ->method('fetchContent')
21 ->willReturn(array('html' => false, 'title' => '', 'url' => '', 'content_type' => '')); 21 ->willReturn(array(
22 'html' => false,
23 'title' => '',
24 'url' => '',
25 'content_type' => '',
26 'language' => '',
27 ));
22 28
23 $proxy = new ContentProxy($graby); 29 $proxy = new ContentProxy($graby);
24 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); 30 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
@@ -28,6 +34,7 @@ class ContentProxyTest extends KernelTestCase
28 $this->assertEquals('<p>Unable to retrieve readable content.</p>', $entry->getContent()); 34 $this->assertEquals('<p>Unable to retrieve readable content.</p>', $entry->getContent());
29 $this->assertEmpty($entry->getPreviewPicture()); 35 $this->assertEmpty($entry->getPreviewPicture());
30 $this->assertEmpty($entry->getMimetype()); 36 $this->assertEmpty($entry->getMimetype());
37 $this->assertEmpty($entry->getLanguage());
31 } 38 }
32 39
33 public function testWithEmptyContentButOG() 40 public function testWithEmptyContentButOG()
@@ -39,7 +46,17 @@ class ContentProxyTest extends KernelTestCase
39 46
40 $graby->expects($this->any()) 47 $graby->expects($this->any())
41 ->method('fetchContent') 48 ->method('fetchContent')
42 ->willReturn(array('html' => false, 'title' => '', 'url' => '', 'content_type' => '', 'open_graph' => array('og_title' => 'my title', 'og_description' => 'desc'))); 49 ->willReturn(array(
50 'html' => false,
51 'title' => '',
52 'url' => '',
53 'content_type' => '',
54 'language' => '',
55 'open_graph' => array(
56 'og_title' => 'my title',
57 'og_description' => 'desc',
58 ),
59 ));
43 60
44 $proxy = new ContentProxy($graby); 61 $proxy = new ContentProxy($graby);
45 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); 62 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
@@ -48,6 +65,7 @@ class ContentProxyTest extends KernelTestCase
48 $this->assertEquals('my title', $entry->getTitle()); 65 $this->assertEquals('my title', $entry->getTitle());
49 $this->assertEquals('<p>Unable to retrieve readable content.</p><p><i>But we found a short description: </i></p>desc', $entry->getContent()); 66 $this->assertEquals('<p>Unable to retrieve readable content.</p><p><i>But we found a short description: </i></p>desc', $entry->getContent());
50 $this->assertEmpty($entry->getPreviewPicture()); 67 $this->assertEmpty($entry->getPreviewPicture());
68 $this->assertEmpty($entry->getLanguage());
51 $this->assertEmpty($entry->getMimetype()); 69 $this->assertEmpty($entry->getMimetype());
52 } 70 }
53 71
@@ -65,6 +83,7 @@ class ContentProxyTest extends KernelTestCase
65 'title' => 'this is my title', 83 'title' => 'this is my title',
66 'url' => 'http://1.1.1.1', 84 'url' => 'http://1.1.1.1',
67 'content_type' => 'text/html', 85 'content_type' => 'text/html',
86 'language' => 'fr',
68 'open_graph' => array( 87 'open_graph' => array(
69 'og_title' => 'my OG title', 88 'og_title' => 'my OG title',
70 'og_description' => 'OG desc', 89 'og_description' => 'OG desc',
@@ -80,5 +99,6 @@ class ContentProxyTest extends KernelTestCase
80 $this->assertEquals('this is my content', $entry->getContent()); 99 $this->assertEquals('this is my content', $entry->getContent());
81 $this->assertEquals('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture()); 100 $this->assertEquals('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture());
82 $this->assertEquals('text/html', $entry->getMimetype()); 101 $this->assertEquals('text/html', $entry->getMimetype());
102 $this->assertEquals('fr', $entry->getLanguage());
83 } 103 }
84} 104}