aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-04-29 11:58:59 +0200
committerMario <mario@mariovavti.com>2019-04-29 11:58:59 +0200
commit674215e9e6632ac22a1b87f9996f0323f5949d94 (patch)
tree152c71c2b99c337ec3ca35d9644a6fe4ec9ff5a4
parentdce6a5763d925e6bf70c6a293be079a05269ce36 (diff)
parentd89d6e8a01ef9af0d300c192367445c385e0252b (diff)
downloadvolse-hubzilla-674215e9e6632ac22a1b87f9996f0323f5949d94.tar.gz
volse-hubzilla-674215e9e6632ac22a1b87f9996f0323f5949d94.tar.bz2
volse-hubzilla-674215e9e6632ac22a1b87f9996f0323f5949d94.zip
Merge branch 'dev' into 'dev'
Add jot videos inline and with poster if possible See merge request hubzilla/core!1613
-rw-r--r--Zotlabs/Lib/Activity.php11
-rw-r--r--Zotlabs/Module/Linkinfo.php45
-rw-r--r--Zotlabs/Module/Poster.php37
-rw-r--r--Zotlabs/Module/Wall_attach.php21
4 files changed, 109 insertions, 5 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 5c3002837..9df7db169 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -195,6 +195,13 @@ class Activity {
if(! $ev['nofinish']) {
$y['endTime'] = (($ev['adjust']) ? datetime_convert('UTC','UTC',$ev['dtend'], ATOM_TIME) : datetime_convert('UTC','UTC',$ev['dtend'],'Y-m-d\\TH:i:s-00:00'));
}
+
+ // copy attachments from the passed object - these are already formatted for ActivityStreams
+
+ if($x['attachment']) {
+ $y['attachment'] = $x['attachment'];
+ }
+
if($actor) {
return $y;
}
@@ -404,7 +411,7 @@ class Activity {
$ret = [];
if($item['attach']) {
- $atts = json_decode($item['attach'],true);
+ $atts = ((is_array($item['attach'])) ? $item['attach'] : json_decode($item['attach'],true));
if($atts) {
foreach($atts as $att) {
if(strpos($att['type'],'image')) {
@@ -416,7 +423,7 @@ class Activity {
}
}
}
-
+
return $ret;
}
diff --git a/Zotlabs/Module/Linkinfo.php b/Zotlabs/Module/Linkinfo.php
index 32b4c0281..b9f90deec 100644
--- a/Zotlabs/Module/Linkinfo.php
+++ b/Zotlabs/Module/Linkinfo.php
@@ -69,6 +69,14 @@ class Linkinfo extends \Zotlabs\Web\Controller {
killme();
}
if(stripos($type,'video/') !== false) {
+ $thumb = self::get_video_poster($url);
+ if($thumb) {
+ if ($zrl)
+ echo $br . '[zvideo poster=\'' . $thumb . '\']' . $url . '[/zvideo]' . $br;
+ else
+ echo $br . '[video poster=\'' . $thumb . '\']' . $url . '[/video]' . $br;
+ killme();
+ }
if($zrl)
echo $br . '[zvideo]' . $url . '[/zvideo]' . $br;
else
@@ -216,7 +224,42 @@ class Linkinfo extends \Zotlabs\Web\Controller {
return($complete);
}
-
+
+ public static function get_video_poster($url) {
+
+ if(strpos($url,z_root() . '/cloud/') === false) {
+ return EMPTY_STR;
+ }
+ $m = parse_url($url,PHP_URL_PATH);
+ if($m) {
+ // strip leading '/cloud/'
+ $m = substr($m,7);
+ }
+ $nick = substr($m,0,strpos($m,'/'));
+ $p = substr($m,strpos($m,'/')+1);
+
+ // get the channel to check permissions
+
+ $u = channelx_by_nick($nick);
+
+ if($u && $p) {
+
+ $sql_extra = permissions_sql(intval($u['channel_id']));
+
+ $r = q("select hash, content from attach where display_path = '%s' and uid = %d and os_storage = 1 $sql_extra limit 1",
+ dbesc($p),
+ intval($u['channel_id'])
+ );
+ if($r) {
+ $path = dbunescbin($r[0]['content']);
+ if($path && @file_exists($path . '.thumb')) {
+ return z_root() . '/poster/' . $nick . '/' . $r[0]['hash'];
+ }
+ }
+ }
+ return EMPTY_STR;
+ }
+
public static function parseurl_getsiteinfo($url) {
$siteinfo = array();
diff --git a/Zotlabs/Module/Poster.php b/Zotlabs/Module/Poster.php
new file mode 100644
index 000000000..10317ee61
--- /dev/null
+++ b/Zotlabs/Module/Poster.php
@@ -0,0 +1,37 @@
+<?php
+
+namespace Zotlabs\Module;
+
+use Zotlabs\Web\Controller;
+
+require_once('include/security.php');
+
+class Poster extends Controller {
+
+ function init() {
+
+ $nick = argv(1);
+ $hash = argv(2);
+
+ if(! ($nick && $hash)) {
+ return;
+ }
+
+ $u = channelx_by_nick($nick);
+
+ $sql_extra = permissions_sql(intval($u['channel_id']));
+
+ $r = q("select content from attach where hash = '%s' and uid = %d and os_storage = 1 $sql_extra limit 1",
+ dbesc($hash),
+ intval($u['channel_id'])
+ );
+ if($r) {
+ $path = dbunescbin($r[0]['content']);
+ if($path && @file_exists($path . '.thumb')) {
+ header('Content-Type: image/jpeg');
+ echo file_get_contents($path . '.thumb');
+ killme();
+ }
+ }
+ }
+}
diff --git a/Zotlabs/Module/Wall_attach.php b/Zotlabs/Module/Wall_attach.php
index 2250e6e44..0ede3ad90 100644
--- a/Zotlabs/Module/Wall_attach.php
+++ b/Zotlabs/Module/Wall_attach.php
@@ -96,9 +96,26 @@ class Wall_attach extends \Zotlabs\Web\Controller {
$s = "\n\n" . $r['body'] . "\n\n";
}
else {
- $s = "\n\n" . '[attachment]' . $r['data']['hash'] . ',' . $r['data']['revision'] . '[/attachment]' . "\n";
+ if(strpos($r['data']['filetype'],'video') === 0) {
+ // give a wee bit of time for the background thumbnail processor to do its thing
+ // or else we'll never see a video poster
+ sleep(3);
+ $url = z_root() . '/cloud/' . $channel['channel_address'] . '/' . $r['data']['display_path'];
+ $thumb = Linkinfo::get_video_poster($url);
+ if($thumb) {
+ $s = "\n\n" . '[zvideo poster=\'' . $thumb . '\']' . $url . '[/zvideo]' . "\n\n";
+ }
+ else {
+ $s = "\n\n" . '[zvideo]' . $url . '[/zvideo]' . "\n\n";
+ }
+ }
+ if(strpos($r['data']['filetype'],'audio') === 0) {
+ $url = z_root() . '/cloud/' . $channel['channel_address'] . '/' . $r['data']['display_path'];
+ echo "\n\n" . '[zaudio]' . $url . '[/zaudio]' . "\n\n";
+ }
+
+ $s .= "\n\n" . '[attachment]' . $r['data']['hash'] . ',' . $r['data']['revision'] . '[/attachment]' . "\n";
}
-
$sync = attach_export_data($channel,$r['data']['hash']);
if($sync) {