diff --git a/controllers/Controller.php b/controllers/Controller.php index ba1a005..93e7361 100644 --- a/controllers/Controller.php +++ b/controllers/Controller.php @@ -44,11 +44,38 @@ class Controller { $site = ORM::for_table('sites')->where_id_is($role->site_id)->find_one(); + $query = ORM::for_table('webmentions')->where('site_id', $site->id) + ->order_by_desc('created_at') + ->limit(20) + ->find_many(); + $webmentions = []; - foreach(ORM::for_table('webmentions')->where('site_id', $site->id)->find_many() as $m) { + foreach($query as $m) { + $statuses = ORM::for_table('webmention_status')->where('webmention_id', $m->id)->order_by_desc('created_at')->find_many(); + if(count($statuses) == 0) { + $icon = 'wait'; + $status = 'pending'; + } else { + $status = $statuses[0]->status; + switch($status) { + case 'success': + case 'accepted': + $icon = 'checkmark'; + break; + case 'not_supported': + case 'error': + $icon = 'warning'; + break; + default: + $icon = ''; + } + } + $webmentions[] = [ 'webmention' => $m, - 'statuses' => ORM::for_table('webmention_status')->where('webmention_id', $m->id)->order_by_desc('created_at')->find_many() + 'statuses' => $statuses, + 'status' => $status, + 'icon' => $icon ]; } @@ -62,6 +89,10 @@ class Controller { return $response; } + public function webmention_details(Request $request, Response $response) { + + } + private function _user() { return ORM::for_table('users')->where_id_is(session('user_id'))->find_one(); } diff --git a/lib/Telegraph/ProfileFetcher.php b/lib/Telegraph/ProfileFetcher.php index d63a1ef..0449db5 100644 --- a/lib/Telegraph/ProfileFetcher.php +++ b/lib/Telegraph/ProfileFetcher.php @@ -9,7 +9,7 @@ class ProfileFetcher { $user = ORM::for_table('users')->where_id_is($id)->find_one(); echo "Looking for representative h-card for ".$user->url."\n"; $data = HTTP::get($user->url); - $parsed = Mf2\parse($data['body']); + $parsed = Mf2\parse($data['body'], $user->url); $representative = Mf2\HCard\representative($parsed, $user->url); if($representative) { echo "Found it!\n"; diff --git a/public/assets/telegraph-icon-white.png b/public/assets/telegraph-icon-white.png new file mode 100644 index 0000000..10af3fc Binary files /dev/null and b/public/assets/telegraph-icon-white.png differ diff --git a/public/index.php b/public/index.php index bfb8af2..34fdaff 100644 --- a/public/index.php +++ b/public/index.php @@ -13,6 +13,7 @@ $router->addRoute('GET', '/api', 'Controller::api'); $router->addRoute('POST', '/webmention', 'API::webmention'); $router->addRoute('GET', '/webmention/{code}', 'API::webmention_status'); +$router->addRoute('GET', '/webmention/{code}/details', 'Controller::webmention_details'); $router->addRoute('GET', '/login', 'Auth::login'); $router->addRoute('GET', '/logout', 'Auth::logout'); diff --git a/views/dashboard.php b/views/dashboard.php index b6610ec..e630894 100644 --- a/views/dashboard.php +++ b/views/dashboard.php @@ -1,16 +1,22 @@ layout('layout-loggedin', ['title' => $title, 'accounts' => $accounts, 'user' => $user]); ?> -
+
- + + +
+ - - - + > + + +
Status Date Source & Target
created_at ?>e($mention['webmention']->source) ?>
e($mention['webmention']->target) ?>
created_at)) ?> + source=e($mention['webmention']->source) ?>
+ target=e($mention['webmention']->target) ?>
diff --git a/views/layout-loggedin.php b/views/layout-loggedin.php index 9500ab3..101551d 100644 --- a/views/layout-loggedin.php +++ b/views/layout-loggedin.php @@ -3,7 +3,7 @@