From 1893c3df163fa99525ea6aa9c78e2c56947a59c0 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 29 Aug 2017 16:40:08 +0000 Subject: [PATCH] Pleroma-Servers are now detected and displayed in the statistics --- include/socgraph.php | 14 +++++++++++--- include/text.php | 1 + mod/admin.php | 5 +++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/include/socgraph.php b/include/socgraph.php index d3f70075b2..d944fa064c 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -1146,6 +1146,7 @@ function poco_check_server($server_url, $network = "", $force = false) { } // Test for Mastodon + $orig_version = $version; $serverret = z_fetch_url($server_url."/api/v1/instance"); if ($serverret["success"] && ($serverret["body"] != '')) { $data = json_decode($serverret["body"]); @@ -1157,6 +1158,9 @@ function poco_check_server($server_url, $network = "", $force = false) { $network = NETWORK_OSTATUS; } } + if (strstr($orig_version, 'Pleroma')) { + $platform = 'Pleroma'; + } } if (!$failure) { @@ -1169,7 +1173,9 @@ function poco_check_server($server_url, $network = "", $force = false) { $version = $data->version; $network = NETWORK_DIASPORA; } - $site_name = $data->site_name; + if (!empty($data->site_name)) { + $site_name = $data->site_name; + } switch ($data->register_policy) { case "REGISTER_OPEN": $register_policy = REGISTER_OPEN; @@ -1249,9 +1255,11 @@ function poco_check_server($server_url, $network = "", $force = false) { $version = preg_replace("=(.+)-(.{4,})=ism", "$1", $version); } - $site_name = $data->name; + if (!empty($data->name)) { + $site_name = $data->name; + } - if (isset($data->network)) { + if (!empty($data->network)) { $platform = $data->network; } diff --git a/include/text.php b/include/text.php index 9cd861fa55..9b7b47a773 100644 --- a/include/text.php +++ b/include/text.php @@ -1425,6 +1425,7 @@ function prepare_body(&$item, $attach = false, $preview = false) { $title .= ' ' . $mtch[2] . ' ' . t('bytes'); if (($filetype == 'image') AND ($item['network'] == NETWORK_OSTATUS)) { + /// @todo Respect the spoiler for mastodon $icon = ''; $s .= '
' . $icon . ''; } else { diff --git a/mod/admin.php b/mod/admin.php index 2919076675..c5043f2252 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -441,7 +441,7 @@ function admin_page_federation(App $a) { // off one % two of them are needed in the query // Add more platforms if you like, when one returns 0 known nodes it is not // displayed on the stats page. - $platforms = array('Friendi%%a', 'Diaspora', '%%red%%', 'Hubzilla', 'BlaBlaNet', 'GNU Social', 'StatusNet', 'Mastodon'); + $platforms = array('Friendi%%a', 'Diaspora', '%%red%%', 'Hubzilla', 'BlaBlaNet', 'GNU Social', 'StatusNet', 'Mastodon', 'Pleroma'); $colors = array('Friendi%%a' => '#ffc018', // orange from the logo 'Diaspora' => '#a1a1a1', // logo is black and white, makes a gray '%%red%%' => '#c50001', // fire red from the logo @@ -449,7 +449,8 @@ function admin_page_federation(App $a) { 'BlaBlaNet' => '#3B5998', // blue from the navbar at blablanet-dot-com 'GNU Social'=> '#a22430', // dark red from the logo 'StatusNet' => '#789240', // the green from the logo (red and blue have already others - 'Mastodon' => '#1a9df9'); // blue from the Mastodon logo + 'Mastodon' => '#1a9df9', // blue from the Mastodon logo + 'Pleroma' => '#E46F0F'); // Orange from the text that is used on Pleroma instances $counts = array(); $total = 0;