Move syndication targets to a config file, fixes #27, also more dynamically generate micropub token
This commit is contained in:
parent
42841eca08
commit
e12b4d39ef
7 changed files with 107 additions and 60 deletions
|
@ -36,6 +36,7 @@ before_script:
|
||||||
- php artisan key:generate
|
- php artisan key:generate
|
||||||
- php artisan migrate
|
- php artisan migrate
|
||||||
- php artisan db:seed
|
- php artisan db:seed
|
||||||
|
- php artisan token:generate
|
||||||
- php artisan serve &
|
- php artisan serve &
|
||||||
- sleep 5 # Give artisan some time to start serving
|
- sleep 5 # Give artisan some time to start serving
|
||||||
|
|
||||||
|
|
59
app/Console/Commands/GenerateToken.php
Normal file
59
app/Console/Commands/GenerateToken.php
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Services\TokenService;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class GenerateToken extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'token:generate';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Generate a token that can be used for testing purposes';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The token service class.
|
||||||
|
*
|
||||||
|
* @var TokenService
|
||||||
|
*/
|
||||||
|
protected $tokenService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle(TokenService $tokenService)
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
'me' => env('APP_URL'),
|
||||||
|
'client_id' => env('APP_URL') . '/notes/new',
|
||||||
|
'scope' => 'post',
|
||||||
|
];
|
||||||
|
$token = $tokenService->getNewToken($data);
|
||||||
|
Storage::disk('local')->put('dev-token', $token);
|
||||||
|
|
||||||
|
$this->info('Set token');
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,6 +16,7 @@ class Kernel extends ConsoleKernel
|
||||||
Commands\SecurityCheck::class,
|
Commands\SecurityCheck::class,
|
||||||
Commands\ParseCachedWebMentions::class,
|
Commands\ParseCachedWebMentions::class,
|
||||||
Commands\ReDownloadWebMentions::class,
|
Commands\ReDownloadWebMentions::class,
|
||||||
|
Commands\GenerateToken::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -124,35 +124,7 @@ class MicropubController extends Controller
|
||||||
//we have a valid token, is `syndicate-to` set?
|
//we have a valid token, is `syndicate-to` set?
|
||||||
if ($request->input('q') === 'syndicate-to') {
|
if ($request->input('q') === 'syndicate-to') {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'syndicate-to' => [
|
'syndicate-to' => config('syndication.targets')
|
||||||
[
|
|
||||||
'uid' => 'https://twitter.com/jonnybarnes',
|
|
||||||
'name' => 'jonnybarnes on Twitter',
|
|
||||||
'service' => [
|
|
||||||
'name' => 'Twitter',
|
|
||||||
'url' => 'https://twitter.com',
|
|
||||||
'photo' => 'https://upload.wikimedia.org/wikipedia/en/9/9f/Twitter_bird_logo_2012.svg',
|
|
||||||
],
|
|
||||||
'user' => [
|
|
||||||
'name' => 'jonnybarnes',
|
|
||||||
'url' => 'https://twitter.com/jonnybarnes',
|
|
||||||
'photo' => 'https://pbs.twimg.com/profile_images/1853565405/jmb-bw.jpg',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'uid' => 'https://facebook.com/jonnybarnes',
|
|
||||||
'name' => 'jonnybarnes on Facebook',
|
|
||||||
'service' => [
|
|
||||||
'name' => 'Facebook',
|
|
||||||
'url' => 'https://facebook.com',
|
|
||||||
'photo' => 'https://en.facebookbrand.com/wp-content/uploads/2016/05/FB-fLogo-Blue-broadcast-2.png',
|
|
||||||
],
|
|
||||||
'user' => [
|
|
||||||
'name' => 'jonnybarnes',
|
|
||||||
'url' => 'https://facebook.com/jonnybarnes',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
//nope, how about a geo URL?
|
//nope, how about a geo URL?
|
||||||
|
@ -176,35 +148,7 @@ class MicropubController extends Controller
|
||||||
//nope, ho about a config query?
|
//nope, ho about a config query?
|
||||||
if ($request->input('q') == 'config') {
|
if ($request->input('q') == 'config') {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'syndicate-to' => [
|
'syndicate-to' => config('syndication.targets')
|
||||||
[
|
|
||||||
'uid' => 'https://twitter.com/jonnybarnes',
|
|
||||||
'name' => 'jonnybarnes on Twitter',
|
|
||||||
'service' => [
|
|
||||||
'name' => 'Twitter',
|
|
||||||
'url' => 'https://twitter.com',
|
|
||||||
'photo' => 'https://upload.wikimedia.org/wikipedia/en/9/9f/Twitter_bird_logo_2012.svg',
|
|
||||||
],
|
|
||||||
'user' => [
|
|
||||||
'name' => 'jonnybarnes',
|
|
||||||
'url' => 'https://twitter.com/jonnybarnes',
|
|
||||||
'photo' => 'https://pbs.twimg.com/profile_images/1853565405/jmb-bw.jpg',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'uid' => 'https://facebook.com/jonnybarnes',
|
|
||||||
'name' => 'jonnybarnes on Facebook',
|
|
||||||
'service' => [
|
|
||||||
'name' => 'Facebook',
|
|
||||||
'url' => 'https://facebook.com',
|
|
||||||
'photo' => 'https://en.facebookbrand.com/wp-content/uploads/2016/05/FB-fLogo-Blue-broadcast-2.png',
|
|
||||||
],
|
|
||||||
'user' => [
|
|
||||||
'name' => 'jonnybarnes',
|
|
||||||
'url' => 'https://facebook.com/jonnybarnes',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ namespace App\Providers;
|
||||||
use App\Tag;
|
use App\Tag;
|
||||||
use App\Note;
|
use App\Note;
|
||||||
use Validator;
|
use Validator;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
|
@ -48,8 +49,10 @@ class AppServiceProvider extends ServiceProvider
|
||||||
|
|
||||||
//allow micropub use in development
|
//allow micropub use in development
|
||||||
if (env('APP_DEBUG') == true) {
|
if (env('APP_DEBUG') == true) {
|
||||||
session(['me' => 'https://jonnybarnes.localhost']);
|
session(['me' => env('APP_URL')]);
|
||||||
session(['token' => 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJtZSI6Imh0dHBzOlwvXC9qb25ueWJhcm5lcy5sb2NhbGhvc3QiLCJjbGllbnRfaWQiOiJodHRwczpcL1wvam9ubnliYXJuZXMubG9jYWxob3N0XC9ub3Rlc1wvbmV3Iiwic2NvcGUiOiJwb3N0IiwiZGF0ZV9pc3N1ZWQiOjE0ODA1ODg2MTYsIm5vbmNlIjoiMTIyOGZlOThjMjFmNTc4OCJ9.xNxViQaFkNaDXIH5gAZiG-GkLeYC-fQq-puHkBSesw0']);
|
if (Storage::exists('dev-token')) {
|
||||||
|
session(['token' => Storage::get('dev-token')]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
- Switch to Makefile for front-end build tasks
|
- Switch to Makefile for front-end build tasks
|
||||||
- Switch to Postgres based search
|
- Switch to Postgres based search
|
||||||
- Update travis to use aforementioned search and php 7.1
|
- Update travis to use aforementioned search and php 7.1
|
||||||
|
- Move syndication tarhets into a config file (issue#27)
|
||||||
|
|
||||||
## Version 0.0.17 (2016-11-25)
|
## Version 0.0.17 (2016-11-25)
|
||||||
- Add a basic search feature using Laravel Scout and Algolia (issue#38)
|
- Add a basic search feature using Laravel Scout and Algolia (issue#38)
|
||||||
|
|
38
config/syndication.php
Normal file
38
config/syndication.php
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Here we define the syndication targets to be
|
||||||
|
* returned by the micropub endpoint.
|
||||||
|
*/
|
||||||
|
|
||||||
|
return [
|
||||||
|
'targets' => [
|
||||||
|
[
|
||||||
|
'uid' => 'https://twitter.com/jonnybarnes',
|
||||||
|
'name' => 'jonnybarnes on Twitter',
|
||||||
|
'service' => [
|
||||||
|
'name' => 'Twitter',
|
||||||
|
'url' => 'https://twitter.com',
|
||||||
|
'photo' => 'https://upload.wikimedia.org/wikipedia/en/9/9f/Twitter_bird_logo_2012.svg',
|
||||||
|
],
|
||||||
|
'user' => [
|
||||||
|
'name' => 'jonnybarnes',
|
||||||
|
'url' => 'https://twitter.com/jonnybarnes',
|
||||||
|
'photo' => 'https://pbs.twimg.com/profile_images/1853565405/jmb-bw.jpg',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'uid' => 'https://facebook.com/jonnybarnes',
|
||||||
|
'name' => 'jonnybarnes on Facebook',
|
||||||
|
'service' => [
|
||||||
|
'name' => 'Facebook',
|
||||||
|
'url' => 'https://facebook.com',
|
||||||
|
'photo' => 'https://en.facebookbrand.com/wp-content/uploads/2016/05/FB-fLogo-Blue-broadcast-2.png',
|
||||||
|
],
|
||||||
|
'user' => [
|
||||||
|
'name' => 'jonnybarnes',
|
||||||
|
'url' => 'https://facebook.com/jonnybarnes',
|
||||||
|
],
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
Loading…
Add table
Add a link
Reference in a new issue