テク諏訪とYTのコメは一緒に

このコミットが含まれているのは:
テクニカル諏訪子 2021-01-03 21:49:12 +09:00
コミット 97c65d1f8f
9個のファイルの変更83行の追加125行の削除

ファイルの表示

@ -20,8 +20,8 @@ class Comment {
'user_id' => ($r->user_id != 0 ?: null),
'post_id' => ($r->isvideo == 'f' ? $id : 0),
'video_id' => ($r->isvideo == 't' ? $r->slug : ''),
'name' => $com['name'],
'email' => $com['mail'],
'name' => (isset($com['name']) ? $com['name'] : null),
'email' => (isset($com['mail']) ? $com['mail'] : null),
'message' => $com['text'],
'created' => time(),
'ipaddress' => getIp(),
@ -33,12 +33,14 @@ class Comment {
$res = DB::table('blg_comments')->select('id', 'name', 'created', 'message')->where('id', $add)->first();
$res->created = date('Y年m月d日 H:i:s', $res->created);
if (count(userDetail($r->user_id)) > 0) {
if (!is_null($r->user_id) && !empty(userDetail($r->user_id))) {
$det = userDetail($r->user_id);
$res->user_id = $det['user_id'];
$res->showname = $det['showname'];
$res->showcol = $det['showcol'];
$res->avatar = $det['avatar'];
$res->replyCount = 0;
$res->isvideo = $r->isvideo;
}
return array('status' => '010100', 'message' => 'OK', 'result' => $res);

ファイルの表示

@ -38,7 +38,7 @@ class CommentList {
$g->name_style = $p->name_style;
$g->display_name = $p->display_name;
if (count(userDetail($g->user_id)) > 0) {
if (!empty(userDetail($g->user_id))) {
$det = userDetail($g->user_id);
$g->user_id = $det['user_id'];
$g->showname = $det['showname'];

ファイルの表示

@ -62,7 +62,10 @@ class Index {
$get->display_name = $p->display_name;
foreach ($get->comments['come'] as $k => $c) {
if (count(userDetail($c->user_id)) > 0) {
$c->replyCount = 0;
$c->isvideo = 'f';
if (!is_null($c->user_id) && !empty(userDetail($c->user_id))) {
$det = userDetail($c->user_id);
$c->user_id = $det['user_id'];
$c->showname = $det['showname'];

ファイルの表示

@ -42,7 +42,7 @@ class MemberList {
$d = DB::table('usr_details')->select('reg_date')->where('user_id', $g->id)->first();
$g->reg_date = date('Y年m月d日 H:i:s', $d->reg_date);
if (count(userDetail($g->id)) > 0) {
if (!empty(userDetail($g->id))) {
$det = userDetail($g->id);
$g->showname = $det['showname'];
$g->showcol = $det['showcol'];

ファイルの表示

@ -46,7 +46,10 @@ class Prayer {
$res->lbcomment = array();
foreach ($comments as $k => $c) {
if (count(userDetail($c->user_id)) > 0) {
$c->replyCount = 0;
$c->isvideo = 't';
if (!is_null($c->user_id) && !empty(userDetail($c->user_id))) {
$det = userDetail($c->user_id);
$c->user_id = $det['user_id'];
$c->showname = $det['showname'];
@ -68,6 +71,8 @@ class Prayer {
$res->user = userDetail(null, $this->cook);
$res->comments['total'] = count($comments);
$res->comments['come'] = $comments;
$res->comments['total'] += $res->ytcomment['total'];
$res->comments['come'] = array_merge($res->comments['come'], $res->ytcomment['come']);
return view('pages.site.video.prayer', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]);
}
@ -106,6 +111,7 @@ class Prayer {
$g->comment->created = date('Y年m月d日 H:i:s', strtotime($g->snippet->topLevelComment->snippet->publishedAt));
$g->comment->message = strip_tags($g->snippet->topLevelComment->snippet->textDisplay, array('<br />'));
$g->comment->replyCount = (isset($g->snippet->totalReplyCount) ? $g->snippet->totalReplyCount : 0);
$g->comment->isvideo = 'n';
if (isset($g->replies)) {
$g->comment->replies = array();

ファイルの表示

@ -60,7 +60,7 @@ function userDetail ($id, $kero=null) {
return array('user_id' => $user_id, 'showname' => $showname, 'showcol' => $showcol, 'avatar' => $p3->avatar);
}
return array();
return new \stdClass();
}
?>

バイナリ
public/img/Eqjk_WgVQAE2psn.jpeg ノーマルファイル

バイナリファイルは表示されません。

変更後

幅:  |  高さ:  |  サイズ: 2.1 MiB

ファイルの表示

@ -1,15 +1,54 @@
<template>
<div id="comments" class="comments-area clearfix">
<h3 class="comments-count section-heading uppercase"><span>{{ comment.total }}{{ (comment.nextPage ? '以上' : '') }} 件のコメント</span></h3>
<div v-if="total === 0">コメントがありません</div>
<h3 class="comments-count section-heading uppercase"><span>{{ comment.total }} 件のコメント</span></h3>
<div style="margin: 12px 0;">
<span v-if="isvideo !== 'n'">
<hr />
<div v-if="err" class="alert alert-danger">{{ err }}</div>
<span v-if="Object.keys(user).length === 0">
<div class="form-group row">
<div class="col-md-4 col-lg-3">名前</div>
<div class="input-group col-md col-lg">
<input type="text" id="new-name" class="form-control" v-model="newComment.name" placeholder="ご入力しない場合、名前は「名無しのテクニシャン」になります。" />
</div>
</div>
<div class="form-group row">
<div class="col-md-4 col-lg-3">メールアドレス</div>
<div class="input-group col-md col-lg">
<input type="text" id="new-mail" class="form-control" v-model="newComment.mail" placeholder="返信される場合、メールに通知を送ります。" />
</div>
</div>
</span>
<span v-else>
<div class="form-group row">
<div class="col-md-4 col-lg-3">名前</div>
<div class="input-group col-md col-lg">
<a :href="`/profile/${user.user_id}`" :style="user.showcol"><img style="width: 24px; height: 24px;" :src="user.avatar" :alt="`${user.showname}さんのアイコン`"> {{ user.showname }}</a>
</div>
</div>
</span>
<div class="row">
<div class="col-md-4 col-lg-3">本文 <span class="badge badge-danger">必須</span></div>
<div class="col-md col-lg">
<textarea class="form-control" id="new-message" rows="4" v-on:keyup.ctrl.13="send" v-model="newComment.text"></textarea>
</div>
</div>
<div class="row" style="margin-top: 16px;">
<div class="col">
<button type="button" class="btn btn-block btn-primary" @click="send">送信</button>
</div>
</div>
</span>
</div>
<div v-if="comment.total === 0">コメントがありません</div>
<span v-else>
<ul class="commentlist" v-for="(c, i) in comment.come" :key="`comment-${i}`">
<li class="comment even thread-even depth-1" :id="`li-comment-${c.id}`">
<div class="commentnumber">{{ Number(i)+1 }}</div>
<div :id="`comment-${c.id}`">
<div class="commentnumber">{{ Number(i)+1 }}{{ (c.isvideo == 'n' ? '(YT)' : '(TS)') }}</div>
<div :id="`comment-${c.id}`" :ref="`comment-${c.id}`">
<div>
<cite class="fn">
<span v-if="isvideo === 'n'">
<span v-if="c.isvideo === 'n'">
<img style="height: 24px;" :src="c.icon" :alt="`${c.name}さんのアイコン`">
<a :href="c.channel" style="overflow-wrap: break-word;">{{ (c.name || '名無しのテクニシャン') }}</a>
</span>
@ -21,17 +60,17 @@
<span class="comment-meta commentmetadata" :id="`#comment-${c.id}`"> <a :href="`#comment-${c.id}`">{{ c.created }}</a></span>
</div>
<p style="white-space: pre-wrap; word-wrap: break-word; width: 500px;" v-html="c.message"></p>
<div class="reply">返信{{ isvideo == 'n' ? '('+c.replyCount+')' : ''}}</div>
<div class="reply">返信{{ c.replyCount }}</div>
</div>
</li>
<span v-if="c.replies">
<ul class="commentlist" v-for="(r, j) in c.replies" :key="`comment-${i}-reply-${j}`">
<li class="comment even thread-even depth-2" :id="`li-comment-${r.id}`">
<div class="commentnumber">{{ i+1 }}/{{ j+1 }}</div>
<div class="commentnumber">{{ i+1 }}/{{ j+1 }}{{ (c.isvideo == 'n' ? '(YT)' : '(TS)') }}</div>
<div :id="`comment-${r.id}`">
<div>
<cite class="fn">
<span v-if="isvideo === 'n'">
<span v-if="c.isvideo !== 'f'">
<img style="height: 24px;" :src="r.icon" :alt="`${r.name}さんのアイコン`">
<a :href="r.channel">{{ (r.name || '名無しのテクニシャン') }}</a>
</span>
@ -48,43 +87,6 @@
</ul>
</span>
</ul>
</span>
<span v-if="isvideo !== 'n'">
<hr />
<div v-if="err" class="alert alert-danger">{{ err }}</div>
<span v-if="user.length === 0">
<div class="form-group row">
<div class="col-md-4 col-lg-3">名前</div>
<div class="input-group col-md col-lg">
<input type="text" id="new-name" class="form-control" v-model="newComment.name" placeholder="ご入力しない場合、名前は「名無しのテクニシャン」になります。" />
</div>
</div>
<div class="form-group row">
<div class="col-md-4 col-lg-3">メールアドレス</div>
<div class="input-group col-md col-lg">
<input type="text" id="new-mail" class="form-control" v-model="newComment.mail" placeholder="返信される場合、メールに通知を送ります。" />
</div>
</div>
</span>
<span v-else>
<div class="form-group row">
<div class="col-md-4 col-lg-3">名前</div>
<div class="input-group col-md col-lg">
<a :href="`/profile/${user.user_id}`" :style="user.showcol"><img style="width: 24px; height: 24px;" :src="user.avatar" :alt="`${user.showname}さんのアイコン`"> {{ user.showname }}</a>
</div>
</div>
</span>
<div class="row">
<div class="col-md-4 col-lg-3">本文 <span class="badge badge-danger">必須</span></div>
<div class="col-md col-lg">
<textarea class="form-control" id="new-message" rows="16" v-model="newComment.text"></textarea>
</div>
</div>
<div class="row" style="margin-top: 16px;">
<div class="col">
<button type="button" class="btn btn-block btn-primary" @click="send">送信</button>
</div>
</div>
</span>
</div>
</template>
@ -93,11 +95,6 @@
export default {
props: { user: Object, slug: '', isvideo: '', comments: Object },
data: function () { return { comment: this.comments, newComment: {}, err: '', loading: true, sending: false } },
computed: {
total: function () {
return this.comment.length;
}
},
created: function () { this.reset(); },
methods: {
reset () {
@ -107,24 +104,22 @@
this.newComment.text = '';
},
send () {
if (this.isvideo !== 'n') {
this.err = '';
this.sending = true;
this.err = '';
this.sending = true;
axios.post('/api/comment/new', {
user_id: this.user.user_id,
comment: this.newComment,
isvideo: this.isvideo,
slug: this.slug
}).then(res => {
this.sending = false;
if (res.data.status === '010100') { this.comment.push(res.data.result); this.reset(); }
else this.err = 'エラーコード【' + res.data.status + '】' + res.data.message;
}).catch(err => {
this.sending = false;
this.err = 'サーバーエラーコード【' + err.response.status + '】' + err.response.data.message;
});
}
axios.post('/api/comment/new', {
user_id: this.user.user_id,
comment: this.newComment,
isvideo: this.isvideo,
slug: this.slug
}).then(res => {
this.sending = false;
if (res.data.status === '010100') { this.comment.come.unshift(res.data.result); this.comment.total++; this.reset(); }
else this.err = 'エラーコード【' + res.data.status + '】' + res.data.message;
}).catch(err => {
this.sending = false;
this.err = 'サーバーエラーコード【' + err.response.status + '】' + err.response.data.message;
});
}
}
}

ファイルの表示

@ -31,56 +31,8 @@
@endif
<div style="margin-top: 4px;" class="row">
<div class="col">
<ul class="nav nav-tabs" id="commenting" role="tablist">
<li class="nav-item" role="presentation">
<a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">テク諏訪</a>
</li>
@if ($res->ytcomment)
<li class="nav-item" role="presentation">
<a class="nav-link" id="profile-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false">YT</a>
</li>
@endif
@if ($res->nicocomment)
<li class="nav-item" role="presentation">
<a class="nav-link" id="messages-tab" data-toggle="tab" href="#messages" role="tab" aria-controls="messages" aria-selected="false">ニコ動</a>
</li>
@endif
@if ($res->bccomment)
<li class="nav-item" role="presentation">
<a class="nav-link" id="settings-tab" data-toggle="tab" href="#settings" role="tab" aria-controls="settings" aria-selected="false">Bit</a>
</li>
@endif
@if ($res->lbcomment)
<li class="nav-item" role="presentation">
<a class="nav-link" id="settings-tab" data-toggle="tab" href="#settings" role="tab" aria-controls="settings" aria-selected="false">LBRY</a>
</li>
@endif
</ul>
<div class="tab-content">
<div class="tab-pane active" id="home" role="tabpanel" aria-labelledby="home-tab">
<comments slug="{{$res->pageslug}}" isvideo="t" :comments="{{json_encode($res->comments)}}" :user="{{json_encode($res->user)}}" />
</div>
@if ($res->ytcomment)
<div class="tab-pane" id="profile" role="tabpanel" aria-labelledby="profile-tab">
<comments slug="{{$res->pageslug}}" isvideo="n" :comments="{{json_encode($res->ytcomment)}}" :user="{{json_encode($res->user)}}" />
</div>
@endif
@if ($res->nicocomment)
<div class="tab-pane" id="messages" role="tabpanel" aria-labelledby="messages-tab">
<comments slug="{{$res->pageslug}}" isvideo="n" :comments="{{json_encode($res->nicocomment)}}" :user="{{json_encode($res->user)}}" />
</div>
@endif
@if ($res->bccomment)
<div class="tab-pane" id="settings" role="tabpanel" aria-labelledby="settings-tab">
<comments slug="{{$res->pageslug}}" isvideo="n" :comments="{{json_encode($res->bccomment)}}" :user="{{json_encode($res->user)}}" />
</div>
@endif
@if ($res->lbcomment)
<div class="tab-pane" id="settings" role="tabpanel" aria-labelledby="settings-tab">
<comments slug="{{$res->pageslug}}" isvideo="n" :comments="{{json_encode($res->lbcomment)}}" :user="{{json_encode($res->user)}}" />
</div>
@endif
<div class="tab-pane" id="profile" role="tabpanel" aria-labelledby="profile-tab">
<comments slug="{{$res->pageslug}}" isvideo="t" :comments="{{json_encode($res->comments)}}" :user="{{json_encode($res->user)}}" />
</div>
</div>
</div>