Browse Source

add API docs and finishing touches on copy/layout

pull/3/head
Aaron Parecki 9 years ago
parent
commit
e7e3499e11
14 changed files with 376 additions and 200 deletions
  1. +2
    -119
      README.md
  2. +2
    -1
      composer.json
  3. +53
    -2
      composer.lock
  4. +11
    -5
      controllers/Auth.php
  5. +21
    -0
      controllers/Controller.php
  6. +11
    -0
      public/assets/styles.css
  7. +134
    -0
      views/api.php
  8. +14
    -1
      views/dashboard.php
  9. +31
    -0
      views/footer-block.php
  10. +60
    -50
      views/index.php
  11. +24
    -15
      views/layout-loggedin.php
  12. +1
    -4
      views/layout.php
  13. +1
    -1
      views/webmention-details.php
  14. +11
    -2
      views/webmention-send.php

+ 2
- 119
README.md View File

@ -2,126 +2,9 @@
Telegraph is an API for sending [Webmentions](http://webmention.net). Telegraph is an API for sending [Webmentions](http://webmention.net).
## Send a webmention to a specific page
Post to `https://telegraph.p3k.io/webmention`
* `token` - your API key obtained after signing up
* `source` - the URL of your post
* `target` - the URL you linked to
* `callback` - (optional) - a URL that will receive a web hook when new information about this webmention is available
The Telegraph API will validate the parameters and then queue the webmention for sending. If there was a problem with the request, you will get an error response immediately.
The API will first make an HTTP request to the source URL, and look for a link to the target on the page. This happens synchronously so you will get this error reply immediately.
#### Errors
* `authentication_required` - the token parameter was missing
* `invalid_token` - the token was invalid or expired
* `missing_parameters` - one or more of the three parameters were not in the request
* `invalid_parameter` - one or more of the parameters were invalid, e.g. the target was not a valid URL
* `source_not_html` - the source document could not be parsed as HTML (only in extreme cases, most of the time it just accepts whatever)
* `no_link_found` - the link to the target URL was not found on the source document
An error response in this case will be returned with an HTTP 400 status code an a JSON body:
```json
HTTP/1.1 400 Bad Request
Content-type: application/json
{
"error": "missing_parameters",
"error_description": "The source or target parameters were missing"
}
```
#### Success
If the initial validation succeeds, Telegraph will queue the webmention for sending and return a success response, including a URL you can check for status updates. This URL will be returned even if you also provide a callback URL. The URL will be available in both the `Location` header as well as in the JSON response.
```
HTTP/1.1 201 Created
Content-type: application/json
Location: https://telegraph.p3k.io/webmention/xxxxxxxx
{
"status": "queued",
"location": "https://telegraph.p3k.io/webmention/xxxxxxxx"
}
```
### Status API
You can poll the status URL returned after queuing a webmention for more information on the progress of sending the webmention. The response will look like the following:
```
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "queued",
"summary": "The webmention is still in the processing queue.",
"location": "https://telegraph.p3k.io/webmention/xxxxxxxx"
}
```
```
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "no_link_found",
"summary": "No link was found from source to target"
}
```
```
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "success",
"type": "webmention",
"endpoint":
"summary": "The webmention request was accepted.",
"location": "https://telegraph.p3k.io/webmention/xxxxxxxx"
}
```
The possible fields that are returned are as follows:
* `status` - One of the status codes listed below
* `type` - optional - "webmention" or "pingback", depending on what was discovered at the target
* `endpoint` - optional - The webmention or pingback endpoint that was discovered
* `http_code` - optional - The HTTP code that the webmention or pingback endpoint returned
* `summary` - optional - A human-readable summary of the status
* `location` - optional - If present, you can continue checking this URL for status updates. If not present, no further information will be available about this request.
Other possible status codes are listed below.
* `accepted` - the webmention or pingback request was accepted (pingback does not differentiate between when a request is queued or processed immediately)
* `success` - the webmention status endpoint indicated the webmention was successful after processing it
* `not_supported` - no webmention or pingback endpoint was found at the target
* `no_link_found` - no link was found from source to target
Other status codes may be returned depending on the receiver's status endpoint. You should only assume a webmention was successfully sent if the status is `success` or `accepted`. If the response does not contain a `location` parameter you should not continue polling the endpoint.
### Callback Events
After Telegraph processes your request, you will receive a post to the callback URL. The initial callback you receive will be one of the status codes returned by the status API.
Typically, webmention endpoints defer processing until later, so normally the first callback received will indicate that the webmention was queued. This callback will normally be sent relatively quickly after you make the initial request, typically within a few seconds.
If the webmention endpoint provides status updates, either through a status URL or web hook, then Telegraph will deliver follow-up notifications when it gets updated information.
A callback from Telegraph will include the following post body parameters:
* `source` - the URL of your post
* `target` - the URL you linked to
* `type` - "pingback" or "webmention" depending on what was discovered at the target
* `status` - one of the status codes above, e.g. `accepted`
* `location` - if further updates will be available, the status URL where you can check again in the future
## API
See https://telegraph.p3k.io/api
## Credits ## Credits

+ 2
- 1
composer.json View File

@ -10,7 +10,8 @@
"league/plates": "~3.1", "league/plates": "~3.1",
"j4mie/idiorm": "1.5.*", "j4mie/idiorm": "1.5.*",
"p3k/caterpillar": "0.1.*", "p3k/caterpillar": "0.1.*",
"predis/predis": "1.*"
"predis/predis": "1.*",
"michelf/php-markdown": "1.6.*"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "*" "phpunit/phpunit": "*"

+ 53
- 2
composer.lock View File

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "608bb1b12f4959a9b2dccdd64046ac57",
"content-hash": "eefd85cb3d0c9cf1666ed057a450544d",
"hash": "fe88436a4cf4b629d33a4969c34cefa5",
"content-hash": "40f23b807dfa9bbd43f7542fa5c41faa",
"packages": [ "packages": [
{ {
"name": "barnabywalters/mf-cleaner", "name": "barnabywalters/mf-cleaner",
@ -541,6 +541,57 @@
], ],
"time": "2015-07-12 14:10:01" "time": "2015-07-12 14:10:01"
}, },
{
"name": "michelf/php-markdown",
"version": "1.6.0",
"source": {
"type": "git",
"url": "https://github.com/michelf/php-markdown.git",
"reference": "156e56ee036505ec637d761ee62dc425d807183c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/michelf/php-markdown/zipball/156e56ee036505ec637d761ee62dc425d807183c",
"reference": "156e56ee036505ec637d761ee62dc425d807183c",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-lib": "1.4.x-dev"
}
},
"autoload": {
"psr-0": {
"Michelf": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Michel Fortin",
"email": "michel.fortin@michelf.ca",
"homepage": "https://michelf.ca/",
"role": "Developer"
},
{
"name": "John Gruber",
"homepage": "https://daringfireball.net/"
}
],
"description": "PHP Markdown",
"homepage": "https://michelf.ca/projects/php-markdown/",
"keywords": [
"markdown"
],
"time": "2015-12-24 01:37:31"
},
{ {
"name": "nikic/fast-route", "name": "nikic/fast-route",
"version": "v0.7.0", "version": "v0.7.0",

+ 11
- 5
controllers/Auth.php View File

@ -6,16 +6,22 @@ use \Firebase\JWT\JWT;
class Auth { class Auth {
public function login(Request $request, Response $response) { public function login(Request $request, Response $response) {
$response->setContent(view('login', [
'title' => 'Sign In to Telegraph',
'return_to' => $request->get('return_to')
]));
session_start();
if(session('user_id')) {
$response->setStatusCode(302);
$response->headers->set('Location', '/dashboard');
} else {
$response->setContent(view('login', [
'title' => 'Sign In to Telegraph',
'return_to' => $request->get('return_to')
]));
}
return $response; return $response;
} }
public function logout(Request $request, Response $response) { public function logout(Request $request, Response $response) {
session_start(); session_start();
if(array_key_exists('user_id', $_SESSION)) {
if(session('user_id')) {
$_SESSION['user_id'] = null; $_SESSION['user_id'] = null;
session_destroy(); session_destroy();
} }

+ 21
- 0
controllers/Controller.php View File

@ -47,6 +47,27 @@ class Controller {
return $response; return $response;
} }
public function api(Request $request, Response $response) {
session_start();
if(session('user_id')) {
$role = $this->_get_role($request, $response);
$site = ORM::for_table('sites')->where_id_is($role->site_id)->find_one();
} else {
$role = false;
$site = false;
}
$response->setContent(view('api', [
'title' => 'Telegraph API Documentation',
'user' => $this->_user(),
'accounts' => $this->_accounts(),
'site' => $site,
'role' => $role,
'return_to' => $request->getRequestURI()
]));
return $response;
}
private static function _icon_for_status($status) { private static function _icon_for_status($status) {
switch($status) { switch($status) {
case 'success': case 'success':

+ 11
- 0
public/assets/styles.css View File

@ -0,0 +1,11 @@
.footer.segment {
padding: 5em 0em;
}
.api-docs pre {
padding: 8px 12px;
border-radius: 4px;
border: 1px #ddd solid;
background-color: rgba(248,246,255,1);
font-size: 0.9em;
}

+ 134
- 0
views/api.php View File

@ -0,0 +1,134 @@
<?
use \Michelf\MarkdownExtra;
$this->layout('layout-loggedin', ['title' => $title, 'accounts' => $accounts, 'user' => $user, 'return_to' => $return_to]);
?>
<div class="ui main text container api-docs" style="margin-top: 80px;">
<h1>Telegraph API</h1>
<? ob_start(); ?>
<h2 class="ui dividing header">Send a webmention to a specific page</h2>
Post to `https://telegraph.p3k.io/webmention`
* `token` - your API key obtained after signing up
* `source` - the URL of your post
* `target` - the URL you linked to
* `callback` - (optional) - a URL that will receive a web hook when new information about this webmention is available
The Telegraph API will validate the parameters and then queue the webmention for sending. If there was a problem with the request, you will get an error response immediately.
The API will first make an HTTP request to the source URL, and look for a link to the target on the page. This happens synchronously so you will get this error reply immediately.
#### Errors
* `authentication_required` - the token parameter was missing
* `invalid_token` - the token was invalid or expired
* `missing_parameters` - one or more of the three parameters were not in the request
* `invalid_parameter` - one or more of the parameters were invalid, e.g. the target was not a valid URL
* `source_not_html` - the source document could not be parsed as HTML (only in extreme cases, most of the time it just accepts whatever)
* `no_link_found` - the link to the target URL was not found on the source document
An error response in this case will be returned with an HTTP 400 status code an a JSON body:
```
HTTP/1.1 400 Bad Request
Content-type: application/json
{
"error": "missing_parameters",
"error_description": "The source or target parameters were missing"
}
```
#### Success
If the initial validation succeeds, Telegraph will queue the webmention for sending and return a success response, including a URL you can check for status updates. This URL will be returned even if you also provide a callback URL. The URL will be available in both the `Location` header as well as in the JSON response.
```
HTTP/1.1 201 Created
Content-type: application/json
Location: https://telegraph.p3k.io/webmention/xxxxxxxx
{
"status": "queued",
"location": "https://telegraph.p3k.io/webmention/xxxxxxxx"
}
```
<h2 class="ui dividing header">Status API</h2>
You can poll the status URL returned after queuing a webmention for more information on the progress of sending the webmention. The response will look like the following:
```
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "queued",
"summary": "The webmention is still in the processing queue.",
"location": "https://telegraph.p3k.io/webmention/xxxxxxxx"
}
```
```
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "no_link_found",
"summary": "No link was found from source to target"
}
```
```
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "success",
"type": "webmention",
"endpoint":
"summary": "The webmention request was accepted.",
"location": "https://telegraph.p3k.io/webmention/xxxxxxxx"
}
```
The possible fields that are returned are as follows:
* `status` - One of the status codes listed below
* `type` - optional - "webmention" or "pingback", depending on what was discovered at the target
* `endpoint` - optional - The webmention or pingback endpoint that was discovered
* `http_code` - optional - The HTTP code that the webmention or pingback endpoint returned
* `summary` - optional - A human-readable summary of the status
* `location` - optional - If present, you can continue checking this URL for status updates. If not present, no further information will be available about this request.
Other possible status codes are listed below.
* `accepted` - the webmention or pingback request was accepted (pingback does not differentiate between when a request is queued or processed immediately)
* `success` - the webmention status endpoint indicated the webmention was successful after processing it
* `not_supported` - no webmention or pingback endpoint was found at the target
* `no_link_found` - no link was found from source to target
Other status codes may be returned depending on the receiver's status endpoint. You should only assume a webmention was successfully sent if the status is `success` or `accepted`. If the response does not contain a `location` parameter you should not continue polling the endpoint.
<h2 class="ui dividing header">Callback Events</h2>
After Telegraph processes your request, you will receive a post to the callback URL. The initial callback you receive will be one of the status codes returned by the status API.
Typically, webmention endpoints defer processing until later, so normally the first callback received will indicate that the webmention was queued. This callback will normally be sent relatively quickly after you make the initial request, typically within a few seconds.
If the webmention endpoint provides status updates, either through a status URL or web hook, then Telegraph will deliver follow-up notifications when it gets updated information.
A callback from Telegraph will include the following post body parameters:
* `source` - the URL of your post
* `target` - the URL you linked to
* `type` - "pingback" or "webmention" depending on what was discovered at the target
* `status` - one of the status codes above, e.g. `accepted`
* `location` - if further updates will be available, the status URL where you can check again in the future
<?
$source=ob_get_clean();
echo MarkdownExtra::defaultTransform($source);
?>
</div>

+ 14
- 1
views/dashboard.php View File

@ -1,6 +1,6 @@
<?php $this->layout('layout-loggedin', ['title' => $title, 'accounts' => $accounts, 'user' => $user]); ?> <?php $this->layout('layout-loggedin', ['title' => $title, 'accounts' => $accounts, 'user' => $user]); ?>
<div class="ui main text container" style="margin-top: 80px;">
<div class="ui main text container" style="margin-top: 80px; margin-bottom: 40px;">
<div class="ui top attached tabular menu"> <div class="ui top attached tabular menu">
<a class="item active" data-tab="send-from-source">Find Links</a> <a class="item active" data-tab="send-from-source">Find Links</a>
@ -28,6 +28,7 @@
</form> </form>
</div> </div>
<? if(count($webmentions)): ?>
<table class="ui striped single line table"> <table class="ui striped single line table">
<thead> <thead>
<th>Status</th> <th>Status</th>
@ -57,6 +58,18 @@
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
<? else: ?>
<div class="ui message">It looks like you haven't sent any webmentions yet! Try entering one of your post URLs above and send some.</div>
<? endif; ?>
<form class="ui form">
<div class="field">
<label>API Key</label>
<input type="text" readonly="" value="<?= $role->token ?>">
</div>
<p>Use this key when sending webmentions using the <a href="/api">API</a>.</p>
</form>
</div> </div>
<script> <script>

+ 31
- 0
views/footer-block.php View File

@ -0,0 +1,31 @@
<div class="ui inverted vertical footer segment">
<div class="ui container">
<div class="ui stackable inverted divided equal height stackable grid">
<div class="three wide column">
<h4 class="ui inverted header">Telegraph</h4>
<div class="ui inverted link list">
<a href="https://github.com/aaronpk/Telegraph" class="item">Open Source</a>
<a href="https://github.com/aaronpk/Telegraph/issues" class="item">Issues</a>
<a href="http://webmention.net" class="item">About Webmention</a>
</div>
</div>
<div class="three wide column">
<h4 class="ui inverted header">The p3k Suite</h4>
<div class="ui inverted link list">
<a href="https://monocle.p3k.io" class="item">Monocle</a>
<a href="https://quill.p3k.io" class="item">Quill</a>
<a href="https://teacup.p3k.io" class="item">Teacup</a>
<a href="https://switchboard.p3k.io" class="item">Switchboard</a>
<a href="https://atlas.p3k.io" class="item">Atlas</a>
<a href="https://compass.p3k.io" class="item">Compass</a>
</div>
</div>
<div class="seven wide column">
<h4 class="ui inverted header">IndieWebCamp</h4>
<p>Telegraph and p3k are part of the indieweb. To learn more about the indieweb and IndieWebCamp, visit the <a href="https://indiewebcamp.com/">wiki</a> or join the <a href="https://indiewebcamp.com/irc/today">IRC channel</a>.</p>
<h4 class="ui inverted header"></h4>
<p>Telegraph is built and maintained by <a href="http://aaronparecki.com/">Aaron Parecki</a>.</p>
</div>
</div>
</div>
</div>

+ 60
- 50
views/index.php View File

@ -105,9 +105,18 @@
.ui.secondary.inverted.pointing.menu, .ui.secondary.pointing.menu { .ui.secondary.inverted.pointing.menu, .ui.secondary.pointing.menu {
border: 0; border: 0;
} }
pre.code {
padding: 8px 12px;
border-radius: 4px;
border: 1px #ddd solid;
background-color: rgba(248,246,255,1);
font-size: 0.9em;
}
</style> </style>
<script src="/assets/jquery.js"></script>
<script src="/assets/jquery-1.11.3.min.js"></script>
<script src="/semantic-ui/semantic.min.js"></script> <script src="/semantic-ui/semantic.min.js"></script>
<script> <script>
$(document) $(document)
@ -140,7 +149,6 @@
<?php <?php
$menu = [ $menu = [
'/' => 'Home', '/' => 'Home',
'/dashboard' => 'Dashboard',
'/api' => 'API', '/api' => 'API',
]; ];
?> ?>
@ -193,20 +201,65 @@ $menu = [
<h2>Easily send Webmentions from your website</h2> <h2>Easily send Webmentions from your website</h2>
<a class="ui huge primary button" href="/login">Get Started <i class="right arrow icon"></i></a> <a class="ui huge primary button" href="/login">Get Started <i class="right arrow icon"></i></a>
</div> </div>
</div>
<div class="ui vertical stripe segment">
<div class="ui text container">
<h3 class="ui header">We send webmentions for you</h3>
<p>Instead of doing the hard work of sending webmentions yourself, we have a simple API that will handle endpoint discovery, gracefully handle failures and retries, and will let you know whether a webmention was successfully sent. All you have to do is tell us the page you want to send the webmention to and we'll take it from there.</p>
<a class="ui large button" href="/api">Read More</a>
<!--
<h4 class="ui horizontal header divider">
Case Studies
</h4>
<h3 class="ui header">Did We Tell You About Our Bananas?</h3>
<p>Yes I know you probably disregarded the earlier boasts as non-sequitor filler content, but its really true. It took years of gene splicing and combinatory DNA research, but our bananas can really dance.</p>
<a class="ui large button">I'm Still Quite Interested</a>
-->
</div>
</div>
<div class="ui vertical stripe segment">
<div class="ui middle aligned stackable grid container">
<div class="row">
<div class="seven wide column">
<img src="/assets/dashboard-screenshot.jpg" class="ui large bordered rounded image">
</div>
<div class="eight wide column">
<h3 class="ui header">Webmentions at a glance</h3>
<p>Sign in to quickly send webmentions from the Dashboard, and see the status of your previously sent webmentions.</p>
<p>The status of each webmention can be viewed individually, so you can tell whether it worked or how it failed.</p>
</div>
</div>
</div>
</div> </div>
<div class="ui vertical stripe segment"> <div class="ui vertical stripe segment">
<div class="ui middle aligned stackable grid container"> <div class="ui middle aligned stackable grid container">
<div class="row"> <div class="row">
<div class="eight wide column"> <div class="eight wide column">
<h3 class="ui header">We send webmentions for you</h3>
<p>Let Telegraph send webmentions for you. With a simple API, Telegraph will handle sending webmentions to other websites. Let us handle webmention discovery, and retrying on temporary failures. Telegraph will notify your site when a webmention was successfully sent.</p>
<h3 class="ui header">Send Webmentions with a Simple API</h3>
<p>Let Telegraph send webmentions for you. With a simple API, Telegraph will handle sending webmentions to other websites. Let us handle webmention endpoint discovery and handling failures.</p>
<h3 class="ui header">Get updates on webmention delivery</h3>
<p>With a simple web hook, Telegraph will notify your site when a webmention was successfully sent or if an error occurred.</p>
<!--
<h3 class="ui header">Send webmentions automatically</h3> <h3 class="ui header">Send webmentions automatically</h3>
<p>You can even let Telegraph subscribe to your feed, and it will send webmentions whenever you publish a new post.</p> <p>You can even let Telegraph subscribe to your feed, and it will send webmentions whenever you publish a new post.</p>
-->
</div> </div>
<div class="six wide right floated column">
<img src="assets/images/wireframe/white-image.png" class="ui large bordered rounded image">
<div class="seven wide right floated column">
<pre class="code"><code>
POST /webmention HTTP/1.1
Content-type: application/json
{
"source": "http://source.example.com/post/100",
"target": "http://target.example.net/",
"callback": "http://yoursite.example.org/webmention-status"
"token": "xxxx"
}
</code></pre>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
@ -236,52 +289,9 @@ $menu = [
</div> </div>
--> -->
<div class="ui vertical stripe segment">
<div class="ui text container">
<h3 class="ui header">Send Webmentions with a Simple API</h3>
<p>Instead of doing the hard work of sending webmentions yourself, we have a simple API that will handle endpoint discovery, gracefully handle failures and retries, and will let you know whether a webmention was successfully sent. All you have to do is tell us where to send the webmention and we'll take it from there.</p>
<a class="ui large button" href="/api">Read More</a>
<!--
<h4 class="ui horizontal header divider">
Case Studies
</h4>
<h3 class="ui header">Did We Tell You About Our Bananas?</h3>
<p>Yes I know you probably disregarded the earlier boasts as non-sequitor filler content, but its really true. It took years of gene splicing and combinatory DNA research, but our bananas can really dance.</p>
<a class="ui large button">I'm Still Quite Interested</a>
-->
</div>
</div>
<? $this->insert('footer-block') ?>
<div class="ui inverted vertical footer segment">
<div class="ui container">
<div class="ui stackable inverted divided equal height stackable grid">
<div class="three wide column">
<h4 class="ui inverted header">Telegraph</h4>
<div class="ui inverted link list">
<a href="https://github.com/aaronpk/Telegraph" class="item">Open Source</a>
<a href="https://github.com/aaronpk/Telegraph/issues" class="item">Issues</a>
<a href="http://webmention.net" class="item">About Webmention</a>
</div>
</div>
<div class="three wide column">
<h4 class="ui inverted header">The p3k Suite</h4>
<div class="ui inverted link list">
<a href="https://monocle.p3k.io" class="item">Monocle</a>
<a href="https://quill.p3k.io" class="item">Quill</a>
<a href="https://teacup.p3k.io" class="item">Teacup</a>
<a href="https://switchboard.p3k.io" class="item">Switchboard</a>
<a href="https://atlas.p3k.io" class="item">Atlas</a>
<a href="https://compass.p3k.io" class="item">Compass</a>
</div>
</div>
<div class="seven wide column">
<h4 class="ui inverted header">IndieWebCamp</h4>
<p>You might also be interested in...</p>
</div>
</div>
</div>
</div>
</div> </div>
</body> </body>

+ 24
- 15
views/layout-loggedin.php View File

@ -6,24 +6,33 @@
<img class="logo" src="/assets/telegraph-icon-white.png"> <img class="logo" src="/assets/telegraph-icon-white.png">
Telegraph Telegraph
</a> </a>
<a href="/dashboard" class="item">Dashboard</a>
<? if($user): ?>
<a href="/dashboard" class="item">Dashboard</a>
<? endif; ?>
<a href="/api" class="item">API</a> <a href="/api" class="item">API</a>
<div class="ui right simple dropdown item"> <div class="ui right simple dropdown item">
<img class="ui mini circular image" src="<?= $user->photo ?: '/assets/default-user.jpg' ?>"> <i class="dropdown icon"></i>
<div class="menu">
<div class="header">Websites</div>
<? foreach($accounts as $account): ?>
<a class="item" href="/dashboard?account=<?= $account->id ?>"><?= $this->e($account->name) ?></a>
<? endforeach; ?>
<!--
<div class="divider"></div>
<a class="item" href="/new-site"><i class="plus icon"></i> New Site</a>
<a class="item" href="/profile"><i class="user icon"></i> Profile</a>
-->
<div class="divider"></div>
<a class="item" href="/logout"><i class="sign out icon"></i> Log Out</a>
</div>
<? if($user): ?>
<img class="ui mini circular image" src="<?= $user->photo ?: '/assets/default-user.jpg' ?>"> <i class="dropdown icon"></i>
<div class="menu">
<div class="header">Websites</div>
<? foreach($accounts as $account): ?>
<a class="item" href="/dashboard?account=<?= $account->id ?>"><?= $this->e($account->name) ?></a>
<? endforeach; ?>
<!--
<div class="divider"></div>
<a class="item" href="/new-site"><i class="plus icon"></i> New Site</a>
<a class="item" href="/profile"><i class="user icon"></i> Profile</a>
-->
<div class="divider"></div>
<a class="item" href="/logout"><i class="sign out icon"></i> Log Out</a>
</div>
<? else: ?>
<a href="/login<?= isset($return_to) ? '?return_to='.urlencode($return_to) : '' ?>"><i class="sign in icon"></i> Log In</a>
<? endif; ?>
</div> </div>
</div> </div>
</div> </div>
<?= $this->section('content') ?> <?= $this->section('content') ?>
<? $this->insert('footer-block') ?>

+ 1
- 4
views/layout.php View File

@ -6,8 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<title><?= $this->e($title) ?></title> <title><?= $this->e($title) ?></title>
<link href="/assets/styles.css" rel="stylesheet">
<link href="/semantic-ui/semantic.min.css" rel="stylesheet"> <link href="/semantic-ui/semantic.min.css" rel="stylesheet">
<link href="/assets/styles.css" rel="stylesheet">
<script src="/assets/jquery-1.11.3.min.js"></script> <script src="/assets/jquery-1.11.3.min.js"></script>
<script src="/semantic-ui/semantic.js"></script> <script src="/semantic-ui/semantic.js"></script>
</head> </head>
@ -15,8 +15,5 @@
<?= $this->section('content') ?> <?= $this->section('content') ?>
<footer>
</footer>
</body> </body>
</html> </html>

+ 1
- 1
views/webmention-details.php View File

@ -1,6 +1,6 @@
<?php $this->layout('layout-loggedin', ['title' => $title, 'accounts' => $accounts, 'user' => $user]); ?> <?php $this->layout('layout-loggedin', ['title' => $title, 'accounts' => $accounts, 'user' => $user]); ?>
<div class="ui main text container" style="margin-top: 80px;">
<div class="ui main text container" style="margin-top: 80px; margin-bottom: 40px;">
<h2>Webmention Request</h2> <h2>Webmention Request</h2>

+ 11
- 2
views/webmention-send.php View File

@ -1,9 +1,11 @@
<?php $this->layout('layout-loggedin', ['title' => $title, 'accounts' => $accounts, 'user' => $user]); ?> <?php $this->layout('layout-loggedin', ['title' => $title, 'accounts' => $accounts, 'user' => $user]); ?>
<div class="ui main text container" style="margin-top: 80px;">
<div class="ui main text container" style="margin-top: 80px; margin-bottom: 40px;">
<h2>Send Webmentions</h2> <h2>Send Webmentions</h2>
Source URL: <a href="<?= $url ?>" target="_blank"><?= $url ?></a>
<table class="ui very basic fixed single line unstackable table" id="send-table"> <table class="ui very basic fixed single line unstackable table" id="send-table">
<thead> <thead>
<th class="twelve wide">URL</th> <th class="twelve wide">URL</th>
@ -23,6 +25,12 @@ $(function(){
$.post('/dashboard/get_outgoing_links.json', { $.post('/dashboard/get_outgoing_links.json', {
url: source_url url: source_url
}, function(data) { }, function(data) {
if(data.links.length == 0) {
$("#send-table tbody tr:first td").html('<div class="ui message">No links were found from the given URL. Make sure your post is marked up with <a href="http://indiewebcamp.com/h-entry">h-entry</a> and contains some links.</div>');
$("#send-table").removeClass("fixed").removeClass("single").removeClass("line");
return;
}
$("#send-table tbody").html('<tr><td colspan="2"></td></tr>'); $("#send-table tbody").html('<tr><td colspan="2"></td></tr>');
for(var i in data.links) { for(var i in data.links) {
$("#send-table tr:last").after('<tr data-url="'+data.links[i]+'">' $("#send-table tr:last").after('<tr data-url="'+data.links[i]+'">'
@ -34,6 +42,7 @@ $(function(){
+'</td>' +'</td>'
+'</tr>'); +'</tr>');
} }
$("#send-table tbody tr:first").remove(); $("#send-table tbody tr:first").remove();
// Enable popup on any values that overflowed the container // Enable popup on any values that overflowed the container
@ -101,7 +110,7 @@ function bind_send_buttons() {
.popup { .popup {
word-wrap: break-word; word-wrap: break-word;
} }
#send-table tr {
#send-table tbody tr {
height: 83px; height: 83px;
} }
</style> </style>

Loading…
Cancel
Save