Browse Source

show icons for webmention status

pull/3/head
Aaron Parecki 9 years ago
parent
commit
ea4039a5ad
6 changed files with 47 additions and 9 deletions
  1. +33
    -2
      controllers/Controller.php
  2. +1
    -1
      lib/Telegraph/ProfileFetcher.php
  3. BIN
      public/assets/telegraph-icon-white.png
  4. +1
    -0
      public/index.php
  5. +11
    -5
      views/dashboard.php
  6. +1
    -1
      views/layout-loggedin.php

+ 33
- 2
controllers/Controller.php View File

@ -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();
}

+ 1
- 1
lib/Telegraph/ProfileFetcher.php View File

@ -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";

BIN
public/assets/telegraph-icon-white.png View File

Before After
Width: 256  |  Height: 256  |  Size: 4.8 KiB

+ 1
- 0
public/index.php View File

@ -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');

+ 11
- 5
views/dashboard.php View File

@ -1,16 +1,22 @@
<?php $this->layout('layout-loggedin', ['title' => $title, 'accounts' => $accounts, 'user' => $user]); ?>
<div class="ui main text container">
<div class="ui main text container" style="margin-top: 80px;">
<table class="ui striped table fixed single line">
<table class="ui striped table single line">
<thead>
<th>Status</th>
<th>Date</th>
<th>Source &amp; Target</th>
</thead>
<?php foreach($webmentions as $mention): ?>
<tr>
<td><?= $mention['webmention']->created_at ?></td>
<td><?= $this->e($mention['webmention']->source) ?><br><?= $this->e($mention['webmention']->target) ?></td>
<tr<?= $mention['status'] == 'pending' ? ' class="warning"' : '' ?>>
<td><i class="<?= $mention['icon'] ?> icon"></i></td>
<td><a href="/webmention/<?= $mention['webmention']->token ?>/details"><?= date('M j, g:ia', strtotime($mention['webmention']->created_at)) ?></a></td>
<td>
source=<?= $this->e($mention['webmention']->source) ?><br>
target=<?= $this->e($mention['webmention']->target) ?></td>
</tr>
<?php endforeach; ?>
</table>

+ 1
- 1
views/layout-loggedin.php View File

@ -3,7 +3,7 @@
<div class="ui fixed inverted menu">
<div class="ui container">
<a href="/" class="header item">
<img class="logo" src="/assets/telegraph-logo-256.png">
<img class="logo" src="/assets/telegraph-icon-white.png">
Telegraph
</a>
<a href="/dashboard" class="item">Dashboard</a>

Loading…
Cancel
Save