aboutsummaryrefslogtreecommitdiffhomepage
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/PageBuilder.php5
-rw-r--r--application/Thumbnailer.php49
-rw-r--r--application/config/ConfigManager.php4
3 files changed, 58 insertions, 0 deletions
diff --git a/application/PageBuilder.php b/application/PageBuilder.php
index a4483870..3dba7677 100644
--- a/application/PageBuilder.php
+++ b/application/PageBuilder.php
@@ -105,6 +105,11 @@ class PageBuilder
105 if ($this->linkDB !== null) { 105 if ($this->linkDB !== null) {
106 $this->tpl->assign('tags', $this->linkDB->linksCountPerTag()); 106 $this->tpl->assign('tags', $this->linkDB->linksCountPerTag());
107 } 107 }
108
109 $this->tpl->assign('thumbnails_enabled', $this->conf->get('thumbnails.enabled'));
110 $this->tpl->assign('thumbnails_width', $this->conf->get('thumbnails.width'));
111 $this->tpl->assign('thumbnails_height', $this->conf->get('thumbnails.height'));
112
108 // To be removed with a proper theme configuration. 113 // To be removed with a proper theme configuration.
109 $this->tpl->assign('conf', $this->conf); 114 $this->tpl->assign('conf', $this->conf);
110 } 115 }
diff --git a/application/Thumbnailer.php b/application/Thumbnailer.php
new file mode 100644
index 00000000..b669adae
--- /dev/null
+++ b/application/Thumbnailer.php
@@ -0,0 +1,49 @@
1<?php
2
3use WebThumbnailer\WebThumbnailer;
4
5/**
6 * Class Thumbnailer
7 *
8 * Utility class used to retrieve thumbnails using web-thumbnailer dependency.
9 */
10class Thumbnailer
11{
12 /**
13 * @var WebThumbnailer instance.
14 */
15 protected $wt;
16
17 /**
18 * @var ConfigManager instance.
19 */
20 protected $conf;
21
22 /**
23 * Thumbnailer constructor.
24 *
25 * @param ConfigManager $conf instance.
26 */
27 public function __construct($conf)
28 {
29 $this->conf = $conf;
30 $this->wt = new WebThumbnailer();
31 \WebThumbnailer\Application\ConfigManager::addFile('inc/web-thumbnailer.json');
32 $this->wt->maxWidth($this->conf->get('thumbnails.width'))
33 ->maxHeight($this->conf->get('thumbnails.height'))
34 ->crop(true)
35 ->debug($this->conf->get('dev.debug', false));
36 }
37
38 /**
39 * Retrieve a thumbnail for given URL
40 *
41 * @param string $url where to look for a thumbnail.
42 *
43 * @return bool|string The thumbnail relative cache file path, or false if none has been found.
44 */
45 public function get($url)
46 {
47 return $this->wt->thumbnail($url);
48 }
49}
diff --git a/application/config/ConfigManager.php b/application/config/ConfigManager.php
index 82f4a368..124fedc2 100644
--- a/application/config/ConfigManager.php
+++ b/application/config/ConfigManager.php
@@ -319,6 +319,10 @@ class ConfigManager
319 $this->setEmpty('general.enabled_plugins', self::$DEFAULT_PLUGINS); 319 $this->setEmpty('general.enabled_plugins', self::$DEFAULT_PLUGINS);
320 $this->setEmpty('general.default_note_title', 'Note: '); 320 $this->setEmpty('general.default_note_title', 'Note: ');
321 321
322 $this->setEmpty('thumbnails.enabled', true);
323 $this->setEmpty('thumbnails.width', 120);
324 $this->setEmpty('thumbnails.height', 120);
325
322 $this->setEmpty('updates.check_updates', false); 326 $this->setEmpty('updates.check_updates', false);
323 $this->setEmpty('updates.check_updates_branch', 'stable'); 327 $this->setEmpty('updates.check_updates_branch', 'stable');
324 $this->setEmpty('updates.check_updates_interval', 86400); 328 $this->setEmpty('updates.check_updates_interval', 86400);