Skip to content
Permalink
Browse files

Improved stability and performance and other notable changes

  • Loading branch information...
giterlizzi committed Aug 26, 2019
1 parent 0677779 commit 23b284e65fe109db2a728abc79f2fbe226aeab02
Showing with 154 additions and 62 deletions.
  1. +12 −8 Mdi.php
  2. +5 −1 RELEASE.md
  3. +86 −40 Template.php
  4. +24 −0 css/template.less
  5. +9 −1 js/template.js
  6. +1 −1 lang/en/lang.php
  7. +3 −1 main.php
  8. +2 −3 tpl/badges.php
  9. +12 −7 tpl/navbar.php
20 Mdi.php
@@ -20,7 +20,7 @@ class Mdi
/**
* Add icon
*
* @param string $icon Icon name
* @param string $icon Icon name or full path
* @param string $class Icon Class
* @param int $size Icon size
* @param array $attrs Icon attributes
@@ -45,19 +45,24 @@ public static function icon($icon, $class = null, $size = 24, $attrs = array())
}
// Find the icon, ensure it exists
$filePath = self::$iconsPath . $icon . '.svg';
if (file_exists($icon)) {
$file_path = $icon;
} else {
$file_path = self::$iconsPath . $icon . '.svg';
}
if (!is_file($filePath)) {
msg(sprintf('Unrecognized icon "%s" (svg file "%s" does not exist).', $icon, $filePath), -1);
if (!is_file($file_path)) {
msg(sprintf('Unrecognized icon "%s" (svg file "%s" does not exist).', $icon, $file_path), -1);
return false;
}
// Read the file
$svg = file_get_contents($filePath);
$svg = file_get_contents($file_path);
// Only keep the <path d="..." /> part
if (preg_match('/(<path d=".+" \/>)/', $svg, $matches) !== 1) {
msg(sprintf('"%s" could not be recognized as an icon file', $filePath), -1);
// Old REGEX: (<path d=".+" \/>)
if (preg_match('/(<path\b([\s\S]*?)\/>)/', $svg, $matches) !== 1) {
msg(sprintf('"%s" could not be recognized as an icon file', $file_path), -1);
return false;
}
@@ -107,4 +112,3 @@ function ($val, $key) {
}
// kate: space-indent on; indent-width 4; replace-tabs on;
@@ -4,10 +4,14 @@

### Added
* Added MDI class to embed Material Design SVG icons into HTML
* Added Events dispatch table
* Added events dispatch table
* Re-Added after 4 years the `<bdi>` tag for better compatibility with RLT languages
* Now the callout element of Bootstrap Wrapper Plugin follow the original Bootswatch contextual colors


### Changed
* Removed parsing of some elements (using `simple_html_dom`) for increase the performance
* Used DokuWiki events for modify the appearance of the page
* Used DokuWiki hooks for customize login and profile page (regiter, edit and delete)
* Upgraded `simple_html_dom` to v1.9
* Removed margin in mobile tamplate with `fluidContainer` enabled
@@ -49,7 +49,7 @@ public function __construct()
'tocAffix' => (int) $this->getConf('tocAffix'),
'tocCollapseOnScroll' => (int) $this->getConf('tocCollapseOnScroll'),
'tocCollapsed' => (int) $this->getConf('tocCollapsed'),
'tocLayout' => $this->getConf('tocLayout'),
'tocLayout' => $this->getConf('tocLayout'),
'useAnchorJS' => (int) $this->getConf('useAnchorJS'),
'useAlternativeToolbarIcons' => (int) $this->getConf('useAlternativeToolbarIcons'),
),
@@ -63,20 +63,22 @@ public function __construct()
private function registerHooks()
{
/** @var \Doku_Event_Handler */
global $EVENT_HANDLER;
$events_dispatcher = array(
'FORM_QUICKSEARCH_OUTPUT' => 'searchHandler',
'FORM_SEARCH_OUTPUT' => 'searchHandler',
'HTML_DRAFTFORM_OUTPUT' => 'draftFormHandler',
'HTML_EDITFORM_OUTPUT' => 'editFormHandler',
'HTML_LOGINFORM_OUTPUT' => 'profileFormHandler',
'HTML_PROFILEDELETEFORM_OUTPUT' => 'profileFormHandler',
'HTML_LOGINFORM_OUTPUT' => 'accountFormHandler',
'HTML_RESENDPWDFORM_OUTPUT' => 'accountFormHandler',
'HTML_PROFILEDELETEFORM_OUTPUT' => 'accountFormHandler',
'HTML_RECENTFORM_OUTPUT' => 'revisionsFormHandler',
'HTML_REGISTERFORM_OUTPUT' => 'profileFormHandler',
'HTML_REGISTERFORM_OUTPUT' => 'accountFormHandler',
'HTML_REVISIONSFORM_OUTPUT' => 'revisionsFormHandler',
'HTML_UPDATEPROFILEFORM_OUTPUT' => 'profileFormHandler',
'HTML_SUBSCRIBEFORM_OUTPUT' => 'accountFormHandler',
'HTML_UPDATEPROFILEFORM_OUTPUT' => 'accountFormHandler',
'PLUGIN_TAG_LINK' => 'tagPluginHandler',
'PLUGIN_TPLINC_LOCATIONS_SET' => 'tplIncPluginHandler',
'SEARCH_QUERY_FULLPAGE' => 'searchHandler',
@@ -93,8 +95,11 @@ private function registerHooks()
}
public function testHandler(\Doku_Event $event) {
var_dump($event->data->_content);
}
public function profileFormHandler(\Doku_Event $event) {
public function accountFormHandler(\Doku_Event $event) {
foreach ($event->data->_content as $key => $item) {
@@ -119,17 +124,23 @@ public function profileFormHandler(\Doku_Event $event) {
case 'HTML_REGISTERFORM_OUTPUT':
$title_icon = 'account-plus';
break;
case 'HTML_SUBSCRIBEFORM_OUTPUT':
$title_icon = null;
break;
case 'HTML_RESENDPWDFORM_OUTPUT':
$title_icon = 'lock-reset';
break;
}
// Legend
if ($item['_elem'] == 'openfieldset') {
$event->data->_content[$key]['_legend'] = \Mdi::icon($title_icon) . ' ' . $event->data->_content[$key]['_legend'];
$event->data->_content[$key]['_legend'] = (($title_icon) ? \Mdi::icon($title_icon) : '') . ' ' . $event->data->_content[$key]['_legend'];
}
// Save button
if ($item['type'] == 'submit') {
$event->data->_content[$key]['class'] = " $button_class";
$event->data->_content[$key]['value'] = \Mdi::icon($button_icon) . ' ' . $event->data->_content[$key]['value'];
$event->data->_content[$key]['value'] = (($button_icon) ? \Mdi::icon($button_icon) : '') . ' ' . $event->data->_content[$key]['value'];
}
}
@@ -140,7 +151,40 @@ public function profileFormHandler(\Doku_Event $event) {
/**
* Handle HTML_EDITFORM_OUTPUT event
* Handle HTML_DRAFTFORM_OUTPUT event
*
* @param \Doku_Event $event Event handler
*
* @return void
**/
public function draftFormHandler(\Doku_Event $event) {
foreach ($event->data->_content as $key => $item) {
if (is_array($item) && isset($item['_elem'])) {
if ($item['_action'] == 'draftdel') {
$event->data->_content[$key]['class'] = ' btn btn-danger';
$event->data->_content[$key]['value'] = \Mdi::icon('close') . ' ' . $event->data->_content[$key]['value'];
}
if ($item['_action'] == 'recover') {
$event->data->_content[$key]['value'] = \Mdi::icon('refresh') . ' ' . $event->data->_content[$key]['value'];
}
if ($item['_action'] == 'show') {
$event->data->_content[$key]['value'] = \Mdi::icon('arrow-left') . ' ' . $event->data->_content[$key]['value'];
}
}
}
}
/**
* Handle HTML_EDITFORM_OUTPUT and HTML_DRAFTFORM_OUTPUT event
*
* @param \Doku_Event $event Event handler
*
@@ -163,9 +207,9 @@ public function editFormHandler(\Doku_Event $event) {
$event->data->_content[$key]['value'] = \Mdi::icon('file-document-outline') . ' ' . $event->data->_content[$key]['value'];
}
if ($item['_action'] == 'draftdel') {
$event->data->_content[$key]['class'] = ' btn btn-danger';
$event->data->_content[$key]['value'] = \Mdi::icon('close') . ' ' . $event->data->_content[$key]['value'];
// Cancel button
if ($item['_action'] == 'cancel') {
$event->data->_content[$key]['value'] = \Mdi::icon('arrow-left') . ' ' . $event->data->_content[$key]['value'];
}
}
@@ -1801,11 +1845,6 @@ public function normalizeContent($content)
$elm->class .= ' btn btn-default';
}
foreach ($html->find('#dw__login, #subscribe__form, #media__manager') as $elm) {
foreach ($elm->find('[type=submit]') as $btn) {
$btn->class .= ' btn btn-success';
}
}
# Section Edit Button
foreach ($html->find('.btn_secedit [type=submit]') as $elm) {
@@ -2361,9 +2400,9 @@ public function normalizeContent($content)
}
# Difference
# Difference and Draft
if ($ACT == 'diff') {
if ($ACT == 'diff' || $ACT == 'draft') {
# Import HTML string
$html = new \simple_html_dom;
@@ -2396,15 +2435,15 @@ public function normalizeContent($content)
}
foreach ($html->find('.diffprevrev') as $elm) {
$elm->class .= ' btn btn-xs btn-default mdi mdi-chevron-left';
$elm->class .= ' btn btn-default mdi mdi-chevron-left';
}
foreach ($html->find('.diffnextrev') as $elm) {
$elm->class .= ' btn btn-xs btn-default mdi mdi-chevron-right';
$elm->class .= ' btn btn-default mdi mdi-chevron-right';
}
foreach ($html->find('.diffbothprevrev') as $elm) {
$elm->class .= ' btn btn-xs btn-default mdi mdi-chevron-double-left';
$elm->class .= ' btn btn-default mdi mdi-chevron-double-left';
}
foreach ($html->find('.minor') as $elm) {
@@ -2423,7 +2462,7 @@ public function normalizeContent($content)
$svg_icon = null;
if (!$INFO['exists']) {
$svg_icon = template('assets/mdi/svg/alert.svg');
$svg_icon = 'alert';
}
$menu_class = "\\dokuwiki\\Menu\\Item\\$ACT";
@@ -2444,60 +2483,67 @@ public function normalizeContent($content)
$svg_icon = $plugin->getMenuIcon();
if (!file_exists($svg_icon)) {
$svg_icon = template('assets/mdi/svg/puzzle.svg');
$svg_icon = 'puzzle';
}
} else {
$svg_icon = template('assets/mdi/svg/puzzle.svg');
$svg_icon = 'puzzle';
}
}
break;
case 'resendpwd':
$svg_icon = 'lock-reset';
break;
case 'denied':
$svg_icon = template('assets/mdi/svg/block-helper.svg');
$svg_icon = 'block-helper';
break;
case 'search':
$svg_icon = template('assets/mdi/svg/search-web.svg');
$svg_icon = 'search-web';
break;
case 'preview':
$svg_icon = template('assets/mdi/svg/file-eye.svg');
$svg_icon = 'file-eye';
break;
case 'diff':
$svg_icon = template('assets/mdi/svg/file-compare.svg');
$svg_icon = 'file-compare';
break;
case 'showtag':
$svg_icon = template('assets/mdi/svg/tag-multiple.svg');
$svg_icon = 'tag-multiple';
break;
case 'draft':
$svg_icon = 'android-studio';
break;
}
if ($svg_icon && file_exists($svg_icon)) {
if ($svg_icon) {
$xml = simplexml_load_file($svg_icon);
$svg_attrs = array();
$xml['width'] = '32';
$xml['height'] = '32';
$xml['style'] = 'fill-opacity: 0.2;';
$svg_attrs['style'] = 'fill-opacity: 0.2;';
if (!$INFO['exists'] && $ACT == 'show') {
$xml['style'] .= 'fill: orange;';
$svg_attrs['style'] .= 'fill: orange;';
}
if ($ACT == 'denied') {
$xml['style'] .= 'fill: red;';
$svg_attrs['style'] .= 'fill: red;';
}
if ($ACT == 'admin' && $INPUT->str('page') == 'extension') {
$xml['style'] .= 'fill: green;';
$svg_attrs['style'] .= 'fill: green;';
}
$svg = $this->cleanSVG($xml->asXML());
$svg = \Mdi::icon($svg_icon, null, 32, $svg_attrs);
# Import HTML string
$html = new \simple_html_dom;
@@ -230,6 +230,10 @@ div#picker2 {
padding: 5px;
}

legend {
font-size: 1.8em;
}

fieldset {
background: initial !important;
padding: 0 !important;
@@ -667,6 +671,26 @@ ul.btn-group {
font-weight: bold;
}

.diff.diff_sidebyside {

margin-top: 25px;
margin-bottom: 25px;

td.diff-context {
width: 50%;
}

}

table.diff {
select {
font-size: 1em !important;
}
td {
font-size: 1em !important;
}
}

}

/* Custom DropDown menu with multiple columns */
@@ -477,6 +477,13 @@ jQuery(document).on('bootstrap3:media-manager', function(event) {
jQuery('.qq-upload-button').addClass('btn btn-default');
jQuery('.qq-upload-action').addClass('btn btn-success');

var $btn_delete = jQuery('#mediamanager__btn_delete [type=submit]');
var $btn_update = jQuery('#mediamanager__btn_update [type=submit]');

$btn_delete.addClass('btn btn-danger');
$btn_delete.prepend(jQuery('<i class="mdi mdi-delete"/>'));
$btn_update.prepend(jQuery('<i class="mdi mdi-image-plus"/>'));

}

// Media Manager (page)
@@ -486,7 +493,8 @@ jQuery(document).on('bootstrap3:media-manager', function(event) {

var $sort_buttons = jQuery('.ui-buttonset');

$media_manager.find('.file dl').addClass('dl-horizontal');
//$media_manager.find('.file dl').addClass('dl-horizontal');
$media_manager.find('.file dd').addClass('pl-4');
$media_manager.find('.panel').removeClass('panel').addClass('pull-left');

$sort_buttons.addClass('btn-group');
@@ -14,7 +14,7 @@
$lang['expand_container'] = 'Expand/Reduce';
$lang['administrative_tasks'] = 'Administrative Tasks';
$lang['additional_plugins'] = 'Additional Plugins';
$lang['share_on'] = 'Share on';
$lang['share_on'] = 'Share via';
$lang['send_mail'] = 'Send via e-Mail';
$lang['print'] = 'Print';
$lang['permalink'] = 'Permalink';

0 comments on commit 23b284e

Please sign in to comment.
You can’t perform that action at this time.