summaryrefslogtreecommitdiff
path: root/lib/helpers.php
diff options
context:
space:
mode:
authorAaron Parecki <aaron@parecki.com>2016-12-19 10:39:23 -0800
committerAaron Parecki <aaron@parecki.com>2016-12-19 10:39:23 -0800
commit4aa06023f0c25a10d5eaeafaeb30034e0a4f2e95 (patch)
treee4a694fad5254166d01934aed9f344fc2903a2df /lib/helpers.php
parent53964f2622828bc5b67546dbc24bb455e4d165cb (diff)
clean up note UI, show reply context
* shows reply context of the URL you're replying to * autocomplete nicknames from the post when replying * moved debug info to the settings screen to clean up the UI
Diffstat (limited to 'lib/helpers.php')
-rw-r--r--lib/helpers.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/helpers.php b/lib/helpers.php
index 3a71d90..8948f92 100644
--- a/lib/helpers.php
+++ b/lib/helpers.php
@@ -396,3 +396,46 @@ function correct_photo_rotation($filename) {
}
}
+function tweet_to_h_entry($tweet) {
+ // Converts to XRay's h-entry format
+
+ $entry = [
+ 'type' => 'entry',
+ 'url' => 'https://twitter.com/'.$tweet->user->screen_name.'/status/'.$tweet->id_str,
+ ];
+
+ $published = strtotime($tweet->created_at);
+ $entry['published'] = date('c', $published);
+
+ $entry['content'] = [
+ 'text' => $tweet->text
+ ];
+
+ if($tweet->entities->urls) {
+ foreach($tweet->entities->urls as $url) {
+ $entry['content']['text'] = str_replace($url->url, $url->expanded_url, $entry['content']['text']);
+ }
+ }
+
+ $entry['author'] = [
+ 'type' => 'card',
+ 'url' => 'https://twitter.com/'.$tweet->user->screen_name,
+ 'name' => $tweet->user->name,
+ 'nickname' => $tweet->user->screen_name,
+ 'photo' => $tweet->user->profile_image_url_https
+ ];
+
+ if($tweet->user->url) {
+ $entry['author']['url'] = $tweet->user->entities->url->urls[0]->expanded_url;
+ }
+
+ if($tweet->entities->hashtags) {
+ $entry['category'] = [];
+ foreach($tweet->entities->hashtags as $tag) {
+ $entry['category'][] = $tag->text;
+ }
+ }
+
+ return $entry;
+}
+