Merge pull request #1 from SoftBellies/dev

customs css possibles
master
Gnieark 7 years ago committed by GitHub
commit 5e78309085

@ -14,7 +14,7 @@ Ce module permet de la coloration syntaxique lors de la citation de codes dans u
# Code tiers # Code tiers
Minifier class was made by Tedious https://github.com/tedious/JShrink BSD License. Minifier class was made by Tedious https://github.com/tedious/JShrink BSD License.
# Modifications apportées par ce Fork: # Modifications apportées:
Le plugin Yash insère plusieurs appels à des scripts javascripts, et ajoute des variables JS dans le footer de la page. Le plugin Yash insère plusieurs appels à des scripts javascripts, et ajoute des variables JS dans le footer de la page.
Yash3 concatène tout ça pour ne mettre qu'un seul script en référence. Yash3 concatène tout ça pour ne mettre qu'un seul script en référence.
@ -27,4 +27,4 @@ Les noms de fichiers (css et js) générés sont incrémentés à chaque modific
# Installation # Installation
Installez ce plugin en copiant l'url suivante https://www.ventresmous.fr/public/yash/yash3.zip directement dans l'interface de Dotclear pour l'installer. Installez ce plugin en copiant l'url suivante https://www.ventresmous.fr/public/yash/yash3.zip directement dans l'interface de Dotclear pour l'installer.
Pensez à désactiver le plugin yash si vous l'aviez installé. Pensez à désactiver le plugin yash si vous l'aviez installé.

@ -31,4 +31,4 @@ $_menu['Blog']->addItem(__('YASH3'),
preg_match('/plugin.php\?p=yash3(&.*)?$/',$_SERVER['REQUEST_URI']), preg_match('/plugin.php\?p=yash3(&.*)?$/',$_SERVER['REQUEST_URI']),
$core->auth->check('contentadmin',$core->blog->id)); $core->auth->check('contentadmin',$core->blog->id));
$core->addBehavior('adminPostEditor',array('yash3Behaviors','adminPostEditor')); $core->addBehavior('adminPostEditor',array('yash3Behaviors','adminPostEditor'));

@ -1,7 +1,10 @@
<?php <?php
# ***** BEGIN LICENSE BLOCK ***** # ***** BEGIN LICENSE BLOCK *****
# This file is part of YASH, a plugin for DotClear2. # This file is part of YASH3, a plugin for DotClear2.
# Copyright (c) 2008 Pep and contributors. All rights # Forked by (c) Gnieark https://blog-du-grouik.tinad.fr 2016
# licensed as GPL V2
#
# Original dev is: Yash Copyright (c) 2008 Pep and contributors. All rights
# reserved. # reserved.
# #
# This plugin is free software; you can redistribute it and/or modify # This plugin is free software; you can redistribute it and/or modify
@ -24,9 +27,9 @@ if (!defined('DC_RC_PATH')) { return; }
$this->registerModule( $this->registerModule(
/* Name */ "YASH Fork", /* Name */ "YASH Fork",
/* Description*/ "Fork of Yet Another Syntax Highlighter. Modification: Juste one javascript called on public pages for yash3", /* Description*/ "Fork from Yet Another Syntax Highlighter. Modification: Juste one javascript called on public pages for yash3",
/* Author */ "Forked and modified by Gnieark, origin Pep and contributors", /* Author */ "Forked and modified by Gnieark, origin: Pep and contributors",
/* Version */ '0.8.1', /* Version */ '0.9.1',
array( array(
/* Dependencies */ 'requires' => array(array('core','2.9')), /* Dependencies */ 'requires' => array(array('core','2.9')),
/* Permissions */ 'permissions' => 'usage,contentadmin', /* Permissions */ 'permissions' => 'usage,contentadmin',

@ -44,7 +44,7 @@ if (is_null($core->blog->settings->yash3->yash3_active)) {
// Getting current parameters // Getting current parameters
$active = (boolean)$core->blog->settings->yash3->yash3_active; $active = (boolean)$core->blog->settings->yash3->yash3_active;
$theme = (string)$core->blog->settings->yash3->yash3_theme; $theme = (string)$core->blog->settings->yash3->yash3_theme;
$custom_css = (string)$core->blog->settings->yash3->yash3_custom_css; $customCss = (string)$core->blog->settings->yash3->yash3_custom_css;
if (!empty($_REQUEST['popup'])) { if (!empty($_REQUEST['popup'])) {
$yash3_brushes = array( $yash3_brushes = array(
@ -105,10 +105,10 @@ if (!empty($_POST['saveconfig'])) {
$core->blog->settings->addNameSpace('yash3'); $core->blog->settings->addNameSpace('yash3');
$active = (empty($_POST['active'])) ? false : true; $active = (empty($_POST['active'])) ? false : true;
$theme = (empty($_POST['theme'])) ? 'Default' : $_POST['theme']; $theme = (empty($_POST['theme'])) ? 'Default' : $_POST['theme'];
$custom_css = (empty($_POST['custom_css'])) ? '' : html::sanitizeURL($_POST['custom_css']); $customCss = (empty($_POST['customCss'])) ? '' : $_POST['customCss'];
$core->blog->settings->yash3->put('yash3_active',$active,'boolean'); $core->blog->settings->yash3->put('yash3_active',$active,'boolean');
$core->blog->settings->yash3->put('yash3_theme',$theme,'string'); $core->blog->settings->yash3->put('yash3_theme',$theme,'string');
$core->blog->settings->yash3->put('yash3_custom_css',$custom_css,'string'); $core->blog->settings->yash3->put('yash3_custom_css',$customCss,'string');
$new_concat_version = (integer)$core->blog->settings->yash3->yash3_concat_version + 1; $new_concat_version = (integer)$core->blog->settings->yash3->yash3_concat_version + 1;
@ -142,35 +142,27 @@ if (!empty($_POST['saveconfig'])) {
unlink($cssPreviousFileRealPath); unlink($cssPreviousFileRealPath);
} }
$custom_css = $core->blog->settings->yash3->yash3_custom_css; $custom_css = $core->blog->settings->yash3->yash3_custom_css;
if (!empty($custom_css)) { if (!empty($custom_css)) {
if (strpos('/',$custom_css) === 0) { $fContent = $custom_css;
$cssPathFile = DC_RC_PATH.$custom_css;
}
else {
$cssPathFile = DC_RC_PATH.
$core->blog->settings->system->themes_url."/".
$core->blog->settings->system->theme."/".
$custom_css;
}
} }
else { else {
$theme = (string)$core->blog->settings->yash3->yash3_theme; $theme = (string)$core->blog->settings->yash3->yash3_theme;
if ($theme == '') { if ($theme == '') {
$cssPathFile = dirname(__FILE__)."/syntaxhighlighter/css/shThemeDefault.css"; $fContent = file_get_contents(dirname(__FILE__)."/syntaxhighlighter/css/shThemeDefault.css");
} else { } else {
$cssPathFile = dirname(__FILE__)."/syntaxhighlighter/css/shTheme".$theme.".css"; $fContent = file_get_contents(dirname(__FILE__)."/syntaxhighlighter/css/shTheme".$theme.".css");
} }
} }
$fContent = file_get_contents(dirname(__FILE__)."/syntaxhighlighter/css/shCore.css")."\n". $fContent = file_get_contents(dirname(__FILE__)."/syntaxhighlighter/css/shCore.css")."\n".
file_get_contents($cssPathFile); $fContent;
// Remove comments // Remove comments
//$fContent = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $fContent); $fContent = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $fContent);
// Remove space after colons // Remove space after colons
//$fContent = str_replace(': ', ':', $fContent); $fContent = str_replace(': ', ':', $fContent);
// Remove whitespace // Remove whitespace
//$fContent = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $fContent); $fContent = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $fContent);
//create the file //create the file
file_put_contents( $cssFutureFileRealPath, $fContent ); file_put_contents( $cssFutureFileRealPath, $fContent );
@ -208,6 +200,23 @@ if (!empty($_POST['saveconfig'])) {
<html> <html>
<head> <head>
<title><?php echo __('YASH3'); ?></title> <title><?php echo __('YASH3'); ?></title>
<script type="text/javascript">
//I hate jquery
$(document).ready(function(){
$("#theme").change(function(){;
$(this).find("option:selected").each(function(){
if($(this).attr("value")=="Custom"){
$("#pcustomcss").show();
}else{
$("#pcustomcss").hide();
}
});
}).change();
});
</script>
</head> </head>
<body> <body>
@ -220,18 +229,19 @@ if (!empty($_POST['saveconfig'])) {
echo dcPage::notices(); echo dcPage::notices();
$combo_theme = array( $combo_theme = array(
__('Default') => 'Default', __('Default') => 'Default',
__('Django') => 'Django', __('Custom css') => 'Custom',
__('Eclipse') => 'Eclipse', __('Django') => 'Django',
__('Emacs') => 'Emacs', __('Eclipse') => 'Eclipse',
__('Fade to gray') => 'FadeToGrey', __('Emacs') => 'Emacs',
__('Material') => 'Material', __('Fade to gray') => 'FadeToGrey',
__('MD Ultra') => 'MDUltra', __('Material') => 'Material',
__('Midnight') => 'Midnight', __('MD Ultra') => 'MDUltra',
__('RDark') => 'RDark', __('Midnight') => 'Midnight',
__('Solarized Dark') => 'SolarizedDark', __('RDark') => 'RDark',
__('Solarized Light') => 'SolarizedLight', __('Solarized Dark') => 'SolarizedDark',
__('Tomorrow Night') => 'TomorrowNight' __('Solarized Light') => 'SolarizedLight',
__('Tomorrow Night') => 'TomorrowNight'
); );
?> ?>
@ -246,13 +256,12 @@ $combo_theme = array(
<p class="field"><label for="theme" class="classic"><?php echo __('Theme:'); ?> </label> <p class="field"><label for="theme" class="classic"><?php echo __('Theme:'); ?> </label>
<?php echo form::combo('theme',$combo_theme,$theme); ?> <?php echo form::combo('theme',$combo_theme,$theme); ?>
</p> </p>
<p class="field"> <p class="field" id="pcustomcss">
<label for="custom_css" class="classic"><?php echo __('Use custom CSS:') ; ?> </label> <label for="custom_css" class="classic"><?php echo __('Use custom CSS:') ; ?> </label>
<?php echo form::field('custom_css',40,128,$custom_css); ?> <?php echo form::textarea('customCss',80,20, $customCss); ?>
</p> </p>
<p class="info"> <p class="info">
<?php echo __('You can use a custom CSS by providing its location.'); ?><br /> <?php echo __('You can use a custom CSS. Select custom CSS and paste it on the textarea'); ?>
<?php echo __('A location beginning with a / is treated as absolute, else it is treated as relative to the blog\'s current theme URL'); ?>
</p> </p>
<p><input type="hidden" name="p" value="yash3" /> <p><input type="hidden" name="p" value="yash3" />
@ -261,6 +270,5 @@ $combo_theme = array(
</p> </p>
</form> </form>
</div> </div>
</body> </body>
</html> </html>
Loading…
Cancel
Save