diff --git a/application/modules/admin/controllers/SitoController.php b/application/modules/admin/controllers/SitoController.php index d8f5831db9936a50816d98e7e9e280e248e0aa61..c1a450014756e478dd7a283a03690cdb25c7d3ac 100644 --- a/application/modules/admin/controllers/SitoController.php +++ b/application/modules/admin/controllers/SitoController.php @@ -75,21 +75,27 @@ class Admin_SitoController extends ZendAfi_Controller_Action { $album = Class_Album::newInstance(['type_doc_id' => Class_TypeDoc::WEBSITE, 'categorie' => $category]); - $album->setTitre(trim($dom->queryXpath('//head/title')->current()->textContent)); + + $title_node = $dom->queryXpath('//head/title')->current(); + $album->setTitre($title_node ? trim($title_node->textContent) : $url); if ($description_node = $dom->queryXpath('//head/meta[@name="description"]')->current()) $album->setDescription($description_node->getAttribute('content')); $resource = Class_AlbumRessource::newInstance(['url' => $url, - 'titre' => $album->getTitre()]); + 'titre' => $album->getTitre(), + 'description' => $album->getDescription()]); $album->addRessource($resource); $album->save(); $thumbnailer = (new Class_WebService_WebSiteThumbnail()); + $poster_name = $thumbnailer->fileNameFromUrl($url); $poster_path = $resource->getPosterPath(); + $resource->getFolderManager()->ensure($poster_path); - $thumbnailer->getThumbnailer()->fetchUrlToFile($url, $poster_path . $poster_name); + $thumbnailer->getThumbnailer()->fetchUrlToFile($url, $poster_path . $poster_name, 'medium'); + $resource->setPoster($poster_name); $resource->createThumbnail(); diff --git a/library/Class/WebService/Bluga.php b/library/Class/WebService/Bluga.php index cbff2ffc086bb251bc7f972c24e5aa3e6c3c6c8e..9303112ba357f08604fe0b0c82a6dabe396b6969 100644 --- a/library/Class/WebService/Bluga.php +++ b/library/Class/WebService/Bluga.php @@ -38,7 +38,7 @@ class Class_WebService_Bluga { $this->_bluga = $instance; } - public function fetchUrlToFile($url, $filename) { + public function fetchUrlToFile($url, $filename, $size = 'small') { $api_key = $this->getApiKey(); if (empty($api_key)) return false; @@ -48,7 +48,7 @@ class Class_WebService_Bluga { try { $bluga->setApiKey($api_key); - $job = $bluga->addUrl($url, 'small'); + $job = $bluga->addUrl($url, $size); $bluga->submitRequests(); $nb_of_try = 3; diff --git a/library/ZendAfi/View/Helper/RenderAlbumPreview/WebSite.php b/library/ZendAfi/View/Helper/RenderAlbumPreview/WebSite.php index 38c3a7e4b8d3c17d57195747b841183e16d43795..a7e44a29fb49716d8afad500a7dfb97b3cab9275 100644 --- a/library/ZendAfi/View/Helper/RenderAlbumPreview/WebSite.php +++ b/library/ZendAfi/View/Helper/RenderAlbumPreview/WebSite.php @@ -35,7 +35,7 @@ class ZendAfi_View_Helper_RenderAlbumPreview_WebSite extends ZendAfi_View_Helper $this->_tag('a', $this->_tag('img', '', - ['src' => $ressource->getPosterUrl()]). + ['src' => $ressource->getThumbnailUrl()]). $ressource->getTitre(), ['href' => $ressource->getUrl(), 'target' => '_blank'] diff --git a/public/opac/css/global.css b/public/opac/css/global.css index 74e29d018fa3b96b306b36f85c0676b0aaa67aae..c97365ad9f3a4264d4a7946529f7fe14de957d56 100644 --- a/public/opac/css/global.css +++ b/public/opac/css/global.css @@ -718,9 +718,15 @@ select{color:#666666;font-family:Arial;font-size:1em;} } +.sitotheque { + clear: both; +} + + .sitotheque img { float: left; padding-right: 8px; + width: 80px; } .sitotheque>div { diff --git a/tests/application/modules/admin/controllers/SitothequeControllerTest.php b/tests/application/modules/admin/controllers/SitothequeControllerTest.php index fc77994e1b02692ea350a802c122628f6fef4a20..b7d912a2d14cc8108c2a6d54bc60a822e86cffb5 100644 --- a/tests/application/modules/admin/controllers/SitothequeControllerTest.php +++ b/tests/application/modules/admin/controllers/SitothequeControllerTest.php @@ -659,6 +659,17 @@ class SitothequeControllerImportCnedFromUrlTest extends AbstractControllerTestCa } + /** + * @depends albumShouldHaveOneResourceWithUrlCnedDotFr + * @test + */ + public function resourceDescriptionShouldBeFormationsEnLigne($resource) { + $this->assertContains('Formations en ligne et cours', + $resource->getDescription()); + + } + + /** @test */ public function albumDescriptionShouldBeFormationsEnLigne() { $this->assertContains('Formations en ligne et cours', $this->_cned->getDescription()); @@ -667,6 +678,7 @@ class SitothequeControllerImportCnedFromUrlTest extends AbstractControllerTestCa + class SitothequeControllerImportEnssibFromUrlTest extends AbstractControllerTestCase { protected $_storm_default_to_volatile = true, @@ -689,4 +701,27 @@ class SitothequeControllerImportEnssibFromUrlTest extends AbstractControllerTest } + +class SitothequeControllerImportBnfFromUrlTest extends AbstractControllerTestCase { + protected + $_storm_default_to_volatile = true, + $_bnf; + + public function setUp() { + parent::setUp(); + $this->postDispatch('/admin/sito/create', + ['url' => 'http://www.bnf.fr']); + + $this->_bnf = Class_Album::find(1); + } + + + /** @test */ + public function titleShouldBeBnfDotFr() { + $this->assertEquals('http://www.bnf.fr', + $this->_bnf->getTitre()); + } +} + + ?> \ No newline at end of file