diff --git a/app/Http/Controllers/BookmarkController.php b/app/Http/Controllers/BookmarkController.php index 3a48624..cc763ba 100644 --- a/app/Http/Controllers/BookmarkController.php +++ b/app/Http/Controllers/BookmarkController.php @@ -21,6 +21,10 @@ class BookmarkController extends Controller { $this->authorize('create', Bookmark::class); + $metas = $this->getMeta($request->url); + $request['name'] = (empty($request->name)) ? $metas['title'] : $request->name; + $request['favicon'] = $metas['favicon']; + $bookmark = request()->user()->bookmarks()->create($request->all()); return (new BookmarkResource($bookmark)) @@ -54,4 +58,32 @@ class BookmarkController extends Controller return response([], 204); } + + private function getMeta($url) + { + $metas = []; + $client = new \GuzzleHttp\Client(); + $promise = $client->requestAsync('GET', $url); + $response = $promise->wait(); + $page = $response->getBody()->getContents(); + preg_match("/\(.*)\<\/title\>/i",$page,$title); + $metas['title'] = $title[1]; + + + preg_match('/\/i',$page,$favicon); + if(isset($favicon[1])) { + preg_match('/href="(.*)/i',$favicon[1],$favicon); + $metas['favicon'] = $favicon[1]; + + preg_match('/http/', $metas['favicon'], $matches); + if(empty($matches)) { + $metas['favicon'] = parse_url($url, PHP_URL_SCHEME).'://'.parse_url($url, PHP_URL_HOST).$metas['favicon']; + } +// dd($metas['favicon'], $matches, !isset($matches[1]), empty($matches)); + } else { + $metas['favicon'] = null; + } + + return $metas; + } } diff --git a/resources/js/components/Nav.vue b/resources/js/components/Nav.vue index 475efab..5c252ed 100644 --- a/resources/js/components/Nav.vue +++ b/resources/js/components/Nav.vue @@ -13,6 +13,10 @@ ToDo Lists + + + Bookmarks + Jeux diff --git a/resources/js/router.js b/resources/js/router.js index 656e1fd..49a1c34 100644 --- a/resources/js/router.js +++ b/resources/js/router.js @@ -11,6 +11,7 @@ import MemoShow from './views/Memo/MemoShow' import MemoEdit from './views/Memo/MemoEdit' import ToDoListIndex from './views/ToDoLists/ToDoListIndex' import ToDoListShow from './views/ToDoLists/ToDoListShow' +import BookmarkIndex from './views/Bookmark/BookmarkIndex' import GameIndex from './views/Games/GameIndex' import Hangman from './views/Games/HangMan/Hangman' import Quizz from './views/Games/Quizz/Quizz' @@ -65,6 +66,11 @@ export default new VueRouter({ meta: {title: 'Details of List'} }, + { + path: '/bookmarks', component: BookmarkIndex, + meta: {title: 'Bookmark Lists'} + }, + { path: '/jeux', component: GameIndex, meta: {title: 'Liste des jeux'} diff --git a/resources/js/views/Bookmark/Bookmark.vue b/resources/js/views/Bookmark/Bookmark.vue new file mode 100644 index 0000000..cd248a7 --- /dev/null +++ b/resources/js/views/Bookmark/Bookmark.vue @@ -0,0 +1,95 @@ + + + + + diff --git a/resources/js/views/Bookmark/BookmarkIndex.vue b/resources/js/views/Bookmark/BookmarkIndex.vue new file mode 100644 index 0000000..c37bd43 --- /dev/null +++ b/resources/js/views/Bookmark/BookmarkIndex.vue @@ -0,0 +1,92 @@ + + + + + diff --git a/resources/svg/globe.svg b/resources/svg/globe.svg new file mode 100644 index 0000000..4603b43 --- /dev/null +++ b/resources/svg/globe.svg @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +