Merge branch 'release/0.3'
This commit is contained in:
commit
3bb27d878d
148 changed files with 2523 additions and 2111 deletions
18
.editorconfig
Normal file
18
.editorconfig
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Unix-style newlines with a newline ending every file
|
||||
[*]
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
# Tab indentation
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
tab_width = 4
|
||||
14
.env.dusk.testing
Normal file
14
.env.dusk.testing
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
APP_ENV=testing
|
||||
APP_DEBUG=true
|
||||
APP_KEY=base64:6DJhvZLVjE6dD4Cqrteh+6Z5vZlG+v/soCKcDHLOAH0=
|
||||
APP_URL=http://localhost:8000
|
||||
APP_LONGURL=localhost
|
||||
APP_SHORTURL=local
|
||||
|
||||
DB_CONNECTION=travis
|
||||
|
||||
CACHE_DRIVER=array
|
||||
SESSION_DRIVER=file
|
||||
QUEUE_DRIVER=sync
|
||||
|
||||
SCOUT_DRIVER=pgsql
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
APP_ENV=testing
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_KEY=base64:6DJhvZLVjE6dD4Cqrteh+6Z5vZlG+v/soCKcDHLOAH0=
|
||||
APP_URL=http://localhost:8000
|
||||
APP_LONGURL=localhost
|
||||
APP_SHORTURL=local
|
||||
|
|
|
|||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -10,3 +10,4 @@ Homestead.json
|
|||
/public/files
|
||||
/public/keybase.txt
|
||||
/coverage
|
||||
/LegacyTests
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ preset: laravel
|
|||
|
||||
disabled:
|
||||
- concat_without_spaces
|
||||
- simplified_null_return
|
||||
|
||||
finder:
|
||||
path: app/
|
||||
|
|
|
|||
30
.travis.yml
30
.travis.yml
|
|
@ -3,8 +3,23 @@ language: php
|
|||
sudo: false
|
||||
dist: trusty
|
||||
|
||||
cache:
|
||||
- apt
|
||||
|
||||
addons:
|
||||
postgresql: "9.5"
|
||||
postgresql: "9.6"
|
||||
apt:
|
||||
sources:
|
||||
- sourceline: 'deb http://ppa.launchpad.net/nginx/development/ubuntu trusty main'
|
||||
packages:
|
||||
- nginx
|
||||
- realpath
|
||||
artifacts:
|
||||
s3_region: "eu-west-1"
|
||||
paths:
|
||||
- $(ls tests/Browser/screenshots/*.png | tr "\n" ":")
|
||||
- $(ls tests/Browser/console/*.log | tr "\n" ":")
|
||||
- $(ls /tmp/*.log | tr "\n" ":")
|
||||
|
||||
services:
|
||||
- postgresql
|
||||
|
|
@ -14,7 +29,6 @@ env:
|
|||
- setup=basic
|
||||
|
||||
php:
|
||||
- 7.0.15
|
||||
- 7.1
|
||||
- nightly
|
||||
matrix:
|
||||
|
|
@ -22,13 +36,17 @@ matrix:
|
|||
- php: nightly
|
||||
|
||||
before_install:
|
||||
- phpenv config-rm xdebug.ini || echo "xdebug already absent"
|
||||
- mkdir travis-phantomjs
|
||||
- wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O $PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
|
||||
- tar -xvf $PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C $PWD/travis-phantomjs
|
||||
- export PATH=$PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64/bin:$PATH
|
||||
- travis_retry composer self-update --preview
|
||||
|
||||
install:
|
||||
- if [[ $setup = 'basic' ]]; then travis_retry composer install --no-interaction --prefer-dist; fi
|
||||
- if [[ $setup = 'stable' ]]; then travis_retry composer update --no-interaction --prefer-dist --prefer-stable; fi
|
||||
- if [[ $setup = 'lowest' ]]; then travis_retry composer update --no-interaction --prefer-dist --prefer-lowest --prefer-stable; fi
|
||||
- travis/install-nginx.sh
|
||||
|
||||
before_script:
|
||||
- psql -U travis -c 'create database travis_ci_test'
|
||||
|
|
@ -37,10 +55,10 @@ before_script:
|
|||
- php artisan key:generate
|
||||
- php artisan migrate
|
||||
- php artisan db:seed
|
||||
- php artisan token:generate
|
||||
- php artisan serve &
|
||||
- phantomjs --webdriver=127.0.0.1:9515 --webdriver-loglevel=DEBUG &
|
||||
- sleep 5 # Give artisan some time to start serving
|
||||
|
||||
script:
|
||||
- phpdbg -qrr vendor/bin/phpunit --coverage-text
|
||||
- php vendor/bin/phpunit --coverage-text
|
||||
- php artisan dusk
|
||||
- php artisan security:check
|
||||
|
|
|
|||
3
Makefile
3
Makefile
|
|
@ -3,7 +3,8 @@
|
|||
.PHONY: sass frontend js compress lint-sass lint-js
|
||||
jsfiles := $(wildcard resources/assets/js/*.js)
|
||||
sassfiles := $(wildcard resources/assets/sass/*.scss)
|
||||
yarnfiles:= node_modules/mapbox-gl/dist/mapbox-gl.css
|
||||
yarnfiles:= node_modules/mapbox-gl/dist/mapbox-gl.css \
|
||||
node_modules/alertify.js/dist/css/alertify.css
|
||||
assets := public/assets/css/app.css \
|
||||
public/assets/prism/prism.css public/assets/prism/prism.js \
|
||||
$(wildcard public/assets/js/*.js) \
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@ class GenerateToken extends Command
|
|||
public function handle(TokenService $tokenService)
|
||||
{
|
||||
$data = [
|
||||
'me' => env('APP_URL'),
|
||||
'client_id' => env('APP_URL') . '/notes/new',
|
||||
'me' => config('app.url'),
|
||||
'client_id' => route('micropub-client'),
|
||||
'scope' => 'post',
|
||||
];
|
||||
$token = $tokenService->getNewToken($data);
|
||||
|
|
|
|||
141
app/Http/Controllers/Admin/ArticlesController.php
Normal file
141
app/Http/Controllers/Admin/ArticlesController.php
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Article;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class ArticlesController extends Controller
|
||||
{
|
||||
/**
|
||||
* List the articles that can be edited.
|
||||
*
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$posts = Article::select('id', 'title', 'published')->orderBy('id', 'desc')->get();
|
||||
|
||||
return view('admin.articles.list', ['posts' => $posts]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the new article form.
|
||||
*
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$message = session('message');
|
||||
|
||||
return view('admin.articles.new', ['message' => $message]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process an incoming request for a new article and save it.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$published = $request->input('published');
|
||||
if ($published == null) {
|
||||
$published = '0';
|
||||
}
|
||||
//if a `.md` is attached use that for the main content.
|
||||
$content = null; //set default value
|
||||
if ($request->hasFile('article')) {
|
||||
$file = $request->file('article')->openFile();
|
||||
$content = $file->fread($file->getSize());
|
||||
}
|
||||
$main = $content ?? $request->input('main');
|
||||
try {
|
||||
$article = Article::create(
|
||||
[
|
||||
'url' => $request->input('url'),
|
||||
'title' => $request->input('title'),
|
||||
'main' => $main,
|
||||
'published' => $published,
|
||||
]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$msg = $e->getMessage();
|
||||
$unique = strpos($msg, '1062');
|
||||
if ($unique !== false) {
|
||||
//We've checked for error 1062, i.e. duplicate titleurl
|
||||
return redirect('admin/blog/new')->withInput()->with('message', 'Duplicate title, please change');
|
||||
}
|
||||
//this isn't the error you're looking for
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return view('admin.articles.newsuccess', ['id' => $article->id, 'title' => $article->title]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the edit form for an existing article.
|
||||
*
|
||||
* @param string The article id
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function edit($articleId)
|
||||
{
|
||||
$post = Article::select(
|
||||
'title',
|
||||
'main',
|
||||
'url',
|
||||
'published'
|
||||
)->where('id', $articleId)->get();
|
||||
|
||||
return view('admin.articles.edit', ['id' => $articleId, 'post' => $post]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process an incoming request to edit an article.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string
|
||||
* @return \Illuminate|View\Factory view
|
||||
*/
|
||||
public function update(Request $request, $articleId)
|
||||
{
|
||||
$published = $request->input('published');
|
||||
if ($published == null) {
|
||||
$published = '0';
|
||||
}
|
||||
$article = Article::find($articleId);
|
||||
$article->title = $request->input('title');
|
||||
$article->url = $request->input('url');
|
||||
$article->main = $request->input('main');
|
||||
$article->published = $published;
|
||||
$article->save();
|
||||
|
||||
return view('admin.articles.editsuccess', ['id' => $articleId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the delete confirmation form for an article.
|
||||
*
|
||||
* @param string The article id
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function delete($articleId)
|
||||
{
|
||||
return view('admin.articles.delete', ['id' => $articleId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a request to delete an aricle.
|
||||
*
|
||||
* @param string The article id
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function destroy($articleId)
|
||||
{
|
||||
Article::where('id', $articleId)->delete();
|
||||
|
||||
return view('admin.articles.deletesuccess', ['id' => $articleId]);
|
||||
}
|
||||
}
|
||||
88
app/Http/Controllers/Admin/ClientsController.php
Normal file
88
app/Http/Controllers/Admin/ClientsController.php
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\MicropubClient;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class ClientsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show a list of known clients.
|
||||
*
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$clients = MicropubClient::all();
|
||||
|
||||
return view('admin.clients.list', ['clients' => $clients]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show form to add a client name.
|
||||
*
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('admin.clients.new');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a form to edit a client name.
|
||||
*
|
||||
* @param string The client id
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function edit($clientId)
|
||||
{
|
||||
$client = MicropubClient::findOrFail($clientId);
|
||||
|
||||
return view('admin.clients.edit', [
|
||||
'id' => $clientId,
|
||||
'client_url' => $client->client_url,
|
||||
'client_name' => $client->client_name,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the request to adda new client name.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
MicropubClient::create([
|
||||
'client_url' => $request->input('client_url'),
|
||||
'client_name' => $request->input('client_name'),
|
||||
]);
|
||||
|
||||
return view('admin.clients.newsuccess');
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the request to edit a client name.
|
||||
*
|
||||
* @param string The client id
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function update($clientId, Request $request)
|
||||
{
|
||||
$client = MicropubClient::findOrFail($clientId);
|
||||
if ($request->input('edit')) {
|
||||
$client->client_url = $request->input('client_url');
|
||||
$client->client_name = $request->input('client_name');
|
||||
$client->save();
|
||||
|
||||
return view('admin.clietns.editsuccess');
|
||||
}
|
||||
if ($request->input('delete')) {
|
||||
$client->delete();
|
||||
|
||||
return view('admin.clients.deletesuccess');
|
||||
}
|
||||
}
|
||||
}
|
||||
169
app/Http/Controllers/Admin/ContactsController.php
Normal file
169
app/Http/Controllers/Admin/ContactsController.php
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Contact;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
|
||||
class ContactsController extends Controller
|
||||
{
|
||||
/**
|
||||
* List the currect contacts that can be edited.
|
||||
*
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$contacts = Contact::all();
|
||||
|
||||
return view('admin.contacts.list', ['contacts' => $contacts]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the form to add a new contact.
|
||||
*
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('admin.contacts.new');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form to edit an existing contact.
|
||||
*
|
||||
* @param string The contact id
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function edit($contactId)
|
||||
{
|
||||
$contact = Contact::findOrFail($contactId);
|
||||
|
||||
return view('admin.contacts.edit', ['contact' => $contact]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form to confirm deleting a contact.
|
||||
*
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function delete($contactId)
|
||||
{
|
||||
return view('admin.contacts.delete', ['id' => $contactId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the request to add a new contact.
|
||||
*
|
||||
* @param \Illuminate\Http|request $request
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$contact = new Contact();
|
||||
$contact->name = $request->input('name');
|
||||
$contact->nick = $request->input('nick');
|
||||
$contact->homepage = $request->input('homepage');
|
||||
$contact->twitter = $request->input('twitter');
|
||||
$contact->facebook = $request->input('facebook');
|
||||
$contact->save();
|
||||
|
||||
return view('admin.contacts.newsuccess', ['id' => $contact->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the request to edit a contact.
|
||||
*
|
||||
* @todo Allow saving profile pictures for people without homepages
|
||||
*
|
||||
* @param string The contact id
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function update($contactId, Request $request)
|
||||
{
|
||||
$contact = Contact::findOrFail($contactId);
|
||||
$contact->name = $request->input('name');
|
||||
$contact->nick = $request->input('nick');
|
||||
$contact->homepage = $request->input('homepage');
|
||||
$contact->twitter = $request->input('twitter');
|
||||
$contact->facebook = $request->input('facebook');
|
||||
$contact->save();
|
||||
|
||||
if ($request->hasFile('avatar')) {
|
||||
if ($request->input('homepage') != '') {
|
||||
$dir = parse_url($request->input('homepage'))['host'];
|
||||
$destination = public_path() . '/assets/profile-images/' . $dir;
|
||||
$filesystem = new Filesystem();
|
||||
if ($filesystem->isDirectory($destination) === false) {
|
||||
$filesystem->makeDirectory($destination);
|
||||
}
|
||||
$request->file('avatar')->move($destination, 'image');
|
||||
}
|
||||
}
|
||||
|
||||
return view('admin.contacts.editsuccess');
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the request to delete a contact.
|
||||
*
|
||||
* @param string The contact id
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function destroy($contactId)
|
||||
{
|
||||
$contact = Contact::findOrFail($contactId);
|
||||
$contact->delete();
|
||||
|
||||
return view('admin.contacts.deletesuccess');
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the avatar for a contact.
|
||||
*
|
||||
* This method attempts to find the microformat marked-up profile image
|
||||
* from a given homepage and save it accordingly
|
||||
*
|
||||
* @param string The contact id
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function getAvatar($contactId)
|
||||
{
|
||||
$contact = Contact::findOrFail($contactId);
|
||||
$homepage = $contact->homepage;
|
||||
if (($homepage !== null) && ($homepage !== '')) {
|
||||
$client = new Client();
|
||||
try {
|
||||
$response = $client->get($homepage);
|
||||
$html = (string) $response->getBody();
|
||||
$mf2 = \Mf2\parse($html, $homepage);
|
||||
} catch (\GuzzleHttp\Exception\BadResponseException $e) {
|
||||
return "Bad Response from $homepage";
|
||||
}
|
||||
$avatarURL = null; // Initialising
|
||||
foreach ($mf2['items'] as $microformat) {
|
||||
if ($microformat['type'][0] == 'h-card') {
|
||||
$avatarURL = $microformat['properties']['photo'][0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
$avatar = $client->get($avatarURL);
|
||||
} catch (\GuzzleHttp\Exception\BadResponseException $e) {
|
||||
return "Unable to get $avatarURL";
|
||||
}
|
||||
$directory = public_path() . '/assets/profile-images/' . parse_url($homepage)['host'];
|
||||
$filesystem = new Filesystem();
|
||||
if ($filesystem->isDirectory($directory) === false) {
|
||||
$filesystem->makeDirectory($directory);
|
||||
}
|
||||
$filesystem->put($directory . '/image', $avatar->getBody());
|
||||
|
||||
return view('admin.contacts.getavatarsuccess', ['homepage' => parse_url($homepage)['host']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
145
app/Http/Controllers/Admin/NotesController.php
Normal file
145
app/Http/Controllers/Admin/NotesController.php
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Note;
|
||||
use Validator;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Jobs\SendWebMentions;
|
||||
use App\Services\NoteService;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class NotesController extends Controller
|
||||
{
|
||||
protected $noteService;
|
||||
|
||||
public function __construct(NoteService $noteService = null)
|
||||
{
|
||||
$this->noteService = $noteService ?? new NoteService();
|
||||
}
|
||||
|
||||
/**
|
||||
* List the notes that can be edited.
|
||||
*
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$notes = Note::select('id', 'note')->orderBy('id', 'desc')->get();
|
||||
foreach ($notes as $note) {
|
||||
$note->originalNote = $note->getOriginal('note');
|
||||
}
|
||||
|
||||
return view('admin.notes.list', ['notes' => $notes]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form to make a new note.
|
||||
*
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('admin.notes.new');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the form to edit a specific note.
|
||||
*
|
||||
* @param string The note id
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function edit($noteId)
|
||||
{
|
||||
$note = Note::find($noteId);
|
||||
$note->originalNote = $note->getOriginal('note');
|
||||
|
||||
return view('admin.notes.edit', ['id' => $noteId, 'note' => $note]);
|
||||
}
|
||||
|
||||
/**
|
||||
* The delete note page.
|
||||
*
|
||||
* @param int id
|
||||
* @return view
|
||||
*/
|
||||
public function delete($noteId)
|
||||
{
|
||||
return view('admin.notes.delete', ['id' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a request to make a new note.
|
||||
*
|
||||
* @param Illuminate\Http\Request $request
|
||||
* @todo Sort this mess out
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validator = Validator::make(
|
||||
$request->all(),
|
||||
['photo' => 'photosize'],
|
||||
['photosize' => 'At least one uploaded file exceeds size limit of 5MB']
|
||||
);
|
||||
if ($validator->fails()) {
|
||||
return redirect('/admin/note/new')
|
||||
->withErrors($validator)
|
||||
->withInput();
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['content'] = $request->input('content');
|
||||
$data['in-reply-to'] = $request->input('in-reply-to');
|
||||
$data['location'] = $request->input('location');
|
||||
$data['syndicate'] = [];
|
||||
if ($request->input('twitter')) {
|
||||
$data['syndicate'][] = 'twitter';
|
||||
}
|
||||
if ($request->input('facebook')) {
|
||||
$data['syndicate'][] = 'facebook';
|
||||
}
|
||||
|
||||
$note = $this->noteService->createNote($data);
|
||||
|
||||
return view('admin.notes.newsuccess', [
|
||||
'id' => $note->id,
|
||||
'shorturl' => $note->shorturl,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a request to edit a note. Easy since this can only be done
|
||||
* from the admin CP.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function update($noteId, Request $request)
|
||||
{
|
||||
//update note data
|
||||
$note = Note::findOrFail($noteId);
|
||||
$note->note = $request->input('content');
|
||||
$note->in_reply_to = $request->input('in-reply-to');
|
||||
$note->save();
|
||||
|
||||
if ($request->input('webmentions')) {
|
||||
dispatch(new SendWebMentions($note));
|
||||
}
|
||||
|
||||
return view('admin.notes.editsuccess', ['id' => $noteId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the note.
|
||||
*
|
||||
* @param int id
|
||||
* @return view
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$note = Note::findOrFail($id);
|
||||
$note->delete();
|
||||
|
||||
return view('admin.notes.deletesuccess');
|
||||
}
|
||||
}
|
||||
99
app/Http/Controllers/Admin/PlacesController.php
Normal file
99
app/Http/Controllers/Admin/PlacesController.php
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Place;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\PlaceService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Phaza\LaravelPostgis\Geometries\Point;
|
||||
|
||||
class PlacesController extends Controller
|
||||
{
|
||||
protected $placeService;
|
||||
|
||||
public function __construct(PlaceService $placeService = null)
|
||||
{
|
||||
$this->placeService = $placeService ?? new PlaceService();
|
||||
}
|
||||
|
||||
/**
|
||||
* List the places that can be edited.
|
||||
*
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$places = Place::all();
|
||||
|
||||
return view('admin.places.list', ['places' => $places]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form to make a new place.
|
||||
*
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('admin.places.new');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the form to edit a specific place.
|
||||
*
|
||||
* @param string The place id
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function edit($placeId)
|
||||
{
|
||||
$place = Place::findOrFail($placeId);
|
||||
|
||||
$latitude = $place->getLatitude();
|
||||
$longitude = $place->getLongitude();
|
||||
|
||||
return view('admin.places.edit', [
|
||||
'id' => $placeId,
|
||||
'name' => $place->name,
|
||||
'description' => $place->description,
|
||||
'latitude' => $latitude,
|
||||
'longitude' => $longitude,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a request to make a new place.
|
||||
*
|
||||
* @param Illuminate\Http\Request $request
|
||||
* @return Illuminate\View\Factory view
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = [];
|
||||
$data['name'] = $request->name;
|
||||
$data['description'] = $request->description;
|
||||
$data['latitude'] = $request->latitude;
|
||||
$data['longitude'] = $request->longitude;
|
||||
$place = $this->placeService->createPlace($data);
|
||||
|
||||
return view('admin.places.newsuccess');
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a request to edit a place.
|
||||
*
|
||||
* @param string The place id
|
||||
* @param Illuminate\Http\Request $request
|
||||
* @return Illuminate\View\Factory view
|
||||
*/
|
||||
public function update($placeId, Request $request)
|
||||
{
|
||||
$place = Place::findOrFail($placeId);
|
||||
$place->name = $request->name;
|
||||
$place->description = $request->description;
|
||||
$place->location = new Point((float) $request->latitude, (float) $request->longitude);
|
||||
$place->save();
|
||||
|
||||
return view('admin.places.editsuccess');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
class AdminController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Admin Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here we have the logic for the admin cp
|
||||
|
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set variables.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->username = env('ADMIN_USER');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the main admin CP page.
|
||||
*
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function showWelcome()
|
||||
{
|
||||
return view('admin.welcome', ['name' => $this->username]);
|
||||
}
|
||||
}
|
||||
|
|
@ -12,14 +12,14 @@ class ArticlesController extends Controller
|
|||
*
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function showAllArticles($year = null, $month = null)
|
||||
public function index($year = null, $month = null)
|
||||
{
|
||||
$articles = Article::where('published', '1')
|
||||
->date($year, $month)
|
||||
->orderBy('updated_at', 'desc')
|
||||
->simplePaginate(5);
|
||||
|
||||
return view('articles', compact('articles'));
|
||||
return view('articles.index', compact('articles'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -27,14 +27,14 @@ class ArticlesController extends Controller
|
|||
*
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function singleArticle($year, $month, $slug)
|
||||
public function show($year, $month, $slug)
|
||||
{
|
||||
$article = Article::where('titleurl', $slug)->first();
|
||||
if ($article->updated_at->year != $year || $article->updated_at->month != $month) {
|
||||
throw new \Exception;
|
||||
}
|
||||
|
||||
return view('article', compact('article'));
|
||||
return view('articles.show', compact('article'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -63,7 +63,7 @@ class ArticlesController extends Controller
|
|||
$buildDate = $articles->first()->updated_at->toRssString();
|
||||
|
||||
return response()
|
||||
->view('rss', compact('articles', 'buildDate'), 200)
|
||||
->view('articles.rss', compact('articles', 'buildDate'), 200)
|
||||
->header('Content-Type', 'application/rss+xml');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ class AuthController extends Controller
|
|||
*/
|
||||
public function login(Request $request)
|
||||
{
|
||||
if ($request->input('username') === env('ADMIN_USER')
|
||||
if ($request->input('username') === config('admin.user')
|
||||
&&
|
||||
$request->input('password') === env('ADMIN_PASS')
|
||||
$request->input('password') === config('admin.pass')
|
||||
) {
|
||||
session(['loggedin' => true]);
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class ContactsController extends Controller
|
|||
*
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function showAll()
|
||||
public function index()
|
||||
{
|
||||
$filesystem = new Filesystem();
|
||||
$contacts = Contact::all();
|
||||
|
|
@ -25,7 +25,7 @@ class ContactsController extends Controller
|
|||
'/assets/profile-images/default-image';
|
||||
}
|
||||
|
||||
return view('contacts', compact('contacts'));
|
||||
return view('contacts.index', compact('contacts'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -33,17 +33,17 @@ class ContactsController extends Controller
|
|||
*
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function showSingle($nick)
|
||||
public function show($nick)
|
||||
{
|
||||
$filesystem = new Filesystem();
|
||||
$contact = Contact::where('nick', '=', $nick)->firstOrFail();
|
||||
$contact->homepageHost = parse_url($contact->homepage, PHP_URL_HOST);
|
||||
$file = public_path() . '/assets/profile-images/' . $contact->homepageHost . '/image';
|
||||
$contact->image = ($filesystem->exists($file)) ?
|
||||
$image = ($filesystem->exists($file)) ?
|
||||
'/assets/profile-images/' . $contact->homepageHost . '/image'
|
||||
:
|
||||
'/assets/profile-images/default-image';
|
||||
|
||||
return view('contact', ['contact' => $contact]);
|
||||
return view('contacts.show', compact('contact', 'image'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,8 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use IndieAuth\Client;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Services\TokenService;
|
||||
use Illuminate\Cookie\CookieJar;
|
||||
use App\Services\IndieAuthService;
|
||||
|
||||
class IndieAuthController extends Controller
|
||||
|
|
@ -16,11 +13,6 @@ class IndieAuthController extends Controller
|
|||
*/
|
||||
protected $indieAuthService;
|
||||
|
||||
/**
|
||||
* The IndieAuth Client implementation.
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* The Token handling service.
|
||||
*/
|
||||
|
|
@ -30,16 +22,14 @@ class IndieAuthController extends Controller
|
|||
* Inject the dependencies.
|
||||
*
|
||||
* @param \App\Services\IndieAuthService $indieAuthService
|
||||
* @param \IndieAuth\Client $client
|
||||
* @param \App\Services\TokenService $tokenService
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
IndieAuthService $indieAuthService = null,
|
||||
Client $client = null,
|
||||
TokenService $tokenService = null
|
||||
) {
|
||||
$this->indieAuthService = $indieAuthService ?? new IndieAuthService();
|
||||
$this->client = $client ?? new Client();
|
||||
$this->tokenService = $tokenService ?? new TokenService();
|
||||
}
|
||||
|
||||
|
|
@ -52,24 +42,22 @@ class IndieAuthController extends Controller
|
|||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Routing\RedirectResponse redirect
|
||||
*/
|
||||
public function beginauth(Request $request)
|
||||
public function start(Request $request)
|
||||
{
|
||||
$authorizationEndpoint = $this->indieAuthService->getAuthorizationEndpoint(
|
||||
$request->input('me'),
|
||||
$this->client
|
||||
$request->input('me')
|
||||
);
|
||||
if ($authorizationEndpoint) {
|
||||
if ($authorizationEndpoint !== null) {
|
||||
$authorizationURL = $this->indieAuthService->buildAuthorizationURL(
|
||||
$authorizationEndpoint,
|
||||
$request->input('me'),
|
||||
$this->client
|
||||
$request->input('me')
|
||||
);
|
||||
if ($authorizationURL) {
|
||||
return redirect($authorizationURL);
|
||||
}
|
||||
}
|
||||
|
||||
return redirect('/notes/new')->withErrors('Unable to determine authorisation endpoint', 'indieauth');
|
||||
return redirect(route('micropub-client'))->with('error', 'Unable to determine authorisation endpoint');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -79,35 +67,54 @@ class IndieAuthController extends Controller
|
|||
* @param \Illuminate\Http\Rrequest $request
|
||||
* @return \Illuminate\Routing\RedirectResponse redirect
|
||||
*/
|
||||
public function indieauth(Request $request)
|
||||
public function callback(Request $request)
|
||||
{
|
||||
if ($request->session()->get('state') != $request->input('state')) {
|
||||
return redirect('/notes/new')->withErrors(
|
||||
'Invalid <code>state</code> value returned from indieauth server',
|
||||
'indieauth'
|
||||
return redirect(route('micropub-client'))->with(
|
||||
'error',
|
||||
'Invalid <code>state</code> value returned from indieauth server'
|
||||
);
|
||||
}
|
||||
$tokenEndpoint = $this->indieAuthService->getTokenEndpoint($request->input('me'));
|
||||
if ($tokenEndpoint === false) {
|
||||
return redirect(route('micropub-client'))->with(
|
||||
'error',
|
||||
'Unable to determine token endpoint'
|
||||
);
|
||||
}
|
||||
$tokenEndpoint = $this->indieAuthService->getTokenEndpoint($request->input('me'), $this->client);
|
||||
$redirectURL = config('app.url') . '/indieauth';
|
||||
$clientId = config('app.url') . '/notes/new';
|
||||
$data = [
|
||||
'endpoint' => $tokenEndpoint,
|
||||
'code' => $request->input('code'),
|
||||
'me' => $request->input('me'),
|
||||
'redirect_url' => $redirectURL,
|
||||
'client_id' => $clientId,
|
||||
'redirect_url' => route('indieauth-callback'),
|
||||
'client_id' => route('micropub-client'),
|
||||
'state' => $request->input('state'),
|
||||
];
|
||||
$token = $this->indieAuthService->getAccessToken($data, $this->client);
|
||||
$token = $this->indieAuthService->getAccessToken($data);
|
||||
|
||||
if (array_key_exists('access_token', $token)) {
|
||||
$request->session()->put('me', $token['me']);
|
||||
$request->session()->put('token', $token['access_token']);
|
||||
|
||||
return redirect('/notes/new');
|
||||
return redirect(route('micropub-client'));
|
||||
}
|
||||
|
||||
return redirect('/notes/new')->withErrors('Unable to get a token from the endpoint', 'indieauth');
|
||||
return redirect(route('micropub-client'))->with(
|
||||
'error',
|
||||
'Unable to get a token from the endpoint'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log out the user, flush an session data, and overwrite any cookie data.
|
||||
*
|
||||
* @return \Illuminate\Routing\RedirectResponse redirect
|
||||
*/
|
||||
public function logout(Request $request)
|
||||
{
|
||||
$request->session()->flush();
|
||||
|
||||
return redirect(route('micropub-client'))->cookie('me', 'loggedout', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -125,7 +132,7 @@ class IndieAuthController extends Controller
|
|||
'client_id' => $request->input('client_id'),
|
||||
'state' => $request->input('state'),
|
||||
];
|
||||
$auth = $this->indieAuthService->verifyIndieAuthCode($authData, $this->client);
|
||||
$auth = $this->indieAuthService->verifyIndieAuthCode($authData);
|
||||
if (array_key_exists('me', $auth)) {
|
||||
$scope = $auth['scope'] ?? '';
|
||||
$tokenData = [
|
||||
|
|
@ -140,25 +147,11 @@ class IndieAuthController extends Controller
|
|||
'access_token' => $token,
|
||||
]);
|
||||
|
||||
return (new Response($content, 200))
|
||||
->header('Content-Type', 'application/x-www-form-urlencoded');
|
||||
return response($content)
|
||||
->header('Content-Type', 'application/x-www-form-urlencoded');
|
||||
}
|
||||
$content = 'There was an error verifying the authorisation code.';
|
||||
|
||||
return new Response($content, 400);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log out the user, flush an session data, and overwrite any cookie data.
|
||||
*
|
||||
* @param \Illuminate\Cookie\CookieJar $cookie
|
||||
* @return \Illuminate\Routing\RedirectResponse redirect
|
||||
*/
|
||||
public function indieauthLogout(Request $request, CookieJar $cookie)
|
||||
{
|
||||
$request->session()->flush();
|
||||
$cookie->queue('me', 'loggedout', 5);
|
||||
|
||||
return redirect('/notes/new');
|
||||
return response($content, 400);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,15 +36,12 @@ class MicropubClientController extends Controller
|
|||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function newNotePage(Request $request)
|
||||
public function create(Request $request)
|
||||
{
|
||||
$url = $request->session()->get('me');
|
||||
$syndication = $request->session()->get('syndication');
|
||||
|
||||
return view('micropubnewnotepage', [
|
||||
'url' => $url,
|
||||
'syndication' => $syndication,
|
||||
]);
|
||||
return view('micropub.create', compact('url', 'syndication'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -55,7 +52,7 @@ class MicropubClientController extends Controller
|
|||
* @param \Illuminate\Http\Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function postNewNote(Request $request)
|
||||
public function store(Request $request)
|
||||
{
|
||||
$domain = $request->session()->get('me');
|
||||
$token = $request->session()->get('token');
|
||||
|
|
@ -65,7 +62,7 @@ class MicropubClientController extends Controller
|
|||
$this->indieClient
|
||||
);
|
||||
if (! $micropubEndpoint) {
|
||||
return redirect('notes/new')->withErrors('Unable to determine micropub API endpoint', 'endpoint');
|
||||
return redirect(route('micropub-client'))->with('error', 'Unable to determine micropub API endpoint');
|
||||
}
|
||||
|
||||
$response = $this->postNoteRequest($request, $micropubEndpoint, $token);
|
||||
|
|
@ -79,7 +76,7 @@ class MicropubClientController extends Controller
|
|||
return redirect($location);
|
||||
}
|
||||
|
||||
return redirect('notes/new')->withErrors('Endpoint didn’t create the note.', 'endpoint');
|
||||
return redirect(route('micropub-client'))->with('error', 'Endpoint didn’t create the note.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -90,8 +87,6 @@ class MicropubClientController extends Controller
|
|||
* and syndicate-to
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \IndieAuth\Client $indieClient
|
||||
* @param \GuzzleHttp\Client $guzzleClient
|
||||
* @return \Illuminate\Routing\Redirector redirect
|
||||
*/
|
||||
public function refreshSyndicationTargets(Request $request)
|
||||
|
|
@ -99,9 +94,8 @@ class MicropubClientController extends Controller
|
|||
$domain = $request->session()->get('me');
|
||||
$token = $request->session()->get('token');
|
||||
$micropubEndpoint = $this->indieAuthService->discoverMicropubEndpoint($domain, $this->indieClient);
|
||||
|
||||
if (! $micropubEndpoint) {
|
||||
return redirect('notes/new')->withErrors('Unable to determine micropub API endpoint', 'endpoint');
|
||||
return redirect(route('micropub-client'))->with('error', 'Unable to determine micropub API endpoint');
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -110,14 +104,17 @@ class MicropubClientController extends Controller
|
|||
'query' => ['q' => 'syndicate-to'],
|
||||
]);
|
||||
} catch (\GuzzleHttp\Exception\BadResponseException $e) {
|
||||
return redirect('notes/new')->withErrors('Bad response when refreshing syndication targets', 'endpoint');
|
||||
return redirect(route('micropub-client'))->with(
|
||||
'error',
|
||||
'Bad response when refreshing syndication targets'
|
||||
);
|
||||
}
|
||||
$body = (string) $response->getBody();
|
||||
$syndication = $this->parseSyndicationTargets($body);
|
||||
|
||||
$request->session()->put('syndication', $syndication);
|
||||
|
||||
return redirect('notes/new');
|
||||
return redirect(route('micropub-client'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -184,8 +181,10 @@ class MicropubClientController extends Controller
|
|||
'headers' => $headers,
|
||||
]);
|
||||
} catch (\GuzzleHttp\Exception\BadResponseException $e) {
|
||||
return redirect('notes/new')
|
||||
->withErrors('There was a bad response from the micropub endpoint.', 'endpoint');
|
||||
return redirect(route('micropub-client'))->with(
|
||||
'error',
|
||||
'There was a bad response from the micropub endpoint.'
|
||||
);
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
|
@ -197,7 +196,7 @@ class MicropubClientController extends Controller
|
|||
* @param \Illuminate\Http\Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function postNewPlace(Request $request)
|
||||
public function newPlace(Request $request)
|
||||
{
|
||||
if ($request->session()->has('token') === false) {
|
||||
return response()->json([
|
||||
|
|
@ -274,15 +273,10 @@ class MicropubClientController extends Controller
|
|||
* Make a request to the micropub endpoint requesting any nearby places.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string $latitude
|
||||
* @param string $longitude
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function nearbyPlaces(
|
||||
Request $request,
|
||||
$latitude,
|
||||
$longitude
|
||||
) {
|
||||
public function nearbyPlaces(Request $request)
|
||||
{
|
||||
if ($request->session()->has('token') === false) {
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
|
|
@ -302,7 +296,7 @@ class MicropubClientController extends Controller
|
|||
}
|
||||
|
||||
try {
|
||||
$query = 'geo:' . $latitude . ',' . $longitude;
|
||||
$query = 'geo:' . $request->input('latitude') . ',' . $request->input('longitude');
|
||||
if ($request->input('u') !== null) {
|
||||
$query .= ';u=' . $request->input('u');
|
||||
}
|
||||
|
|
@ -319,7 +313,7 @@ class MicropubClientController extends Controller
|
|||
], 400);
|
||||
}
|
||||
|
||||
return (new Response($response->getBody(), 200))
|
||||
return response($response->getBody(), 200)
|
||||
->header('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
|
|
@ -344,6 +338,8 @@ class MicropubClientController extends Controller
|
|||
'name' => $syn['name'],
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$syndicateTo[] = ['target' => 'http://example.org', 'name' => 'Joe Bloggs on Example'];
|
||||
}
|
||||
if (count($syndicateTo) > 0) {
|
||||
return $syndicateTo;
|
||||
|
|
|
|||
|
|
@ -57,8 +57,46 @@ class MicropubController extends Controller
|
|||
if (array_search('post', $scopes) !== false) {
|
||||
$clientId = $tokenData->getClaim('client_id');
|
||||
if (($request->input('h') == 'entry') || ($request->input('type')[0] == 'h-entry')) {
|
||||
$data = [];
|
||||
$data['client-id'] = $clientId;
|
||||
if ($request->header('Content-Type') == 'application/json') {
|
||||
$data['content'] = $request->input('properties.content')[0];
|
||||
$data['in-reply-to'] = $request->input('properties.in-reply-to')[0];
|
||||
$data['location'] = $request->input('properties.location');
|
||||
//flatten location if array
|
||||
if (is_array($data['location'])) {
|
||||
$data['location'] = $data['location'][0];
|
||||
}
|
||||
} else {
|
||||
$data['content'] = $request->input('content');
|
||||
$data['in-reply-to'] = $request->input('in-reply-to');
|
||||
$data['location'] = $request->input('location');
|
||||
}
|
||||
$data['syndicate'] = [];
|
||||
$targets = array_pluck(config('syndication.targets'), 'uid', 'service.name');
|
||||
if (is_string($request->input('mp-syndicate-to'))) {
|
||||
$service = array_search($request->input('mp-syndicate-to'));
|
||||
if ($service == 'Twitter') {
|
||||
$data['syndicate'][] = 'twitter';
|
||||
}
|
||||
if ($service == 'Facebook') {
|
||||
$data['syndicate'][] = 'facebook';
|
||||
}
|
||||
}
|
||||
if (is_array($request->input('mp-syndicate-to'))) {
|
||||
foreach ($targets as $service => $target) {
|
||||
if (in_array($target, $request->input('mp-syndicate-to'))) {
|
||||
if ($service == 'Twitter') {
|
||||
$data['syndicate'][] = 'twitter';
|
||||
}
|
||||
if ($service == 'Facebook') {
|
||||
$data['syndicate'][] = 'facebook';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
$note = $this->noteService->createNote($request, $clientId);
|
||||
$note = $this->noteService->createNote($data);
|
||||
} catch (Exception $exception) {
|
||||
return response()->json(['error' => true], 400);
|
||||
}
|
||||
|
|
@ -69,8 +107,26 @@ class MicropubController extends Controller
|
|||
], 201)->header('Location', $note->longurl);
|
||||
}
|
||||
if ($request->input('h') == 'card' || $request->input('type')[0] == 'h-card') {
|
||||
$data = [];
|
||||
if ($request->header('Content-Type') == 'application/json') {
|
||||
$data['name'] = $request->input('properties.name');
|
||||
$data['description'] = $request->input('properties.description') ?? null;
|
||||
if ($request->has('properties.geo')) {
|
||||
$data['geo'] = $request->input('properties.geo');
|
||||
}
|
||||
} else {
|
||||
$data['name'] = $request->input('name');
|
||||
$data['description'] = $request->input('description');
|
||||
if ($request->has('geo')) {
|
||||
$data['geo'] = $request->input('geo');
|
||||
}
|
||||
if ($request->has('latitude')) {
|
||||
$data['latitude'] = $request->input('latitude');
|
||||
$data['longitude'] = $request->input('longitude');
|
||||
}
|
||||
}
|
||||
try {
|
||||
$place = $this->placeService->createPlace($request);
|
||||
$place = $this->placeService->createPlace($data);
|
||||
} catch (Exception $exception) {
|
||||
return response()->json(['error' => true], 400);
|
||||
}
|
||||
|
|
@ -106,7 +162,7 @@ class MicropubController extends Controller
|
|||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function getEndpoint(Request $request)
|
||||
public function get(Request $request)
|
||||
{
|
||||
$httpAuth = $request->header('Authorization');
|
||||
if (preg_match('/Bearer (.+)/', $httpAuth, $match)) {
|
||||
|
|
@ -162,16 +218,11 @@ class MicropubController extends Controller
|
|||
],
|
||||
]);
|
||||
}
|
||||
$content = 'No OAuth token sent with request.';
|
||||
$content = <<<'EOD'
|
||||
{
|
||||
"response": "error",
|
||||
"error": "no_token",
|
||||
"error_description": "No token provided with request"
|
||||
}
|
||||
EOD;
|
||||
|
||||
return (new Response($content, 400))
|
||||
->header('Content-Type', 'application/json');
|
||||
return response()->json([
|
||||
'response' => 'error',
|
||||
'error' => 'no_token',
|
||||
'error_description' => 'No token provided with request',
|
||||
], 400);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue