diff --git a/app/Http/Controllers/Peertube/Common.php b/app/Http/Controllers/Peertube/Common.php new file mode 100644 index 0000000..1c4e8b3 --- /dev/null +++ b/app/Http/Controllers/Peertube/Common.php @@ -0,0 +1,69 @@ +getLocal(); + // $this->getMe(); + // $this->getNotify(); + $this->engine = new Engine; + } + + public function getLocal () { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, env('PEER_URI').'/api/v1/oauth-clients/local'); + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + $get = curl_exec($ch); + $err = curl_error($ch); + curl_close($ch); + + if (!$get) return $err; + $get = json_decode($get); + if (isset($get->status) && $get->status == 404) return []; + + return $get; + } + + public function getMe () { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, env('PEER_URI').'/api/v1/users/me'); + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + $get = curl_exec($ch); + $err = curl_error($ch); + curl_close($ch); + + if (!$get) return $err; + $get = json_decode($get); + if (isset($get->status) && $get->status == 404) return []; + + return $get; + } + + public function getNotify () { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, env('PEER_URI').'/api/v1/users/me/notifications?start=0&count=0&unread=true'); + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + $get = curl_exec($ch); + $err = curl_error($ch); + curl_close($ch); + + if (!$get) return $err; + $get = json_decode($get); + if (isset($get->status) && $get->status == 404) return []; + + return $get; + } +} diff --git a/app/Http/Controllers/Peertube/Watch.php b/app/Http/Controllers/Peertube/Watch.php new file mode 100644 index 0000000..97b60a2 --- /dev/null +++ b/app/Http/Controllers/Peertube/Watch.php @@ -0,0 +1,78 @@ +common = new Common; + } + + public function index ($id) { + $res = []; + $res['detail'] = $this->getDetail($id); + $res['comment'] = $this->getComment($id); + $res['recommend'] = $this->getRecommend($res['detail']->tags); + return view('pages.peertube.w', ['res' => $res]); + } + + function getDetail ($id) { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, env('PEER_URI').'/api/v1/videos/'.$id); + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + $get = curl_exec($ch); + $err = curl_error($ch); + curl_close($ch); + + if (!$get) return $err; + $get = json_decode($get); + + return $get; + } + + public function getRecommend ($tags) { + $ch = curl_init(); + $tag = ''; + foreach ($tags as $t) { + $tag .= 'tagsOneOf='.urlencode($t).'&'; + } + + curl_setopt($ch, CURLOPT_URL, env('PEER_URI').'/api/v1/search/videos?start=0&count=6&nsfw=both&'.$tag.'sort=-publishedAt&searchTarget=local'); + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + $get = curl_exec($ch); + $err = curl_error($ch); + curl_close($ch); + + if (!$get) return $err; + $get = json_decode($get); + if (isset($get->status) && $get->status == 404) return []; + + return $get; + } + + public function getComment ($id) { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, env('PEER_URI').'/api/v1/videos/'.$id.'/comment-threads'); + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + $get = curl_exec($ch); + $err = curl_error($ch); + curl_close($ch); + + if (!$get) return $err; + $get = json_decode($get); + if (isset($get->status) && $get->status == 404) return []; + + return $get; + } +} diff --git a/resources/views/pages/peertube/w.blade.php b/resources/views/pages/peertube/w.blade.php new file mode 100644 index 0000000..686e2d2 --- /dev/null +++ b/resources/views/pages/peertube/w.blade.php @@ -0,0 +1,13 @@ +@extends('theme.'.env('THEME').'.peertube') + +@section('content') + +
+ @include('theme.'.env('THEME').'.component.peertube.parts.header') +
+ @include('theme.'.env('THEME').'.component.peertube.parts.menu') + @include('theme.'.env('THEME').'.component.peertube.w') +
+
+ +@endsection diff --git a/resources/views/theme/techsuwa/component/peertube/parts/header.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/header.blade.php new file mode 100644 index 0000000..e9689c0 --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/header.blade.php @@ -0,0 +1,64 @@ +
+
+ + + 076動画 + + + + Tor + + + + RSS + +
+
+ + +
+ + + + + +
+
+ + + 投稿 + +
+
+
\ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/manifest.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/manifest.blade.php new file mode 100644 index 0000000..6c21683 --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/manifest.blade.php @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + +{{ $res['detail']->name }} - 076動画 + \ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/menu.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/menu.blade.php new file mode 100644 index 0000000..f8ad150 --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/menu.blade.php @@ -0,0 +1,8 @@ + + + \ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/menu/footer.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/menu/footer.blade.php new file mode 100644 index 0000000..3e815ab --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/menu/footer.blade.php @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/menu/top.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/menu/top.blade.php new file mode 100644 index 0000000..a70bb19 --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/menu/top.blade.php @@ -0,0 +1,5 @@ +
+ @include('theme.'.env('THEME').'.component.peertube.parts.menu.top.loggedin') + @include('theme.'.env('THEME').'.component.peertube.parts.menu.top.inmylibrary') + @include('theme.'.env('THEME').'.component.peertube.parts.menu.top.oninstance') +
\ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/menu/top/inmylibrary.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/menu/top/inmylibrary.blade.php new file mode 100644 index 0000000..3ee3fe8 --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/menu/top/inmylibrary.blade.php @@ -0,0 +1,29 @@ + \ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/menu/top/loggedin.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/menu/top/loggedin.blade.php new file mode 100644 index 0000000..1033e63 --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/menu/top/loggedin.blade.php @@ -0,0 +1,45 @@ +
+
+ + @include('theme.'.env('THEME').'.component.peertube.parts.menu.top.notification') +
+
+ + + 自分のアカウント + + + + 自分のライブラリ + + + + 管理 + + + + ログアウト + +
+
\ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/menu/top/notification.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/menu/top/notification.blade.php new file mode 100644 index 0000000..9fba61c --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/menu/top/notification.blade.php @@ -0,0 +1,7 @@ + +
+ + + +
+
\ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/menu/top/oninstance.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/menu/top/oninstance.blade.php new file mode 100644 index 0000000..497d0a6 --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/menu/top/oninstance.blade.php @@ -0,0 +1,33 @@ + \ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/meta.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/meta.blade.php new file mode 100644 index 0000000..6a910cf --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/meta.blade.php @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/style.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/style.blade.php new file mode 100644 index 0000000..fca483a --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/style.blade.php @@ -0,0 +1,1479 @@ + \ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/stylelink.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/stylelink.blade.php new file mode 100644 index 0000000..d1a8702 --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/stylelink.blade.php @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/w/info.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/w/info.blade.php new file mode 100644 index 0000000..0f98ebd --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/w/info.blade.php @@ -0,0 +1,9 @@ +
+
+ @include('theme.'.env('THEME').'.component.peertube.parts.w.info.first') + @include('theme.'.env('THEME').'.component.peertube.parts.w.info.description') + @include('theme.'.env('THEME').'.component.peertube.parts.w.info.attrib') + @include('theme.'.env('THEME').'.component.peertube.parts.w.info.comments') +
+ @include('theme.'.env('THEME').'.component.peertube.parts.w.videorecommend') +
\ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/w/info/attrib.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/w/info/attrib.blade.php new file mode 100644 index 0000000..68597f0 --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/w/info/attrib.blade.php @@ -0,0 +1,53 @@ + +
+ 公開設定 + {{ $res['detail']->privacy->label }} +
+ +
+ カテゴリ + @if (is_null($res['detail']->category->id)) {{ $res['detail']->category->label }} + @else {{ $res['detail']->category->label }} @endif +
+ + @if (!is_null($res['detail']->originallyPublishedAt)) +
+ 投稿日 + {{ date('Y年m月d日', strtotime($res['detail']->originallyPublishedAt)) }} +
+ @endif + +
+ ライセンス + {{ $res['detail']->licence->label }} +
+ +
+ 言語 + @if (is_null($res['detail']->language->id)) {{ $res['detail']->language->label }} + @else {{ $res['detail']->language->label }} @endif +
+ +
+ タグ + @if (count($res['detail']->tags) > 0) + + @foreach ($res['detail']->tags as $k => $v) + {{ $v }}{{ count($res['detail']->tags)-1 != $k ? ', ' : '' }} + @endforeach + + @endif +
+ +
+ 再生時間 + @php + $seconds = $res['detail']->duration; + $hours = floor($seconds / 3600); + $seconds -= $hours * 3600; + $minutes = floor($seconds / 60); + $seconds -= $minutes * 60; + @endphp + {{ $hours != 0 ? $hours.'時' : '' }}{{ $minutes != 0 ? $minutes.'分' : '' }}{{ $seconds.'秒' }} +
+
\ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/w/info/channel.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/w/info/channel.blade.php new file mode 100644 index 0000000..0ce5614 --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/w/info/channel.blade.php @@ -0,0 +1,22 @@ +
+ +
+ + + チャンネルのアバター + + + +
+
+ +
\ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/w/info/comments.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/w/info/comments.blade.php new file mode 100644 index 0000000..ad0501e --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/w/info/comments.blade.php @@ -0,0 +1,90 @@ + +
+
+

{{ $res['comment']->totalNotDeletedComments }} コメント

+ +
+ + + +
+
+ +
+ +
+
+ + + +
+ +
+
+
+
+
+ @if (count($res['comment']->data) == 0) +
コメントがありません。
+ @else + @foreach ($res['comment']->data as $k => $v) + @if (!$v->isDeleted) + + @endif + @endforeach + @endif +
+
+
+
+
+
+
\ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/w/info/description.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/w/info/description.blade.php new file mode 100644 index 0000000..c0d1cea --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/w/info/description.blade.php @@ -0,0 +1,7 @@ + +
+
+ description); ?> +
+
+
\ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/w/info/first.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/w/info/first.blade.php new file mode 100644 index 0000000..44ef2ee --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/w/info/first.blade.php @@ -0,0 +1,27 @@ +
+
+
+
+

{{ $res['detail']->name }}

+
+
+ @include('theme.'.env('THEME').'.component.peertube.parts.w.info.viewsdate') + +
+
+ @include('theme.'.env('THEME').'.component.peertube.parts.w.info.videorate') + @include('theme.'.env('THEME').'.component.peertube.parts.w.info.support') + @include('theme.'.env('THEME').'.component.peertube.parts.w.info.share') + @include('theme.'.env('THEME').'.component.peertube.parts.w.info.save') + @include('theme.'.env('THEME').'.component.peertube.parts.w.info.more') +
+
+
+
+
+
+ @include('theme.'.env('THEME').'.component.peertube.parts.w.info.channel') + @include('theme.'.env('THEME').'.component.peertube.parts.w.info.subscribe') +
+
+
\ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/w/info/more.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/w/info/more.blade.php new file mode 100644 index 0000000..b2b2661 --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/w/info/more.blade.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/w/info/save.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/w/info/save.blade.php new file mode 100644 index 0000000..1c2bd85 --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/w/info/save.blade.php @@ -0,0 +1,53 @@ + \ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/w/info/share.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/w/info/share.blade.php new file mode 100644 index 0000000..69b8eec --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/w/info/share.blade.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/w/info/subscribe.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/w/info/subscribe.blade.php new file mode 100644 index 0000000..a6adbdd --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/w/info/subscribe.blade.php @@ -0,0 +1,39 @@ + +
+ + +
+
\ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/w/info/support.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/w/info/support.blade.php new file mode 100644 index 0000000..b449730 --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/w/info/support.blade.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/w/info/videorate.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/w/info/videorate.blade.php new file mode 100644 index 0000000..db05a34 --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/w/info/videorate.blade.php @@ -0,0 +1,14 @@ + + + + \ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/w/info/viewsdate.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/w/info/viewsdate.blade.php new file mode 100644 index 0000000..b222dd5 --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/w/info/viewsdate.blade.php @@ -0,0 +1,10 @@ +
+ + {{ date('Y年m月d日 H:i:s T', strtotime($res['detail']->publishedAt)) }} + + に投稿 + • + + {{ $res['detail']->views }} 回視聴 + +
\ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/w/player.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/w/player.blade.php new file mode 100644 index 0000000..f2c5d7e --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/w/player.blade.php @@ -0,0 +1,30 @@ +
+
+
+ +
+
+
\ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/parts/w/videorecommend.blade.php b/resources/views/theme/techsuwa/component/peertube/parts/w/videorecommend.blade.php new file mode 100644 index 0000000..a98513a --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/parts/w/videorecommend.blade.php @@ -0,0 +1,61 @@ + +
+
+

