Added support for user-uploadable avatar

This commit is contained in:
Andy Miller
2017-03-29 22:41:24 -07:00
parent 5d2f182fc0
commit 7af4d3b767
14 changed files with 51 additions and 16 deletions

View File

@@ -1,6 +1,8 @@
# v1.3.0-rc.4
## 03/xx/2017
1. [](#new)
* User uploadable avatar (still falls back to Gravatar if not provided)
1. [](#improved)
* Improved tabs CSS to handle long titles [#1036](https://github.com/getgrav/grav-plugin-admin/issues/1036)
* Fixed `step` in range field [Form#136](https://github.com/getgrav/grav-plugin-form/issues/136)

View File

@@ -339,8 +339,12 @@ class AdminBaseController
}
// Set destination
$destination = Folder::getRelativePath(rtrim($settings->destination, '/'));
$destination = $this->admin->getPagePathFromToken($destination);
if ($this->grav['locator']->isStream($settings->destination)) {
$destination = $this->grav['locator']->findResource($settings->destination, false, true);
} else {
$destination = Folder::getRelativePath(rtrim($settings->destination, '/'));
$destination = $this->admin->getPagePathFromToken($destination);
}
// Create destination if needed
if (!is_dir($destination)) {

View File

@@ -489,7 +489,6 @@ class AdminController extends AdminBaseController
$parent = $route && $route != '/' && $route != '.' ? $pages->dispatch($route, true) : $pages->root();
$original_slug = $obj->slug();
$original_order = intval(trim($obj->order(), '.'));
// Change parent if needed and initialize move (might be needed also on ordering/folder change).
@@ -559,6 +558,7 @@ class AdminController extends AdminBaseController
if ($this->view === 'user') {
if ($obj->username == $this->grav['user']->username) {
//Editing current user. Reload user object
unset($this->grav['user']->avatar);
$this->grav['user']->merge(User::load($this->admin->route)->toArray());
}
}
@@ -1783,7 +1783,7 @@ class AdminController extends AdminBaseController
if (isset($input['folder']) && ($input['folder'] != $page->value('folder'))) {
if ($input['folder'] != $page->value('folder')) {
$order = $page->value('order');
$ordering = $order ? sprintf('%02d.', $order) : '';
$page->folder($ordering . $input['folder']);
@@ -1881,8 +1881,6 @@ class AdminController extends AdminBaseController
$order = $this->getNextOrderInFolder($page->parent()->path());
}
$this->preparePage($page);
// Make sure the header is loaded in case content was set through raw() (expert mode)
$page->header();

View File

@@ -170,6 +170,7 @@ PLUGIN_ADMIN:
EVERYTHING_UPDATED: "Everything updated"
UPDATES_FAILED: "Updates failed"
AVATAR_BY: "Avatar by"
AVATAR_UPLOAD_OWN: "Or upload your own..."
LAST_BACKUP: "Last Backup"
FULL_NAME: "Full name"
USERNAME: "Username"

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -345,6 +345,12 @@ tr {
}
}
.block-userinfo {
img {
border: 4px solid $form-border;
}
}
#admin-user-details, .admin-user-details {
border-bottom: 1px solid lighten($nav-bg, 5%);

View File

@@ -311,6 +311,26 @@ $sidebar-padding: 2rem;
}
}
.block-userinfo {
img {
width: 200px;
height: 200px;
object-fit: cover;
}
& ~ .block-file {
margin-top: -5rem !important;
}
}
#admin-user-details {
img {
width: 47px;
height: 47px;
object-fit: cover;
}
}
#admin-user-details, .admin-user-details {
padding: 15px 10px;
min-height: 80px;

View File

@@ -1,6 +1,10 @@
<div class="form-field grid user-details">
<div class="form-label block size-1-3">
<label>{% include 'partials/userinfo-avatar.html.twig' %}</label>
{% if data.avatar %}
<label><img src="{{ base_url_simple ~ '/' ~ (data.avatar|first).path }}" /></label>
{% else %}
<label>{% include 'partials/userinfo-avatar.html.twig' %}</label>
{% endif %}
</div>
<div class="form-data block size-2-3">
<h2>{{ data.fullname }}</h2>

View File

@@ -1 +1 @@
<img src="https://www.gravatar.com/avatar/{{ admin.user.email|md5 }}?s=47" />
<img src="{{ admin.user.avatarUrl() }}?s=47" />

View File

@@ -1 +1 @@
<p class="gravatar">{{ "PLUGIN_ADMIN.AVATAR_BY"|tu }} <a href="https://gravatar.com" target="_blank">gravatar.com</a></p>
<p class="gravatar">{{ "PLUGIN_ADMIN.AVATAR_BY"|tu }} <a href="https://gravatar.com" target="_blank">gravatar.com</a>. {{ "PLUGIN_ADMIN.AVATAR_UPLOAD_OWN"|tu }}</p>

View File

@@ -1 +1 @@
<img src="https://www.gravatar.com/avatar/{{ data.email|md5 }}?s=128" />
<img src="https://www.gravatar.com/avatar/{{ data.email|md5 }}?s=200" />