From a96d6f835ca5325f1d54db8246e900f8bc85bf99 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 27 Dec 2013 01:48:43 +0100 Subject: [PATCH 1/2] API: Supporting twidere --- include/api.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/api.php b/include/api.php index f133d2ad6..72c65f35d 100644 --- a/include/api.php +++ b/include/api.php @@ -331,16 +331,18 @@ 'location' => NULL, 'description' => NULL, 'profile_image_url' => $r[0]["avatar"], + 'profile_image_url_https' => $r[0]["avatar"], 'url' => $r[0]["url"], 'protected' => false, 'followers_count' => 0, 'friends_count' => 0, - 'created_at' => '', + 'created_at' => api_date(0), 'favourites_count' => 0, 'utc_offset' => 0, 'time_zone' => 'UTC', 'statuses_count' => 0, - 'following' => 1, + 'following' => false, + 'verified' => false, 'statusnet_blocking' => false, 'notifications' => false, 'statusnet_profile_url' => $r[0]["url"], @@ -430,6 +432,7 @@ 'location' => ($usr) ? $usr[0]['default-location'] : NULL, 'description' => (($profile) ? $profile[0]['pdesc'] : NULL), 'profile_image_url' => $uinfo[0]['micro'], + 'profile_image_url_https' => $uinfo[0]['micro'], 'url' => $uinfo[0]['url'], 'protected' => false, 'followers_count' => intval($countfollowers), From 4b0e370c4c2ec606833aa326fba49922a7c470ab Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 27 Dec 2013 01:58:21 +0100 Subject: [PATCH 2/2] Better handling of the network field in the item table. --- include/diaspora.php | 15 ++++-- include/ostatus_conversation.php | 1 + include/plugin.php | 6 +-- mod/display.php | 4 +- mod/item.php | 40 +++++++++----- mod/network.php | 8 +-- mod/profile.php | 8 +-- object/Item.php | 4 +- view/theme/vier/style.css | 20 +++++-- view/theme/vier/templates/wall_thread.tpl | 3 ++ view/theme/vier/theme.php | 65 +++++++---------------- 11 files changed, 92 insertions(+), 82 deletions(-) diff --git a/include/diaspora.php b/include/diaspora.php index abc518cd5..f40566267 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -642,7 +642,7 @@ function diaspora_request($importer,$xml) { return; } - + $ret = find_diaspora_person_by_handle($sender_handle); @@ -868,6 +868,7 @@ function diaspora_post($importer,$xml,$msg) { $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $contact['id']; $datarray['wall'] = 0; + $datarray['network'] = NETWORK_DIASPORA; $datarray['guid'] = $guid; $datarray['uri'] = $datarray['parent-uri'] = $message_id; $datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created); @@ -1032,6 +1033,7 @@ function diaspora_reshare($importer,$xml,$msg) { $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $contact['id']; $datarray['wall'] = 0; + $datarray['network'] = NETWORK_DIASPORA; $datarray['guid'] = $guid; $datarray['uri'] = $datarray['parent-uri'] = $message_id; $datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created); @@ -1136,10 +1138,11 @@ function diaspora_asphoto($importer,$xml,$msg) { $datarray = array(); - + $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $contact['id']; $datarray['wall'] = 0; + $datarray['network'] = NETWORK_DIASPORA; $datarray['guid'] = $guid; $datarray['uri'] = $datarray['parent-uri'] = $message_id; $datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created); @@ -1153,7 +1156,7 @@ function diaspora_asphoto($importer,$xml,$msg) { $datarray['author-link'] = $contact['url']; $datarray['author-avatar'] = $contact['thumb']; $datarray['body'] = $body; - + $datarray['app'] = 'Diaspora/Cubbi.es'; $message_id = item_store($datarray); @@ -1312,6 +1315,7 @@ function diaspora_comment($importer,$xml,$msg) { $datarray['contact-id'] = $contact['id']; $datarray['type'] = 'remote-comment'; $datarray['wall'] = $parent_item['wall']; + $datarray['network'] = NETWORK_DIASPORA; $datarray['gravity'] = GRAVITY_COMMENT; $datarray['guid'] = $guid; $datarray['uri'] = $message_id; @@ -1332,7 +1336,7 @@ function diaspora_comment($importer,$xml,$msg) { $datarray['tag'] = $str_tags; // We can't be certain what the original app is if the message is relayed. - if(($parent_item['origin']) && (! $parent_author_signature)) + if(($parent_item['origin']) && (! $parent_author_signature)) $datarray['app'] = 'Diaspora'; $message_id = item_store($datarray); @@ -1894,6 +1898,7 @@ EOT; $arr['uri'] = $uri; $arr['uid'] = $importer['uid']; $arr['guid'] = $guid; + $arr['network'] = NETWORK_DIASPORA; $arr['contact-id'] = $contact['id']; $arr['type'] = 'activity'; $arr['wall'] = $parent_item['wall']; @@ -1909,7 +1914,7 @@ EOT; $arr['author-name'] = $person['name']; $arr['author-link'] = $person['url']; $arr['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']); - + $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]'; $alink = '[url=' . $parent_item['author-link'] . ']' . $parent_item['author-name'] . '[/url]'; $plink = '[url=' . $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $parent_item['id'] . ']' . $post_type . '[/url]'; diff --git a/include/ostatus_conversation.php b/include/ostatus_conversation.php index 1185c01f9..65c0d6787 100644 --- a/include/ostatus_conversation.php +++ b/include/ostatus_conversation.php @@ -146,6 +146,7 @@ function complete_conversation($itemid, $conversation_url, $only_add_conversatio } $arr = array(); + $arr["network"] = NETWORK_OSTATUS; $arr["uri"] = $single_conv->id; $arr["plink"] = $single_conv->id; $arr["uid"] = $message["uid"]; diff --git a/include/plugin.php b/include/plugin.php index 9002c7bce..32962cd0c 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -328,10 +328,10 @@ function get_theme_info($theme){ $info[$k]=$v; } } - + } } - + } return $info; }} @@ -351,7 +351,7 @@ function get_theme_screenshot($theme) { if (! function_exists('uninstall_theme')){ function uninstall_theme($theme){ logger("Addons: uninstalling theme " . $theme); - + @include_once("view/theme/$theme/theme.php"); if(function_exists("{$theme}_uninstall")) { $func = "{$theme}_uninstall"; diff --git a/mod/display.php b/mod/display.php index 538dc6454..efae937e1 100644 --- a/mod/display.php +++ b/mod/display.php @@ -134,7 +134,7 @@ function display_content(&$a, $update = 0) { return ''; } - $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, + $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` @@ -163,7 +163,7 @@ function display_content(&$a, $update = 0) { if($r) { $item_uri = $r[0]['uri']; - $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, + $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` diff --git a/mod/item.php b/mod/item.php index 14acc5d0f..805701dc3 100644 --- a/mod/item.php +++ b/mod/item.php @@ -3,17 +3,17 @@ /** * * This is the POST destination for most all locally posted - * text stuff. This function handles status, wall-to-wall status, - * local comments, and remote coments that are posted on this site + * text stuff. This function handles status, wall-to-wall status, + * local comments, and remote coments that are posted on this site * (as opposed to being delivered in a feed). - * Also processed here are posts and comments coming through the - * statusnet/twitter API. - * All of these become an "item" which is our basic unit of + * Also processed here are posts and comments coming through the + * statusnet/twitter API. + * All of these become an "item" which is our basic unit of * information. - * Posts that originate externally or do not fall into the above - * posting categories go through item_store() instead of this function. + * Posts that originate externally or do not fall into the above + * posting categories go through item_store() instead of this function. * - */ + */ require_once('include/crypto.php'); require_once('include/enotify.php'); @@ -200,6 +200,7 @@ function item_post(&$a) { $body = escape_tags(trim($_REQUEST['body'])); $private = $orig_post['private']; $pubmail_enable = $orig_post['pubmail']; + $network = $orig_post['network']; } else { @@ -234,6 +235,7 @@ function item_post(&$a) { $verb = notags(trim($_REQUEST['verb'])); $emailcc = notags(trim($_REQUEST['emailcc'])); $body = escape_tags(trim($_REQUEST['body'])); + $network = notags(trim($_REQUEST['network'])); $naked_body = preg_replace('/\[(.+?)\]/','',$body); @@ -275,6 +277,12 @@ function item_post(&$a) { if($parent_item) { $private = 0; + // for non native networks use the network of the original post as network of the item + if (($parent_item['network'] != NETWORK_DIASPORA) + AND ($parent_item['network'] != NETWORK_OSTATUS) + AND ($network == "")) + $network = $parent_item['network']; + if(($parent_item['private']) || strlen($parent_item['allow_cid']) || strlen($parent_item['allow_gid']) @@ -288,7 +296,6 @@ function item_post(&$a) { $str_contact_deny = $parent_item['deny_cid']; $str_group_deny = $parent_item['deny_gid']; } - $pubmail_enable = ((x($_REQUEST,'pubmail_enable') && intval($_REQUEST['pubmail_enable']) && (! $private)) ? 1 : 0); // if using the API, we won't see pubmail_enable - figure out if it should be set @@ -519,7 +526,7 @@ function item_post(&$a) { && ($parent_contact['nick']) && (! in_array('@' . $parent_contact['nick'],$tags))) { $body = '@' . $parent_contact['nick'] . ' ' . $body; $tags[] = '@' . $parent_contact['nick']; - } + } $tagged = array(); @@ -584,13 +591,16 @@ function item_post(&$a) { if(! strlen($verb)) $verb = ACTIVITY_POST ; + if ($network == "") + $network = NETWORK_DFRN; + $gravity = (($parent) ? 6 : 0 ); // even if the post arrived via API we are considering that it // originated on this site by default for determining relayability. $origin = ((x($_REQUEST,'origin')) ? intval($_REQUEST['origin']) : 1); - + $notify_type = (($parent) ? 'comment-new' : 'wall-new' ); $uri = (($message_id) ? $message_id : item_new_uri($a->get_hostname(),$profile_uid)); @@ -604,6 +614,7 @@ function item_post(&$a) { $datarray['type'] = $post_type; $datarray['wall'] = $wall; $datarray['gravity'] = $gravity; + $datarray['network'] = $network; $datarray['contact-id'] = $contact_id; $datarray['owner-name'] = $contact_record['name']; $datarray['owner-link'] = $contact_record['url']; @@ -709,15 +720,16 @@ function item_post(&$a) { $post_id = 0; - $r = q("INSERT INTO `item` (`guid`, `uid`,`type`,`wall`,`gravity`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`, + $r = q("INSERT INTO `item` (`guid`, `uid`,`type`,`wall`,`gravity`, `network`, `contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `author-name`, `author-link`, `author-avatar`, `created`, `edited`, `commented`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`, `tag`, `inform`, `verb`, `postopts`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach`, `bookmark`,`origin`, `moderated`, `file` ) - VALUES( '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s' )", + VALUES( '%s', %d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s' )", dbesc($datarray['guid']), intval($datarray['uid']), dbesc($datarray['type']), intval($datarray['wall']), intval($datarray['gravity']), + dbesc($datarray['network']), intval($datarray['contact-id']), dbesc($datarray['owner-name']), dbesc($datarray['owner-link']), @@ -1103,7 +1115,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) { if(count($r)) { $profile = $r[0]['url']; //set newname to nick, find alias - if($r[0]['network'] === 'stat') { + if(($r[0]['network'] === NETWORK_OSTATUS) OR ($r[0]['network'] === NETWORK_TWITTER)) { $newname = $r[0]['nick']; $stat = true; if($r[0]['alias']) diff --git a/mod/network.php b/mod/network.php index de5e45e6e..a8faeb459 100644 --- a/mod/network.php +++ b/mod/network.php @@ -746,7 +746,7 @@ function network_content(&$a, $update = 0) { if($nouveau) { // "New Item View" - show all items unthreaded in reverse created date order - $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, + $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` @@ -786,7 +786,7 @@ function network_content(&$a, $update = 0) { // Fetch a page full of parent items for this page if($update) { - $r = q("SELECT `item`.`parent` AS `item_id`, `contact`.`uid` AS `contact_uid` + $r = q("SELECT `item`.`parent` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid` FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND (`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."' OR item.verb = '" . ACTIVITY_DISLIKE . "') @@ -797,7 +797,7 @@ function network_content(&$a, $update = 0) { ); } else { - $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact_uid` + $r = q("SELECT `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid` FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 AND `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 @@ -832,7 +832,7 @@ function network_content(&$a, $update = 0) { foreach ($parents_arr AS $parents_str) { - $thread_items = q("SELECT `item`.*, `item`.`id` AS `item_id`, + $thread_items = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`writable`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` diff --git a/mod/profile.php b/mod/profile.php index f0f5d3623..28e93b294 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -217,7 +217,8 @@ function profile_content(&$a, $update = 0) { if($update) { - $r = q("SELECT distinct(parent) AS `item_id`, `contact`.`uid` AS `contact-uid` + $r = q("SELECT distinct(parent) AS `item_id`, `item`.`network` AS `item_network`, + `contact`.`uid` AS `contact-uid` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND (`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."' OR item.verb = '" . ACTIVITY_DISLIKE . "') @@ -278,7 +279,8 @@ function profile_content(&$a, $update = 0) { // FROM `item` FORCE INDEX (created, uid) LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` - $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact-uid` + $r = q("SELECT `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, + `contact`.`uid` AS `contact-uid` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 @@ -299,7 +301,7 @@ function profile_content(&$a, $update = 0) { $parents_arr[] = $rr['item_id']; $parents_str = implode(', ', $parents_arr); - $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, + $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`network`, `contact`.`rel`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` diff --git a/object/Item.php b/object/Item.php index 0a793e5f3..9003c93c1 100644 --- a/object/Item.php +++ b/object/Item.php @@ -322,7 +322,9 @@ class Item extends BaseObject { 'wait' => t('Please wait'), 'thread_level' => $thread_level, 'postopts' => $langstr, - 'edited' => $edited + 'edited' => $edited, + 'network' => $item["item_network"], + 'network_name' => network_to_name($item['item_network']), ); $arr = array('item' => $item, 'output' => $tmp_item); diff --git a/view/theme/vier/style.css b/view/theme/vier/style.css index e1f9b3def..03aaf8940 100644 --- a/view/theme/vier/style.css +++ b/view/theme/vier/style.css @@ -480,8 +480,9 @@ div.jGrowl div.info { padding-left: 58px; } -div.jGrowl div.jGrowl-notification { - margin-top: 40px; +div.jGrowl.top-right { + top: 40px; + z-index: 90; } /* header */ @@ -533,7 +534,8 @@ nav { top: 0px; padding: 0px; padding-left: 0px; - background: #2d2d2d; + /* background: #2d2d2d; */ + background: rgb(36, 76, 94); /*background: #364A84; background: -moz-linear-gradient(top, #516499 0%, #364a84 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#516499), color-stop(100%,#364a84)); @@ -1160,6 +1162,14 @@ border-bottom: 1px solid #D2D2D2; color: #999; font-size: 12px; } + +.wall-item-network { + color: #999; + font-size: 12px; + text-align: right; + float: right; +} + .wall-item-location { width: 350px; float: left; @@ -1396,8 +1406,8 @@ border-bottom: 1px solid #D2D2D2; .shiny { /* border-right: 10px solid #fce94f; */ - border-right: 1px solid #A7C7F7; - padding-right: 12px; +/* border-right: 1px solid #A7C7F7; + padding-right: 12px; */ } #profile-jot-form #profile-jot-text { diff --git a/view/theme/vier/templates/wall_thread.tpl b/view/theme/vier/templates/wall_thread.tpl index e6d5bfb5d..d51014a96 100644 --- a/view/theme/vier/templates/wall_thread.tpl +++ b/view/theme/vier/templates/wall_thread.tpl @@ -62,6 +62,9 @@ {{if $item.plink}}{{$item.ago}}{{else}} {{$item.ago}} {{/if}} {{if $item.lock}}{{$item.lock}} {{/if}} + + {{$item.network_name}} +
diff --git a/view/theme/vier/theme.php b/view/theme/vier/theme.php index 7da0731f7..db343d127 100644 --- a/view/theme/vier/theme.php +++ b/view/theme/vier/theme.php @@ -11,10 +11,29 @@ function vier_init(&$a) { set_template_engine($a, 'smarty3'); +$baseurl = $a->get_baseurl(); + $a->theme_info = array(); $a->page['htmlhead'] .= <<< EOT + EOT; }