Browse Source

feed status

master
Aaron Parecki 9 years ago
parent
commit
a03be6e4dc
3 changed files with 94 additions and 2 deletions
  1. +22
    -0
      controllers/controllers.php
  2. +2
    -2
      public/css/style.css
  3. +70
    -0
      views/feed-status.php

+ 22
- 0
controllers/controllers.php View File

@ -32,3 +32,25 @@ $app->get('/subscription/:hash', function($hash) use($app) {
}
});
$app->get('/feed/:hash', function($hash) use($app) {
$res = $app->response();
$feed = db\get_by_col('feeds', 'hash', $hash);
$subscribers = ORM::for_table('subscriptions')->where('feed_id', $feed->id)->where('active', 1)->find_many();
$num_subscribers = ORM::for_table('subscriptions')->where('feed_id', $feed->id)->where('active', 1)->count();
if(!$feed) {
$app->response()->status(404);
} else {
ob_start();
render('feed-status', array(
'title' => 'Switchboard',
'meta' => '',
'feed' => $feed,
'subscribers' => $subscribers,
'num_subscribers' => $num_subscribers
));
$html = ob_get_clean();
$res->body($html);
}
});

+ 2
- 2
public/css/style.css View File

@ -64,14 +64,14 @@ body.logged-out {
font-size: 18px;
}
.subscription-status {
.subscription-status, .feed-status {
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
border: 1px #ccc solid;
}
.subscription-status pre {
.subscription-status pre, .feed-status pre {
max-width: 500px;
overflow: pre-wrap;
}

+ 70
- 0
views/feed-status.php View File

@ -0,0 +1,70 @@
<?php $tz = -7 * 3600; ?>
<div class="narrow subscription-status">
<h3>Feed Status</h3>
<table class="table">
<tr>
<td>URL</td>
<td><?= $this->feed->feed_url ?></td>
</tr>
<tr>
<td>Last Ping Received</td>
<td><?= friendly_date($this->feed->push_last_ping_received, $tz) ?></td>
</tr>
<tr>
<td>Last Retrieved</td>
<td><?= friendly_date($this->feed->last_retrieved, $tz) ?></td>
</tr>
</table>
<h3>Subscribers</h3>
<table class="table">
<tr>
<td colspan="2">
<?= $this->num_subscribers ?> active subscribers
</td>
</tr>
<? foreach($this->subscribers as $subscriber): ?>
<tr>
<td colspan="2"><h4><?= $subscriber->callback_url ?></h4></td>
</tr>
<tr>
<td>Date Subscribed</td>
<td><?= friendly_date($subscriber->date_created, $tz) ?></td>
</tr>
<tr>
<td>Last Confirmed</td>
<td><?= friendly_date($subscriber->date_confirmed, $tz) ?></td>
</tr>
<tr>
<td>Date Expires</td>
<td><?= friendly_date($subscriber->date_expires, $tz) ?></td>
</tr>
<tr>
<td>Last Ping Sent</td>
<td><?= friendly_date($subscriber->date_last_ping_sent, $tz) ?></td>
</tr>
<tr>
<td>Last Response<br>(from subscriber)</td>
<td><pre><?= htmlspecialchars($subscriber->last_ping_headers."\n\n".$subscriber->last_ping_body) ?></pre></td>
</tr>
<tr>
<td>Last ping was successful?</td>
<td><?= $subscriber->last_ping_success ? 'Yes' : 'No' ?><br>(Subscriber must return 2xx on success)</td>
</tr>
<? if($subscriber->last_ping_success == 0): ?>
<tr>
<td>Retrying ping in</td>
<td>
<?= $subscriber->last_ping_error_delay/2 ?> seconds<br>
(Will be de-activated after 1 hour from first failed ping)
</td>
</tr>
<? endif; ?>
<? endforeach; ?>
</table>
</div>

Loading…
Cancel
Save