他の動画

+
+ @foreach ($res['recommend']->data as $k => $v) + + + +
+ @endforeach +
+
\ No newline at end of file diff --git a/resources/views/theme/techsuwa/component/peertube/w.blade.php b/resources/views/theme/techsuwa/component/peertube/w.blade.php new file mode 100644 index 0000000..cbefc34 --- /dev/null +++ b/resources/views/theme/techsuwa/component/peertube/w.blade.php @@ -0,0 +1,10 @@ +
+
+ +
+ @include('theme.'.env('THEME').'.component.peertube.parts.w.player') + @include('theme.'.env('THEME').'.component.peertube.parts.w.info') +
+
+
+
\ No newline at end of file diff --git a/resources/views/theme/techsuwa/peertube.blade.php b/resources/views/theme/techsuwa/peertube.blade.php new file mode 100644 index 0000000..c6d958f --- /dev/null +++ b/resources/views/theme/techsuwa/peertube.blade.php @@ -0,0 +1,13 @@ + + + + @include('theme.'.env('THEME').'.component.peertube.parts.manifest') + @include('theme.'.env('THEME').'.component.peertube.parts.style') + @include('theme.'.env('THEME').'.component.peertube.parts.meta') + @include('theme.'.env('THEME').'.component.peertube.parts.stylelink') + + + + @yield('content') + + \ No newline at end of file diff --git a/routes/view/peertube.php b/routes/view/peertube.php new file mode 100644 index 0000000..6ae604d --- /dev/null +++ b/routes/view/peertube.php @@ -0,0 +1,5 @@ + 'peertube'], function () { + Route::any('/w/{id}', 'Peertube\Watch@index'); +}); diff --git a/routes/web.php b/routes/web.php index 0090c7e..e9e7de8 100644 --- a/routes/web.php +++ b/routes/web.php @@ -25,4 +25,5 @@ require(__DIR__.'/api/user.php'); Route::get('/logout', 'User\Logout@index'); require(__DIR__.'/view/bash.php'); +require(__DIR__.'/view/peertube.php'); require(__DIR__.'/view/site.php');