diff --git a/app/Bookmark.php b/app/Bookmark.php new file mode 100644 index 00000000..1c4a5e02 --- /dev/null +++ b/app/Bookmark.php @@ -0,0 +1,23 @@ +belongsToMany('App\Tag'); + } +} diff --git a/app/Http/Controllers/BookmarksController.php b/app/Http/Controllers/BookmarksController.php new file mode 100644 index 00000000..701f54bd --- /dev/null +++ b/app/Http/Controllers/BookmarksController.php @@ -0,0 +1,15 @@ +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. * diff --git a/database/factories/BookmarkFactory.php b/database/factories/BookmarkFactory.php new file mode 100644 index 00000000..db879299 --- /dev/null +++ b/database/factories/BookmarkFactory.php @@ -0,0 +1,11 @@ +define(App\Bookmark::class, function (Faker $faker) { + return [ + 'url' => $faker->url, + 'name' => $faker->sentence, + 'content' => $faker->text, + ]; +}); diff --git a/database/migrations/2017_10_07_163425_create_bookmarks_table.php b/database/migrations/2017_10_07_163425_create_bookmarks_table.php new file mode 100644 index 00000000..b9ee2ba3 --- /dev/null +++ b/database/migrations/2017_10_07_163425_create_bookmarks_table.php @@ -0,0 +1,34 @@ +increments('id'); + $table->string('url'); + $table->string('name')->nullable(); + $table->text('content')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('bookmarks'); + } +} diff --git a/database/migrations/2017_10_07_164651_create_bookmark_tag_pivot_table.php b/database/migrations/2017_10_07_164651_create_bookmark_tag_pivot_table.php new file mode 100644 index 00000000..13ee73da --- /dev/null +++ b/database/migrations/2017_10_07_164651_create_bookmark_tag_pivot_table.php @@ -0,0 +1,36 @@ +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'); + } +} diff --git a/database/seeds/BookmarksTableSeeder.php b/database/seeds/BookmarksTableSeeder.php new file mode 100644 index 00000000..1d56e105 --- /dev/null +++ b/database/seeds/BookmarksTableSeeder.php @@ -0,0 +1,16 @@ +create(); + } +} diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index bb2d4f85..9fa48d40 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -19,5 +19,6 @@ class DatabaseSeeder extends Seeder $this->call(WebMentionsTableSeeder::class); $this->call(IndieWebUserTableSeeder::class); $this->call(LikesTableSeeder::class); + $this->call(BookmarksTableSeeder::class); } } diff --git a/resources/views/bookmarks/index.blade.php b/resources/views/bookmarks/index.blade.php new file mode 100644 index 00000000..773f634e --- /dev/null +++ b/resources/views/bookmarks/index.blade.php @@ -0,0 +1,23 @@ +@extends('master') + +@section('title') +Bookmarks « +@stop + +@section('content') +
+@foreach($bookmarks as $bookmark) +
+ + @isset($bookmark->name) + {{ $bookmark->name }} + @endisset + + @empty($bookmark->name) + {{ $bookmark->url }} + @endempty + +
+@endforeach +
+@stop diff --git a/routes/web.php b/routes/web.php index ae1713bb..d5b07e7f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -114,6 +114,12 @@ Route::group(['domain' => config('url.longurl')], function () { Route::get('/{like}', 'LikesController@show'); }); + // Bookmarks + Route::group(['prefix' => 'bookmarks'], function () { + Route::get('/', 'BookmarksController@index'); + Route::get('/{bookmark}', 'BookmarksController@show'); + }); + // Micropub Client Route::group(['prefix' => 'micropub'], function () { Route::get('/create', 'MicropubClientController@create')->name('micropub-client');