Преглед изворни кода

Display ban messages within threads

staging
Christopher Ross Hind пре 3 година
родитељ
комит
b6796f9420
8 измењених фајлова са 55 додато и 14 уклоњено
  1. +7
    -2
      app/Knockout/Ban.php
  2. +6
    -0
      app/Knockout/Post.php
  3. +17
    -0
      app/Knockout/User.php
  4. +1
    -1
      public/css/page/thread.css
  5. +1
    -1
      resources/views/page/user.blade.php
  6. +4
    -0
      resources/views/partial/ban.blade.php
  7. +15
    -0
      resources/views/partial/post-info.blade.php
  8. +4
    -10
      resources/views/partial/post.blade.php

+ 7
- 2
app/Knockout/Ban.php Прегледај датотеку

@@ -38,16 +38,21 @@ class Ban {
}

// grab thread if available
if (isset($ban->thread)) {
if (isset($ban->thread) && isset($ban->thread->id)) {
$s->thread = Thread::unwrap($ban->thread);
}

// grab post if available
if (isset($ban->post)) {
if (isset($ban->post) && isset($ban->post->id)) {
$s->post = Post::unwrap($ban->post);
}

return $s;
}

public function dateDiff()
{
return Carbon::createFromFormat('d/m/Y H:i', $this->endsAt)->longAbsoluteDiffForHumans();
}

}

+ 6
- 0
app/Knockout/Post.php Прегледај датотеку

@@ -16,6 +16,7 @@ class Post {
// related
public User $user;
public $ratings = [];
public $bans = [];

public static function unwrap($post)
{
@@ -35,6 +36,11 @@ class Post {
return Rating::unwrap($rating);
}, $post->ratings ?? []);

// grab bans if available
$s->bans = array_map(function($ban) {
return Ban::unwrap($ban);
}, $post->bans ?? []);

return $s;
}



+ 17
- 0
app/Knockout/User.php Прегледај датотеку

@@ -10,6 +10,7 @@ class User {
public $username;
public $avatar;
public $background;
public $banned = false;

public static function unwrap($user)
{
@@ -19,6 +20,7 @@ class User {
$s->username = $user->username;
$s->avatar = sprintf("https://cdn.knockout.chat/image/%u.webp", $user->id);
$s->background = sprintf("https://cdn.knockout.chat/image/%u-bg.webp", $user->id);
$s->banned = $user->banned;

return $s;
}
@@ -78,4 +80,19 @@ class User {
});
}

public function postInfoClasses() {
$classes = [];
$showAvatar = true;
$showBackground = true;

if ($this->banned) {
$classes[] = 'banned';
}

$classes[] = $showAvatar ? 'show-avatar' : 'hide-avatar';
$classes[] = $showBackground ? 'show-backgrounds' : 'hide-backgrounds';

return implode(' ', $classes);
}

}

+ 1
- 1
public/css/page/thread.css Прегледај датотеку

@@ -200,7 +200,7 @@
color: #ff8f8f;
background-color: #854540 !important;
border-color: #bf6c66 !important;
background-image: url('/shared/img/ban-icon.gif');
background-image: url('/img/ban-icon.gif');
background-position: 15px center;
background-repeat: no-repeat;
}


+ 1
- 1
resources/views/page/user.blade.php Прегледај датотеку

@@ -11,7 +11,7 @@
@endsection

@section('content')
@include('partial/user')
@include('partial/user', ['user' => $user])
<div class="row spacer"></div>
<div class="row">
<p>Will add bios later, probably</p>


+ 4
- 0
resources/views/partial/ban.blade.php Прегледај датотеку

@@ -0,0 +1,4 @@
<div class="row banInfo">
<p>User was banned by <b>{{ $ban->creator->username }}</b> for this post for <b>{{ $ban->dateDiff() }}</b> with reason:</p>
<span>{{ $ban->reason }}</span>
</div>

+ 15
- 0
resources/views/partial/post-info.blade.php Прегледај датотеку

@@ -0,0 +1,15 @@
<div class="row postInfo {{ $user->postInfoClasses() }}">
<div class="userBackground">
<img src="{{ $user->background }}" />
</div>
<div class="userForeground">
<img class="avatar" src="{{ $user->avatar }}" height="32px" />
<a href="{{ route('user', ['user' => $user->id]) }}" class="username">
{{ $user->username }}
@if ($user->banned)
<b>(Banned)</b>
@endif
</a>
<a class="date" href="#post-{{ $postId }}">{{ $date }}</a>
</div>
</div>

+ 4
- 10
resources/views/partial/post.blade.php Прегледај датотеку

@@ -1,14 +1,5 @@
<a id="post-{{ $post->id }}"></a>
<div class="row postInfo show-avatar show-backgrounds">
<div class="userBackground">
<img src="{{ $post->user->background }}" />
</div>
<div class="userForeground">
<img class="avatar" src="{{ $post->user->avatar }}" height="32px" />
<a href="{{ route('user', ['user' => $post->user->id]) }}" class="username">{{ $post->user->username }}</a>
<a class="date" href="#post-{{ $post->id }}">{{ $post->dateDiff() }}</a>
</div>
</div>
@include('partial/post-info', ['user' => $post->user, 'postId' => $post->id, 'date' => $post->dateDiff()])
<div class="row post">
<div class="inner">
<div class="postContent">
@@ -29,4 +20,7 @@
</div>
</div>
</div>
@foreach($post->bans as $ban)
@include('partial/ban', ['ban' => $ban])
@endforeach
<div class="row spacer"></div>

Loading…
Откажи
Сачувај