open graph support for shaarli (proper indent)
This commit is contained in:
parent
0fd2c4faff
commit
766c0f7ae1
1 changed files with 38 additions and 32 deletions
|
@ -1,6 +1,6 @@
|
||||||
--- Shaarli/index.php 2017-01-20 16:47:36.000000000 +0100
|
--- /root/Shaarli/index.php 2017-01-20 16:47:36.000000000 +0100
|
||||||
+++ Shaarli.0.8.3/index.php 2017-02-11 15:37:50.327954000 +0100
|
+++ index.php 2017-02-11 18:19:24.618226000 +0100
|
||||||
@@ -1821,10 +1821,13 @@
|
@@ -1821,11 +1821,16 @@
|
||||||
$path = parse_url($url,PHP_URL_PATH);
|
$path = parse_url($url,PHP_URL_PATH);
|
||||||
if ("/talks/" !== substr($path,0,7)) return array(); // This is not a single video URL.
|
if ("/talks/" !== substr($path,0,7)) return array(); // This is not a single video URL.
|
||||||
}
|
}
|
||||||
|
@ -9,14 +9,18 @@
|
||||||
- return array('src'=>index_url($_SERVER).'?do=genthumbnail&hmac='.$sign.'&url='.urlencode($url),
|
- return array('src'=>index_url($_SERVER).'?do=genthumbnail&hmac='.$sign.'&url='.urlencode($url),
|
||||||
+ $thumbname=hash('sha1',$url).'.gif';
|
+ $thumbname=hash('sha1',$url).'.gif';
|
||||||
+ $filepath = $conf->get('resource.thumbnails_cache').'/'.$thumbname;
|
+ $filepath = $conf->get('resource.thumbnails_cache').'/'.$thumbname;
|
||||||
|
+ //echo sha1_file($filepath);
|
||||||
|
+ //echo $filepath;
|
||||||
+ if (sha1_file($filepath) != '48d45d7ada69f9f858849bbd6e459f66c9694ee7')
|
+ if (sha1_file($filepath) != '48d45d7ada69f9f858849bbd6e459f66c9694ee7')
|
||||||
+ return array('src'=>index_url($_SERVER).'?do=genthumbnail&hmac='.$sign.'&url='.urlencode($url),
|
+ return array('src'=>index_url($_SERVER).'?do=genthumbnail&hmac='.$sign.'&url='.urlencode($url),
|
||||||
'href'=>$href,'width'=>'120','style'=>'height:auto;','alt'=>'thumbnail');
|
'href'=>$href,'width'=>'120','style'=>'height:auto;','alt'=>'thumbnail');
|
||||||
- }
|
- }
|
||||||
|
-
|
||||||
|
+
|
||||||
// For all other, we try to make a thumbnail of links ending with .jpg/jpeg/png/gif
|
// For all other, we try to make a thumbnail of links ending with .jpg/jpeg/png/gif
|
||||||
// Technically speaking, we should download ALL links and check their Content-Type to see if they are images.
|
// Technically speaking, we should download ALL links and check their Content-Type to see if they are images.
|
||||||
@@ -2154,18 +2157,32 @@
|
// But using the extension will do.
|
||||||
|
@@ -2154,19 +2159,33 @@
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// For all other domains, we try to download the image and make a thumbnail.
|
// For all other domains, we try to download the image and make a thumbnail.
|
||||||
|
@ -32,8 +36,9 @@
|
||||||
- echo file_get_contents($filepath);
|
- echo file_get_contents($filepath);
|
||||||
- return;
|
- return;
|
||||||
- }
|
- }
|
||||||
+ list($httpstatus,$headers,$data) = get_http_response($url,30); // We allow 30 seconds max to download (and downloads are limited to 4 Mb)
|
- }
|
||||||
+ if (strpos($httpstatus,'200 OK')!==false)
|
+ list($headers, $content) = get_http_response($url,30); // We allow 30 seconds max to download (and downloads are limited to 4 Mb)
|
||||||
|
+ if (strpos($headers[0], '200 OK') !== false)
|
||||||
+ {
|
+ {
|
||||||
+ // Extract the link to the thumbnail
|
+ // Extract the link to the thumbnail
|
||||||
+ $doc = new DOMDocument();
|
+ $doc = new DOMDocument();
|
||||||
|
@ -46,7 +51,7 @@
|
||||||
+ if (!empty($imageurl))
|
+ if (!empty($imageurl))
|
||||||
+ { // Let's download the image.
|
+ { // Let's download the image.
|
||||||
+ list($headers, $content) = get_http_response($imageurl, 20);
|
+ list($headers, $content) = get_http_response($imageurl, 20);
|
||||||
+ if (strpos($httpstatus,'200 OK')!==false)
|
+ if (strpos($headers[0], '200 OK') !== false)
|
||||||
+ {
|
+ {
|
||||||
+ $filepath = $conf->get('resource.thumbnails_cache').'/'.$thumbname;
|
+ $filepath = $conf->get('resource.thumbnails_cache').'/'.$thumbname;
|
||||||
+ file_put_contents($filepath,$content); // Save image to cache.
|
+ file_put_contents($filepath,$content); // Save image to cache.
|
||||||
|
@ -58,6 +63,7 @@
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
}
|
+ }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue