Merge branch 'develop' into feature/integrate-with-admin-pro

This commit is contained in:
Flavio Copes
2015-11-01 14:03:10 +01:00
12 changed files with 2390 additions and 2323 deletions

View File

@@ -1,3 +1,53 @@
# v1.0.0-rc.4
## 10/29/2015
1. [](#improved)
* Changed admin menu event hook to `onAdminMenu()`
* Minor improvements for admin page location
* Additional lang strings for Grav 1.0.0-rc.3
# v1.0.0-rc.3
## 10/27/2015
1. [](#improved)
* Rely on context-language for active language
* Improved some Russian translations
* Only show login if not already logged in
1. [](#bugfix)
* Disable asset pipeline in admin only
* Fix Editor cursor insertion point when text is selected in some actions
# v1.0.0-rc.2
## 10/23/2015
1. [](#bugfix)
* Reverted lang redirect code. Needs to be reworked to be more reliable
# v1.0.0-rc.1
## 10/23/2015
1. [](#new)
* Redirect to non-language URL except for `pages/`
1. [](#improved)
* New language strings for new `system.yaml` fields
* Improved Russian translations
* Improved compatibility with PECL Yaml parser
1. [](#bugfix)
* Redirect to correct page if you change folder/slug
* Fix issue with Asset pipeline not being disabled in admin
* Fix for HTML in text input fields
* Fixed various icons in headers
# v0.6.2
## 10/15/2015
1. [](#improved)
* Use `title` rather than `menu` in Page listing
* Wrapped language strings in double-quotes
* New language strings for new fields
1. [](#bugfix)
* Fixed issue with IE not able to save pages
# v0.6.1 # v0.6.1
## 10/07/2015 ## 10/07/2015

View File

@@ -3,6 +3,7 @@ namespace Grav\Plugin;
use Grav\Common\GPM\GPM; use Grav\Common\GPM\GPM;
use Grav\Common\Grav; use Grav\Common\Grav;
use Grav\Common\Language\Language;
use Grav\Common\Page\Page; use Grav\Common\Page\Page;
use Grav\Common\Page\Pages; use Grav\Common\Page\Pages;
use Grav\Common\Plugin; use Grav\Common\Plugin;
@@ -103,6 +104,10 @@ class AdminPlugin extends Plugin
if ($this->active) { if ($this->active) {
$this->grav['debugger']->addMessage("Admin Basic"); $this->grav['debugger']->addMessage("Admin Basic");
$this->initializeAdmin(); $this->initializeAdmin();
// Disable Asset pipelining
$this->config->set('system.assets.css_pipeline', false);
$this->config->set('system.assets.js_pipeline', false);
} }
// We need popularity no matter what // We need popularity no matter what
@@ -127,10 +132,6 @@ class AdminPlugin extends Plugin
// Set original route for the home page. // Set original route for the home page.
$home = '/' . trim($this->config->get('system.home.alias'), '/'); $home = '/' . trim($this->config->get('system.home.alias'), '/');
// Disable Asset pipelining
$this->config->set('system.assets.css_pipeline', false);
$this->config->set('system.assets.js_pipeline', false);
// set the default if not set before // set the default if not set before
$this->session->expert = $this->session->expert ?: false; $this->session->expert = $this->session->expert ?: false;
@@ -195,15 +196,13 @@ class AdminPlugin extends Plugin
$plugins = Grav::instance()['config']->get('plugins', []); $plugins = Grav::instance()['config']->get('plugins', []);
foreach($plugins as $plugin => $data) { foreach($plugins as $plugin => $data) {
$folder = GRAV_ROOT . "/user/plugins/" . $plugin . "/admin"; $path = $this->grav['locator']->findResource(
"user://plugins/{$plugin}/admin/pages/{$self->template}.md");
if (file_exists($folder)) { if (file_exists($path)) {
$file = $folder . "/pages/{$self->template}.md"; $page->init(new \SplFileInfo($path));
if (file_exists($file)) { $page->slug(basename($self->template));
$page->init(new \SplFileInfo($file)); return $page;
$page->slug(basename($self->template));
return $page;
}
} }
} }
}; };
@@ -237,14 +236,17 @@ class AdminPlugin extends Plugin
$twig->twig_vars['location'] = $this->template; $twig->twig_vars['location'] = $this->template;
$twig->twig_vars['base_url_relative_frontend'] = $twig->twig_vars['base_url_relative'] ?: '/'; $twig->twig_vars['base_url_relative_frontend'] = $twig->twig_vars['base_url_relative'] ?: '/';
$twig->twig_vars['admin_route'] = trim($this->config->get('plugins.admin.route'), '/'); $twig->twig_vars['admin_route'] = trim($this->config->get('plugins.admin.route'), '/');
$twig->twig_vars['base_url_relative'] .= $twig->twig_vars['base_url_relative'] =
($twig->twig_vars['base_url_relative'] != '/' ? '/' : '') . $twig->twig_vars['admin_route']; $twig->twig_vars['base_url_simple'] . '/' . $twig->twig_vars['admin_route'];
$twig->twig_vars['theme_url'] = '/user/plugins/admin/themes/' . $this->theme; $twig->twig_vars['theme_url'] = '/user/plugins/admin/themes/' . $this->theme;
$twig->twig_vars['base_url'] = $twig->twig_vars['base_url_relative']; $twig->twig_vars['base_url'] = $twig->twig_vars['base_url_relative'];
$twig->twig_vars['base_path'] = GRAV_ROOT; $twig->twig_vars['base_path'] = GRAV_ROOT;
$twig->twig_vars['admin'] = $this->admin; $twig->twig_vars['admin'] = $this->admin;
// Gather Plugin-hooked nav items // Gather Plugin-hooked nav items
$this->grav->fireEvent('onAdminMenu');
// DEPRECATED
$this->grav->fireEvent('onAdminTemplateNavPluginHook'); $this->grav->fireEvent('onAdminTemplateNavPluginHook');
switch ($this->template) { switch ($this->template) {
@@ -293,19 +295,23 @@ class AdminPlugin extends Plugin
switch ($action) { switch ($action) {
case 'getUpdates': case 'getUpdates':
$resources_updates = $gpm->getUpdatable(); $resources_updates = $gpm->getUpdatable();
$grav_updates = [ if ($gpm->grav != null) {
"isUpdatable" => $gpm->grav->isUpdatable(), $grav_updates = [
"assets" => $gpm->grav->getAssets(), "isUpdatable" => $gpm->grav->isUpdatable(),
"version" => GRAV_VERSION, "assets" => $gpm->grav->getAssets(),
"available" => $gpm->grav->getVersion(), "version" => GRAV_VERSION,
"date" => $gpm->grav->getDate(), "available" => $gpm->grav->getVersion(),
"isSymlink" => $gpm->grav->isSymlink() "date" => $gpm->grav->getDate(),
]; "isSymlink" => $gpm->grav->isSymlink()
];
echo json_encode([ echo json_encode([
"status" => "success", "status" => "success",
"payload" => ["resources" => $resources_updates, "grav" => $grav_updates, "installed" => $gpm->countInstalled(), 'flushed' => $flush] "payload" => ["resources" => $resources_updates, "grav" => $grav_updates, "installed" => $gpm->countInstalled(), 'flushed' => $flush]
]); ]);
} else {
echo json_encode(["status" => "error", "message" => "Cannot connect to the GPM"]);
}
break; break;
} }
} catch (\Exception $e) { } catch (\Exception $e) {
@@ -346,8 +352,6 @@ class AdminPlugin extends Plugin
} }
} }
// Decide admin template and route. // Decide admin template and route.
$path = trim(substr($this->uri->route(), strlen($this->base)), '/'); $path = trim(substr($this->uri->route(), strlen($this->base)), '/');
$this->template = 'dashboard'; $this->template = 'dashboard';
@@ -358,6 +362,13 @@ class AdminPlugin extends Plugin
$this->route = array_shift($array); $this->route = array_shift($array);
} }
/** @var Language $language */
// $require_language = ['pages', 'translations'];
// $language = $this->grav['language'];
// if ($language->isLanguageInUrl() && !in_array($this->template, $require_language)) {
// $this->grav->redirect($this->uri->route());
// }
// Initialize admin class. // Initialize admin class.
require_once __DIR__ . '/classes/admin.php'; require_once __DIR__ . '/classes/admin.php';
$this->admin = new Admin($this->grav, $this->base, $this->template, $this->route); $this->admin = new Admin($this->grav, $this->base, $this->template, $this->route);

View File

@@ -1,5 +1,5 @@
name: Admin Panel name: Admin Panel
version: 0.6.1 version: 1.0.0-rc.4
description: Adds an advanced administration panel to manage your site description: Adds an advanced administration panel to manage your site
icon: empire icon: empire
author: author:

View File

@@ -1014,8 +1014,10 @@ class AdminController
$obj->language($this->grav['session']->admin_lang); $obj->language($this->grav['session']->admin_lang);
} }
} }
$admin_route = $this->grav['config']->get('plugins.admin.route');
$redirect_url = '/' . ($multilang ? ($obj->language()) : '') . $admin_route . '/' . $this->view . $obj->route();
$this->setRedirect('/' . ($multilang ? ($obj->language()) : '') . $this->grav['uri']->route()); $this->setRedirect($redirect_url);
} }
return true; return true;

File diff suppressed because it is too large Load Diff

View File

@@ -333,18 +333,17 @@
}); });
}; };
this.replaceSelection = function(replace) { this.replaceSelection = function(replace, action) {
var text = this.editor.getSelection(), var text = this.editor.getSelection(),
indexOf = -1; indexOf = -1,
cur = this.editor.getCursor(),
curLine = this.editor.getLine(cur.line),
start = cur.ch,
end = start;
if (!text.length) { if (!text.length) {
var cur = this.editor.getCursor(),
curLine = this.editor.getLine(cur.line),
start = cur.ch,
end = start;
while (end < curLine.length && /[\w$]+/.test(curLine.charAt(end))) ++end; while (end < curLine.length && /[\w$]+/.test(curLine.charAt(end))) ++end;
while (start && /[\w$]+/.test(curLine.charAt(start - 1))) --start; while (start && /[\w$]+/.test(curLine.charAt(start - 1))) --start;
@@ -361,11 +360,18 @@
var html = replace.replace('$1', text); var html = replace.replace('$1', text);
this.editor.replaceSelection(html, 'end'); this.editor.replaceSelection(html, 'end');
if (indexOf !== -1) this.editor.setCursor({ line: cur.line, ch: start + indexOf }); if (indexOf !== -1) {
this.editor.setCursor({ line: cur.line, ch: start + indexOf });
} else {
if (action == 'link' || action == 'image') {
this.editor.setCursor({ line: cur.line, ch: html.length -1 });
}
}
this.editor.focus(); this.editor.focus();
}; };
this.replaceLine = function(replace) { this.replaceLine = function(replace, action) {
var pos = this.editor.getDoc().getCursor(), var pos = this.editor.getDoc().getCursor(),
text = this.editor.getLine(pos.line), text = this.editor.getLine(pos.line),
html = replace.replace('$1', text); html = replace.replace('$1', text);
@@ -510,7 +516,7 @@
function addAction(name, replace, mode) { function addAction(name, replace, mode) {
editor.element.on('action.'+name, function() { editor.element.on('action.'+name, function() {
if (editor.getCursorMode() == 'markdown') { if (editor.getCursorMode() == 'markdown') {
editor[mode == 'replaceLine' ? 'replaceLine' : 'replaceSelection'](replace); editor[mode == 'replaceLine' ? 'replaceLine' : 'replaceSelection'](replace, name);
} }
}); });
} }

View File

@@ -45,7 +45,7 @@
<input <input
{# required attribute structures #} {# required attribute structures #}
name="{{ (scope ~ field.name)|fieldName }}" name="{{ (scope ~ field.name)|fieldName }}"
value="{{ value|join(', ') }}" value="{{ value|e('html_attr')|join(', ') }}"
{# input attribute structures #} {# input attribute structures #}
{% block input_attributes %} {% block input_attributes %}
{% if field.classes is defined %}class="{{ field.classes }}" {% endif %} {% if field.classes is defined %}class="{{ field.classes }}" {% endif %}

View File

@@ -4,7 +4,7 @@
<div class="button-bar"> <div class="button-bar">
<a class="button" href="{{ base_url }}"><i class="fa fa-reply"></i> {{ "PLUGIN_ADMIN.BACK"|tu }}</a> <a class="button" href="{{ base_url }}"><i class="fa fa-reply"></i> {{ "PLUGIN_ADMIN.BACK"|tu }}</a>
</div> </div>
<h1><i class="fa fa-fw fa-th"></i> {{ "PLUGIN_ADMIN.CONFIGURATION"|tu }} - {{ "PLUGIN_ADMIN.PHP_INFO"|tu }}</h1> <h1><i class="fa fa-fw fa-wrench"></i> {{ "PLUGIN_ADMIN.CONFIGURATION"|tu }} - {{ "PLUGIN_ADMIN.PHP_INFO"|tu }}</h1>
{% endblock %} {% endblock %}
{% block content_top %} {% block content_top %}

View File

@@ -13,8 +13,12 @@
{% if notAuthorized %} {% if notAuthorized %}
<a class="button secondary" onclick="window.history.back()"><i class="fa fa-reply"></i> {{ 'PLUGIN_ADMIN.BACK'|tu }}</a> <a class="button secondary" onclick="window.history.back()"><i class="fa fa-reply"></i> {{ 'PLUGIN_ADMIN.BACK'|tu }}</a>
{% else %} {% else %}
<a class="button secondary" href="{{ base_url_relative }}/forgot"><i class="fa fa-exclamation-circle"></i> {{ 'PLUGIN_ADMIN.LOGIN_BTN_FORGOT'|tu }}</a> {% if not authenticated %}
<button type="submit" class="button primary" name="task" value="login"><i class="fa fa-sign-in"></i> {{ 'PLUGIN_ADMIN.LOGIN_BTN'|tu }}</button> <a class="button secondary" href="{{ base_url_relative }}/forgot"><i class="fa fa-exclamation-circle"></i> {{ 'PLUGIN_ADMIN.LOGIN_BTN_FORGOT'|tu }}</a>
<button type="submit" class="button primary" name="task" value="login"><i class="fa fa-sign-in"></i> {{ 'PLUGIN_ADMIN.LOGIN_BTN'|tu }}</button>
{% else %}
<button type="submit" class="button primary" name="task" value="logout"><i class="fa fa-sign-in"></i> {{ 'PLUGIN_ADMIN.LOGOUT'|tu }}</button>
{% endif %}
{% endif %} {% endif %}
</div> </div>

View File

@@ -7,7 +7,7 @@
<a class="button" href="{{ base_url }}"><i class="fa fa-reply"></i> {{ "PLUGIN_ADMIN.BACK"|tu }}</a> <a class="button" href="{{ base_url }}"><i class="fa fa-reply"></i> {{ "PLUGIN_ADMIN.BACK"|tu }}</a>
<button class="button" type="submit" name="task" value="save" form="blueprints"><i class="fa fa-check"></i> Save</button> <button class="button" type="submit" name="task" value="save" form="blueprints"><i class="fa fa-check"></i> Save</button>
</div> </div>
<h1><i class="fa fa-fw fa-th"></i> {{ "PLUGIN_ADMIN.CONFIGURATION"|tu }} - {{ "PLUGIN_ADMIN.SITE"|tu }}</h1> <h1><i class="fa fa-fw fa-wrench"></i> {{ "PLUGIN_ADMIN.CONFIGURATION"|tu }} - {{ "PLUGIN_ADMIN.SITE"|tu }}</h1>
{% endblock %} {% endblock %}
{% block content_top %} {% block content_top %}

View File

@@ -7,7 +7,7 @@
<a class="button" href="{{ base_url }}"><i class="fa fa-reply"></i> {{ "PLUGIN_ADMIN.BACK"|tu }}</a> <a class="button" href="{{ base_url }}"><i class="fa fa-reply"></i> {{ "PLUGIN_ADMIN.BACK"|tu }}</a>
<button class="button" type="submit" name="task" value="save" form="blueprints"><i class="fa fa-check"></i> {{ "PLUGIN_ADMIN.SAVE"|tu }}</button> <button class="button" type="submit" name="task" value="save" form="blueprints"><i class="fa fa-check"></i> {{ "PLUGIN_ADMIN.SAVE"|tu }}</button>
</div> </div>
<h1><i class="fa fa-fw fa-th"></i> {{ "PLUGIN_ADMIN.CONFIGURATION"|tu }} - {{ "PLUGIN_ADMIN.SYSTEM"|tu }}</h1> <h1><i class="fa fa-fw fa-wrench"></i> {{ "PLUGIN_ADMIN.CONFIGURATION"|tu }} - {{ "PLUGIN_ADMIN.SYSTEM"|tu }}</h1>
{% endblock %} {% endblock %}
{% block content_top %} {% block content_top %}

View File

@@ -29,7 +29,7 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
</div> </div>
<h1><i class="fa fa-fw fa-plug"></i> {{ "PLUGIN_ADMIN.THEMES"|tu }}</h1> <h1><i class="fa fa-fw fa-tint"></i> {{ "PLUGIN_ADMIN.THEMES"|tu }}</h1>
{% else %} {% else %}
{% if (installed) %} {% if (installed) %}
<div class="button-bar"> <div class="button-bar">