Improve likes
Squashed commit of the following: commit 4dc223939c31fd5771b9e6895c8e9e0c88fc6663 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Jan 12 21:19:29 2018 +0000 update changelog commit 7b15937a097c12145e60dfec67cad19e385fcb9f Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Jan 12 21:19:13 2018 +0000 re-compile frontend assets commit f533d5e463d06e158b7bedbfd3602af70113acbc Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Jan 12 21:14:11 2018 +0000 Only use “by” if there is an author name to show commit 7b067fd559ce2f4a82ad747a3ebd3474e221169c Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Jan 12 21:12:27 2018 +0000 Some styles for the likes page commit 039523f595115c1329a3939837ebf589184de995 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Jan 12 21:11:44 2018 +0000 Add a like with just the url to the seeder commit c43d4b07936fceeeb59460399a20abec7a9bc3ae Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Jan 12 20:44:46 2018 +0000 Add test for the admin cp part of likes commit eb115fa481319e98bf54a9fa6aa682479e56787d Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Jan 12 20:44:28 2018 +0000 Catch 400 errors from a POSSE attempt, its not that important commit 79f7aa7807534eb76ae57dee72002f99249255b0 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Jan 12 20:01:19 2018 +0000 Better fetch data for tweets, attempt to POSSE them back to twitter commit 1ad078929f918c00db550c0af315677cd991dad6 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Jan 12 20:00:40 2018 +0000 Only filter the like content when its actual HTML commit 10f1ba430d4d5262d28e24ca0413474900ea6145 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Jan 12 19:59:57 2018 +0000 Add link to POSSE to twitter via bridgy commit 7f8e5c6dd39716fb51b5766de2f24c7e01355dbb Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Jan 12 19:59:22 2018 +0000 add links in the admin welcome page for likes commit ebe80b07759881ffb98f8f5117ef25310aaabe6c Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Jan 12 18:22:35 2018 +0000 Add the admin routes commit 5e150a7c39f5d71688b7ef14c924d09ba2ec82ba Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Jan 12 18:22:15 2018 +0000 Add admin functionality for likes
This commit is contained in:
parent
6ccd564d56
commit
50facf52de
23 changed files with 281 additions and 12 deletions
61
app/Http/Controllers/Admin/LikesController.php
Normal file
61
app/Http/Controllers/Admin/LikesController.php
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Models\Like;
|
||||||
|
use App\Jobs\ProcessLike;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
|
||||||
|
class LikesController extends Controller
|
||||||
|
{
|
||||||
|
public function index(): View
|
||||||
|
{
|
||||||
|
$likes = Like::all();
|
||||||
|
|
||||||
|
return view('admin.likes.index', compact('likes'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(): View
|
||||||
|
{
|
||||||
|
return view('admin.likes.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(): RedirectResponse
|
||||||
|
{
|
||||||
|
$like = Like::create([
|
||||||
|
'url' => normalize_url(request()->input('like_url')),
|
||||||
|
]);
|
||||||
|
ProcessLike::dispatch($like);
|
||||||
|
|
||||||
|
return redirect('/admin/likes');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(int $likeId): View
|
||||||
|
{
|
||||||
|
$like = Like::findOrFail($likeId);
|
||||||
|
|
||||||
|
return view('admin.likes.edit', [
|
||||||
|
'id' => $like->id,
|
||||||
|
'like_url' => $like->url,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(int $likeId): RedirectResponse
|
||||||
|
{
|
||||||
|
$like = Like::findOrFail($likeId);
|
||||||
|
$like->url = normalize_url(request()->input('like_url'));
|
||||||
|
$like->save();
|
||||||
|
ProcessLike::dispatch($like);
|
||||||
|
|
||||||
|
return redirect('/admin/likes');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(int $likeId): RedirectResponse
|
||||||
|
{
|
||||||
|
Like::where('id', $likeId)->delete();
|
||||||
|
|
||||||
|
return redirect('/admin/likes');
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,8 +5,10 @@ namespace App\Jobs;
|
||||||
use App\Models\Like;
|
use App\Models\Like;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Thujohn\Twitter\Facades\Twitter;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use GuzzleHttp\Exception\ClientException;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Jonnybarnes\WebmentionsParser\Authorship;
|
use Jonnybarnes\WebmentionsParser\Authorship;
|
||||||
|
@ -35,6 +37,32 @@ class ProcessLike implements ShouldQueue
|
||||||
*/
|
*/
|
||||||
public function handle(Client $client, Authorship $authorship)
|
public function handle(Client $client, Authorship $authorship)
|
||||||
{
|
{
|
||||||
|
if ($this->isTweet($this->like->url)) {
|
||||||
|
$tweet = Twitter::getOembed(['url' => $this->like->url]);
|
||||||
|
$this->like->author_name = $tweet->author_name;
|
||||||
|
$this->like->author_url = $tweet->author_url;
|
||||||
|
$this->like->content = $tweet->html;
|
||||||
|
$this->like->save();
|
||||||
|
|
||||||
|
//POSSE like
|
||||||
|
try {
|
||||||
|
$response = $client->request(
|
||||||
|
'POST',
|
||||||
|
'https://brid.gy/publish/webmention',
|
||||||
|
[
|
||||||
|
'form_params' => [
|
||||||
|
'source' => $this->like->url,
|
||||||
|
'target' => 'https://brid.gy/publish/twitter',
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
} catch(ClientException $exception) {
|
||||||
|
//no biggie
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
$response = $client->request('GET', $this->like->url);
|
$response = $client->request('GET', $this->like->url);
|
||||||
$mf2 = \Mf2\parse((string) $response->getBody(), $this->like->url);
|
$mf2 = \Mf2\parse((string) $response->getBody(), $this->like->url);
|
||||||
if (array_has($mf2, 'items.0.properties.content')) {
|
if (array_has($mf2, 'items.0.properties.content')) {
|
||||||
|
@ -51,9 +79,17 @@ class ProcessLike implements ShouldQueue
|
||||||
$this->like->author_name = $author;
|
$this->like->author_name = $author;
|
||||||
}
|
}
|
||||||
} catch (AuthorshipParserException $exception) {
|
} catch (AuthorshipParserException $exception) {
|
||||||
return;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->like->save();
|
$this->like->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function isTweet(string $url): bool
|
||||||
|
{
|
||||||
|
$host = parse_url($url, PHP_URL_HOST);
|
||||||
|
$parts = array_reverse(explode('.', $host));
|
||||||
|
|
||||||
|
return $parts[0] === 'com' && $parts[1] === 'twitter';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,13 @@ class Like extends Model
|
||||||
|
|
||||||
$mf2 = Mf2\parse($value, $this->url);
|
$mf2 = Mf2\parse($value, $this->url);
|
||||||
|
|
||||||
return $this->filterHTML($mf2['items'][0]['properties']['content'][0]['html']);
|
if (array_get($mf2, 'items.0.properties.content.0.html')) {
|
||||||
|
return $this->filterHTML(
|
||||||
|
$mf2['items'][0]['properties']['content'][0]['html']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function filterHTML($html)
|
public function filterHTML($html)
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Version {next}
|
||||||
|
- Improve `likes`, including adding a new section in the admin cp
|
||||||
|
- Add the ability to POSSE the like of a Tweet
|
||||||
|
|
||||||
## Version 0.15.2 (2018-01-11)
|
## Version 0.15.2 (2018-01-11)
|
||||||
- Update micropub endpoint to support access tokens being sent in either acceptable form
|
- Update micropub endpoint to support access tokens being sent in either acceptable form
|
||||||
- Improve admin control panel forms
|
- Improve admin control panel forms
|
||||||
|
|
|
@ -14,6 +14,7 @@ class LikesTableSeeder extends Seeder
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
factory(Like::class, 10)->create();
|
factory(Like::class, 10)->create();
|
||||||
|
sleep(1);
|
||||||
|
|
||||||
$faker = new Generator();
|
$faker = new Generator();
|
||||||
$faker->addProvider(new \Faker\Provider\en_US\Person($faker));
|
$faker->addProvider(new \Faker\Provider\en_US\Person($faker));
|
||||||
|
@ -24,5 +25,8 @@ class LikesTableSeeder extends Seeder
|
||||||
'author_url' => $faker->url,
|
'author_url' => $faker->url,
|
||||||
'author_name' => $faker->name,
|
'author_name' => $faker->name,
|
||||||
]);
|
]);
|
||||||
|
sleep(1);
|
||||||
|
|
||||||
|
Like::create(['url' => 'https://example.com']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
public/assets/css/app.css
vendored
2
public/assets/css/app.css
vendored
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
|
@ -1 +1 @@
|
||||||
{"version":3,"sources":["../../../resources/assets/sass/_border-box.scss","../../../resources/assets/sass/_base-font.scss","../../../resources/assets/sass/_header.scss","../../../resources/assets/sass/_variables.scss","../../../resources/assets/sass/_main.scss","../../../resources/assets/sass/_hovercard.scss","../../../resources/assets/sass/_notes.scss","../../../resources/assets/sass/_pagination.scss","../../../resources/assets/sass/_contacts-page.scss","../../../resources/assets/sass/_projects.scss","../../../resources/assets/sass/_footer.scss","../../../resources/assets/sass/_admin-form.scss","../../../resources/assets/sass/_form.scss","../../../resources/assets/sass/_bridgy-links.scss","../../../resources/assets/sass/_emoji.scss","../../../resources/assets/sass/_mapbox.scss","../../../resources/assets/sass/_colors.scss","../../../resources/assets/sass/_styles.scss","../../../resources/assets/sass/_tags.scss"],"names":[],"mappings":"AAKA,KACI,8BAAsB,AAAtB,qBAAsB,CACzB,qBAKG,2BAAmB,AAAnB,kBAAmB,CACtB,KCVG,eACA,gCAAiC,CACpC,gBAGG,oBAAqB,CACxB,WCNG,oBACA,AADA,oBACA,AADA,aACA,8BACA,AADA,6BACA,AADA,kBACA,AADA,cACA,yBACA,AADA,sBACA,AADA,mBACA,WACA,eCJgB,CDKnB,cAGG,eACA,cAAe,CAClB,eAGG,cAAe,CAClB,KEdG,oBACA,AADA,oBACA,AADA,aACA,4BACA,AADA,6BACA,AADA,0BACA,AADA,sBACA,0BACA,AADA,uBACA,AADA,oBACA,gBACA,cACA,iBACA,cAAe,CAClB,WAIG,gBAAiB,CACpB,aCZG,iBAAkB,CACrB,qBAGG,iBAAkB,CACrB,2BAGG,WAAY,CACf,WAGG,kBACA,8BACA,AADA,6BACA,AADA,uBACA,AADA,mBACA,yBACA,AADA,sBACA,AADA,8BACA,sBACA,AADA,mBACA,AADA,qBACA,iBACA,YACA,WACA,UACA,WACA,uBACA,kBACA,2CACA,AADA,mCACA,YAAa,CAChB,8BAGG,oBAAa,AAAb,oBAAa,AAAb,YAAa,CAChB,0BAGG,WACA,WAAY,CACf,sBAGG,YAAa,CCnCjB,MACI,oBACA,AADA,oBACA,AADA,aACA,4BACA,AADA,6BACA,AADA,0BACA,AADA,sBACA,cAAe,CAClB,UAGG,eACA,eAAgB,CACnB,eAGG,oBACA,AADA,oBACA,AADA,aACA,8BACA,AADA,6BACA,AADA,uBACA,AADA,mBACA,yBAA8B,AAA9B,sBAA8B,AAA9B,6BAA8B,CACjC,MAGG,WACA,UAAW,CACd,YCtBG,oBACA,AADA,oBACA,AADA,aACA,8BACA,AADA,6BACA,AADA,uBACA,AADA,mBACA,8BACA,AADA,2BACA,AADA,6BACA,eACA,oBAAqB,CACxB,cCLG,eACA,oBACA,AADA,oBACA,AADA,aACA,8BACA,AADA,8BACA,AADA,+BACA,AADA,2BACA,yBACA,AADA,sBACA,AADA,8BACA,eAAgB,CACnB,kBAGG,WACA,WAAY,CACf,UCVG,cAAe,CAClB,gBCDG,gBACA,cACA,gBAAiB,CACpB,OAGG,gBACA,cACA,oBACA,AADA,oBACA,AADA,aACA,4BACA,AADA,6BACA,AADA,0BACA,AADA,sBACA,yBAAmB,AAAnB,sBAAmB,AAAnB,kBAAmB,CACtB,YCXG,gBACA,kBAAmB,CACtB,MCFG,oBACA,AADA,oBACA,AADA,aACA,4BAAsB,AAAtB,6BAAsB,AAAtB,0BAAsB,AAAtB,qBAAsB,CACzB,UAGG,oBACA,AADA,oBACA,AADA,aACA,4BAAsB,AAAtB,6BAAsB,AAAtB,0BAAsB,AAAtB,qBAAsB,CACzB,aAGG,8BAAmB,AAAnB,6BAAmB,AAAnB,uBAAmB,AAAnB,kBAAmB,CACtB,qDCVG,YAAa,CAChB,2BCAG,iBAAkB,CACrB,gFAIG,kBACA,cACA,UACA,aACA,OACA,cACA,qBACA,yBACA,oBACA,4CACA,AADA,oCACA,yBACA,kCACA,WACA,cACA,0CAAkC,AAAlC,iCAAkC,CACrC,2BAGG,KACI,aACA,6BACA,wCACA,0BACA,8BAAkC,AAAlC,qBAAkC,CAGtC,GACI,aACA,kCACA,yBACA,WACA,4CAAgD,AAAhD,mCAAgD,CAAA,CAIxD,AApBC,mBAGG,KACI,aACA,6BACA,wCACA,0BACA,8BAAkC,AAAlC,qBAAkC,CAGtC,GACI,aACA,kCACA,yBACA,WACA,4CAAgD,AAAhD,mCAAgD,CAAA,CAIxD,aACI,kCACI,kCAAmC,CACtC,CC9CL,KACI,YAAa,CAChB,oBAGG,kBAAmB,CACtB,QAGG,y4HACA,wBACA,WACA,WAAY,CACf,UAGG,kBACA,MACA,OACA,iBACA,cAAe,CAClB,gBAGG,gBACA,gBAAiB,CACpB,KCzBG,gCACA,kBAAmB,CACtB,WAGG,8BACA,kBAAmB,CACtB,YAIG,iBAAkB,CACrB,KCZG,oBAAqB,CACxB,aAGG,oBAAqB,CACxB,MCHG,SACA,gBACA,SAAU,CACb,SAGG,WACA,oBAAqB,CACxB,kBAIG,wBACA,0BACA,mBACA,qBACA,cACA,mBACA,sBACA,kBACA,qBACA,qBACA,8BAAsB,AAAtB,qBAAsB,CACzB,YAGG,0BACA,uCACA,oCACA,oCACA,WACA,kBACA,QACA,KAAM,CACT,WAGG,4BACA,kBAAmB,CACtB,kBAGG,4BAA6B,CAChC","file":"app.css"}
|
{"version":3,"sources":["../../../resources/assets/sass/_border-box.scss","../../../resources/assets/sass/_base-font.scss","../../../resources/assets/sass/_header.scss","../../../resources/assets/sass/_variables.scss","../../../resources/assets/sass/_main.scss","../../../resources/assets/sass/_hovercard.scss","../../../resources/assets/sass/_notes.scss","../../../resources/assets/sass/_pagination.scss","../../../resources/assets/sass/_contacts-page.scss","../../../resources/assets/sass/_projects.scss","../../../resources/assets/sass/_footer.scss","../../../resources/assets/sass/_admin-form.scss","../../../resources/assets/sass/_form.scss","../../../resources/assets/sass/_likes.scss","../../../resources/assets/sass/_bridgy-links.scss","../../../resources/assets/sass/_emoji.scss","../../../resources/assets/sass/_mapbox.scss","../../../resources/assets/sass/_colors.scss","../../../resources/assets/sass/_styles.scss","../../../resources/assets/sass/_tags.scss"],"names":[],"mappings":"AAKA,KACI,8BAAsB,AAAtB,qBAAsB,CACzB,qBAKG,2BAAmB,AAAnB,kBAAmB,CACtB,KCVG,eACA,gCAAiC,CACpC,gBAGG,oBAAqB,CACxB,WCNG,oBACA,AADA,oBACA,AADA,aACA,8BACA,AADA,6BACA,AADA,kBACA,AADA,cACA,yBACA,AADA,sBACA,AADA,mBACA,WACA,eCJgB,CDKnB,cAGG,eACA,cAAe,CAClB,eAGG,cAAe,CAClB,KEdG,oBACA,AADA,oBACA,AADA,aACA,4BACA,AADA,6BACA,AADA,0BACA,AADA,sBACA,0BACA,AADA,uBACA,AADA,oBACA,gBACA,cACA,iBACA,cAAe,CAClB,WAIG,gBAAiB,CACpB,aCZG,iBAAkB,CACrB,qBAGG,iBAAkB,CACrB,2BAGG,WAAY,CACf,WAGG,kBACA,8BACA,AADA,6BACA,AADA,uBACA,AADA,mBACA,yBACA,AADA,sBACA,AADA,8BACA,sBACA,AADA,mBACA,AADA,qBACA,iBACA,YACA,WACA,UACA,WACA,uBACA,kBACA,2CACA,AADA,mCACA,YAAa,CAChB,8BAGG,oBAAa,AAAb,oBAAa,AAAb,YAAa,CAChB,0BAGG,WACA,WAAY,CACf,sBAGG,YAAa,CCnCjB,MACI,oBACA,AADA,oBACA,AADA,aACA,4BACA,AADA,6BACA,AADA,0BACA,AADA,sBACA,cAAe,CAClB,UAGG,eACA,eAAgB,CACnB,eAGG,oBACA,AADA,oBACA,AADA,aACA,8BACA,AADA,6BACA,AADA,uBACA,AADA,mBACA,yBAA8B,AAA9B,sBAA8B,AAA9B,6BAA8B,CACjC,MAGG,WACA,UAAW,CACd,YCtBG,oBACA,AADA,oBACA,AADA,aACA,8BACA,AADA,6BACA,AADA,uBACA,AADA,mBACA,8BACA,AADA,2BACA,AADA,6BACA,eACA,oBAAqB,CACxB,cCLG,eACA,oBACA,AADA,oBACA,AADA,aACA,8BACA,AADA,8BACA,AADA,+BACA,AADA,2BACA,yBACA,AADA,sBACA,AADA,8BACA,eAAgB,CACnB,kBAGG,WACA,WAAY,CACf,UCVG,cAAe,CAClB,gBCDG,gBACA,cACA,gBAAiB,CACpB,OAGG,gBACA,cACA,oBACA,AADA,oBACA,AADA,aACA,4BACA,AADA,6BACA,AADA,0BACA,AADA,sBACA,yBAAmB,AAAnB,sBAAmB,AAAnB,kBAAmB,CACtB,YCXG,gBACA,kBAAmB,CACtB,MCFG,oBACA,AADA,oBACA,AADA,aACA,4BAAsB,AAAtB,6BAAsB,AAAtB,0BAAsB,AAAtB,qBAAsB,CACzB,UAGG,oBACA,AADA,oBACA,AADA,aACA,4BAAsB,AAAtB,6BAAsB,AAAtB,0BAAsB,AAAtB,qBAAsB,CACzB,aAGG,8BAAmB,AAAnB,6BAAmB,AAAnB,uBAAmB,AAAnB,kBAAmB,CACtB,WCXG,eAAgB,CACnB,qDCAG,YAAa,CAChB,2BCAG,iBAAkB,CACrB,gFAIG,kBACA,cACA,UACA,aACA,OACA,cACA,qBACA,yBACA,oBACA,4CACA,AADA,oCACA,yBACA,kCACA,WACA,cACA,0CAAkC,AAAlC,iCAAkC,CACrC,2BAGG,KACI,aACA,6BACA,wCACA,0BACA,8BAAkC,AAAlC,qBAAkC,CAGtC,GACI,aACA,kCACA,yBACA,WACA,4CAAgD,AAAhD,mCAAgD,CAAA,CAIxD,AApBC,mBAGG,KACI,aACA,6BACA,wCACA,0BACA,8BAAkC,AAAlC,qBAAkC,CAGtC,GACI,aACA,kCACA,yBACA,WACA,4CAAgD,AAAhD,mCAAgD,CAAA,CAIxD,aACI,kCACI,kCAAmC,CACtC,CC9CL,KACI,YAAa,CAChB,oBAGG,kBAAmB,CACtB,QAGG,y4HACA,wBACA,WACA,WAAY,CACf,UAGG,kBACA,MACA,OACA,iBACA,cAAe,CAClB,gBAGG,gBACA,gBAAiB,CACpB,KCzBG,gCACA,kBAAmB,CACtB,WAGG,8BACA,kBAAmB,CACtB,YAIG,iBAAkB,CACrB,KCZG,oBAAqB,CACxB,aAGG,oBAAqB,CACxB,MCHG,SACA,gBACA,SAAU,CACb,SAGG,WACA,oBAAqB,CACxB,kBAIG,wBACA,0BACA,mBACA,qBACA,cACA,mBACA,sBACA,kBACA,qBACA,qBACA,8BAAsB,AAAtB,qBAAsB,CACzB,YAGG,0BACA,uCACA,oCACA,oCACA,WACA,kBACA,QACA,KAAM,CACT,WAGG,4BACA,kBAAmB,CACtB,kBAGG,4BAA6B,CAChC","file":"app.css"}
|
2
public/assets/js/newnote.js
vendored
2
public/assets/js/newnote.js
vendored
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
5
resources/assets/sass/_likes.scss
vendored
Normal file
5
resources/assets/sass/_likes.scss
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
//likes.scss
|
||||||
|
|
||||||
|
.u-like-of {
|
||||||
|
margin-top: 1rem;
|
||||||
|
}
|
1
resources/assets/sass/app.scss
vendored
1
resources/assets/sass/app.scss
vendored
|
@ -18,6 +18,7 @@
|
||||||
@import "footer";
|
@import "footer";
|
||||||
@import "admin-form";
|
@import "admin-form";
|
||||||
@import "form";
|
@import "form";
|
||||||
|
@import "likes";
|
||||||
|
|
||||||
//hide the custom bridgy posse content
|
//hide the custom bridgy posse content
|
||||||
@import "bridgy-links";
|
@import "bridgy-links";
|
||||||
|
|
17
resources/views/admin/likes/create.blade.php
Normal file
17
resources/views/admin/likes/create.blade.php
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
@extends('master')
|
||||||
|
|
||||||
|
@section('title')New Like « Admin CP « @stop
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<h1>New Like</h1>
|
||||||
|
<form action="/admin/likes/" method="post" accept-charset="utf-8" class="admin-form form">
|
||||||
|
{{ csrf_field() }}
|
||||||
|
<div>
|
||||||
|
<label for="like_url">Like URL:</label>
|
||||||
|
<input type="text" name="like_url" id="like_url" placeholder="Like URL">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button type="submit" name="submit">Submit</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
@stop
|
24
resources/views/admin/likes/edit.blade.php
Normal file
24
resources/views/admin/likes/edit.blade.php
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
@extends('master')
|
||||||
|
|
||||||
|
@section('title')Edit Like « Admin CP « @stop
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<h1>Edit Like</h1>
|
||||||
|
<form action="/admin/likes/{{ $id }}" method="post" accept-charset="utf-8" class="admin-form form">
|
||||||
|
{{ csrf_field() }}
|
||||||
|
{{ method_field('PUT') }}
|
||||||
|
<div>
|
||||||
|
<label for="like_url">Like URL:</label>
|
||||||
|
<input type="text" name="like_url" id="like_url" value="{{ $like_url }}">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button type="submit" name="edit">Edit</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<hr>
|
||||||
|
<form action="/admin/likes/{{ $id }}" method="post">
|
||||||
|
{{ csrf_field() }}
|
||||||
|
{{ method_field('DELETE') }}
|
||||||
|
<button type="submit" name="delete">Delete Like</button>
|
||||||
|
</form>
|
||||||
|
@stop
|
15
resources/views/admin/likes/index.blade.php
Normal file
15
resources/views/admin/likes/index.blade.php
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
@extends('master')
|
||||||
|
|
||||||
|
@section('title')List Likes « Admin CP « @stop
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<h1>Likes</h1>
|
||||||
|
<ul>
|
||||||
|
@foreach($likes as $like)
|
||||||
|
<li>{{ $like['url'] }}
|
||||||
|
<a href="/admin/likes/{{ $like['id'] }}/edit">edit?</a>
|
||||||
|
</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
<p>Create a <a href="/admin/likes/create">new like</a>?</p>
|
||||||
|
@stop
|
|
@ -11,6 +11,9 @@
|
||||||
<h2>Notes</h2>
|
<h2>Notes</h2>
|
||||||
<p>You can either <a href="/admin/notes/create">create</a> new notes, or <a href="/admin/notes/">edit</a> them.<p>
|
<p>You can either <a href="/admin/notes/create">create</a> new notes, or <a href="/admin/notes/">edit</a> them.<p>
|
||||||
|
|
||||||
|
<h2>Likes</h2>
|
||||||
|
<p>You can either <a href="/admin/likes/create">create</a> a new like, or <a href="/admin/likes/">edit</a> them.<p>
|
||||||
|
|
||||||
<h2>Clients</h2>
|
<h2>Clients</h2>
|
||||||
<p>You can either <a href="/admin/clients/create">create</a> new client names, or <a href="/admin/clients/">edit</a> them.</p>
|
<p>You can either <a href="/admin/clients/create">create</a> new client names, or <a href="/admin/clients/">edit</a> them.</p>
|
||||||
|
|
||||||
|
|
|
@ -3,18 +3,20 @@
|
||||||
@section('title')Likes « @stop
|
@section('title')Likes « @stop
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="h-feed top-space">
|
<div class="h-feed">
|
||||||
@foreach($likes as $like)
|
@foreach($likes as $like)
|
||||||
<div class="h-entry">
|
<div class="h-entry">
|
||||||
<div class="h-cite u-like-of">
|
<div class="h-cite u-like-of">
|
||||||
Liked <a class="u-url" href="{{ $like->url }}">a post</a> by
|
Liked <a class="u-url" href="{{ $like->url }}">a post</a>
|
||||||
<span class="p-author h-card">
|
@isset($like->author_name)
|
||||||
|
by <span class="p-author h-card">
|
||||||
@isset($like->author_url)
|
@isset($like->author_url)
|
||||||
<a class="u-url p-name" href="{{ $like->author_url }}">{{ $like->author_name }}</a>
|
<a class="u-url p-name" href="{{ $like->author_url }}">{{ $like->author_name }}</a>
|
||||||
@else
|
@else
|
||||||
<span class="p-name">{{ $like->author_name }}</span>
|
<span class="p-name">{{ $like->author_name }}</span>
|
||||||
@endisset
|
@endisset
|
||||||
</span>
|
</span>
|
||||||
|
@endisset
|
||||||
@isset($like->content)
|
@isset($like->content)
|
||||||
<blockquote class="e-content">
|
<blockquote class="e-content">
|
||||||
{!! $like->content !!}
|
{!! $like->content !!}
|
||||||
|
|
|
@ -5,17 +5,22 @@
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="h-entry top-space">
|
<div class="h-entry top-space">
|
||||||
<div class="h-cite u-like-of">
|
<div class="h-cite u-like-of">
|
||||||
Liked <a class="u-url" href="{{ $like->url }}">a post</a> by
|
Liked <a class="u-url" href="{{ $like->url }}">a post</a>
|
||||||
<span class="p-author h-card">
|
@isset($like->author_name)
|
||||||
|
by <span class="p-author h-card">
|
||||||
@isset($like->author_url)
|
@isset($like->author_url)
|
||||||
<a class="u-url p-name" href="{{ $like->author_url }}">{{ $like->author_name }}</a>
|
<a class="u-url p-name" href="{{ $like->author_url }}">{{ $like->author_name }}</a>
|
||||||
@else
|
@else
|
||||||
<span class="p-name">{{ $like->author_name }}</span>
|
<span class="p-name">{{ $like->author_name }}</span>
|
||||||
@endisset
|
@endisset
|
||||||
</span>:
|
</span>
|
||||||
|
@endisset
|
||||||
<blockquote class="e-content">
|
<blockquote class="e-content">
|
||||||
{!! $like->content !!}
|
{!! $like->content !!}
|
||||||
</blockquote>
|
</blockquote>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- POSSE to Twitter -->
|
||||||
|
<a href="https://brid.gy/publish/twitter"></a>
|
||||||
@stop
|
@stop
|
||||||
|
|
|
@ -85,6 +85,16 @@ Route::group(['domain' => config('url.longurl')], function () {
|
||||||
Route::post('/merge', 'PlacesController@mergeStore');
|
Route::post('/merge', 'PlacesController@mergeStore');
|
||||||
Route::delete('/{id}', 'PlacesController@destroy');
|
Route::delete('/{id}', 'PlacesController@destroy');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Likes
|
||||||
|
Route::group(['prefix' => 'likes'], function () {
|
||||||
|
Route::get('/', 'LikesController@index');
|
||||||
|
Route::get('/create', 'LikesController@create');
|
||||||
|
Route::post('/', 'LikesController@store');
|
||||||
|
Route::get('/{id}/edit', 'LikesController@edit');
|
||||||
|
Route::put('/{id}', 'LikesController@update');
|
||||||
|
Route::delete('/{id}', 'LikesController@destroy');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//Blog pages using ArticlesController
|
//Blog pages using ArticlesController
|
||||||
|
|
76
tests/Feature/Admin/LikesTest.php
Normal file
76
tests/Feature/Admin/LikesTest.php
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Admin;
|
||||||
|
|
||||||
|
use Tests\TestCase;
|
||||||
|
use App\Models\Like;
|
||||||
|
use App\Jobs\ProcessLike;
|
||||||
|
use Illuminate\Support\Facades\Queue;
|
||||||
|
use Illuminate\Foundation\Testing\WithFaker;
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
|
||||||
|
class LikesTest extends TestCase
|
||||||
|
{
|
||||||
|
use DatabaseTransactions;
|
||||||
|
|
||||||
|
public function test_index_page()
|
||||||
|
{
|
||||||
|
$response = $this->withSession(['loggedin' => true])
|
||||||
|
->get('/admin/likes');
|
||||||
|
$response->assertSeeText('Likes');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_create_page()
|
||||||
|
{
|
||||||
|
$response = $this->withSession(['loggedin' => true])
|
||||||
|
->get('/admin/likes/create');
|
||||||
|
$response->assertSeeText('New Like');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_create_new_like()
|
||||||
|
{
|
||||||
|
Queue::fake();
|
||||||
|
$this->withSession(['loggedin' => true])
|
||||||
|
->post('/admin/likes', [
|
||||||
|
'like_url' => 'https://example.com'
|
||||||
|
]);
|
||||||
|
$this->assertDatabaseHas('likes', [
|
||||||
|
'url' => 'https://example.com'
|
||||||
|
]);
|
||||||
|
Queue::assertPushed(ProcessLike::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_see_edit_form()
|
||||||
|
{
|
||||||
|
$response = $this->withSession(['loggedin' => true])
|
||||||
|
->get('/admin/likes/1/edit');
|
||||||
|
$response->assertSee('Edit Like');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_edit_like()
|
||||||
|
{
|
||||||
|
Queue::fake();
|
||||||
|
$this->withSession(['loggedin' => true])
|
||||||
|
->post('/admin/likes/1', [
|
||||||
|
'_method' => 'PUT',
|
||||||
|
'like_url' => 'https://example.com',
|
||||||
|
]);
|
||||||
|
$this->assertDatabaseHas('likes', [
|
||||||
|
'url' => 'https://example.com',
|
||||||
|
]);
|
||||||
|
Queue::assertPushed(ProcessLike::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_delete_like()
|
||||||
|
{
|
||||||
|
$like = Like::find(1);
|
||||||
|
$url = $like->url;
|
||||||
|
$this->withSession(['loggedin' => true])
|
||||||
|
->post('/admin/likes/1', [
|
||||||
|
'_method' => 'DELETE',
|
||||||
|
]);
|
||||||
|
$this->assertDatabaseMissing('likes', [
|
||||||
|
'url' => $url,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue