diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-04-19 23:52:25 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-04-19 23:52:25 -0300 |
commit | 79be2a1431af533baab0d2be0cbce882ba6a1fd8 (patch) | |
tree | 8ce44e903076e9c19b1b3fc5fad3ccd2bab37713 | |
parent | bc9aa35e8f2f32e6b2537d15eb5cd87ef3bd08f3 (diff) | |
download | semanticscuttle-79be2a1431af533baab0d2be0cbce882ba6a1fd8.tar.gz semanticscuttle-79be2a1431af533baab0d2be0cbce882ba6a1fd8.tar.bz2 |
Cache: Handle PDF links
-rw-r--r-- | data/templates/default/bookmarks.tpl.php | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/data/templates/default/bookmarks.tpl.php b/data/templates/default/bookmarks.tpl.php index a2ff752..818eea0 100644 --- a/data/templates/default/bookmarks.tpl.php +++ b/data/templates/default/bookmarks.tpl.php @@ -344,9 +344,17 @@ if ($currenttag!= '') { // Hashing discussion at http://linuxprocess.free.fr/MHonArc/Oct-2005/msg00016.html $assetHash = sha1($row['bAddress'] . "\n"); $assetHash = substr($assetHash, 0, 2) . '/' . substr($assetHash, 2, 2) . '/' . $assetHash; - $assetLink = $GLOBALS['cacheUrl'] . '/' . $assetHash; - $assetPdf = $assetLink .'/screenshot.pdf'; - $assetPng = $assetLink .'/screenshot.png'; + $assetBase = $GLOBALS['cacheUrl'] . '/' . $assetHash; + $assetLink = $assetBase; + $assetPdf = $assetBase.'/screenshot.pdf'; + $assetPng = $assetBase .'/screenshot.png'; + + // Handle PDF links + $assetFile = basename(parse_url($row['bAddress'])['path']); + $assetExt = strtolower(pathinfo($assetFile, PATHINFO_EXTENSION)); + if ($assetExt == 'pdf') { + $assetLink = $GLOBALS['cacheUrl'] . '/' . $assetHash . '/' . $assetFile; + } // Check if the link exists if (file_exists($cacheInfo .'/'. $assetHash .'/hascache')) { @@ -360,7 +368,7 @@ if ($currenttag!= '') { $cacheLink .= " | <a href=\"$assetPng\">PNG</a>"; } } - else if ($fp = curl_init($assetLink)) { + else if ($fp = curl_init($assetBase)) { curl_setopt($fp, CURLOPT_NOBODY, true); curl_exec($fp); |