aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.travis.yml8
-rw-r--r--Capfile15
-rw-r--r--Gemfile6
-rw-r--r--Gemfile.lock37
-rw-r--r--app/config/capistrano/deploy.rb19
-rw-r--r--app/config/capistrano/deploy/production.rb0
-rw-r--r--app/config/capistrano/deploy/staging.rb2
-rw-r--r--src/Wallabag/CoreBundle/Controller/ExportController.php12
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig19
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig19
-rw-r--r--tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php63
11 files changed, 104 insertions, 96 deletions
diff --git a/.travis.yml b/.travis.yml
index 229e3e0e..c09bcd22 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -16,12 +16,15 @@ cache:
16 - $HOME/.npm 16 - $HOME/.npm
17 - $HOME/.yarn-cache 17 - $HOME/.yarn-cache
18 18
19if: |
20 type = pull_request OR \
21 branch = master
22
19php: 23php:
20 - 7.1 24 - 7.1
21 - 7.2 25 - 7.2
22 - 7.3 26 - 7.3
23 - 7.4 27 - 7.4
24 - nightly
25 28
26node_js: 29node_js:
27 - "5" 30 - "5"
@@ -34,11 +37,10 @@ env:
34matrix: 37matrix:
35 fast_finish: true 38 fast_finish: true
36 include: 39 include:
37 - php: 7.2 40 - php: 7.3
38 env: CS_FIXER=run VALIDATE_TRANSLATION_FILE=run ASSETS=build DB=sqlite 41 env: CS_FIXER=run VALIDATE_TRANSLATION_FILE=run ASSETS=build DB=sqlite
39 allow_failures: 42 allow_failures:
40 - php: 7.4 43 - php: 7.4
41 - php: nightly
42 44
43# exclude v1 branches 45# exclude v1 branches
44branches: 46branches:
diff --git a/Capfile b/Capfile
deleted file mode 100644
index cc807112..00000000
--- a/Capfile
+++ /dev/null
@@ -1,15 +0,0 @@
1set :deploy_config_path, 'app/config/capistrano/deploy.rb'
2set :stage_config_path, 'app/config/capistrano/deploy'
3
4# Load DSL and set up stages
5require 'capistrano/setup'
6
7# Include default deployment tasks
8require 'capistrano/deploy'
9
10require 'capistrano/composer'
11require 'capistrano/file-permissions'
12require 'capistrano/symfony'
13
14# Load custom tasks from `lib/capistrano/tasks` if you have any defined
15Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
diff --git a/Gemfile b/Gemfile
deleted file mode 100644
index 233be899..00000000
--- a/Gemfile
+++ /dev/null
@@ -1,6 +0,0 @@
1source "https://rubygems.org"
2
3gem 'capistrano', '~> 3.4'
4gem 'capistrano-composer'
5gem 'capistrano-symfony', '~> 1.0.0.rc1'
6gem 'capistrano-file-permissions'
diff --git a/Gemfile.lock b/Gemfile.lock
deleted file mode 100644
index 7b13b399..00000000
--- a/Gemfile.lock
+++ /dev/null
@@ -1,37 +0,0 @@
1GEM
2 remote: https://rubygems.org/
3 specs:
4 capistrano (3.4.0)
5 i18n
6 rake (>= 10.0.0)
7 sshkit (~> 1.3)
8 capistrano-composer (0.0.6)
9 capistrano (>= 3.0.0.pre)
10 capistrano-file-permissions (1.0.0)
11 capistrano (~> 3.0)
12 capistrano-symfony (1.0.0.rc1)
13 capistrano (~> 3.1)
14 capistrano-composer (~> 0.0.3)
15 capistrano-file-permissions (~> 1.0)
16 colorize (0.7.7)
17 i18n (0.7.0)
18 net-scp (1.2.1)
19 net-ssh (>= 2.6.5)
20 net-ssh (2.9.2)
21 rake (10.4.2)
22 sshkit (1.7.1)
23 colorize (>= 0.7.0)
24 net-scp (>= 1.1.2)
25 net-ssh (>= 2.8.0)
26
27PLATFORMS
28 ruby
29
30DEPENDENCIES
31 capistrano (~> 3.4)
32 capistrano-composer
33 capistrano-file-permissions
34 capistrano-symfony (~> 1.0.0.rc1)
35
36BUNDLED WITH
37 1.13.5
diff --git a/app/config/capistrano/deploy.rb b/app/config/capistrano/deploy.rb
deleted file mode 100644
index fee04620..00000000
--- a/app/config/capistrano/deploy.rb
+++ /dev/null
@@ -1,19 +0,0 @@
1# config valid only for current version of Capistrano
2
3set :application, 'wallabag'
4set :repo_url, 'git@github.com:wallabag/wallabag.git'
5
6set :ssh_user, 'framasoft_bag'
7server '78.46.248.87', user: fetch(:ssh_user), roles: %w{web app db}
8
9set :format, :pretty
10set :log_level, :info
11# set :log_level, :debug
12
13set :composer_install_flags, '--no-dev --prefer-dist --no-interaction --optimize-autoloader'
14
15set :linked_files, %w{app/config/parameters.yml}
16set :linked_dirs, [fetch(:log_path), "var/sessions", "web/uploads", "data"]
17set :keep_releases, 3
18
19after 'deploy:updated', 'symfony:cache:clear'
diff --git a/app/config/capistrano/deploy/production.rb b/app/config/capistrano/deploy/production.rb
deleted file mode 100644
index e69de29b..00000000
--- a/app/config/capistrano/deploy/production.rb
+++ /dev/null
diff --git a/app/config/capistrano/deploy/staging.rb b/app/config/capistrano/deploy/staging.rb
deleted file mode 100644
index ad899a85..00000000
--- a/app/config/capistrano/deploy/staging.rb
+++ /dev/null
@@ -1,2 +0,0 @@
1set :branch, 'master'
2set :deploy_to, '/var/www/v2.wallabag.org/web/'
diff --git a/src/Wallabag/CoreBundle/Controller/ExportController.php b/src/Wallabag/CoreBundle/Controller/ExportController.php
index 282fd733..cec8d499 100644
--- a/src/Wallabag/CoreBundle/Controller/ExportController.php
+++ b/src/Wallabag/CoreBundle/Controller/ExportController.php
@@ -68,6 +68,18 @@ class ExportController extends Controller
68 ); 68 );
69 69
70 $title = 'Tag ' . $tag->getLabel(); 70 $title = 'Tag ' . $tag->getLabel();
71 } elseif ('search' === $category) {
72 $searchTerm = (isset($request->get('search_entry')['term']) ? $request->get('search_entry')['term'] : '');
73 $currentRoute = (null !== $request->query->get('currentRoute') ? $request->query->get('currentRoute') : '');
74
75 $entries = $repository->getBuilderForSearchByUser(
76 $this->getUser()->getId(),
77 $searchTerm,
78 $currentRoute
79 )->getQuery()
80 ->getResult();
81
82 $title = 'Search ' . $searchTerm;
71 } else { 83 } else {
72 $entries = $repository 84 $entries = $repository
73 ->$methodBuilder($this->getUser()->getId()) 85 ->$methodBuilder($this->getUser()->getId())
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig
index b747ed84..4182628f 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig
@@ -96,16 +96,21 @@
96 {% if tag is defined %} 96 {% if tag is defined %}
97 {% set currentTag = tag %} 97 {% set currentTag = tag %}
98 {% endif %} 98 {% endif %}
99 {% set exportSearchTerm = null %}
100 {% if searchTerm is defined %}
101 {% set exportSearchTerm = searchTerm %}
102 {% endif %}
103 {% set previousRoute = app.request.attributes.get('currentRoute') %}
99 <h2>{{ 'entry.list.export_title'|trans }}</h2> 104 <h2>{{ 'entry.list.export_title'|trans }}</h2>
100 <a href="javascript: void(null);" id="download-form-close" class="close-button--popup close-button">&times;</a> 105 <a href="javascript: void(null);" id="download-form-close" class="close-button--popup close-button">&times;</a>
101 <ul> 106 <ul>
102 {% if craue_setting('export_epub') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'epub', 'tag' : currentTag }) }}">EPUB</a></li>{% endif %} 107 {% if craue_setting('export_epub') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'epub', 'tag' : currentTag, 'search_entry[term]' : exportSearchTerm, 'currentRoute' : previousRoute }) }}">EPUB</a></li>{% endif %}
103 {% if craue_setting('export_mobi') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'mobi', 'tag' : currentTag }) }}">MOBI</a></li>{% endif %} 108 {% if craue_setting('export_mobi') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'mobi', 'tag' : currentTag, 'search_entry[term]' : exportSearchTerm, 'currentRoute' : previousRoute }) }}">MOBI</a></li>{% endif %}
104 {% if craue_setting('export_pdf') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'pdf', 'tag' : currentTag }) }}">PDF</a></li>{% endif %} 109 {% if craue_setting('export_pdf') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'pdf', 'tag' : currentTag, 'search_entry[term]' : exportSearchTerm, 'currentRoute' : previousRoute }) }}">PDF</a></li>{% endif %}
105 {% if craue_setting('export_json') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'json', 'tag' : currentTag }) }}">JSON</a></li>{% endif %} 110 {% if craue_setting('export_json') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'json', 'tag' : currentTag, 'search_entry[term]' : exportSearchTerm, 'currentRoute' : previousRoute }) }}">JSON</a></li>{% endif %}
106 {% if craue_setting('export_csv') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'csv', 'tag' : currentTag }) }}">CSV</a></li>{% endif %} 111 {% if craue_setting('export_csv') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'csv', 'tag' : currentTag, 'search_entry[term]' : exportSearchTerm, 'currentRoute' : previousRoute }) }}">CSV</a></li>{% endif %}
107 {% if craue_setting('export_txt') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'txt', 'tag' : currentTag }) }}">TXT</a></li>{% endif %} 112 {% if craue_setting('export_txt') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'txt', 'tag' : currentTag, 'search_entry[term]' : exportSearchTerm, 'currentRoute' : previousRoute }) }}">TXT</a></li>{% endif %}
108 {% if craue_setting('export_xml') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'xml', 'tag' : currentTag }) }}">XML</a></li>{% endif %} 113 {% if craue_setting('export_xml') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'xml', 'tag' : currentTag, 'search_entry[term]' : exportSearchTerm, 'currentRoute' : previousRoute }) }}">XML</a></li>{% endif %}
109 </ul> 114 </ul>
110 </aside> 115 </aside>
111 116
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig
index 3906e1e0..0c21dc5d 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig
@@ -63,15 +63,20 @@
63 {% if tag is defined %} 63 {% if tag is defined %}
64 {% set currentTag = tag.slug %} 64 {% set currentTag = tag.slug %}
65 {% endif %} 65 {% endif %}
66 {% set exportSearchTerm = null %}
67 {% if searchTerm is defined %}
68 {% set exportSearchTerm = searchTerm %}
69 {% endif %}
70 {% set previousRoute = app.request.attributes.get('currentRoute') %}
66 <h4 class="center">{{ 'entry.list.export_title'|trans }}</h4> 71 <h4 class="center">{{ 'entry.list.export_title'|trans }}</h4>
67 <ul> 72 <ul>
68 {% if craue_setting('export_epub') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'epub', 'tag' : currentTag }) }}">EPUB</a></li>{% endif %} 73 {% if craue_setting('export_epub') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'epub', 'tag' : currentTag, 'search_entry[term]' : exportSearchTerm, 'currentRoute' : previousRoute }) }}">EPUB</a></li>{% endif %}
69 {% if craue_setting('export_mobi') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'mobi', 'tag' : currentTag }) }}">MOBI</a></li>{% endif %} 74 {% if craue_setting('export_mobi') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'mobi', 'tag' : currentTag, 'search_entry[term]' : exportSearchTerm, 'currentRoute' : previousRoute }) }}">MOBI</a></li>{% endif %}
70 {% if craue_setting('export_pdf') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'pdf', 'tag' : currentTag }) }}">PDF</a></li>{% endif %} 75 {% if craue_setting('export_pdf') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'pdf', 'tag' : currentTag, 'search_entry[term]' : exportSearchTerm, 'currentRoute' : previousRoute }) }}">PDF</a></li>{% endif %}
71 {% if craue_setting('export_json') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'json', 'tag' : currentTag }) }}">JSON</a></li>{% endif %} 76 {% if craue_setting('export_json') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'json', 'tag' : currentTag, 'search_entry[term]' : exportSearchTerm, 'currentRoute' : previousRoute }) }}">JSON</a></li>{% endif %}
72 {% if craue_setting('export_csv') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'csv', 'tag' : currentTag }) }}">CSV</a></li>{% endif %} 77 {% if craue_setting('export_csv') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'csv', 'tag' : currentTag, 'search_entry[term]' : exportSearchTerm, 'currentRoute' : previousRoute }) }}">CSV</a></li>{% endif %}
73 {% if craue_setting('export_txt') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'txt', 'tag' : currentTag }) }}">TXT</a></li>{% endif %} 78 {% if craue_setting('export_txt') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'txt', 'tag' : currentTag, 'search_entry[term]' : exportSearchTerm, 'currentRoute' : previousRoute }) }}">TXT</a></li>{% endif %}
74 {% if craue_setting('export_xml') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'xml', 'tag' : currentTag }) }}">XML</a></li>{% endif %} 79 {% if craue_setting('export_xml') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'xml', 'tag' : currentTag, 'search_entry[term]' : exportSearchTerm, 'currentRoute' : previousRoute }) }}">XML</a></li>{% endif %}
75 </ul> 80 </ul>
76 </div> 81 </div>
77 82
diff --git a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php
index d7ce7c45..36822ab3 100644
--- a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php
@@ -3,9 +3,13 @@
3namespace Tests\Wallabag\CoreBundle\Controller; 3namespace Tests\Wallabag\CoreBundle\Controller;
4 4
5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; 5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
6use Wallabag\CoreBundle\Entity\Entry;
6 7
7class ExportControllerTest extends WallabagCoreTestCase 8class ExportControllerTest extends WallabagCoreTestCase
8{ 9{
10 private $adminEntry;
11 private $bobEntry;
12
9 public function testLogin() 13 public function testLogin()
10 { 14 {
11 $client = $this->getClient(); 15 $client = $this->getClient();
@@ -243,6 +247,30 @@ class ExportControllerTest extends WallabagCoreTestCase
243 $this->assertContains('foo', $content[0]['tags']); 247 $this->assertContains('foo', $content[0]['tags']);
244 } 248 }
245 249
250 public function testJsonExportFromSearch()
251 {
252 $this->setUpForJsonExportFromSearch();
253
254 $this->logInAs('admin');
255 $client = $this->getClient();
256
257 ob_start();
258 $crawler = $client->request('GET', '/export/search.json?search_entry[term]=entry+search&currentRoute=homepage');
259 ob_end_clean();
260
261 $this->assertSame(200, $client->getResponse()->getStatusCode());
262
263 $headers = $client->getResponse()->headers;
264 $this->assertSame('application/json', $headers->get('content-type'));
265 $this->assertSame('attachment; filename="Search entry search articles.json"', $headers->get('content-disposition'));
266 $this->assertSame('UTF-8', $headers->get('content-transfer-encoding'));
267
268 $content = json_decode($client->getResponse()->getContent(), true);
269 $this->assertCount(1, $content);
270
271 $this->tearDownForJsonExportFromSearch();
272 }
273
246 public function testXmlExport() 274 public function testXmlExport()
247 { 275 {
248 $this->logInAs('admin'); 276 $this->logInAs('admin');
@@ -282,6 +310,41 @@ class ExportControllerTest extends WallabagCoreTestCase
282 $this->assertNotEmpty('updated_at', (string) $content->entry[0]->updated_at); 310 $this->assertNotEmpty('updated_at', (string) $content->entry[0]->updated_at);
283 } 311 }
284 312
313 private function setUpForJsonExportFromSearch()
314 {
315 $client = $this->getClient();
316 $em = $this->getEntityManager();
317
318 $userRepository = $client->getContainer()
319 ->get('wallabag_user.user_repository.test');
320
321 $user = $userRepository->findOneByUserName('admin');
322 $this->adminEntry = new Entry($user);
323 $this->adminEntry->setUrl('http://0.0.0.0/entry-search-admin');
324 $this->adminEntry->setTitle('test title entry search admin');
325 $this->adminEntry->setContent('this is my content /o/');
326 $em->persist($this->adminEntry);
327
328 $user = $userRepository->findOneByUserName('bob');
329 $this->bobEntry = new Entry($user);
330 $this->bobEntry->setUrl('http://0.0.0.0/entry-search-bob');
331 $this->bobEntry->setTitle('test title entry search bob');
332 $this->bobEntry->setContent('this is my content /o/');
333 $em->persist($this->bobEntry);
334
335 $em->flush();
336 }
337
338 private function tearDownForJsonExportFromSearch()
339 {
340 $em = $this->getEntityManager();
341
342 $em->remove($this->adminEntry);
343 $em->remove($this->bobEntry);
344
345 $em->flush();
346 }
347
285 private function getSanitizedFilename($title) 348 private function getSanitizedFilename($title)
286 { 349 {
287 return preg_replace('/[^A-Za-z0-9\- \']/', '', iconv('utf-8', 'us-ascii//TRANSLIT', $title)); 350 return preg_replace('/[^A-Za-z0-9\- \']/', '', iconv('utf-8', 'us-ascii//TRANSLIT', $title));