From: Jeremy Benoist For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file."
+ # description: "This importer will import all your Firefox bookmarks. Just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file."
# how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
#chrome:
# page_title: 'Import > Chrome'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
index 1dcd7dbe..2e683b8c 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
@@ -45,6 +45,7 @@ footer:
social: 'Soziales'
powered_by: 'angetrieben von'
about: 'Ãber'
+ # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day!
config:
page_title: 'Einstellungen'
@@ -352,7 +353,7 @@ import:
# enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:"
firefox:
page_title: 'Aus Firefox importieren'
- # description: "This importer will import all your Firefox bookmarks. For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file."
+ # description: "This importer will import all your Firefox bookmarks. Just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file."
# how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
chrome:
page_title: 'Aus Chrome importieren'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
index e75166bf..d629312c 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
@@ -45,6 +45,7 @@ footer:
social: 'Social'
powered_by: 'powered by'
about: 'About'
+ stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day!
config:
page_title: 'Config'
@@ -352,7 +353,7 @@ import:
enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:"
firefox:
page_title: 'Import > Firefox'
- description: "This importer will import all your Firefox bookmarks. For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file."
+ description: "This importer will import all your Firefox bookmarks. Just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file."
how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
chrome:
page_title: 'Import > Chrome'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
index 0884e9e6..860c466f 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
@@ -45,6 +45,7 @@ footer:
social: 'Social'
powered_by: 'funciona por'
about: 'Acerca de'
+ # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day!
config:
page_title: 'Configuración'
@@ -352,7 +353,7 @@ import:
# enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:"
firefox:
page_title: 'Importar > Firefox'
- # description: "This importer will import all your Firefox bookmarks. For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file."
+ # description: "This importer will import all your Firefox bookmarks. Just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file."
# how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
chrome:
page_title: 'Importar > Chrome'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
index 1d30d5b2..6e02010c 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
@@ -45,6 +45,7 @@ footer:
social: 'شبکÙâÙØ§Û Ø§Ø¬ØªÙ
اعÛ'
powered_by: 'تÙاÙÙ
Ùد با'
about: 'دربارÙ'
+ # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day!
config:
page_title: 'Ù¾ÛکربÙدÛ'
@@ -352,7 +353,7 @@ import:
# enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:"
firefox:
page_title: 'درÙÙâرÛØ²Û > Firefox'
- # description: "This importer will import all your Firefox bookmarks. For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file."
+ # description: "This importer will import all your Firefox bookmarks. Just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file."
# how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
chrome:
page_title: 'درÙÙâرÛØ²Û > Chrome'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
index c3647731..0eeda011 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
@@ -45,6 +45,7 @@ footer:
social: 'Social'
powered_by: 'propulsé par'
about: 'Ã propos'
+ stats: Depuis le %user_creation% vous avez lu %nb_archives% articles. Ce qui fait %per_day% par jour !
config:
page_title: 'Configuration'
@@ -352,7 +353,7 @@ import:
enabled: "Les imports sont asynchrones. Une fois l'import commencé un worker externe traitera les messages un par un. Le service activé est :"
firefox:
page_title: 'Import > Firefox'
- description: "Cet outil va vous permettre d'importer tous vos marques-pages de Firefox. Pour Firefox, ouvrez le panneau des marques-pages (Ctrl+Maj+O), puis dans « Importation et sauvegarde », choisissez « Sauvegarde... ». Vous allez récupérer un fichier .json.
For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." + # description: "This importer will import all your Firefox bookmarks. Just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." chrome: page_title: 'Importa da > Chrome' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index ebebcbc0..bcc59b29 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml @@ -19,14 +19,14 @@ menu: unread: 'Pas legits' starred: 'Favorits' archive: 'Legits' - all_articles: 'Tots los articles' + all_articles: 'Totes los articles' config: 'Configuracion' tags: 'Etiquetas' internal_settings: 'Configuracion interna' import: 'Importar' howto: 'Ajuda' developer: 'Desvolopador' - logout: 'Déconnexion' + logout: 'Desconnexion' about: 'A prepaus' search: 'Cercar' save_link: 'Enregistrar un novèl article' @@ -45,9 +45,10 @@ footer: social: 'Social' powered_by: 'propulsat per' about: 'A prepaus' - page_title: 'Configuracion' + # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day! config: + page_title: 'Configuracion' tab_menu: settings: 'Paramètres' rss: 'RSS' @@ -72,8 +73,8 @@ config: form_rss: description: "Los fluxes RSS fornits per wallabag vos permeton de legir vòstres articles salvagardats dins vòstre lector de fluxes preferit. Per los poder emplegar, vos cal, d'en primièr crear un geton." token_label: 'Geton RSS' - no_token: 'Aucun jeton généré' - token_create: 'Pas cap de geton generat' + no_token: 'Pas cap de geton generat' + token_create: 'Creatz vòstre geton' token_reset: 'Reïnicializatz vòstre geton' rss_links: 'URL de vòstres fluxes RSS' rss_link: @@ -188,7 +189,7 @@ entry: re_fetch_content: 'Tornar cargar lo contengut' delete: 'Suprimir' add_a_tag: 'Ajustar una etiqueta' - share_content: 'Partatjar' + share_content: 'Partejar' share_email_label: 'Corrièl' public_link: 'ligam public' delete_public_link: 'suprimir lo ligam public' @@ -225,7 +226,7 @@ about: developped_by: 'Desvolopat per' website: 'Site web' many_contributors: 'E un fum de contributors ⥠sur Github' - project_website: 'Site web del projète' + project_website: 'Site web del projècte' license: 'Licéncia' version: 'Version' getting_help: @@ -246,7 +247,7 @@ about: howto: page_title: 'Ajuda' - page_description: "I a mai d'un biai d'enregistrar un article :" + page_description: "I a mai d'un biais d'enregistrar un article :" top_menu: browser_addons: 'Extensions de navigator' mobile_apps: 'Aplicacions mobil' @@ -345,26 +346,26 @@ import: page_title: 'Importar > Wallabag v2' description: "Aquesta aisina importarà totas vòstras donadas d'una instà ncia mai de wallabag v2. Anatz dins totes vòstres articles, puèi, sus la barra laterala, clicatz sus \"JSON\". Traparatz un fichièr \"All articles.json\"" readability: - page_title: 'Importer > Readability' + page_title: 'Importar > Readability' description: "Aquesta aisina importarà totas vòstres articles de Readability. Sus la pagina de l'aisina (https://www.readability.com/tools/), clicatz sus \"Export your data\" dins la seccion \"Data Export\". Recebretz un corrièl per telecargar un json (qu'acaba pas amb un .json de fach)." how_to: "Mercés de seleccionar vòstre Readability fichièr e de clicar sul boton dejós per lo telecargar e l'importar." worker: - # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:" + enabled: "L'importacion se fa de manièra asincròna. Un còp l'importacion lançada, una aisina externa s'ocuparà dels messatges un per un. Lo servici actual es : " firefox: - page_title: 'Importer > Firefox' - # description: "This importer will import all your Firefox bookmarks.
For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." - # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." + page_title: 'Importar > Firefox' + description: "Aquesta aisina importarà totas vòstres favorits de Firefox. Just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." + how_to: "Mercés de causir lo fichièr de salvagarda e de clicar sul boton dejós per l'importar. Notatz que lo tractament pòt durar un moment ja que totes los articles an d'èsser recuperats." chrome: - page_title: 'Importer > Chrome' - # description: "This importer will import all your Chrome bookmarks. The location of the file depends on your operating system :
~/.config/chromium/Default/
directory%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default
~/Library/Application Support/Google/Chrome/Default/Bookmarks
~/.config/chromium/Default/
%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default
~/Library/Application Support/Google/Chrome/Default/Bookmarks
Dla Firefoksa, idź do twoich zakÅadek (Ctrl+Shift+O), nastÄpnie w \"Import i kopie zapasowe\", wybierz \"Utwórz kopiÄ zapasowÄ ...\". Uzyskasz plik .json." + description: "Ten importer zaimportuje wszystkie twoje zakÅadki z Firefoksa. Idź do twoich zakÅadek (Ctrl+Shift+O), nastÄpnie w \"Import i kopie zapasowe\", wybierz \"Utwórz kopiÄ zapasowÄ ...\". Uzyskasz plik .json." how_to: "Wybierz swój plik z zakÅadkami i naciÅnij poniższy przycisk, aby je zaimportowaÄ. Może to zajÄ Ä dÅuższÄ chwilÄ, zanim wszystkie artykuÅy zostanÄ przeniesione." chrome: page_title: 'Import > Chrome' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index d107a96e..a54efb4c 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml @@ -45,6 +45,7 @@ footer: # social: 'Social' # powered_by: 'powered by' about: 'Despre' + # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day! config: page_title: 'ConfiguraÈie' @@ -352,7 +353,7 @@ import: # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:" # firefox: # page_title: 'Import > Firefox' - # description: "This importer will import all your Firefox bookmarks.
For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." + # description: "This importer will import all your Firefox bookmarks. Just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." # chrome: # page_title: 'Import > Chrome' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index 8bc0c4b9..e46c17c8 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml @@ -45,6 +45,7 @@ footer: social: 'Sosyal' powered_by: 'powered by' about: 'Hakkımızda' + # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day! config: page_title: 'Yapılandırma' @@ -351,7 +352,7 @@ import: # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:" firefox: page_title: 'İçe Aktar > Firefox' - # description: "This importer will import all your Firefox bookmarks.
For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." + # description: "This importer will import all your Firefox bookmarks. Just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." chrome: page_title: 'İçe Aktar > Chrome' diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig index df05e2a4..b2d77c2e 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig @@ -122,8 +122,19 @@ diff --git a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php index fb4c7412..783cde3e 100644 --- a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php +++ b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php @@ -5,6 +5,7 @@ namespace Wallabag\CoreBundle\Twig; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Wallabag\CoreBundle\Repository\EntryRepository; use Wallabag\CoreBundle\Repository\TagRepository; +use Symfony\Component\Translation\TranslatorInterface; class WallabagExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface { @@ -12,13 +13,15 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa private $entryRepository; private $tagRepository; private $lifeTime; + private $translator; - public function __construct(EntryRepository $entryRepository = null, TagRepository $tagRepository = null, TokenStorageInterface $tokenStorage = null, $lifeTime = 0) + public function __construct(EntryRepository $entryRepository, TagRepository $tagRepository, TokenStorageInterface $tokenStorage, $lifeTime, TranslatorInterface $translator) { $this->entryRepository = $entryRepository; $this->tagRepository = $tagRepository; $this->tokenStorage = $tokenStorage; $this->lifeTime = $lifeTime; + $this->translator = $translator; } public function getFilters() @@ -33,6 +36,7 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa return array( new \Twig_SimpleFunction('count_entries', [$this, 'countEntries']), new \Twig_SimpleFunction('count_tags', [$this, 'countTags']), + new \Twig_SimpleFunction('display_stats', [$this, 'displayStats']), ); } @@ -107,6 +111,40 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa return $this->tagRepository->countAllTags($user->getId()); } + /** + * Display a single line about reading stats. + * + * @return string + */ + public function displayStats() + { + $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null; + + if (null === $user || !is_object($user)) { + return 0; + } + + $query = $this->entryRepository->getBuilderForArchiveByUser($user->getId()) + ->select('e.id') + ->groupBy('e.id') + ->getQuery(); + + $query->useQueryCache(true); + $query->useResultCache(true); + $query->setResultCacheLifetime($this->lifeTime); + + $nbArchives = count($query->getArrayResult()); + + $interval = $user->getCreatedAt()->diff(new \DateTime('now')); + $nbDays = (int) $interval->format('%a') ?: 1; + + return $this->translator->trans('footer.stats', [ + '%user_creation%' => $user->getCreatedAt()->format('F jS, Y'), + '%nb_archives%' => $nbArchives, + '%per_day%' => round($nbArchives / $nbDays, 2), + ]); + } + public function getName() { return 'wallabag_extension'; diff --git a/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php b/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php index 8ec2a75a..b1c8c946 100644 --- a/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php +++ b/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php @@ -8,7 +8,23 @@ class WallabagExtensionTest extends \PHPUnit_Framework_TestCase { public function testRemoveWww() { - $extension = new WallabagExtension(); + $entryRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') + ->disableOriginalConstructor() + ->getMock(); + + $tagRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository') + ->disableOriginalConstructor() + ->getMock(); + + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface') + ->disableOriginalConstructor() + ->getMock(); + + $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface') + ->disableOriginalConstructor() + ->getMock(); + + $extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator); $this->assertEquals('lemonde.fr', $extension->removeWww('www.lemonde.fr')); $this->assertEquals('lemonde.fr', $extension->removeWww('lemonde.fr'));