From 84c085dcd7c88fbea1f143f0ee3029685617afe9 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 31 May 2015 22:16:14 -0700 Subject: bare bones ASLD --- include/items.php | 48 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index a04cd1c76..bb7d9e28c 100755 --- a/include/items.php +++ b/include/items.php @@ -4884,6 +4884,17 @@ function comment_local_origin($item) { } +function gen_asld($items) { + $ret = array(); + if(! $items) + return $ret; + foreach($items as $item) { + $ret[] = i2asld($item); + } + return $ret; +} + + function i2asld($i) { if(! $i) @@ -4896,25 +4907,54 @@ function i2asld($i) { $ret['@type'] = ucfirst(basename($i['verb'])); } $ret['@id'] = $i['plink']; + $ret['published'] = datetime_convert('UTC','UTC',$i['created'],ATOM_TIME); - if($i['title']) - $ret['title'] = $i['title']; - $ret['content'] = bbcode($i['body']); + + if($i['obj_type'] === ACTIVITY_OBJ_NOTE) + $ret['object'] = asencode_note($i); + $ret['actor'] = asencode_person($i['author']); - $ret['owner'] = asencode_person($i['owner']); return $ret; } +function asencode_note($i) { + + $ret = array(); + + $ret['@type'] = 'Note'; + $ret['@id'] = $i['plink']; + $ret['@context'] = array('zot' => 'http://purl.org/zot/protocol'); + if($i['title']) + $ret['title'] = bbcode($i['title']); + $ret['content'] = bbcode($i['body']); + $ret['zot:owner'] = asencode_person($i['owner']); + $ret['published'] = datetime_convert('UTC','UTC',$i['created'],ATOM_TIME); + if($i['created'] !== $i['edited']) + $ret['updated'] = datetime_convert('UTC','UTC',$i['edited'],ATOM_TIME); + + return $ret; +} + function asencode_person($p) { $ret = array(); $ret['@type'] = 'Person'; $ret['@id'] = 'acct:' . $p['xchan_addr']; $ret['displayName'] = $p['xchan_name']; + $ret['icon'] = array( + '@type' => 'Link', + 'mediaType' => $p['xchan_photo_mimetype'], + 'href' => $p['xchan_photo_m'] + ); + $ret['url'] = array( + '@type' => 'Link', + 'mediaType' => 'text/html', + 'href' => $p['xchan_url'] + ); return $ret; } \ No newline at end of file -- cgit v1.2.3 From c1e139a550e864117ec092a38b47755ffcf46475 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 31 May 2015 22:22:37 -0700 Subject: error in directory bbcode image filter --- include/bbcode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index e2403b8eb..e248c3771 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -968,5 +968,5 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true) { function strip_bbimage($s) { - $Text = preg_replace("/\[[zi]mg(.*?)\](.*?)\[\/[zi]mg\]/ism", '', $Text); + return preg_replace("/\[[zi]mg(.*?)\](.*?)\[\/[zi]mg\]/ism", '', $s); } -- cgit v1.2.3 From b2fde73952c8de7cf8e746ed674770c1dcf6032b Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 2 Jun 2015 17:46:22 -0700 Subject: asjld work --- include/items.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index bb7d9e28c..47a2e6c18 100755 --- a/include/items.php +++ b/include/items.php @@ -4902,14 +4902,25 @@ function i2asld($i) { $ret = array(); + $ret['@context'] = array( 'http://www.w3.org/ns/activitystreams', 'zot' => 'http://purl.org/zot/protocol'); + if($i['verb']) { - $ret['@context'] = dirname($i['verb']); - $ret['@type'] = ucfirst(basename($i['verb'])); + if(strpos(dirname($i['verb'],'activitystrea.ms/schema/1.0'))) { + $ret['@type'] = ucfirst(basename($i['verb'])); + } + elseif(strpos(dirname($i['verb'],'purl.org/zot'))) { + $ret['@type'] = 'zot:' . ucfirst(basename($i['verb'])); + } } $ret['@id'] = $i['plink']; $ret['published'] = datetime_convert('UTC','UTC',$i['created'],ATOM_TIME); + // we need to pass the parent into this +// if($i['id'] != $i['parent'] && $i['obj_type'] === ACTIVITY_OBJ_NOTE) { +// $ret['inReplyTo'] = asencode_note +// } + if($i['obj_type'] === ACTIVITY_OBJ_NOTE) $ret['object'] = asencode_note($i); @@ -4927,7 +4938,6 @@ function asencode_note($i) { $ret['@type'] = 'Note'; $ret['@id'] = $i['plink']; - $ret['@context'] = array('zot' => 'http://purl.org/zot/protocol'); if($i['title']) $ret['title'] = bbcode($i['title']); $ret['content'] = bbcode($i['body']); -- cgit v1.2.3