Merge branch 'feature/bookmarks' into develop
This commit is contained in:
commit
f987a0f53b
29 changed files with 2767 additions and 1894 deletions
31
app/Bookmark.php
Normal file
31
app/Bookmark.php
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Bookmark extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = ['url', 'name', 'content'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The tags that belong to the bookmark.
|
||||||
|
*/
|
||||||
|
public function tags()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany('App\Tag');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The full url of a bookmark.
|
||||||
|
*/
|
||||||
|
public function getLongurlAttribute()
|
||||||
|
{
|
||||||
|
return config('app.url') . '/bookmarks/' . $this->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
22
app/Http/Controllers/BookmarksController.php
Normal file
22
app/Http/Controllers/BookmarksController.php
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Bookmark;
|
||||||
|
|
||||||
|
class BookmarksController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$bookmarks = Bookmark::latest()->with('tags')->withCount('tags')->paginate(10);
|
||||||
|
|
||||||
|
return view('bookmarks.index', compact('bookmarks'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(Bookmark $bookmark)
|
||||||
|
{
|
||||||
|
$bookmark->loadMissing('tags');
|
||||||
|
|
||||||
|
return view('bookmarks.show', compact('bookmark'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,8 +3,6 @@
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\IndieWebUser;
|
use App\IndieWebUser;
|
||||||
use IndieAuth\Client as IndieClient;
|
|
||||||
use GuzzleHttp\Client as GuzzleClient;
|
|
||||||
use Illuminate\Http\{Request, Response};
|
use Illuminate\Http\{Request, Response};
|
||||||
use GuzzleHttp\Exception\{ClientException, ServerException};
|
use GuzzleHttp\Exception\{ClientException, ServerException};
|
||||||
|
|
||||||
|
|
@ -14,8 +12,8 @@ class MicropubClientController extends Controller
|
||||||
* Inject the dependencies.
|
* Inject the dependencies.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
IndieClient $indieClient,
|
\IndieAuth\Client $indieClient,
|
||||||
GuzzleClient $guzzleClient
|
\GuzzleHttp\Client $guzzleClient
|
||||||
) {
|
) {
|
||||||
$this->indieClient = $indieClient;
|
$this->indieClient = $indieClient;
|
||||||
$this->guzzleClient = $guzzleClient;
|
$this->guzzleClient = $guzzleClient;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ use Monolog\Logger;
|
||||||
use Ramsey\Uuid\Uuid;
|
use Ramsey\Uuid\Uuid;
|
||||||
use App\Jobs\ProcessImage;
|
use App\Jobs\ProcessImage;
|
||||||
use App\Services\LikeService;
|
use App\Services\LikeService;
|
||||||
|
use App\Services\BookmarkService;
|
||||||
use Monolog\Handler\StreamHandler;
|
use Monolog\Handler\StreamHandler;
|
||||||
use App\{Like, Media, Note, Place};
|
use App\{Like, Media, Note, Place};
|
||||||
use Intervention\Image\ImageManager;
|
use Intervention\Image\ImageManager;
|
||||||
|
|
@ -82,6 +83,14 @@ class MicropubController extends Controller
|
||||||
'location' => config('app.url') . "/likes/$like->id",
|
'location' => config('app.url') . "/likes/$like->id",
|
||||||
], 201)->header('Location', config('app.url') . "/likes/$like->id");
|
], 201)->header('Location', config('app.url') . "/likes/$like->id");
|
||||||
}
|
}
|
||||||
|
if ($request->has('properties.bookmark-of') || $request->has('bookmark-of')) {
|
||||||
|
$bookmark = (new BookmarkService())->createBookmark($request);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'response' => 'created',
|
||||||
|
'location' => config('app.url') . "/bookmarks/$bookmark->id",
|
||||||
|
], 201)->header('Location', config('app.url') . "/bookmarks/$bookmark->id");
|
||||||
|
}
|
||||||
$data = [];
|
$data = [];
|
||||||
$data['client-id'] = $tokenData->getClaim('client_id');
|
$data['client-id'] = $tokenData->getClaim('client_id');
|
||||||
if ($request->header('Content-Type') == 'application/json') {
|
if ($request->header('Content-Type') == 'application/json') {
|
||||||
|
|
|
||||||
56
app/Jobs/ProcessBookmark.php
Normal file
56
app/Jobs/ProcessBookmark.php
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Bookmark;
|
||||||
|
use Ramsey\Uuid\Uuid;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Spatie\Browsershot\Browsershot;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
|
||||||
|
class ProcessBookmark implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
protected $bookmark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(Bookmark $bookmark)
|
||||||
|
{
|
||||||
|
$this->bookmark = $bookmark;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle(Browsershot $browsershot, Client $client)
|
||||||
|
{
|
||||||
|
//save a local screenshot
|
||||||
|
$uuid = Uuid::uuid4();
|
||||||
|
$browsershot->url($this->bookmark->url)
|
||||||
|
->windowSize(960, 640)
|
||||||
|
->save(public_path() . '/assets/img/bookmarks/' . $uuid . '.png');
|
||||||
|
$this->bookmark->screenshot = $uuid;
|
||||||
|
|
||||||
|
//get an internet archive link
|
||||||
|
$response = $client->request('GET', 'https://web.archive.org/save/' . $this->bookmark->url);
|
||||||
|
if ($response->hasHeader('Content-Location')) {
|
||||||
|
if (starts_with($response->getHeader('Content-Location')[0], '/web')) {
|
||||||
|
$this->bookmark->archive = $response->getHeader('Content-Location')[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//save
|
||||||
|
$this->bookmark->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
54
app/Jobs/SyndicateBookmarkToFacebook.php
Normal file
54
app/Jobs/SyndicateBookmarkToFacebook.php
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Bookmark;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
|
||||||
|
class SyndicateBookmarkToFacebook implements ShouldQueue
|
||||||
|
{
|
||||||
|
use InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
protected $bookmark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(Bookmark $bookmark)
|
||||||
|
{
|
||||||
|
$this->bookmark = $bookmark;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle(Client $guzzle)
|
||||||
|
{
|
||||||
|
//send webmention
|
||||||
|
$response = $guzzle->request(
|
||||||
|
'POST',
|
||||||
|
'https://brid.gy/publish/webmention',
|
||||||
|
[
|
||||||
|
'form_params' => [
|
||||||
|
'source' => $this->bookmark->longurl,
|
||||||
|
'target' => 'https://brid.gy/publish/facebook',
|
||||||
|
'bridgy_omit_link' => 'maybe',
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
//parse for syndication URL
|
||||||
|
if ($response->getStatusCode() == 201) {
|
||||||
|
$json = json_decode((string) $response->getBody());
|
||||||
|
$this->bookmark->update(['syndicates->facebook' => $json->url]);
|
||||||
|
$this->bookmark->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
54
app/Jobs/SyndicateBookmarkToTwitter.php
Normal file
54
app/Jobs/SyndicateBookmarkToTwitter.php
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Bookmark;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
|
||||||
|
class SyndicateBookmarkToTwitter implements ShouldQueue
|
||||||
|
{
|
||||||
|
use InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
protected $bookmark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(Bookmark $bookmark)
|
||||||
|
{
|
||||||
|
$this->bookmark = $bookmark;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle(Client $guzzle)
|
||||||
|
{
|
||||||
|
//send webmention
|
||||||
|
$response = $guzzle->request(
|
||||||
|
'POST',
|
||||||
|
'https://brid.gy/publish/webmention',
|
||||||
|
[
|
||||||
|
'form_params' => [
|
||||||
|
'source' => $this->bookmark->longurl,
|
||||||
|
'target' => 'https://brid.gy/publish/twitter',
|
||||||
|
'bridgy_omit_link' => 'maybe',
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
//parse for syndication URL
|
||||||
|
if ($response->getStatusCode() == 201) {
|
||||||
|
$json = json_decode((string) $response->getBody());
|
||||||
|
$this->bookmark->update(['syndicates->twitter' => $json->url]);
|
||||||
|
$this->bookmark->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
54
app/Jobs/SyndicateNoteToFacebook.php
Normal file
54
app/Jobs/SyndicateNoteToFacebook.php
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Note;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
|
||||||
|
class SyndicateNoteToFacebook implements ShouldQueue
|
||||||
|
{
|
||||||
|
use InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
protected $note;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(Note $note)
|
||||||
|
{
|
||||||
|
$this->note = $note;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle(Client $guzzle)
|
||||||
|
{
|
||||||
|
//send webmention
|
||||||
|
$response = $guzzle->request(
|
||||||
|
'POST',
|
||||||
|
'https://brid.gy/publish/webmention',
|
||||||
|
[
|
||||||
|
'form_params' => [
|
||||||
|
'source' => $this->note->longurl,
|
||||||
|
'target' => 'https://brid.gy/publish/facebook',
|
||||||
|
'bridgy_omit_link' => 'maybe',
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
//parse for syndication URL
|
||||||
|
if ($response->getStatusCode() == 201) {
|
||||||
|
$json = json_decode((string) $response->getBody());
|
||||||
|
$this->note->facebook_url = $json->url;
|
||||||
|
$this->note->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
56
app/Jobs/SyndicateNoteToTwitter.php
Normal file
56
app/Jobs/SyndicateNoteToTwitter.php
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Note;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
|
||||||
|
class SyndicateNoteToTwitter implements ShouldQueue
|
||||||
|
{
|
||||||
|
use InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
protected $note;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(Note $note)
|
||||||
|
{
|
||||||
|
$this->note = $note;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @param \GuzzleHttp\Client $guzzle
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle(Client $guzzle)
|
||||||
|
{
|
||||||
|
//send webmention
|
||||||
|
$response = $guzzle->request(
|
||||||
|
'POST',
|
||||||
|
'https://brid.gy/publish/webmention',
|
||||||
|
[
|
||||||
|
'form_params' => [
|
||||||
|
'source' => $this->note->longurl,
|
||||||
|
'target' => 'https://brid.gy/publish/twitter',
|
||||||
|
'bridgy_omit_link' => 'maybe',
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
//parse for syndication URL
|
||||||
|
if ($response->getStatusCode() == 201) {
|
||||||
|
$json = json_decode((string) $response->getBody());
|
||||||
|
$tweet_id = basename(parse_url($json->url, PHP_URL_PATH));
|
||||||
|
$this->note->tweet_id = $tweet_id;
|
||||||
|
$this->note->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
85
app/Services/BookmarkService.php
Normal file
85
app/Services/BookmarkService.php
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Tag;
|
||||||
|
use App\Bookmark;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Jobs\ProcessBookmark;
|
||||||
|
use App\Jobs\SyndicateBookmarkToTwitter;
|
||||||
|
use App\Jobs\SyndicateBookmarkToFacebook;
|
||||||
|
|
||||||
|
class BookmarkService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new Bookmark.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
*/
|
||||||
|
public function createBookmark(Request $request): Bookmark
|
||||||
|
{
|
||||||
|
if ($request->header('Content-Type') == 'application/json') {
|
||||||
|
//micropub request
|
||||||
|
$url = normalize_url($request->input('properties.bookmark-of.0'));
|
||||||
|
$name = $request->input('properties.name.0');
|
||||||
|
$content = $request->input('properties.content.0');
|
||||||
|
$categories = $request->input('properties.category');
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
($request->header('Content-Type') == 'application/x-www-form-urlencoded')
|
||||||
|
||
|
||||||
|
(str_contains($request->header('Content-Type'), 'multipart/form-data'))
|
||||||
|
) {
|
||||||
|
$url = normalize_url($request->input('bookmark-of'));
|
||||||
|
$name = $request->input('name');
|
||||||
|
$content = $request->input('content');
|
||||||
|
$categories = $request->input('category');
|
||||||
|
}
|
||||||
|
|
||||||
|
$bookmark = Bookmark::create([
|
||||||
|
'url' => $url,
|
||||||
|
'name' => $name,
|
||||||
|
'content' => $content,
|
||||||
|
]);
|
||||||
|
|
||||||
|
foreach ((array) $categories as $category) {
|
||||||
|
$tag = Tag::firstOrCreate(['tag' => $category]);
|
||||||
|
$bookmark->tags()->save($tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
$targets = array_pluck(config('syndication.targets'), 'uid', 'service.name');
|
||||||
|
$mpSyndicateTo = null;
|
||||||
|
if ($request->has('mp-syndicate-to')) {
|
||||||
|
$mpSyndicateTo = $request->input('mp-syndicate-to');
|
||||||
|
}
|
||||||
|
if ($request->has('properties.mp-syndicate-to')) {
|
||||||
|
$mpSyndicateTo = $request->input('properties.mp-syndicate-to');
|
||||||
|
}
|
||||||
|
if (is_string($mpSyndicateTo)) {
|
||||||
|
$service = array_search($mpSyndicateTo, $targets);
|
||||||
|
if ($service == 'Twitter') {
|
||||||
|
SyndicateBookmarkToTwitter::dispatch($bookmark);
|
||||||
|
}
|
||||||
|
if ($service == 'Facebook') {
|
||||||
|
SyndicateBookmarkToFacebook::dispatch($bookmark);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is_array($mpSyndicateTo)) {
|
||||||
|
foreach ($mpSyndicateTo as $uid) {
|
||||||
|
$service = array_search($uid, $targets);
|
||||||
|
if ($service == 'Twitter') {
|
||||||
|
SyndicateBookmarkToTwitter::dispatch($bookmark);
|
||||||
|
}
|
||||||
|
if ($service == 'Facebook') {
|
||||||
|
SyndicateBookmarkToFacebook::dispatch($bookmark);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ProcessBookmark::dispatch($bookmark);
|
||||||
|
|
||||||
|
return $bookmark;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use App\{Media, Note, Place};
|
use App\{Media, Note, Place};
|
||||||
use App\Jobs\{SendWebMentions, SyndicateToFacebook, SyndicateToTwitter};
|
use App\Jobs\{SendWebMentions, SyndicateNoteToFacebook, SyndicateNoteToTwitter};
|
||||||
|
|
||||||
class NoteService
|
class NoteService
|
||||||
{
|
{
|
||||||
|
|
@ -105,10 +105,10 @@ class NoteService
|
||||||
|
|
||||||
//syndication targets
|
//syndication targets
|
||||||
if (in_array('twitter', $data['syndicate'])) {
|
if (in_array('twitter', $data['syndicate'])) {
|
||||||
dispatch(new SyndicateToTwitter($note));
|
dispatch(new SyndicateNoteToTwitter($note));
|
||||||
}
|
}
|
||||||
if (in_array('facebook', $data['syndicate'])) {
|
if (in_array('facebook', $data['syndicate'])) {
|
||||||
dispatch(new SyndicateToFacebook($note));
|
dispatch(new SyndicateNoteToFacebook($note));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $note;
|
return $note;
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,14 @@ class Tag extends Model
|
||||||
return $this->belongsToMany('App\Note');
|
return $this->belongsToMany('App\Note');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The bookmarks that belong to the tag.
|
||||||
|
*/
|
||||||
|
public function bookmarks()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany('App\Bookmark');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes excluded from the model's JSON form.
|
* The attributes excluded from the model's JSON form.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,11 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Version {next}
|
||||||
|
- Bookmarks!
|
||||||
|
- They can only be added via micropub
|
||||||
|
- A screenshot is taken
|
||||||
|
- The page is saved to the internet archive
|
||||||
|
|
||||||
## Version 0.9 (2017-10-06)
|
## Version 0.9 (2017-10-06)
|
||||||
- Add support for `likes` (issue#69)
|
- Add support for `likes` (issue#69)
|
||||||
- Only included links on truncated syndicated notes https://brid.gy/about#omit-link
|
- Only included links on truncated syndicated notes https://brid.gy/about#omit-link
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
"predis/predis": "~1.0",
|
"predis/predis": "~1.0",
|
||||||
"ramsey/uuid": "^3.5",
|
"ramsey/uuid": "^3.5",
|
||||||
"sensiolabs/security-checker": "^4.0",
|
"sensiolabs/security-checker": "^4.0",
|
||||||
|
"spatie/browsershot": "^2.4",
|
||||||
"thujohn/twitter": "~2.0"
|
"thujohn/twitter": "~2.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
|
|
||||||
3211
composer.lock
generated
3211
composer.lock
generated
File diff suppressed because it is too large
Load diff
11
database/factories/BookmarkFactory.php
Normal file
11
database/factories/BookmarkFactory.php
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
|
$factory->define(App\Bookmark::class, function (Faker $faker) {
|
||||||
|
return [
|
||||||
|
'url' => $faker->url,
|
||||||
|
'name' => $faker->sentence,
|
||||||
|
'content' => $faker->text,
|
||||||
|
];
|
||||||
|
});
|
||||||
9
database/factories/TagFactory.php
Normal file
9
database/factories/TagFactory.php
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
|
$factory->define(App\Tag::class, function (Faker $faker) {
|
||||||
|
return [
|
||||||
|
'tag' => $faker->word,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class CreateBookmarksTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('bookmarks', function (Blueprint $table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->string('url');
|
||||||
|
$table->string('name')->nullable();
|
||||||
|
$table->text('content')->nullable();
|
||||||
|
$table->uuid('screenshot')->nullable();
|
||||||
|
$table->string('archive')->nullable();
|
||||||
|
$table->jsonb('syndicates')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('bookmarks');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class CreateBookmarkTagPivotTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('bookmark_tag', function (Blueprint $table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->unsignedInteger('bookmark_id');
|
||||||
|
$table->unsignedInteger('tag_id');
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->foreign('bookmark_id')->references('id')->on('bookmarks');
|
||||||
|
$table->foreign('tag_id')->references('id')->on('tags');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('bookmark_tag');
|
||||||
|
}
|
||||||
|
}
|
||||||
18
database/seeds/BookmarksTableSeeder.php
Normal file
18
database/seeds/BookmarksTableSeeder.php
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class BookmarksTableSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
factory(App\Bookmark::class, 10)->create()->each(function ($bookmark) {
|
||||||
|
$bookmark->tags()->save(factory(App\Tag::class)->make());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue