switch ($this->connection->getDatabasePlatform()->getName()) {
case 'mysql':
+ $this->addSql('UPDATE ' . $this->getTable('entry') . ' SET reading_time = 0 WHERE reading_time IS NULL;');
$this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE reading_time reading_time INT(11) NOT NULL;');
break;
case 'postgresql':
--- /dev/null
+<?php
+
+namespace Application\Migrations;
+
+use Doctrine\DBAL\Migrations\AbstractMigration;
+use Doctrine\DBAL\Schema\Schema;
+use Symfony\Component\DependencyInjection\ContainerAwareInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * Add origin_url column.
+ */
+class Version20171105202000 extends AbstractMigration implements ContainerAwareInterface
+{
+ /**
+ * @var ContainerInterface
+ */
+ private $container;
+
+ public function setContainer(ContainerInterface $container = null)
+ {
+ $this->container = $container;
+ }
+
+ /**
+ * @param Schema $schema
+ */
+ public function up(Schema $schema)
+ {
+ $entryTable = $schema->getTable($this->getTable('entry'));
+
+ $this->skipIf($entryTable->hasColumn('origin_url'), 'It seems that you already played this migration.');
+
+ $entryTable->addColumn('origin_url', 'text', [
+ 'notnull' => false,
+ ]);
+ }
+
+ /**
+ * @param Schema $schema
+ */
+ public function down(Schema $schema)
+ {
+ $entryTable = $schema->getTable($this->getTable('entry'));
+
+ $this->skipIf(!$entryTable->hasColumn('origin_url'), 'It seems that you already played this migration.');
+
+ $entryTable->dropColumn('origin_url');
+ }
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
+}
"ext-iconv": "*",
"ext-tokenizer": "*",
"ext-pdo": "*",
- "symfony/symfony": "3.3.*",
- "doctrine/orm": "^2.5",
- "doctrine/doctrine-bundle": "^1.6",
- "doctrine/doctrine-cache-bundle": "^1.2",
- "twig/extensions": "~1.0",
- "symfony/swiftmailer-bundle": "^2.3",
- "symfony/monolog-bundle": "^3.0",
- "sensio/distribution-bundle": "^5.0",
- "sensio/framework-extra-bundle": "^3.0",
- "incenteev/composer-parameter-handler": "^2.0",
- "nelmio/cors-bundle": "~1.4",
+ "symfony/symfony": "~3.3.13",
+ "doctrine/orm": "^2.5.12",
+ "doctrine/doctrine-bundle": "^1.8.0",
+ "doctrine/doctrine-cache-bundle": "^1.3.2",
+ "twig/extensions": "^1.5.1",
+ "symfony/swiftmailer-bundle": "^2.6.7",
+ "symfony/monolog-bundle": "^3.1.2",
+ "sensio/distribution-bundle": "^5.0.21",
+ "sensio/framework-extra-bundle": "^3.0.28",
+ "incenteev/composer-parameter-handler": "^2.1.2",
+ "nelmio/cors-bundle": "~1.5",
"friendsofsymfony/rest-bundle": "~2.1",
"jms/serializer-bundle": "~2.2",
- "nelmio/api-doc-bundle": "~2.7",
+ "nelmio/api-doc-bundle": "^2.13.2",
"mgargano/simplehtmldom": "~1.5",
- "wallabag/tcpdf": "^6.2",
+ "wallabag/tcpdf": "^6.2.15",
"simplepie/simplepie": "~1.5",
- "willdurand/hateoas-bundle": "~1.0",
- "liip/theme-bundle": "~1.1",
- "lexik/form-filter-bundle": "~5.0",
+ "willdurand/hateoas-bundle": "~1.3",
+ "liip/theme-bundle": "^1.4.6",
+ "lexik/form-filter-bundle": "^5.0.4",
"j0k3r/graby": "^1.0",
- "friendsofsymfony/user-bundle": "^2.0",
- "friendsofsymfony/oauth-server-bundle": "^1.5",
+ "friendsofsymfony/user-bundle": "^2.0.1",
+ "friendsofsymfony/oauth-server-bundle": "^1.5.2",
"stof/doctrine-extensions-bundle": "^1.2",
- "scheb/two-factor-bundle": "~2.0",
- "grandt/phpepub": "~4.0",
+ "scheb/two-factor-bundle": "^2.14.0",
+ "grandt/phpepub": "^4.0.7",
"wallabag/php-mobi": "~1.0.0",
"kphoen/rulerz-bundle": "~0.13",
"guzzlehttp/guzzle": "^5.3.1",
- "doctrine/doctrine-migrations-bundle": "^1.0",
- "paragonie/random_compat": "~2.0",
+ "doctrine/doctrine-migrations-bundle": "^1.3",
+ "paragonie/random_compat": "^2.0.11",
"craue/config-bundle": "~2.0",
"mnapoli/piwik-twig-extension": "^1.0",
- "ocramius/proxy-manager": "1.*",
- "white-october/pagerfanta-bundle": "^1.0",
- "php-amqplib/rabbitmq-bundle": "^1.8",
- "predis/predis": "^1.0",
+ "ocramius/proxy-manager": "^1.0.2",
+ "white-october/pagerfanta-bundle": "^1.1.0",
+ "php-amqplib/rabbitmq-bundle": "^1.14",
+ "predis/predis": "^1.1.1",
"javibravo/simpleue": "^2.0",
- "symfony/dom-crawler": "^3.1",
- "friendsofsymfony/jsrouting-bundle": "^1.6",
+ "symfony/dom-crawler": "^3.3.13",
+ "friendsofsymfony/jsrouting-bundle": "^1.6.3",
"bdunogier/guzzle-site-authenticator": "^1.0.0@dev",
"defuse/php-encryption": "^2.1",
"html2text/html2text": "^4.1"
* {"name"="published_at", "dataType"="datetime|integer", "format"="YYYY-MM-DDTHH:II:SS+TZ or a timestamp", "required"=false, "description"="Published date of the entry"},
* {"name"="authors", "dataType"="string", "format"="Name Firstname,author2,author3", "required"=false, "description"="Authors of the entry"},
* {"name"="public", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="will generate a public link for the entry"},
+ * {"name"="origin_url", "dataType"="string", "required"=false, "format"="http://www.test.com/article.html", "description"="Origin url for the entry (from where you found it)."},
* }
* )
*
$this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $data['tags']);
}
+ if (!empty($data['origin_url'])) {
+ $entry->setOriginUrl($data['origin_url']);
+ }
+
if (null !== $data['isPublic']) {
if (true === (bool) $data['isPublic'] && null === $entry->getUid()) {
$entry->generateUid();
* {"name"="published_at", "dataType"="datetime|integer", "format"="YYYY-MM-DDTHH:II:SS+TZ or a timestamp", "required"=false, "description"="Published date of the entry"},
* {"name"="authors", "dataType"="string", "format"="Name Firstname,author2,author3", "required"=false, "description"="Authors of the entry"},
* {"name"="public", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="will generate a public link for the entry"},
+ * {"name"="origin_url", "dataType"="string", "required"=false, "format"="http://www.test.com/article.html", "description"="Origin url for the entry (from where you found it)."},
* }
* )
*
}
}
+ if (!empty($data['origin_url'])) {
+ $entry->setOriginUrl($data['origin_url']);
+ }
+
$em = $this->getDoctrine()->getManager();
$em->persist($entry);
$em->flush();
'picture' => $request->request->get('preview_picture'),
'publishedAt' => $request->request->get('published_at'),
'authors' => $request->request->get('authors', ''),
+ 'origin_url' => $request->request->get('origin_url', ''),
];
}
$entry2->setMimetype('text/html');
$entry2->setTitle('test title entry2');
$entry2->setContent('This is my content /o/');
+ $entry2->setOriginUrl('ftp://oneftp.tld');
$entry2->setLanguage('fr');
$manager->persist($entry2);
*/
private $tags;
+ /**
+ * @var string
+ *
+ * @ORM\Column(name="origin_url", type="text", nullable=true)
+ *
+ * @Groups({"entries_for_user", "export_all"})
+ */
+ private $originUrl;
+
/*
* @param User $user
*/
return $this;
}
+
+ /**
+ * Set origin url.
+ *
+ * @param string $originUrl
+ *
+ * @return Entry
+ */
+ public function setOriginUrl($originUrl)
+ {
+ $this->originUrl = $originUrl;
+
+ return $this;
+ }
+
+ /**
+ * Get origin url.
+ *
+ * @return string
+ */
+ public function getOriginUrl()
+ {
+ return $this->originUrl;
+ }
}
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
+use Symfony\Component\Form\Extension\Core\Type\UrlType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
'required' => true,
'label' => 'entry.edit.title_label',
])
- ->add('url', TextType::class, [
+ ->add('url', UrlType::class, [
'disabled' => true,
'required' => false,
'label' => 'entry.edit.url_label',
])
+ ->add('origin_url', UrlType::class, [
+ 'required' => false,
+ 'property_path' => 'originUrl',
+ 'label' => 'entry.edit.origin_url_label',
+ ])
->add('save', SubmitType::class, [
'label' => 'entry.edit.save_label',
])
created_at: 'Oprettelsesdato'
# published_at: 'Publication date'
# published_by: 'Published by'
+ # provided_by: 'Provided by'
new:
page_title: 'Gem ny artikel'
placeholder: 'http://website.com'
# page_title: 'Edit an entry'
# title_label: 'Title'
url_label: 'Url'
+ # origin_url_label: 'Origin url (from where you found that entry)'
save_label: 'Gem'
public:
# shared_by_wallabag: "This article has been shared by %username% with <a href='%wallabag_instance%'>wallabag</a>"
created_at: 'Erstellungsdatum'
published_at: 'Erscheinungsdatum'
published_by: 'Veröffentlicht von'
+ # provided_by: 'Provided by'
new:
page_title: 'Neuen Artikel speichern'
placeholder: 'https://website.de'
page_title: 'Eintrag bearbeiten'
title_label: 'Titel'
url_label: 'URL'
+ # origin_url_label: 'Origin url (from where you found that entry)'
save_label: 'Speichern'
public:
shared_by_wallabag: 'Dieser Artikel wurde von %username% mittels <a href="%wallabag_instance%">wallabag</a> geteilt'
created_at: 'Creation date'
published_at: 'Publication date'
published_by: 'Published by'
+ provided_by: 'Provided by'
new:
page_title: 'Save new entry'
placeholder: 'http://website.com'
page_title: 'Edit an entry'
title_label: 'Title'
url_label: 'Url'
+ origin_url_label: 'Origin url (from where you found that entry)'
save_label: 'Save'
public:
shared_by_wallabag: "This article has been shared by %username% with <a href='%wallabag_instance%'>wallabag</a>"
created_at: 'Fecha de creación'
# published_at: 'Publication date'
# published_by: 'Published by'
+ # provided_by: 'Provided by'
new:
page_title: 'Guardar un nuevo artículo'
placeholder: 'http://sitioweb.com'
page_title: 'Editar un artículo'
title_label: 'Título'
url_label: 'URL'
+ # origin_url_label: 'Origin url (from where you found that entry)'
save_label: 'Guardar'
public:
shared_by_wallabag: "Este artículo se ha compartido con <a href='%wallabag_instance%'>wallabag</a>"
created_at: 'زمان ساخت'
# published_at: 'Publication date'
# published_by: 'Published by'
+ # provided_by: 'Provided by'
new:
page_title: 'ذخیرهٔ مقالهٔ تازه'
placeholder: 'http://website.com'
page_title: 'ویرایش مقاله'
title_label: 'عنوان'
url_label: 'نشانی'
+ # origin_url_label: 'Origin url (from where you found that entry)'
save_label: 'ذخیره'
public:
# shared_by_wallabag: "This article has been shared by %username% with <a href='%wallabag_instance%'>wallabag</a>"
created_at: "Date de création"
published_at: "Date de publication"
published_by: "Publié par"
+ provided_by: "Fourni par"
new:
page_title: "Sauvegarder un nouvel article"
placeholder: "http://website.com"
page_title: "Éditer un article"
title_label: "Titre"
url_label: "Adresse"
+ origin_url_label: "Adresse d'origine (d'où vous avez trouvé cet article)"
save_label: "Enregistrer"
public:
shared_by_wallabag: "Cet article a été partagé par %username% avec <a href=\"%wallabag_instance%\">wallabag</a>"
created_at: 'Data di creazione'
published_at: 'Data di pubblicazione'
published_by: 'Pubblicato da'
+ # provided_by: 'Provided by'
new:
page_title: 'Salva un nuovo contenuto'
placeholder: 'http://website.com'
page_title: 'Modifica voce'
title_label: 'Titolo'
url_label: 'Url'
+ # origin_url_label: 'Origin url (from where you found that entry)'
save_label: 'Salva'
public:
shared_by_wallabag: "Questo articolo è stato condiviso da %username% con <a href='%wallabag_instance%'>wallabag</a>"
created_at: 'Data de creacion'
published_at: 'Data de publicacion'
published_by: 'Publicat per'
+ # provided_by: 'Provided by'
new:
page_title: 'Enregistrar un novèl article'
placeholder: 'http://website.com'
page_title: 'Modificar un article'
title_label: 'Títol'
url_label: 'Url'
+ # origin_url_label: 'Origin url (from where you found that entry)'
save_label: 'Enregistrar'
public:
shared_by_wallabag: "Aqueste article es estat partejat per <a href='%wallabag_instance%'>wallabag</a>"
created_at: 'Czas stworzenia'
published_at: 'Data publikacji'
published_by: 'Opublikowane przez'
+ # provided_by: 'Provided by'
new:
page_title: 'Zapisz nowy wpis'
placeholder: 'http://website.com'
page_title: 'Edytuj wpis'
title_label: 'Tytuł'
url_label: 'Adres URL'
+ # origin_url_label: 'Origin url (from where you found that entry)'
save_label: 'Zapisz'
public:
shared_by_wallabag: "Ten artykuł został udostępniony przez <a href='%wallabag_instance%'>wallabag</a>"
created_at: 'Data de criação'
# published_at: 'Publication date'
# published_by: 'Published by'
+ # provided_by: 'Provided by'
new:
page_title: 'Salvar nova entrada'
placeholder: 'http://website.com'
page_title: 'Editar uma entrada'
title_label: 'Título'
url_label: 'Url'
+ # origin_url_label: 'Origin url (from where you found that entry)'
save_label: 'Salvar'
public:
shared_by_wallabag: "Este artigo foi compartilhado pelo <a href='%wallabag_instance%'>wallabag</a>"
created_at: 'Data creării'
# published_at: 'Publication date'
# published_by: 'Published by'
+ # provided_by: 'Provided by'
new:
page_title: 'Salvează un nou articol'
placeholder: 'http://website.com'
# page_title: 'Edit an entry'
# title_label: 'Title'
url_label: 'Url'
+ # origin_url_label: 'Origin url (from where you found that entry)'
save_label: 'Salvează'
public:
# shared_by_wallabag: "This article has been shared by %username% with <a href='%wallabag_instance%'>wallabag</a>"
original_article: 'оригинал'
annotations_on_the_entry: '{0} Нет аннотации|{1} Одна аннотация|]1,Inf[ %count% аннотаций'
created_at: 'Дата создания'
+ # provided_by: 'Provided by'
new:
page_title: 'Сохранить новую запись'
placeholder: 'http://website.com'
page_title: 'Изменить запись'
title_label: 'Название'
url_label: 'Ссылка'
+ # origin_url_label: 'Origin url (from where you found that entry)'
is_public_label: 'Публичная'
save_label: 'Сохранить'
public:
created_at: 'Oluşturulma tarihi'
# published_at: 'Publication date'
# published_by: 'Published by'
+ # provided_by: 'Provided by'
new:
page_title: 'Yeni makaleyi kaydet'
placeholder: 'http://website.com'
page_title: 'Makaleyi düzenle'
title_label: 'Başlık'
url_label: 'Url'
+ # origin_url_label: 'Origin url (from where you found that entry)'
save_label: 'Kaydet'
public:
# shared_by_wallabag: "This article has been shared by %username% with <a href='%wallabag_instance%'>wallabag</a>"
</i>
<span class="tool link"><i class="material-icons link">comment</i> {{ 'entry.view.annotations_on_the_entry'|transchoice(entry.annotations | length) }}</span>
+
+ {% if entry.originUrl is not empty %}
+ <i class="material-icons" title="{{ 'entry.view.provided_by'|trans }}">launch</i>
+ <a href="{{ entry.originUrl|e }}" target="_blank" class="tool">
+ {{ entry.originUrl|striptags|removeSchemeAndWww|truncate(32) }}
+ </a>
+ {% endif %}
+
<aside class="tags">
<div class="card-entry-tags">
{% for tag in entry.tags %}
{{ form_label(form.url) }}
{{ form_widget(form.url) }}
</div>
+
+ <div class="input-field s12">
+ {{ form_label(form.origin_url) }}
+ {{ form_widget(form.origin_url) }}
+ </div>
<br>
{{ form_widget(form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }}
{% endif %}
{% if craue_setting('share_shaarli') %}
<li>
- <a href="{{ craue_setting('shaarli_url') }}/index.php?post={{ entry.url|url_encode }}&title={{ entry.title|striptags|url_encode }}&tags={{ entry.tags|join(',')|striptags|url_encode }}" target="_blank" title="shaarli" class="tool icon-image shaarli">
+ <a href="{{ craue_setting('shaarli_url') }}/index.php?post={{ entry.url|url_encode }}&title={{ entry.title|striptags|url_encode }}&tags={{ entry.tags|join(',')|striptags|url_encode }}&lf_original_url={{ entry.originUrl|url_encode }}" target="_blank" title="shaarli" class="tool icon-image shaarli">
<span>shaarli</span>
</a>
</li>
<i class="material-icons link">comment</i>
{{ 'entry.view.annotations_on_the_entry'|transchoice(entry.annotations | length) }}
</li>
+ {% if entry.originUrl is not empty %}
+ <li>
+ <i class="material-icons" title="{{ 'entry.view.provided_by'|trans }}">launch</i>
+ <a href="{{ entry.originUrl|e }}" target="_blank" class="tool">
+ {{ entry.originUrl|striptags|removeSchemeAndWww|truncate(32) }}
+ </a>
+ </li>
+ {% endif %}
</ul>
<ul class="tags">
{% for tag in entry.tags %}
{
return [
new \Twig_SimpleFilter('removeWww', [$this, 'removeWww']),
+ new \Twig_SimpleFilter('removeSchemeAndWww', [$this, 'removeSchemeAndWww']),
];
}
return preg_replace('/^www\./i', '', $url);
}
+ public function removeSchemeAndWww($url)
+ {
+ return $this->removeWww(
+ preg_replace('@^https?://@i', '', $url)
+ );
+ }
+
/**
* Return number of entries depending of the type (unread, archive, starred or all).
*
$this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
}
+ public function testGetOneEntryWithOriginUrl()
+ {
+ $entry = $this->client->getContainer()
+ ->get('doctrine.orm.entity_manager')
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->findOneBy(['user' => 1, 'url' => 'http://0.0.0.0/entry2']);
+
+ if (!$entry) {
+ $this->markTestSkipped('No content found in db.');
+ }
+
+ $this->client->request('GET', '/api/entries/' . $entry->getId() . '.json');
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
+
+ $content = json_decode($this->client->getResponse()->getContent(), true);
+
+ $this->assertSame($entry->getOriginUrl(), $content['origin_url']);
+ }
+
public function testExportEntry()
{
$entry = $this->client->getContainer()
$this->assertSame('New title for my article', $content['title']);
$this->assertSame(1, $content['user_id']);
$this->assertCount(2, $content['tags']);
+ $this->assertNull($content['origin_url']);
$this->assertSame('my content', $content['content']);
$this->assertSame('de', $content['language']);
$this->assertSame('2016-09-08T11:55:58+0200', $content['published_at']);
$this->assertSame(1, $content['is_starred']);
}
+ public function testPostEntryWithOriginUrl()
+ {
+ $this->client->request('POST', '/api/entries.json', [
+ 'url' => 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html',
+ 'tags' => 'google',
+ 'title' => 'New title for my article',
+ 'content' => 'my content',
+ 'language' => 'de',
+ 'published_at' => '2016-09-08T11:55:58+0200',
+ 'authors' => 'bob,helen',
+ 'public' => 1,
+ 'origin_url' => 'http://mysource.tld',
+ ]);
+
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
+
+ $content = json_decode($this->client->getResponse()->getContent(), true);
+
+ $this->assertGreaterThan(0, $content['id']);
+ $this->assertSame('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']);
+ $this->assertSame('http://mysource.tld', $content['origin_url']);
+ }
+
public function testPatchEntry()
{
$entry = $this->client->getContainer()
$this->assertSame($previousLanguage, $content['language'], 'Ensure language has not moved');
}
+ public function testPatchEntryWithOriginUrl()
+ {
+ $entry = $this->client->getContainer()
+ ->get('doctrine.orm.entity_manager')
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->findOneByUser(1);
+
+ if (!$entry) {
+ $this->markTestSkipped('No content found in db.');
+ }
+
+ $previousContent = $entry->getContent();
+ $previousLanguage = $entry->getLanguage();
+
+ $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [
+ 'title' => 'Another awesome title just for profit',
+ 'origin_url' => 'https://myawesomesource.example.com',
+ ]);
+
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
+
+ $content = json_decode($this->client->getResponse()->getContent(), true);
+
+ $this->assertSame($entry->getId(), $content['id']);
+ $this->assertSame($entry->getUrl(), $content['url']);
+ $this->assertSame('https://myawesomesource.example.com', $content['origin_url']);
+ $this->assertEmpty($content['published_by'], 'Authors were not saved because of an array instead of a string');
+ $this->assertSame($previousContent, $content['content'], 'Ensure content has not moved');
+ $this->assertSame($previousLanguage, $content['language'], 'Ensure language has not moved');
+ }
+
+ public function testPatchEntryRemoveOriginUrl()
+ {
+ $entry = $this->client->getContainer()
+ ->get('doctrine.orm.entity_manager')
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->findOneByUser(1);
+
+ if (!$entry) {
+ $this->markTestSkipped('No content found in db.');
+ }
+
+ $previousContent = $entry->getContent();
+ $previousLanguage = $entry->getLanguage();
+ $previousTitle = $entry->getTitle();
+
+ $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [
+ 'origin_url' => '',
+ ]);
+
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
+
+ $content = json_decode($this->client->getResponse()->getContent(), true);
+
+ $this->assertSame($entry->getId(), $content['id']);
+ $this->assertSame($entry->getUrl(), $content['url']);
+ $this->assertEmpty($content['origin_url']);
+ $this->assertEmpty($content['published_by'], 'Authors were not saved because of an array instead of a string');
+ $this->assertSame($previousContent, $content['content'], 'Ensure content has not moved');
+ $this->assertSame($previousLanguage, $content['language'], 'Ensure language has not moved');
+ $this->assertSame($previousTitle, $content['title'], 'Ensure title has not moved');
+ }
+
+ public function testPatchEntryNullOriginUrl()
+ {
+ $entry = $this->client->getContainer()
+ ->get('doctrine.orm.entity_manager')
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->findOneByUser(1);
+
+ if (!$entry) {
+ $this->markTestSkipped('No content found in db.');
+ }
+
+ $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [
+ 'origin_url' => null,
+ ]);
+
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
+
+ $content = json_decode($this->client->getResponse()->getContent(), true);
+
+ $this->assertNull($content['origin_url']);
+ }
+
public function testGetTagsEntry()
{
$entry = $this->client->getContainer()
$data = [
'entry[title]' => 'My updated title hehe :)',
+ 'entry[origin_url]' => 'https://example.io',
];
$client->submit($form, $data);
$crawler = $client->followRedirect();
- $this->assertGreaterThan(1, $alert = $crawler->filter('div[id=article] h1')->extract(['_text']));
- $this->assertContains('My updated title hehe :)', $alert[0]);
+ $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text']));
+ $this->assertContains('My updated title hehe :)', $title[0]);
+ $this->assertGreaterThan(1, $stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text']));
+ $this->assertContains('example.io', trim($stats[1]));
+ }
+
+ public function testEditRemoveOriginUrl()
+ {
+ $this->logInAs('admin');
+ $client = $this->getClient();
+
+ $entry = new Entry($this->getLoggedInUser());
+ $entry->setUrl($this->url);
+ $this->getEntityManager()->persist($entry);
+ $this->getEntityManager()->flush();
+
+ $crawler = $client->request('GET', '/edit/' . $entry->getId());
+
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+
+ $form = $crawler->filter('button[type=submit]')->form();
+
+ $data = [
+ 'entry[title]' => 'My updated title hehe :)',
+ 'entry[origin_url]' => '',
+ ];
+
+ $client->submit($form, $data);
+
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
+
+ $crawler = $client->followRedirect();
+
+ $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text']));
+ $this->assertContains('My updated title hehe :)', $title[0]);
+ $this->assertSame(1, count($stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text'])));
+ $this->assertNotContains('example.io', trim($stats[0]));
}
public function testToggleArchive()
$this->assertSame('lemonde.fr', $extension->removeWww('lemonde.fr'));
$this->assertSame('gist.github.com', $extension->removeWww('gist.github.com'));
}
+
+ public function testRemoveSchemeAndWww()
+ {
+ $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->assertSame('lemonde.fr', $extension->removeSchemeAndWww('www.lemonde.fr'));
+ $this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('http://lemonde.fr'));
+ $this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('https://www.lemonde.fr'));
+ $this->assertSame('gist.github.com', $extension->removeSchemeAndWww('https://gist.github.com'));
+ $this->assertSame('ftp://gist.github.com', $extension->removeSchemeAndWww('ftp://gist.github.com'));
+ }
}