diff --git a/CHANGELOG.md b/CHANGELOG.md index 650386589ea015647921eb66c442540adee4d868..f8a0404564cd7662ce047baabc11248c52d5eb10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ The format is based on [Keep a Changelog] and this project adheres to [Semantic Versioning]. ## [Unreleased] +:exclamation: DB migrations required! (see [SQL migration script][2.4.0-sql-migration]) ### Added - Added bootstrapping to simplify initialisation of config and database - Config syntax has changed to array style (#155) @@ -10,6 +11,7 @@ The format is based on [Keep a Changelog] and this project adheres to [Semantic - Podmin can choose at what fail score to send the notice out - Podmin email shares details on why pod is failing - Only retrieve location data for remote servers / IPs +- Fontawesome for icons ### Changed - Introduce proper changelog format (#189) - Moved DB migration scripts into `db` folder @@ -23,6 +25,7 @@ The format is based on [Keep a Changelog] and this project adheres to [Semantic - Score now goes to -5000 before a pod is removed so dead pods get checked a while then removed for good - Move functions to dedicated file to allow reuse - Backup script rewrite +- Store services as json array ### Deprecated ### Removed ### Fixed @@ -84,8 +87,9 @@ The format is based on [Keep a Changelog] and this project adheres to [Semantic ### Fixed - Fix ipv6 -[2.2.0-sql-migration]: https://git.feneas.org/diasporg/Poduptime/blob/master/db/migrations/2.1.4-2.2.0.sql +[2.4.0-sql-migration]: https://git.feneas.org/diasporg/Poduptime/blob/master/db/migrations/2.3.0-2.4.0.sql [2.3.0-sql-migration]: https://git.feneas.org/diasporg/Poduptime/blob/master/db/migrations/2.2.0-2.3.0.sql +[2.2.0-sql-migration]: https://git.feneas.org/diasporg/Poduptime/blob/master/db/migrations/2.1.4-2.2.0.sql [Unreleased]: https://git.feneas.org/diasporg/Poduptime/compare/master...develop [2.3.1]: https://git.feneas.org/diasporg/Poduptime/compare/2.3.0...2.3.1 diff --git a/css/poduptime.css b/css/poduptime.css index e8a1b4900eae1d2c901dfd731e841c7eacea22a4..753140fc9d32db306a080d5450d1de7a575458e4 100644 --- a/css/poduptime.css +++ b/css/poduptime.css @@ -25,35 +25,8 @@ } .smlogo { - width: 16px; - height: 16px; - background: url('/images/smlogo.png') 0 0; - display: inline-block; - margin: 0; -} - -.smlogo-twitter { - background-position: 0 -776px; -} - -.smlogo-facebook { - background-position: 0 -824px; -} - -.smlogo-tumblr { - background-position: 0 -792px; -} - -.smlogo-wordpress { - background-position: 0 -656px; -} - -.smlogo-xmpp { background: none; -} - -.smlogo-xmpp img { - vertical-align: unset; + display: inline-block; } #map { diff --git a/db/migrations/2.3.0-2.4.0.sql b/db/migrations/2.3.0-2.4.0.sql index 98101ee0163edf193b41e35dc006cd2d370782fc..6a2abc29f4be131ff9b882a8abb0584252dd0416 100644 --- a/db/migrations/2.3.0-2.4.0.sql +++ b/db/migrations/2.3.0-2.4.0.sql @@ -1 +1,3 @@ +ALTER TABLE pods ADD services jsonb; +ALTER TABLE pods DROP COLUMN service_facebook, DROP COLUMN service_wordpress, DROP COLUMN service_tumblr, DROP COLUMN service_twitter; ALTER TABLE pods ADD podmin_notify_level int DEFAULT 50; diff --git a/db/pull.php b/db/pull.php index 56c789bfbea3b1ae1248e094f12b7078512b3d67..64dfaa5be0e82d59a4e8e9c872bc66fd83d39489 100644 --- a/db/pull.php +++ b/db/pull.php @@ -138,17 +138,10 @@ foreach ($pods as $pod) { $local_posts = $jsonssl->usage->localPosts ?? 0; $comment_counts = $jsonssl->usage->localComments ?? 0; $service_xmpp = ($jsonssl->metadata->xmppChat ?? false) === true; - $service_facebook = false; - $service_twitter = false; - $service_tumblr = false; - $service_wordpress = false; if (json_last_error() === 0) { (!$jsonssl->software->version) || $score += 1; if (is_array($jsonssl->services->outbound)) { - $service_facebook = in_array('facebook', $jsonssl->services->outbound, true); - $service_twitter = in_array('twitter', $jsonssl->services->outbound, true); - $service_tumblr = in_array('tumblr', $jsonssl->services->outbound, true); - $service_wordpress = in_array('wordpress', $jsonssl->services->outbound, true); + $services = json_encode($jsonssl->services->outbound); } } @@ -396,7 +389,6 @@ foreach ($pods as $pod) { $p['state'] = $state; $p['lat'] = $lat; $p['long'] = $long; - $p['detectedlanguage'] = $detectedlanguage; $p['userrating'] = $user_rating; $p['masterversion'] = $masterversion; $p['weightedscore'] = $weightedscore; @@ -411,12 +403,10 @@ foreach ($pods as $pod) { $p['active_users_monthly'] = $active_users_monthly; $p['local_posts'] = $local_posts; $p['name'] = $name; + $p['detectedlanguage'] = $detectedlanguage; $p['comment_counts'] = $comment_counts; - $p['service_facebook'] = $service_facebook; - $p['service_tumblr'] = $service_tumblr; - $p['service_twitter'] = $service_twitter; - $p['service_wordpress'] = $service_wordpress; $p['service_xmpp'] = $service_xmpp; + $p['services'] = $services; $p['softwarename'] = $softwarename; } diff --git a/db/tables.sql b/db/tables.sql index 40a97765b5584788e9c23423edd4dade9435173d..7a99ba6445f5d9562ce16cb136f9efccbb278fbc 100644 --- a/db/tables.sql +++ b/db/tables.sql @@ -30,11 +30,8 @@ CREATE TABLE pods ( uptime_alltime numeric(5,2), status smallint DEFAULT 1, latency smallint, - service_facebook boolean, - service_twitter boolean, - service_tumblr boolean, - service_wordpress boolean, service_xmpp boolean, + services jsonb, token text, publickey text, tokenexpire timestamp, diff --git a/images/icon-xmpp.png b/images/icon-xmpp.png deleted file mode 100644 index 471f6b621f00dfa1bbd90fcefb07958a6d2d0a2a..0000000000000000000000000000000000000000 Binary files a/images/icon-xmpp.png and /dev/null differ diff --git a/images/smlogo.png b/images/smlogo.png deleted file mode 100644 index 97ca7791b3aa9b3a19c62aa8b39b191b6922131d..0000000000000000000000000000000000000000 Binary files a/images/smlogo.png and /dev/null differ diff --git a/index.php b/index.php index a8d05ddddbba1ce3454c8a14d250e9705119e13e..5b866ea5942fbba3b77c88baa35597415ec711cf 100644 --- a/index.php +++ b/index.php @@ -35,6 +35,7 @@ $fullview = false; + diff --git a/package.json b/package.json index 2ca44cd677540a4dc51b82b64b0d70545a529355..2b0e676a4997a6e7d49514c43d2f0bc09063d091 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "Poduptime is software to get live stats and data on listed Diaspora Pods.", "main": "index.php", "dependencies": { + "@fortawesome/fontawesome-free": "^5.2.0", "bootstrap": "^4.1.3", "chart.js": "^2.7.2", "featherlight": "^1.7.13", @@ -14,7 +15,6 @@ "popper.js": "^1.14.3", "tablesorter": "^2.30.7" }, - "devDependencies": {}, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, diff --git a/podstat-uptime.php b/podstat-uptime.php index 1ec1e6cf3a0723451e097780a995b2ea97a17500..049651bff0e4b41294ea49ff7579757e36c451aa 100644 --- a/podstat-uptime.php +++ b/podstat-uptime.php @@ -17,7 +17,7 @@ $sql = " SELECT to_char(date_checked, 'yyyy MM') AS yymm, count(*) AS total_checks, - round(avg(online::INT),2)*100 AS uptime, + round(avg(online::INT),4)*100 AS uptime, round(avg(latency),2) * 1000 AS latency FROM checks WHERE domain = ? diff --git a/showfull.php b/showfull.php index f668da1ab1a5945e527a4e3cb598f89b849cc428..9e328fb2857658517e5cce9a0534b763e1dd6fde 100644 --- a/showfull.php +++ b/showfull.php @@ -58,7 +58,7 @@ $country_code = $_SERVER['HTTP_CF_IPCOUNTRY'] ?? '';
Version
Software
Uptime
- IPv6 +
IPv6
Latency
Signups
Users
@@ -75,12 +75,7 @@ $country_code = $_SERVER['HTTP_CF_IPCOUNTRY'] ?? '';
City
State
Language
-
Services
-
Facebook
-
Twitter
-
Tumblr
-
Wordpress
-
XMPP
+
Services
Info
diff --git a/showmap.php b/showmap.php index 4d724b46887f5fb3ed773e7ccf5e46dc18ac2612..55c7c8dbd19f4e3c332b8bfa234c75089dc481cc 100644 --- a/showmap.php +++ b/showmap.php @@ -24,7 +24,7 @@ if ($country_code) { try { $pods = R::getAll(" - SELECT domain, signup, name, lat, long, softwarename, uptime_alltime, active_users_halfyear, service_facebook, service_twitter, service_tumblr, service_wordpress, service_xmpp + SELECT domain, signup, name, lat, long, softwarename, uptime_alltime, active_users_halfyear, services, service_xmpp FROM pods WHERE long != '' AND lat != '' @@ -52,11 +52,41 @@ try { $i++ > 0 && print ','; $feat = ''; - $pod['service_facebook'] && $feat .= ''; - $pod['service_twitter'] && $feat .= ''; - $pod['service_tumblr'] && $feat .= ''; - $pod['service_wordpress'] && $feat .= ''; - $pod['service_xmpp'] && $feat .= ''; + $services = json_decode($pod['services'] ?? '[]') ?: []; + + // Special case for XMPP, which is not an official service, but listed in the same cell. + ($pod['service_xmpp'] ?? false) && $services[] = 'xmpp'; + + $services_list = [ + 'facebook' => ['fa' => 'fab fa-facebook-f', 'title' => 'Publish to Facebook'], + 'twitter' => ['fa' => 'fab fa-twitter', 'title' => 'Publish to Twitter'], + 'tumblr' => ['fa' => 'fab fa-tumblr', 'title' => 'Publish to Tumblr'], + 'wordpress' => ['fa' => 'fab fa-wordpress-simple', 'title' => 'Publish to WordPress'], + 'xmpp' => ['fa' => 'fas fa-comments', 'title' => 'XMPP chat server'], + 'appnet' => ['fa' => 'fas fa-th', 'title' => 'Publish to App.net'], + 'atom1.0' => ['fa' => 'fas fa-rss', 'title' => 'Publish to Atom'], + 'blogger' => ['fa' => 'fab fa-blogger-b', 'title' => 'Publish to Blogger'], + 'gnusocial' => ['fa' => 'fab fa-grunt', 'title' => 'Publish to GNUSocial'], + 'google' => ['fa' => 'fab fa-google', 'title' => 'Publish to Google+'], + 'libertree' => ['fa' => 'fas fa-tree', 'title' => 'Publish to Libertree'], + 'linkedin' => ['fa' => 'fab fa-linkedin-in', 'title' => 'Publish to LinkedIn'], + 'livejournal' => ['fa' => 'fas fa-pencil-alt', 'title' => 'Publish to Live Journal'], + 'pinterest' => ['fa' => 'fab fa-pinterest-p', 'title' => 'Publish to Pinterest'], + 'pumpio' => ['fa' => 'fas fa-greater-than', 'title' => 'Publish to Pump.io'], + ]; + + foreach ($services as $service) { + // Make sure we have this service in the list. + if (!isset($services_list[$service])) { + continue; + } + + $feat .= sprintf( + '', + $services_list[$service]['fa'], + $services_list[$service]['title'] + ); + } $pod_name = htmlentities($pod['name'] ?? '', ENT_QUOTES); $signup = $pod['signup'] ? 'yes' : 'no'; diff --git a/tabledata.php b/tabledata.php index 4a24fa303bd18407631a249a87e960446e797f6e..544fad644f52635f327f788d774891b301712bd2 100644 --- a/tabledata.php +++ b/tabledata.php @@ -16,7 +16,7 @@ $iso = new Matriphe\ISO639\ISO639; try { $pods = R::getAll(' - SELECT domain, dnssec, podmin_statement, sslexpire, masterversion, shortversion, softwarename, daysmonitored, monthsmonitored, score, signup, name, country, countryname, city, state, detectedlanguage, uptime_alltime, active_users_halfyear, active_users_monthly, service_facebook, service_twitter, service_tumblr, service_wordpress, service_xmpp, latency, date_updated, ipv6, total_users, local_posts, comment_counts, userrating, status + SELECT domain, dnssec, podmin_statement, sslexpire, masterversion, shortversion, softwarename, daysmonitored, monthsmonitored, score, signup, name, country, countryname, city, state, detectedlanguage, uptime_alltime, active_users_halfyear, active_users_monthly, services, service_xmpp, latency, date_updated, ipv6, total_users, local_posts, comment_counts, userrating, status FROM pods WHERE status < ? AND score > 0 @@ -81,19 +81,45 @@ foreach ($pods as $pod) { echo '' . $pod['city'] . ''; echo '' . $pod['state'] . ''; echo '' . ($pod['detectedlanguage'] ? strtoupper($pod['detectedlanguage']) : '') . ''; + + $services = json_decode($pod['services'] ?? '[]') ?: []; + + // Special case for XMPP, which is not an official service, but listed in the same cell. + ($pod['service_xmpp'] ?? false) && $services[] = 'xmpp'; + + $services_list = [ + 'facebook' => ['fa' => 'fab fa-facebook-f', 'title' => 'Publish to Facebook'], + 'twitter' => ['fa' => 'fab fa-twitter', 'title' => 'Publish to Twitter'], + 'tumblr' => ['fa' => 'fab fa-tumblr', 'title' => 'Publish to Tumblr'], + 'wordpress' => ['fa' => 'fab fa-wordpress-simple', 'title' => 'Publish to WordPress'], + 'xmpp' => ['fa' => 'fas fa-comments', 'title' => 'XMPP chat server'], + 'appnet' => ['fa' => 'fas fa-th', 'title' => 'Publish to App.net'], + 'atom1.0' => ['fa' => 'fas fa-rss', 'title' => 'Publish to Atom'], + 'blogger' => ['fa' => 'fab fa-blogger-b', 'title' => 'Publish to Blogger'], + 'gnusocial' => ['fa' => 'fab fa-grunt', 'title' => 'Publish to GNUSocial'], + 'google' => ['fa' => 'fab fa-google', 'title' => 'Publish to Google+'], + 'libertree' => ['fa' => 'fas fa-tree', 'title' => 'Publish to Libertree'], + 'linkedin' => ['fa' => 'fab fa-linkedin-in', 'title' => 'Publish to LinkedIn'], + 'livejournal' => ['fa' => 'fas fa-pencil-alt', 'title' => 'Publish to Live Journal'], + 'pinterest' => ['fa' => 'fab fa-pinterest-p', 'title' => 'Publish to Pinterest'], + 'pumpio' => ['fa' => 'fas fa-greater-than', 'title' => 'Publish to Pump.io'], + ]; + echo ''; - $pod['service_facebook'] && print ''; - $pod['service_twitter'] && print ''; - $pod['service_tumblr'] && print ''; - $pod['service_wordpress'] && print ''; - $pod['service_xmpp'] && print ''; - echo ''; - echo '' . ($pod['service_facebook'] ? 'Yes' : 'No') . ''; - echo '' . ($pod['service_twitter'] ? 'Yes' : 'No') . ''; - echo '' . ($pod['service_tumblr'] ? 'Yes' : 'No') . ''; - echo '' . ($pod['service_wordpress'] ? 'Yes' : 'No') . ''; - echo '' . ($pod['service_xmpp'] ? 'Yes' : 'No') . ''; + foreach ($services as $service) { + // Make sure we have this service in the list. + if (!isset($services_list[$service])) { + continue; + } + printf( + '', + $services_list[$service]['fa'], + $services_list[$service]['title'], + $service + ); + } + echo ''; $podmin_statement = htmlentities($pod['podmin_statement'] ?? '', ENT_QUOTES); echo '' . ($podmin_statement ? '💬' : ' ') . ''; } diff --git a/yarn.lock b/yarn.lock index e582b5a00f1bb72347debff71d22ab02b51e96c4..d6bfb81af6ee8aa4c41898858747aacbb01b7185 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,10 @@ # yarn lockfile v1 +"@fortawesome/fontawesome-free@^5.2.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-5.2.0.tgz#50cd9856774351c56c0b1b0db4efe122d7913e58" + bootstrap@^4.1.3: version "4.1.3" resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-4.1.3.tgz#0eb371af2c8448e8c210411d0cb824a6409a12be" @@ -61,8 +65,8 @@ moment@^2.10.2: resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.2.tgz#3c257f9839fc0e93ff53149632239eb90783ff66" popper.js@^1.14.3: - version "1.14.3" - resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.14.3.tgz#1438f98d046acf7b4d78cd502bf418ac64d4f095" + version "1.14.4" + resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.14.4.tgz#8eec1d8ff02a5a3a152dd43414a15c7b79fd69b6" tablesorter@^2.30.7: version "2.30.7"