jonnybarnes.uk/app/Http/Controllers/MicropubClientController.php

437 lines
14 KiB
PHP
Raw Normal View History

2016-05-19 15:01:28 +01:00
<?php
namespace App\Http\Controllers;
use App\Services\IndieAuthService;
use IndieAuth\Client as IndieClient;
use GuzzleHttp\Client as GuzzleClient;
use Illuminate\Http\{Request, Response};
use GuzzleHttp\Exception\{ClientException, ServerException};
2016-05-19 15:01:28 +01:00
class MicropubClientController extends Controller
{
/**
* The IndieAuth service container.
*/
protected $indieAuthService;
/**
* Inject the dependencies.
*/
public function __construct(
IndieAuthService $indieAuthService = null,
IndieClient $indieClient = null,
GuzzleClient $guzzleClient = null
) {
$this->indieAuthService = $indieAuthService ?? new IndieAuthService();
$this->guzzleClient = $guzzleClient ?? new GuzzleClient();
$this->indieClient = $indieClient ?? new IndieClient();
}
/**
* Display the new notes form.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\View\Factory view
*/
public function create(Request $request)
2016-05-19 15:01:28 +01:00
{
$url = $request->session()->get('me');
$syndication = $request->session()->get('syndication');
$mediaEndpoint = $request->session()->get('media-endpoint');
$mediaURLs = $request->session()->get('media-links');
2016-05-19 15:01:28 +01:00
return view('micropub.create', compact('url', 'syndication', 'mediaEndpoint', 'mediaURLs'));
}
/**
* Process an upload to the media endpoint.
*
* @param Illuminate\Http\Request $request
* @return Illuminate\Http\Response
*/
public function processMedia(Request $request)
{
if ($request->hasFile('file') == false) {
return back();
}
$mediaEndpoint = $request->session()->get('media-endpoint');
if ($mediaEndpoint == null) {
return back();
}
$token = $request->session()->get('token');
$mediaURLs = [];
foreach ($request->file('file') as $file) {
try {
$response = $this->guzzleClient->request('POST', $mediaEndpoint, [
'headers' => [
'Authorization' => 'Bearer ' . $token,
],
'multipart' => [
[
'name' => 'file',
'contents' => fopen($file->path(), 'r'),
'filename' => $file->getClientOriginalName(),
],
],
]);
} catch (ClientException | ServerException $e) {
continue;
}
$mediaURLs[] = $response->getHeader('Location')[0];
}
$storedMediaURLs = $request->session()->get('media-links') ?? [];
$mediaURLsToSave = array_merge($storedMediaURLs, $mediaURLs);
$request->session()->put('media-links', $mediaURLsToSave);
return redirect(route('micropub-client'));
}
public function clearLinks(Request $request)
{
$request->session()->forget('media-links');
return redirect(route('micropub-client'));
2016-05-19 15:01:28 +01:00
}
/**
* Post the notes content to the relavent micropub API endpoint.
*
* @todo make sure this works with multiple syndication targets
*
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public function store(Request $request)
2016-05-19 15:01:28 +01:00
{
$domain = $request->session()->get('me');
$token = $request->session()->get('token');
$micropubEndpoint = $this->indieAuthService->discoverMicropubEndpoint(
$domain,
$this->indieClient
);
if (! $micropubEndpoint) {
return redirect(route('micropub-client'))->with('error', 'Unable to determine micropub API endpoint');
2016-05-19 15:01:28 +01:00
}
$response = $this->postNoteRequest($request, $micropubEndpoint, $token);
if ($response->getStatusCode() == 201) {
$request->session()->forget('media-links');
2016-05-19 15:01:28 +01:00
$location = $response->getHeader('Location');
if (is_array($location)) {
return redirect($location[0]);
}
return redirect($location);
}
2017-02-23 08:59:56 +00:00
return redirect(route('micropub-client'))->with('error', 'Endpoint didnt create the note.');
2016-05-19 15:01:28 +01:00
}
/**
* Show currently stored configuration values.
*
* @param Illuminate\Http\Request $request
* @return view
*/
public function config(Request $request)
{
$data['me'] = $request->session()->get('me');
$data['token'] = $request->session()->get('token');
$data['syndication'] = $request->session()->get('syndication') ?? 'none defined';
$data['media-endpoint'] = $request->session()->get('media-endpoint') ?? 'none defined';
return view('micropub.config', compact('data'));
}
/**
* Query the micropub endpoint and store response in the session.
*
* @param Illuminate\Http\Request $request
* @return redirect
*/
public function queryEndpoint(Request $request)
{
$domain = $request->session()->get('me');
$token = $request->session()->get('token');
$micropubEndpoint = $this->indieAuthService->discoverMicropubEndpoint($domain);
if ($micropubEndpoint !== null) {
try {
$response = $this->guzzleClient->get($micropubEndpoint, [
'headers' => ['Authorization' => 'Bearer ' . $token],
'query' => 'q=config',
]);
} catch (ClientException | ServerException $e) {
return back();
}
$body = (string) $response->getBody();
$syndication = $this->parseSyndicationTargets($body);
$request->session()->put('syndication', $syndication);
$mediaEndpoint = $this->parseMediaEndpoint($body);
$request->session()->put('media-endpoint', $mediaEndpoint);
return back();
}
}
2016-05-19 15:01:28 +01:00
/**
* This method performs the actual POST request.
*
* @param \Illuminate\Http\Request $request
* @param string The Micropub endpoint to post to
* @param string The token to authenticate the request with
* @return \GuzzleHttp\Response $response | \Illuminate\RedirectFactory redirect
*/
private function postNoteRequest(
Request $request,
$micropubEndpoint,
$token
) {
$multipart = [
[
'name' => 'h',
'contents' => 'entry',
],
[
'name' => 'content',
'contents' => $request->input('content'),
],
];
if ($request->hasFile('photo')) {
$photos = $request->file('photo');
foreach ($photos as $photo) {
$multipart[] = [
'name' => 'photo[]',
'contents' => fopen($photo->path(), 'r'),
'filename' => $photo->getClientOriginalName(),
2016-05-19 15:01:28 +01:00
];
}
}
if ($request->input('in-reply-to') != '') {
$multipart[] = [
'name' => 'in-reply-to',
'contents' => $request->input('in-reply-to'),
2016-05-19 15:01:28 +01:00
];
}
if ($request->input('mp-syndicate-to')) {
foreach ($request->input('mp-syndicate-to') as $syn) {
2016-05-19 15:01:28 +01:00
$multipart[] = [
'name' => 'mp-syndicate-to[]',
2016-05-19 15:01:28 +01:00
'contents' => $syn,
];
}
}
if ($request->input('location')) {
if ($request->input('location') !== 'no-location') {
2016-05-19 15:01:28 +01:00
$multipart[] = [
'name' => 'location',
2016-10-05 16:13:00 +01:00
'contents' => $request->input('location'),
2016-05-19 15:01:28 +01:00
];
}
}
if ($request->input('media')) {
foreach ($request->input('media') as $media) {
$multipart[] = [
'name' => 'photo[]',
'contents' => $media,
];
}
}
2016-05-19 15:01:28 +01:00
$headers = [
'Authorization' => 'Bearer ' . $token,
];
try {
$response = $this->guzzleClient->post($micropubEndpoint, [
'multipart' => $multipart,
'headers' => $headers,
]);
} catch (\GuzzleHttp\Exception\BadResponseException $e) {
2017-03-02 16:01:48 +00:00
return redirect(route('micropub-client'))->with(
'error',
'There was a bad response from the micropub endpoint.'
);
2016-05-19 15:01:28 +01:00
}
return $response;
}
/**
* Create a new place.
*
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public function newPlace(Request $request)
2016-05-19 15:01:28 +01:00
{
if ($request->session()->has('token') === false) {
return response()->json([
'error' => true,
'error_description' => 'No known token',
], 400);
}
2016-05-19 15:01:28 +01:00
$domain = $request->session()->get('me');
$token = $request->session()->get('token');
$micropubEndpoint = $this->indieAuthService->discoverMicropubEndpoint($domain, $this->indieClient);
if (! $micropubEndpoint) {
return response()->json([
2016-05-19 15:01:28 +01:00
'error' => true,
'error_description' => 'Could not determine the micropub endpoint.',
], 400);
2016-05-19 15:01:28 +01:00
}
$place = $this->postPlaceRequest($request, $micropubEndpoint, $token);
if ($place === false) {
return response()->json([
2016-05-19 15:01:28 +01:00
'error' => true,
'error_description' => 'Unable to create the new place',
], 400);
2016-05-19 15:01:28 +01:00
}
return response()->json([
2016-10-07 12:17:12 +01:00
'uri' => $place,
2016-05-19 15:01:28 +01:00
'name' => $request->input('place-name'),
'latitude' => $request->input('place-latitude'),
'longitude' => $request->input('place-longitude'),
]);
2016-05-19 15:01:28 +01:00
}
/**
* Actually make a micropub request to make a new place.
*
* @param \Illuminate\Http\Request $request
* @param string The Micropub endpoint to post to
* @param string The token to authenticate the request with
* @param \GuzzleHttp\Client $client
* @return \GuzzleHttp\Response $response | \Illuminate\RedirectFactory redirect
*/
private function postPlaceRequest(
Request $request,
$micropubEndpoint,
$token
) {
$formParams = [
'h' => 'card',
'name' => $request->input('place-name'),
'description' => $request->input('place-description'),
'geo' => 'geo:' . $request->input('place-latitude') . ',' . $request->input('place-longitude'),
];
$headers = [
'Authorization' => 'Bearer ' . $token,
];
try {
$response = $this->guzzleClient->request('POST', $micropubEndpoint, [
'form_params' => $formParams,
'headers' => $headers,
]);
} catch (ClientException $e) {
return false;
2016-05-19 15:01:28 +01:00
}
if ($response->getStatusCode() == 201) {
return $response->getHeader('Location')[0];
}
return false;
}
/**
* Make a request to the micropub endpoint requesting any nearby places.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function nearbyPlaces(Request $request)
{
if ($request->session()->has('token') === false) {
return response()->json([
'error' => true,
'error_description' => 'No known token',
], 400);
}
2016-05-19 15:01:28 +01:00
$domain = $request->session()->get('me');
$token = $request->session()->get('token');
2016-05-19 15:01:28 +01:00
$micropubEndpoint = $this->indieAuthService->discoverMicropubEndpoint($domain, $this->indieClient);
if (! $micropubEndpoint) {
return response()->json([
'error' => true,
'error_description' => 'No known endpoint',
], 400);
2016-05-19 15:01:28 +01:00
}
try {
$query = 'geo:' . $request->input('latitude') . ',' . $request->input('longitude');
2016-10-03 14:46:53 +01:00
if ($request->input('u') !== null) {
$query .= ';u=' . $request->input('u');
Squashed commit of the following: commit e7f1c4c84579b959fe2997ff4d2315ee53acfe9a Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Thu Sep 29 11:22:44 2016 +0100 Add latest change, fix spelling errors in rest of changelog commit 637b5107b557f1c2a56327a40b3d7b4b7297fa29 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 21:13:06 2016 +0100 Add a test for uncertainty parameter commit 5e7504b323debf9c91e0cca428b4dca7dda0789d Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 21:11:12 2016 +0100 Format the ternaty operator correctly commit 19c978a5ac59cd7dfdceee9a8f1aaa6539d8ac66 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 20:46:19 2016 +0100 Fix typo commit d4e5b5fc384d0ccd715ea28a51821f958f6c2caa Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 20:41:23 2016 +0100 Add paraphanalia commit a96f104894de6c06dc5e41044482de2355cb4965 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 20:35:17 2016 +0100 Add the geolocation uncertainty to nearby places request commit 0f6d5649e2f3316040d7453f5fcc96ac1f0ac783 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 20:34:38 2016 +0100 Use a query parameter for geolocation uncertainty commit a9147a074315fabb0d76e5991b34a70b2143761c Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 19:58:08 2016 +0100 Make use of uncertainty parameter when finding nearby places commit bad384b5d8be3ea8905d8f6ca3c20f448869853d Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 19:28:42 2016 +0100 Support sending uncertainty value to micropub endpoint
2016-09-29 11:28:31 +01:00
}
2016-05-19 15:01:28 +01:00
$response = $this->guzzleClient->get($micropubEndpoint, [
'headers' => ['Authorization' => 'Bearer ' . $token],
Squashed commit of the following: commit e7f1c4c84579b959fe2997ff4d2315ee53acfe9a Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Thu Sep 29 11:22:44 2016 +0100 Add latest change, fix spelling errors in rest of changelog commit 637b5107b557f1c2a56327a40b3d7b4b7297fa29 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 21:13:06 2016 +0100 Add a test for uncertainty parameter commit 5e7504b323debf9c91e0cca428b4dca7dda0789d Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 21:11:12 2016 +0100 Format the ternaty operator correctly commit 19c978a5ac59cd7dfdceee9a8f1aaa6539d8ac66 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 20:46:19 2016 +0100 Fix typo commit d4e5b5fc384d0ccd715ea28a51821f958f6c2caa Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 20:41:23 2016 +0100 Add paraphanalia commit a96f104894de6c06dc5e41044482de2355cb4965 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 20:35:17 2016 +0100 Add the geolocation uncertainty to nearby places request commit 0f6d5649e2f3316040d7453f5fcc96ac1f0ac783 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 20:34:38 2016 +0100 Use a query parameter for geolocation uncertainty commit a9147a074315fabb0d76e5991b34a70b2143761c Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 19:58:08 2016 +0100 Make use of uncertainty parameter when finding nearby places commit bad384b5d8be3ea8905d8f6ca3c20f448869853d Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 19:28:42 2016 +0100 Support sending uncertainty value to micropub endpoint
2016-09-29 11:28:31 +01:00
'query' => ['q' => $query],
2016-05-19 15:01:28 +01:00
]);
} catch (\GuzzleHttp\Exception\BadResponseException $e) {
return response()->json([
'error' => true,
Squashed commit of the following: commit 19ec350ca9c3a2ec9da6ee3823f3b0a09efe3eaa Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Tue Nov 22 16:07:42 2016 +0000 Update changelog commit 73428d3d94c659e5e4431b6740ba10dc2a609e44 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Tue Nov 22 16:03:37 2016 +0000 output of gulp compress commit 4bb8038e787e35b5d38be9d63600b10bb9d75a07 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Tue Nov 22 16:03:11 2016 +0000 import Guzzle’s ClientException namespace commit 4bcb676bb95274da2422023fefa88b8d246b7f97 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Tue Nov 22 16:02:24 2016 +0000 Update manual testing token commit d902de76f00b4f3bba94ce6528f87e43f6c113f9 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Tue Nov 22 16:01:52 2016 +0000 output of gulp js-assets commit 0a495956e4f540aae0d1515229dd29c30c76fd64 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Tue Nov 22 16:01:27 2016 +0000 Update new note page to use Mapbox GL JS commit bf22004256179c9487c668eb77785a9bc90227bc Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Mon Nov 21 18:47:59 2016 +0000 output of gulp js-assets commit 22ed61cb853d98a4638754d44f042841e2b4495c Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Mon Nov 21 18:47:06 2016 +0000 Attempting to use mapbox gl on the newnote page commit 47fd891f1b3f0da59d10e937f7ed11f3b603c4af Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Sat Nov 19 17:21:53 2016 +0000 gulp derived assets commit 19e83f33b1c8c7a90a74d0ad17a6cace8761bcef Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Sat Nov 19 17:21:16 2016 +0000 Move .map styles into mapbox.scss commit 3d848d59126032671907a1e354cf121441d9a6e3 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Sat Nov 19 17:12:51 2016 +0000 gulp derived assets commit 9e51e8690ac8b782bc56663e7ec682837b27d4a1 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Sat Nov 19 17:12:32 2016 +0000 Link to mapbox-gl files commit 296b5fd7770f2a1c5c26ed4efedd99a7a0ad0bed Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Sat Nov 19 17:12:08 2016 +0000 Use mapbox gl to add maps to notes commit bd031df6e969b7af741730acabe41465f68bd3a1 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Sat Nov 19 17:11:27 2016 +0000 Update sass to style mapbox gl maps commit a7cd5e6eaa9510b5c9de672b6d5ed6917dabd7c6 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Nov 18 16:19:45 2016 +0000 output of gulp compress commit fe63c7ed394d62cd0e47a9ef718d9629d8643e71 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Nov 18 16:18:47 2016 +0000 output of gulp sass commit 15ac4012681635753a4b1f52d81f7f9e24830eb4 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Nov 18 16:18:05 2016 +0000 Add a dividing line between notes and bio on the homepage commit 5ada66b1a01ae57359145eb757cab65769400f1e Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Nov 18 16:12:01 2016 +0000 output of gulp sass commit 86adf97c3831c3310683a25c2671c7560700de1a Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Nov 18 16:11:33 2016 +0000 Resize note metadata for spacial flow commit 3f3fc51ea8df8206d5b13512295ac09827bb2ede Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Nov 18 15:37:21 2016 +0000 output of gulp sass commit df6f7f827641dc4deca621d099357757f760ece4 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Nov 18 15:36:51 2016 +0000 Use system UI fonts commit b71950275ddaf274b26195694a07c1b58f746725 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Nov 18 15:31:30 2016 +0000 output of gulp compress commit 5ff5d73a803b9bcc4e2f314946c1d757dcabae67 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Nov 18 15:30:12 2016 +0000 output of gulp js-assets commit d8ff563569223bddc836ab9f8fc7c43970273b44 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Nov 18 15:29:27 2016 +0000 use containing divs in new place section of form commit 3cbf3083612210cdd7609c930737cf7a698ec024 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Nov 18 14:39:27 2016 +0000 gulp sass output commit 239b742a355a397f5b84377b26b2d7a4254bd50e Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Nov 18 14:38:52 2016 +0000 Better spacing of form elements on mobile commit a20279e3f4216b87ff59ed4e507b6de9e212db9f Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Nov 18 13:41:31 2016 +0000 Derived assets commit 86ebd05472498814084e86fb0c2d674633f00096 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Nov 18 13:40:42 2016 +0000 Use containing divs for flex layout commit 00e0e6f3f462ca575e92209a86ada67b7f5ff757 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Thu Nov 17 14:38:39 2016 +0000 Correct scss according to stylelint commit 6dd8ff4d13c3ab83c6a811501b817c45b89338ce Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Thu Nov 17 14:33:46 2016 +0000 Get stylelint working commit 9b9a64defd9335014b46070e2b92a392929f4aa5 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Thu Nov 17 09:48:28 2016 +0000 Add missing new-line to match style commit 2521446f32420047d6d5f7372f4f7afc17200a1c Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Tue Nov 15 13:16:45 2016 +0000 Add logging during an error, improve the error message commit 095507bec225992aac510a2ca852f65c197f0298 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Tue Nov 15 13:15:59 2016 +0000 Update test token commit 374ef70fecaedf041f12a57688ed9596e25a2ce6 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Tue Nov 15 13:15:16 2016 +0000 Remove typekit for now commit f5671ad435732ddb3288a2e02de7631a6acb4183 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Nov 11 16:06:01 2016 +0000 Better designed new note form commit f38df507b85502e733fa38e970cd584f7d79bca1 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Nov 11 13:28:21 2016 +0000 More styling, use normal pagination, improve bio commit 077076d4f92014d488bca5d4dbbab5af913e6cf0 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Nov 11 00:05:56 2016 +0000 Use an anchor for permalinks, re-word projects page commit 37c6e862b693c2bfd3a39654a533627e0f73fd1a Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Thu Nov 10 23:58:54 2016 +0000 The resulting CSS files commit 1a3b6d7064b1b67238ffd3909d6d1ae54a4f78e1 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Thu Nov 10 23:31:53 2016 +0000 Sass for very basic redesign commit e5d9e9d41b50d7f316fcae9bae75863aa09a7d63 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Thu Nov 10 23:00:35 2016 +0000 Use app.(s)css commit 231c5292e68220f588e9d300975bb19dfea20b4f Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Thu Nov 10 22:59:50 2016 +0000 Restructure homepage to show notes, also show bio when on '/', but note '/notes' commit 11a272b2a3050297dd84105a6c70adc937a0c409 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Thu Nov 10 17:49:30 2016 +0000 Set my homepage to the stream of notes commit 2e46ccad4038be64b5007f15dabee0321061fe98 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Tue Nov 8 23:58:11 2016 +0000 Drop sanitize.css and use normalize.css instead, also fix compress method commit 8082403d7464a873691fabab07ae4f6116993cdf Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Tue Nov 8 23:48:35 2016 +0000 Sort out yarn dependencies commit 8ef7137d160ae8577e42ab1fd19e957aa37cf08b Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Tue Nov 8 23:39:49 2016 +0000 Remove the compiled css commit 8284cdf838f5222eff87c942f119d6000a1b6fc6 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Tue Nov 8 23:16:27 2016 +0000 Remove sass files
2016-11-22 16:08:02 +00:00
'error_description' => 'The endpoint ' . $micropubEndpoint . ' returned a non-good response',
], 400);
2016-05-19 15:01:28 +01:00
}
return response($response->getBody(), 200)
2016-05-19 15:01:28 +01:00
->header('Content-Type', 'application/json');
}
/**
* Parse the syndication targets retreived from a cookie, to a form that can
* be used in a view.
*
* @param string $syndicationTargets
* @return array|null
*/
private function parseSyndicationTargets($syndicationTargets = null)
{
if ($syndicationTargets === null) {
2017-02-24 14:38:52 +00:00
return;
2016-05-19 15:01:28 +01:00
}
$syndicateTo = [];
$data = json_decode($syndicationTargets, true);
if (array_key_exists('syndicate-to', $data)) {
foreach ($data['syndicate-to'] as $syn) {
2016-07-13 17:32:10 +01:00
$syndicateTo[] = [
'target' => $syn['uid'],
'name' => $syn['name'],
];
}
2016-05-19 15:01:28 +01:00
}
if (count($syndicateTo) > 0) {
return $syndicateTo;
2016-05-19 15:01:28 +01:00
}
}
/**
* Parse the media-endpoint retrieved from querying a micropub endpoint.
*
* @param string|null
* @return string
*/
private function parseMediaEndpoint($queryResponse = null)
{
if ($queryResponse === null) {
return;
}
$data = json_decode($queryResponse, true);
if (array_key_exists('media-endpoint', $data)) {
return $data['media-endpoint'];
}
}
2016-05-19 15:01:28 +01:00
}