From 4aa06023f0c25a10d5eaeafaeb30034e0a4f2e95 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Mon, 19 Dec 2016 10:39:23 -0800 Subject: 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 --- lib/helpers.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'lib/helpers.php') 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; +} + -- cgit v1.2.3