From 59201088b4fc13fd361238396f630dabd9bd1990 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 21 Sep 2016 17:47:47 +0200 Subject: bring chrome and firefox as separate imports --- src/Wallabag/ImportBundle/Import/FirefoxImport.php | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/Wallabag/ImportBundle/Import/FirefoxImport.php (limited to 'src/Wallabag/ImportBundle/Import/FirefoxImport.php') diff --git a/src/Wallabag/ImportBundle/Import/FirefoxImport.php b/src/Wallabag/ImportBundle/Import/FirefoxImport.php new file mode 100644 index 00000000..cbf10b87 --- /dev/null +++ b/src/Wallabag/ImportBundle/Import/FirefoxImport.php @@ -0,0 +1,71 @@ + $entry['name'], + 'html' => '', + 'url' => $entry['url'], + 'is_archived' => $this->markAsRead, + 'tags' => '', + 'created_at' => $entry['date_added'], + ]; + + if (array_key_exists('tags', $entry) && $entry['tags'] != '') { + $data['tags'] = $entry['tags']; + } + + return $data; + } + + + /** + * {@inheritdoc} + */ + protected function setEntryAsRead(array $importedEntry) + { + $importedEntry['is_archived'] = 1; + + return $importedEntry; + } +} -- cgit v1.2.3 From 2c61db30b737685ae9102ec10f2371778fb13f1a Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 21 Sep 2016 18:00:08 +0200 Subject: cs & fixes --- src/Wallabag/ImportBundle/Import/FirefoxImport.php | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src/Wallabag/ImportBundle/Import/FirefoxImport.php') diff --git a/src/Wallabag/ImportBundle/Import/FirefoxImport.php b/src/Wallabag/ImportBundle/Import/FirefoxImport.php index cbf10b87..351cbef1 100644 --- a/src/Wallabag/ImportBundle/Import/FirefoxImport.php +++ b/src/Wallabag/ImportBundle/Import/FirefoxImport.php @@ -2,13 +2,6 @@ namespace Wallabag\ImportBundle\Import; -use Psr\Log\LoggerInterface; -use Psr\Log\NullLogger; -use Doctrine\ORM\EntityManager; -use Wallabag\CoreBundle\Entity\Entry; -use Wallabag\UserBundle\Entity\User; -use Wallabag\CoreBundle\Helper\ContentProxy; - class FirefoxImport extends BrowserImport { protected $filepath; @@ -42,7 +35,7 @@ class FirefoxImport extends BrowserImport */ protected function prepareEntry($entry = []) { - $data = [ + $data = [ 'title' => $entry['name'], 'html' => '', 'url' => $entry['url'], @@ -51,13 +44,12 @@ class FirefoxImport extends BrowserImport 'created_at' => $entry['date_added'], ]; - if (array_key_exists('tags', $entry) && $entry['tags'] != '') { - $data['tags'] = $entry['tags']; - } - - return $data; - } + if (array_key_exists('tags', $entry) && $entry['tags'] != '') { + $data['tags'] = $entry['tags']; + } + return $data; + } /** * {@inheritdoc} -- cgit v1.2.3 From 27acc6ddb8b0a1549a3f015171621e3056ef65d2 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sun, 25 Sep 2016 15:29:40 +0200 Subject: Fix bad date format in Browser import --- src/Wallabag/ImportBundle/Import/FirefoxImport.php | 31 ---------------------- 1 file changed, 31 deletions(-) (limited to 'src/Wallabag/ImportBundle/Import/FirefoxImport.php') diff --git a/src/Wallabag/ImportBundle/Import/FirefoxImport.php b/src/Wallabag/ImportBundle/Import/FirefoxImport.php index 351cbef1..1a0b1154 100644 --- a/src/Wallabag/ImportBundle/Import/FirefoxImport.php +++ b/src/Wallabag/ImportBundle/Import/FirefoxImport.php @@ -29,35 +29,4 @@ class FirefoxImport extends BrowserImport { return 'import.firefox.description'; } - - /** - * {@inheritdoc} - */ - protected function prepareEntry($entry = []) - { - $data = [ - 'title' => $entry['name'], - 'html' => '', - 'url' => $entry['url'], - 'is_archived' => $this->markAsRead, - 'tags' => '', - 'created_at' => $entry['date_added'], - ]; - - if (array_key_exists('tags', $entry) && $entry['tags'] != '') { - $data['tags'] = $entry['tags']; - } - - return $data; - } - - /** - * {@inheritdoc} - */ - protected function setEntryAsRead(array $importedEntry) - { - $importedEntry['is_archived'] = 1; - - return $importedEntry; - } } -- cgit v1.2.3 From 990adfb34c148e7cd28b9cb784cf2b7388caae8f Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 26 Sep 2016 07:30:02 +0200 Subject: Move prepareEntry to dedicated place Yeah first try was ugly, now each part are in the dedicated place. Also, the date is hardly truncated to 10 chars because Firefox date are 16 chars long and Chrome are 17 chars long. So instead of divised them by a huge number, I prefer to truncate them. --- src/Wallabag/ImportBundle/Import/FirefoxImport.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/Wallabag/ImportBundle/Import/FirefoxImport.php') diff --git a/src/Wallabag/ImportBundle/Import/FirefoxImport.php b/src/Wallabag/ImportBundle/Import/FirefoxImport.php index 1a0b1154..e010f5a4 100644 --- a/src/Wallabag/ImportBundle/Import/FirefoxImport.php +++ b/src/Wallabag/ImportBundle/Import/FirefoxImport.php @@ -29,4 +29,25 @@ class FirefoxImport extends BrowserImport { return 'import.firefox.description'; } + + /** + * {@inheritdoc} + */ + protected function prepareEntry(array $entry = []) + { + $data = [ + 'title' => $entry['title'], + 'html' => '', + 'url' => $entry['uri'], + 'is_archived' => $this->markAsRead, + 'tags' => '', + 'created_at' => substr($entry['dateAdded'], 0, 10), + ]; + + if (array_key_exists('tags', $entry) && $entry['tags'] != '') { + $data['tags'] = $entry['tags']; + } + + return $data; + } } -- cgit v1.2.3