aboutsummaryrefslogtreecommitdiff
path: root/data/templates
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-03-25 22:08:01 -0300
committerSilvio Rhatto <rhatto@riseup.net>2017-03-25 22:08:01 -0300
commitde24e70ae17850b12ff8ac69439da86bb6d77d74 (patch)
treef329869c7aebbeef353b3d122fd3ce1dde060275 /data/templates
parent153bf795eb756fdd92583ccd4d2485640085015d (diff)
downloadsemanticscuttle-de24e70ae17850b12ff8ac69439da86bb6d77d74.tar.gz
semanticscuttle-de24e70ae17850b12ff8ac69439da86bb6d77d74.tar.bz2
Cache cacheUrl information to avoid slowness due to excessive curls calls
Diffstat (limited to 'data/templates')
-rw-r--r--data/templates/default/bookmarks.tpl.php21
1 files changed, 20 insertions, 1 deletions
diff --git a/data/templates/default/bookmarks.tpl.php b/data/templates/default/bookmarks.tpl.php
index 4f22e91..6b8a7c7 100644
--- a/data/templates/default/bookmarks.tpl.php
+++ b/data/templates/default/bookmarks.tpl.php
@@ -338,6 +338,7 @@ if ($currenttag!= '') {
}
// Local cache
+ $cacheInfo = $GLOBALS['dir_cache'] .'/urls';
$cacheLink = null;
if ($GLOBALS['cacheUrl'] != null) {
// Hashing discussion at http://linuxprocess.free.fr/MHonArc/Oct-2005/msg00016.html
@@ -348,13 +349,29 @@ if ($currenttag!= '') {
$assetPng = $assetLink .'/screenshot.png';
// Check if the link exists
- if ($fp = curl_init($assetLink)) {
+ if (file_exists($cacheInfo .'/' $assetHash .'/hascache')) {
+ $cacheLink = "| <a href=\"$assetLink\">Cache</a>";
+
+ if (file_exists($cacheInfo .'/' $assetHash .'/haspdf')) {
+ $cacheLink .= " | <a href=\"$assetPdf\">PDF</a>";
+ }
+
+ if (file_exists($cacheInfo .'/' $assetHash .'/haspng')) {
+ $cacheLink .= " | <a href=\"$assetPng\">PNG</a>";
+ }
+ }
+ else if ($fp = curl_init($assetLink)) {
curl_setopt($fp, CURLOPT_NOBODY, true);
curl_exec($fp);
$retcode = curl_getinfo($fp, CURLINFO_HTTP_CODE);
if ($retcode != 404) {
+ if (!file_exists($cacheInfo .'/' $assetHash)) {
+ mkdir($cacheInfo .'/' $assetHash);
+ }
+
+ touch($cacheInfo .'/' $assetHash .'/hascache');
$cacheLink = "| <a href=\"$assetLink\">Cache</a>";
// Check if PDF is available
@@ -365,6 +382,7 @@ if ($currenttag!= '') {
$retcode = curl_getinfo($fp, CURLINFO_HTTP_CODE);
if ($retcode != 404) {
+ touch($cacheInfo .'/' $assetHash .'/haspdf');
$cacheLink .= " | <a href=\"$assetPdf\">PDF</a>";
}
@@ -379,6 +397,7 @@ if ($currenttag!= '') {
$retcode = curl_getinfo($fp, CURLINFO_HTTP_CODE);
if ($retcode != 404) {
+ touch($cacheInfo .'/' $assetHash .'/haspng');
$cacheLink .= " | <a href=\"$assetPng\">PNG</a>";
}