1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-01-31 12:11:37 +01:00

Added user avatars. Fixes #20

This commit is contained in:
Dan Brown 2015-08-23 13:41:35 +01:00
parent 7b65ba49f6
commit 958ed627dd
9 changed files with 88 additions and 22 deletions

View File

@ -32,4 +32,16 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
* @var array
*/
protected $hidden = ['password', 'remember_token'];
/**
* Returns the user's avatar,
* Uses Gravatar as the avatar service.
* @param int $size
* @return string
*/
public function getAvatar($size = 50)
{
$emailHash = md5(strtolower(trim($this->email)));
return '//www.gravatar.com/avatar/' . $emailHash . '?s=' . $size . '&d=identicon';
}
}

View File

@ -8,6 +8,7 @@ table.table {
text-align: left;
border: none;
padding: $-xs $-xs;
vertical-align: middle;
}
th {
font-weight: bold;

View File

@ -46,7 +46,7 @@ header {
}
.logo-container {
padding: $-l $-s;
padding: $-l $-s 0 $-s;
color: #CCC;
.logo {
display: block;
@ -59,6 +59,15 @@ header {
}
}
.user-overview {
margin-top: $-m;
.user-name {
display: inline-block;
vertical-align: top;
padding: $-m $-s;
}
}
.search-box {
input {
@ -432,4 +441,15 @@ body.dragging, body.dragging * {
padding: $-s 0;
color: #888;
border-bottom: 1px solid #EEE;
font-size: 0.9em;
.left {
float: left;
}
.left + .right {
margin-left: 30px + $-s;
}
}
.avatar {
border-radius: 100%;
}

View File

@ -37,7 +37,12 @@
<div class="padded row clearfix">
<div class="col-md-12 logo-container">
<a href="/" class="logo">BookStack</a>
<div><i class="zmdi zmdi-account"></i> {{ Auth::user()->name }}</div>
<div class="user-overview">
<img class="avatar" src="{{Auth::user()->getAvatar(50)}}" alt="{{ Auth::user()->name }}">
<span class="user-name">
{{ Auth::user()->name }}
</span>
</div>
</div>
</div>
</header>

View File

@ -20,14 +20,15 @@
<table class="table">
<tr>
<th>Name</th>
<th>Created By</th>
<th colspan="2">Created By</th>
<th>Revision Date</th>
<th>Actions</th>
</tr>
@foreach($page->revisions as $revision)
<tr>
<td>{{$revision->name}}</td>
<td>{{$revision->createdBy->name}}</td>
<td style="line-height: 0;"><img class="avatar" src="{{ $revision->createdBy->getAvatar(30) }}" alt="{{$revision->createdBy->name}}"></td>
<td> {{$revision->createdBy->name}}</td>
<td><small>{{$revision->created_at->format('jS F, Y H:i:s')}} ({{$revision->created_at->diffForHumans()}})</small></td>
<td>
<a href="{{$revision->getUrl()}}" target="_blank">Preview</a>

View File

@ -1,16 +1,26 @@
{{--Requires an Activity item with the name $activity passed in--}}
@if($activity->user) {{$activity->user->name}} @endif
{{ $activity->getText() }}
@if($activity->entity())
<a href="{{ $activity->entity()->getUrl() }}">{{ $activity->entity()->name }}</a>
@if($activity->user)
<div class="left">
<img class="avatar" src="{{ $activity->user->getAvatar(30) }}" alt="{{$activity->user->name}}">
</div>
@endif
@if($activity->extra) "{{$activity->extra}}" @endif
<div class="right">
@if($activity->user)
{{$activity->user->name}}
@endif
<br>
{{ $activity->getText() }}
<span class="text-muted"><small><i class="zmdi zmdi-time"></i>{{ $activity->created_at->diffForHumans() }}</small></span>
@if($activity->entity())
<a href="{{ $activity->entity()->getUrl() }}">{{ $activity->entity()->name }}</a>
@endif
@if($activity->extra) "{{$activity->extra}}" @endif
<br>
<span class="text-muted"><small><i class="zmdi zmdi-time"></i>{{ $activity->created_at->diffForHumans() }}</small></span>
</div>

View File

@ -10,7 +10,7 @@
<form action="/users/{{$user->id}}" method="POST">
{!! csrf_field() !!}
<input type="hidden" name="_method" value="DELETE">
<a href="/user/{{$user->id}}" class="button muted">Cancel</a>
<a href="/users/{{$user->id}}" class="button muted">Cancel</a>
<button type="submit" class="button neg">Confirm</button>
</form>
</div>

View File

@ -12,14 +12,29 @@
</div>
</div>
<div class="page-content">
<h1>Edit User</h1>
<form action="/users/{{$user->id}}" method="post">
{!! csrf_field() !!}
<input type="hidden" name="_method" value="put">
@include('users/form', ['model' => $user])
</form>
<div class="row">
<div class="page-content">
<div class="row">
<div class="col-md-6">
<h1>Edit User</h1>
<form action="/users/{{$user->id}}" method="post">
{!! csrf_field() !!}
<input type="hidden" name="_method" value="put">
@include('users/form', ['model' => $user])
</form>
</div>
<div class="col-md-6">
<h1>&nbsp;</h1>
<div class="shaded padded margin-top">
<p>
<img class="avatar" src="{{ $user->getAvatar(80) }}" alt="{{ $user->name }}">
</p>
<p class="text-muted">You can change your profile picture at <a href="http://en.gravatar.com/">Gravatar</a>.</p>
</div>
</div>
</div>
</div>
</div>
@stop

View File

@ -18,11 +18,13 @@
<h1>Users</h1>
<table class="table">
<tr>
<th></th>
<th>Name</th>
<th>Email</th>
</tr>
@foreach($users as $user)
<tr>
<td style="line-height: 0;"><img class="avatar" src="{{$user->getAvatar(40)}}" alt="{{$user->name}}"></td>
<td><a href="/users/{{$user->id}}">{{$user->name}}</a></td>
<td>{{$user->email}}</td>
</tr>