aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-09-10 19:22:47 +0200
committerNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-09-10 19:22:47 +0200
commit12d9cfbcaa236a7d1aa3208a836519af1e1af8ce (patch)
tree939a744a000668327e29293826564e3a9e3d0da3
parentf3a6080fce5d0473b6452a5984a2092c97df77ec (diff)
parent964481d023676bee964141a1d14f638995ac8d30 (diff)
downloadwallabag-12d9cfbcaa236a7d1aa3208a836519af1e1af8ce.tar.gz
wallabag-12d9cfbcaa236a7d1aa3208a836519af1e1af8ce.tar.zst
wallabag-12d9cfbcaa236a7d1aa3208a836519af1e1af8ce.zip
Merge branch 'Flattr' of git://github.com/tcitworld/poche into tcitworld-Flattr
Conflicts: inc/3rdparty/site_config
-rw-r--r--inc/3rdparty/FlattrItem.class.php49
-rw-r--r--inc/poche/Poche.class.php14
-rwxr-xr-xinc/poche/config.inc.php1
-rw-r--r--inc/poche/define.inc.php5
-rw-r--r--tpl/css/style-light.css4
-rw-r--r--tpl/img/light/flattr.pngbin0 -> 3521 bytes
-rw-r--r--tpl/view.twig2
7 files changed, 71 insertions, 4 deletions
diff --git a/inc/3rdparty/FlattrItem.class.php b/inc/3rdparty/FlattrItem.class.php
new file mode 100644
index 00000000..c940fcd6
--- /dev/null
+++ b/inc/3rdparty/FlattrItem.class.php
@@ -0,0 +1,49 @@
1<?php
2/*
3* Class for Flattr querying
4*/
5class FlattrItem {
6
7 public $status;
8 public $urltoflattr;
9 public $flattrItemURL;
10 public $numflattrs;
11
12 public function checkItem($urltoflattr) {
13 $this->cacheflattrfile($urltoflattr);
14 $flattrResponse = file_get_contents(CACHE . "/flattr/".base64_encode($urltoflattr).".cache");
15 if($flattrResponse != FALSE) {
16 $result = json_decode($flattrResponse);
17 if (isset($result->message)){
18 if ($result->message == "flattrable") {
19 $this->status = FLATTRABLE;
20 }
21 }
22 elseif ($result->link) {
23 $this->status = FLATTRED;
24 $this->flattrItemURL = $result->link;
25 $this->numflattrs = $result->flattrs;
26 }
27 else {
28 $this->status = NOT_FLATTRABLE;
29 }
30 }
31 else {
32 $this->status = "FLATTR_ERR_CONNECTION";
33 }
34 }
35
36 private function cacheflattrfile($urltoflattr) {
37 if (!is_dir(CACHE . '/flattr')) {
38 mkdir(CACHE . '/flattr', 0777);
39 }
40
41 // if a cache flattr file for this url already exists and it's been less than one day than it have been updated, see in /cache
42 if ((!file_exists(CACHE . "/flattr/".base64_encode($urltoflattr).".cache")) || (time() - filemtime(CACHE . "/flattr/".base64_encode($urltoflattr).".cache") > 86400)) {
43 $askForFlattr = Tools::getFile(FLATTR_API . $urltoflattr);
44 $flattrCacheFile = fopen(CACHE . "/flattr/".base64_encode($urltoflattr).".cache", 'w+');
45 fwrite($flattrCacheFile, $askForFlattr);
46 fclose($flattrCacheFile);
47 }
48 }
49} \ No newline at end of file
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 534e660a..9db4a034 100644
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -247,17 +247,23 @@ class Poche
247 $tidy = tidy_parse_string($content, array('indent'=>true, 'show-body-only' => true), 'UTF8'); 247 $tidy = tidy_parse_string($content, array('indent'=>true, 'show-body-only' => true), 'UTF8');
248 $tidy->cleanRepair(); 248 $tidy->cleanRepair();
249 $content = $tidy->value; 249 $content = $tidy->value;
250 } 250
251 $tpl_vars = array( 251 # flattr checking
252 $flattr = new FlattrItem();
253 $flattr->checkItem($entry['url']);
254
255 $tpl_vars = array(
252 'entry' => $entry, 256 'entry' => $entry,
253 'content' => $content, 257 'content' => $content,
254 ); 258 'flattr' => $flattr
259 );
260 }
255 } 261 }
256 else { 262 else {
257 Tools::logm('error in view call : entry is null'); 263 Tools::logm('error in view call : entry is null');
258 } 264 }
259 break; 265 break;
260 default: # home, favorites and archive views 266 default: # home, favorites and archive views
261 $entries = $this->store->getEntriesByView($view, $this->user->getId()); 267 $entries = $this->store->getEntriesByView($view, $this->user->getId());
262 $tpl_vars = array( 268 $tpl_vars = array(
263 'entries' => '', 269 'entries' => '',
diff --git a/inc/poche/config.inc.php b/inc/poche/config.inc.php
index 7f1b8c92..45526695 100755
--- a/inc/poche/config.inc.php
+++ b/inc/poche/config.inc.php
@@ -37,6 +37,7 @@ require_once __DIR__ . '/../../inc/3rdparty/humble-http-agent/CookieJar.php';
37require_once __DIR__ . '/../../inc/3rdparty/feedwriter/FeedItem.php'; 37require_once __DIR__ . '/../../inc/3rdparty/feedwriter/FeedItem.php';
38require_once __DIR__ . '/../../inc/3rdparty/feedwriter/FeedWriter.php'; 38require_once __DIR__ . '/../../inc/3rdparty/feedwriter/FeedWriter.php';
39require_once __DIR__ . '/../../inc/3rdparty/feedwriter/DummySingleItemFeed.php'; 39require_once __DIR__ . '/../../inc/3rdparty/feedwriter/DummySingleItemFeed.php';
40require_once __DIR__ . '/../../inc/3rdparty/FlattrItem.class.php';
40 41
41if (DOWNLOAD_PICTURES) { 42if (DOWNLOAD_PICTURES) {
42 require_once __DIR__ . '/../../inc/poche/pochePictures.php'; 43 require_once __DIR__ . '/../../inc/poche/pochePictures.php';
diff --git a/inc/poche/define.inc.php b/inc/poche/define.inc.php
index 53c275dd..40f77b5c 100644
--- a/inc/poche/define.inc.php
+++ b/inc/poche/define.inc.php
@@ -22,6 +22,11 @@ define ('SHARE_TWITTER', TRUE);
22define ('SHARE_MAIL', TRUE); 22define ('SHARE_MAIL', TRUE);
23define ('SHARE_SHAARLI', FALSE); 23define ('SHARE_SHAARLI', FALSE);
24define ('SHAARLI_URL', 'http://myshaarliurl.com'); 24define ('SHAARLI_URL', 'http://myshaarliurl.com');
25define ('FLATTR', TRUE);
26define ('FLATTR_API', 'https://api.flattr.com/rest/v2/things/lookup/?url=');
27define ('NOT_FLATTRABLE', '0');
28define ('FLATTRABLE', '1');
29define ('FLATTRED', '2');
25define ('ABS_PATH', 'assets/'); 30define ('ABS_PATH', 'assets/');
26define ('TPL', __DIR__ . '/../../tpl'); 31define ('TPL', __DIR__ . '/../../tpl');
27define ('LOCALE', __DIR__ . '/../../locale'); 32define ('LOCALE', __DIR__ . '/../../locale');
diff --git a/tpl/css/style-light.css b/tpl/css/style-light.css
index e2788a1c..224ef182 100644
--- a/tpl/css/style-light.css
+++ b/tpl/css/style-light.css
@@ -48,6 +48,10 @@ a.shaarli span {
48 background: url('../img/light/shaarli.png') no-repeat; 48 background: url('../img/light/shaarli.png') no-repeat;
49} 49}
50 50
51a.flattr span {
52 background: url('../img/light/flattr.png');
53}
54
51a.email span { 55a.email span {
52 background: url('../img/light/envelop.png') no-repeat; 56 background: url('../img/light/envelop.png') no-repeat;
53} 57}
diff --git a/tpl/img/light/flattr.png b/tpl/img/light/flattr.png
new file mode 100644
index 00000000..d9007c0c
--- /dev/null
+++ b/tpl/img/light/flattr.png
Binary files differ
diff --git a/tpl/view.twig b/tpl/view.twig
index 28508772..ee16afa6 100644
--- a/tpl/view.twig
+++ b/tpl/view.twig
@@ -11,6 +11,7 @@
11 {% if constant('SHARE_TWITTER') == 1 %}<li><a href="https://twitter.com/home?status={{entry.title|url_encode}}%20{{ entry.url|url_encode }}%20via%20@getpoche" target="_blank" class="tool twitter" title="{% trans "tweet" %}"><span>{% trans "tweet" %}</span></a></li>{% endif %} 11 {% if constant('SHARE_TWITTER') == 1 %}<li><a href="https://twitter.com/home?status={{entry.title|url_encode}}%20{{ entry.url|url_encode }}%20via%20@getpoche" target="_blank" class="tool twitter" title="{% trans "tweet" %}"><span>{% trans "tweet" %}</span></a></li>{% endif %}
12 {% if constant('SHARE_MAIL') == 1 %}<li><a href="mailto:?subject={{ entry.title|url_encode }}&amp;body={{ entry.url|url_encode }}%20via%20@getpoche" class="tool email" title="{% trans "email" %}"><span>{% trans "email" %}</span></a></li>{% endif %} 12 {% if constant('SHARE_MAIL') == 1 %}<li><a href="mailto:?subject={{ entry.title|url_encode }}&amp;body={{ entry.url|url_encode }}%20via%20@getpoche" class="tool email" title="{% trans "email" %}"><span>{% trans "email" %}</span></a></li>{% endif %}
13 {% if constant('SHARE_SHAARLI') == 1 %}<li><a href="{{ constant('SHAARLI_URL') }}/index.php?post={{ entry.url|url_encode }}&amp;title={{ entry.title|url_encode }}" target="_blank" class="tool shaarli" title="{% trans "shaarli" %}"><span>{% trans "shaarli" %}</span></a></li>{% endif %} 13 {% if constant('SHARE_SHAARLI') == 1 %}<li><a href="{{ constant('SHAARLI_URL') }}/index.php?post={{ entry.url|url_encode }}&amp;title={{ entry.title|url_encode }}" target="_blank" class="tool shaarli" title="{% trans "shaarli" %}"><span>{% trans "shaarli" %}</span></a></li>{% endif %}
14 {% if constant('FLATTR') == 1 %}{% if flattr.status == constant('FLATTRABLE') %}<li><a href="http://flattr.com/submit/auto?url={{ entry.url }}" class="tool flattr" target="_blank" title="{% trans "flattr" %}"><span>flattr</span></a></li>{% elseif flattr.status == constant('FLATTRED') %}<li><a href="{{ flattr.flattrItemURL }}" class="tool flattr" target="_blank" title="{% trans "flattr" %}"><span>flattr</span>{{ flattr.numflattrs }}</a></li>{% endif %}{% endif %}
14 </ul> 15 </ul>
15 </div> 16 </div>
16 <header class="mbm"> 17 <header class="mbm">
@@ -31,6 +32,7 @@
31 {% if constant('SHARE_TWITTER') == 1 %}<li><a href="https://twitter.com/home?status={{entry.title|url_encode}}%20{{ entry.url|url_encode }}%20via%20@getpoche" target="_blank" class="tool twitter" title="{% trans "tweet" %}"><span>{% trans "tweet" %}</span></a></li>{% endif %} 32 {% if constant('SHARE_TWITTER') == 1 %}<li><a href="https://twitter.com/home?status={{entry.title|url_encode}}%20{{ entry.url|url_encode }}%20via%20@getpoche" target="_blank" class="tool twitter" title="{% trans "tweet" %}"><span>{% trans "tweet" %}</span></a></li>{% endif %}
32 {% if constant('SHARE_MAIL') == 1 %}<li><a href="mailto:?subject={{ entry.title|url_encode }}&amp;body={{ entry.url|url_encode }}%20via%20@getpoche" class="tool email" title="{% trans "email" %}"><span>{% trans "email" %}</span></a></li>{% endif %} 33 {% if constant('SHARE_MAIL') == 1 %}<li><a href="mailto:?subject={{ entry.title|url_encode }}&amp;body={{ entry.url|url_encode }}%20via%20@getpoche" class="tool email" title="{% trans "email" %}"><span>{% trans "email" %}</span></a></li>{% endif %}
33 {% if constant('SHARE_SHAARLI') == 1 %}<li><a href="{{ constant('SHAARLI_URL') }}/index.php?post={{ entry.url|url_encode }}&amp;title={{ entry.title|url_encode }}" target="_blank" class="tool shaarli" title="{% trans "shaarli" %}"><span>{% trans "shaarli" %}</span></a></li>{% endif %} 34 {% if constant('SHARE_SHAARLI') == 1 %}<li><a href="{{ constant('SHAARLI_URL') }}/index.php?post={{ entry.url|url_encode }}&amp;title={{ entry.title|url_encode }}" target="_blank" class="tool shaarli" title="{% trans "shaarli" %}"><span>{% trans "shaarli" %}</span></a></li>{% endif %}
35 {% if constant('FLATTR') == 1 %}{% if flattr.status == constant('FLATTRABLE') %}<li><a href="http://flattr.com/submit/auto?url={{ entry.url }}" class="tool flattr" target="_blank" title="{% trans "flattr" %}"><span>flattr</span></a></li>{% elseif flattr.status == constant('FLATTRED') %}<li><a href="{{ flattr.flattrItemURL }}" class="tool flattr" target="_blank" title="{% trans "flattr" %}"><span>flattr</span>{{ flattr.numflattrs }}</a></li>{% endif %}{% endif %}
34 </ul> 36 </ul>
35 <p>{% trans "this article appears wrong?" %} <a href="https://github.com/inthepoche/poche/issues/new">{% trans "create an issue" %}</a> {% trans "or" %} <a href="mailto:support@inthepoche.com?subject=Wrong%20display%20in%20poche&amp;body={{ entry.url|url_encode }}">{% trans "contact us by mail" %}</a></p> 37 <p>{% trans "this article appears wrong?" %} <a href="https://github.com/inthepoche/poche/issues/new">{% trans "create an issue" %}</a> {% trans "or" %} <a href="mailto:support@inthepoche.com?subject=Wrong%20display%20in%20poche&amp;body={{ entry.url|url_encode }}">{% trans "contact us by mail" %}</a></p>
36 </div> 38 </div>