Browse Source

- Formulaire de configuration pour pouvoir choisir de ne pas mettre les scripts du PP dans le public.

- Mise à jour des scripts d'expression régulière pour la fonction .split() que l'auteur à intégré dans une librairie plus générale, reprenant .replace(), .match() aussi notamment : http://xregexp.com/
- Charger la barre après le chargement de la page.
2.1 v1.7.0
marcimat@rezo.net 13 years ago
parent
commit
3177e85779
  1. 8
      .gitattributes
  2. 2
      barre_outils/edition.php
  3. 41
      configuration/porte_plume.php
  4. 28
      formulaires/configurer_porte_plume.html
  5. 28
      formulaires/configurer_porte_plume.php
  6. 3
      inc/barre_outils.php
  7. 119
      javascript/jquery.markitup_pour_spip.js
  8. 2
      javascript/xregexp-min.js
  9. 21
      lang/barre_outils_fr.php
  10. 13
      plugin.xml
  11. 3
      porte_plume.js.html
  12. 52
      porte_plume_pipelines.php
  13. 9
      porte_plume_start.js.html
  14. 0
      porte_plume_start.js_fonctions.php
  15. 3
      prive/configurer/porte_plume.html

8
.gitattributes vendored

@ -2,11 +2,14 @@
barre_outils/edition.php -text
barre_outils/forum.php -text
/barre_outils_icones.css.html -text
configuration/porte_plume.php -text
css/barre_outils.css -text
css/barre_outils_prive.css -text
css/images/handle.png -text
css/images/menu.png -text
css/images/submenu.png -text
formulaires/configurer_porte_plume.html -text
formulaires/configurer_porte_plume.php -text
icones_barre/aelig-maj.png -text
icones_barre/aelig.png -text
icones_barre/agrave-maj.png -text
@ -47,6 +50,7 @@ javascript/jquery.markitup.js -text
javascript/jquery.markitup_pour_spip.js -text
javascript/jquery.previsu_spip.js -text
javascript/porte_plume_forcer_hauteur.js -text
javascript/xregexp-min.js -text
lang/barre_outils_ar.php -text
lang/barre_outils_en.php -text
lang/barre_outils_es.php -text
@ -55,13 +59,13 @@ markitup/readme.txt -text
markitup/templates/preview.css -text
markitup/templates/preview.html -text
/plugin.xml -text
/porte_plume.js.html -text
/porte_plume.js_fonctions.php -text
/porte_plume_options.php -text
/porte_plume_pipelines.php -text
/porte_plume_preview.html -text
/porte_plume_preview_fonctions.php -text
/porte_plume_start.js.html -text
/porte_plume_start.js_fonctions.php -text
prive/configurer/porte_plume.html -text
tests/all_tests.php -text
tests/barre_outil_markitup.php -text
tests/lanceur_spip.php -text

2
barre_outils/edition.php

@ -16,7 +16,7 @@ function barre_outils_edition(){
#'previewAutoRefresh'=> true,
#'previewParserPath' => url_absolue(generer_url_public('preview')),
'onShiftEnter' => array('keepDefault'=>false, 'replaceWith'=>"\n_ "),
'onCtrlEnter' => array('keepDefault'=>false, 'replaceWith'=>"\n\n"),
'onCtrlEnter' => array('keepDefault'=>true, 'replaceWith'=>"\n\n"),
// garder les listes si on appuie sur entree
'onEnter' => array('keepDefault'=>false, 'selectionType'=>'return', 'replaceWith'=>"\n"),
'onTab' => array('keepDefault'=>false, 'replaceWith'=>"\t"),

41
configuration/porte_plume.php

@ -0,0 +1,41 @@
<?php
/***************************************************************************\
* SPIP, Systeme de publication pour l'internet *
* *
* Copyright (c) 2001-2010 *
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
* *
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
if (!defined("_ECRIRE_INC_VERSION")) return;
include_spip('inc/presentation');
include_spip('inc/config');
function configuration_porte_plume_dist()
{
$res = propre(_T("barre_outils:explication_barre_outils_public"));
$res .= propre(_T("barre_outils:explication_barre_outils_public_2"));
$res .= afficher_choix('barre_outils_public', $GLOBALS['meta']["barre_outils_public"],
array(
'oui' => _T("barre_outils:label_barre_outils_public_oui"),
'non' => _T("barre_outils:label_barre_outils_public_non")
),
" <br /> ");
$res = debut_cadre_trait_couleur(find_in_path("images/porte-plume-24.png"), true, "", _T("barre_outils:info_porte_plume_titre"))
. ajax_action_post('configurer', 'porte_plume', 'configuration','',$res)
. fin_cadre_trait_couleur(true);
return ajax_action_greffe('configurer-porte_plume', '', $res);
}
?>

28
formulaires/configurer_porte_plume.html

@ -0,0 +1,28 @@
<div class='formulaire_spip formulaire_configurer formulaire_configurer_#FORM' id='formulaire_configurer_#FORM'>
<h3 class='titrem'>[(#CHEMIN{images/porte-plume-24.png}|balise_img{'',cadre-icone})]<:barre_outils:info_porte_plume_titre:></h3>
[<p class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</p>]
[<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>]
<form action="#ENV{action}#formulaire_configurer_#FORM" method="post"><div>
[(#ACTION_FORMULAIRE{#ENV{action}})]
<ul>
<li class='configurer_barre_outils_public[ (#ENV**{erreurs}|table_valeur{barre_outils_public}|oui)erreur]'>
<label><:barre_outils:info_barre_outils_public:></label>
<p class='explication'><:barre_outils:explication_barre_outils_public:></p>
<p class='explication'><:barre_outils:explication_barre_outils_public_2:></p>
[<span class='erreur_message'>(#ENV**{erreurs}|table_valeur{barre_outils_public})</span>]
<div class='choix'>
<input class='radio' type="radio" name="barre_outils_public" value='oui'[ (#ENV{barre_outils_public}|!={non}|oui)checked="checked"] id="barre_outils_public_oui"/>
<label for="barre_outils_public_oui"><:barre_outils:label_barre_outils_public_oui:></label>
</div>
<div class='choix'>
<input class='radio' type="radio" name="barre_outils_public" value='non'[ (#ENV{barre_outils_public}|=={non}|oui)checked="checked"] id="barre_outils_public_non"/>
<label for="barre_outils_public_non"><:barre_outils:label_barre_outils_public_non:></label>
</div>
</li>
</ul>
<p class='boutons'><input class='submit' type="submit" name="ok" value="<:bouton_enregistrer:>"/></p>
</div></form>
</div>

28
formulaires/configurer_porte_plume.php

@ -0,0 +1,28 @@
<?php
/***************************************************************************\
* SPIP, Systeme de publication pour l'internet *
* *
* Copyright (c) 2001-2009 *
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
* *
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
if (!defined("_ECRIRE_INC_VERSION")) return;
function formulaires_configurer_porte_plume_charger_dist(){
$valeurs = array();
$valeurs['barre_outils_public'] = $GLOBALS['meta']['barre_outils_public'];
return $valeurs;
}
function formulaires_configurer_porte_plume_traiter_dist(){
include_spip('inc/config');
appliquer_modifs_config();
return array('message_ok'=>_T('config_info_enregistree'));
}
?>

3
inc/barre_outils.php

@ -36,8 +36,7 @@ class Barre_outils{
// private
var $_liste_params_autorises = array(
'keepDefault',
'replaceWith',
'openWith',
'closeWith',

119
javascript/jquery.markitup_pour_spip.js

@ -1,9 +1,9 @@
// ----------------------------------------------------------------------------
// markItUp! Universal MarkUp Engine, JQuery plugin
// v 1.1.6
// v 1.1.6.1
// Dual licensed under the MIT and GPL licenses.
// ----------------------------------------------------------------------------
// Copyright (C) 2007-2009 Jay Salvat
// Copyright (C) 2007-2010 Jay Salvat
// http://markitup.jaysalvat.com/
// ----------------------------------------------------------------------------
// Permission is hereby granted, free of charge, to any person obtaining a copy
@ -26,7 +26,7 @@
// ----------------------------------------------------------------------------
/*
* Le code original de markitup 1.1.5
* Le code original de markitup 1.1.6.1
* a ete modifie pour prendre en compte
*
* 1) la langue utilisee dans les textarea :
@ -55,8 +55,8 @@
*/
;(function($) {
$.fn.markItUp = function(settings, extraSettings) {
var options, ctrlKey, shiftKey, altKey, enterKey;
ctrlKey = shiftKey = altKey = enterKey = false;
var options, ctrlKey, shiftKey, altKey;
ctrlKey = shiftKey = altKey = false;
options = { id: '',
nameSpace: '',
@ -137,6 +137,7 @@
footer = $('<div class="markItUpFooter"></div>').insertAfter($$);
// add the resize handle after textarea
if (options.resizeHandle === true && $.browser.safari !== true) {
resizeHandle = $('<div class="markItUpResizeHandle"></div>')
.insertAfter($$)
@ -314,8 +315,8 @@
before = $$.val().substring(0, caretEffectivePosition);
after = $$.val().substring(caretEffectivePosition + selection.length - fixOperaBug(selection) - fixIeBug(selection));
before = before.xSplit(pattern);
after = after.xSplit(pattern);
before = before.split(pattern);
after = after.split(pattern);
}
function selectionSave(){
@ -343,8 +344,7 @@
caretPosition:caretPosition,
ctrlKey:ctrlKey,
shiftKey:shiftKey,
altKey:altKey,
enterKey:enterKey
altKey:altKey
}
);
@ -389,7 +389,6 @@
before[before.length-1] = before_last;
selectionSave();
}
}
// / fin corrections
@ -404,7 +403,7 @@
// insertion forcee en multiligne ou ctrl+click
if ((button.forceMultiline === true && selection.length)
|| (ctrlKey === true && shiftKey === true)) {
lines = selection.xSplit(/\r?\n/);
lines = selection.split(/\r?\n/);
for (j = 0, n = lines.length, i = 0; i < n; i++) {
if ($.trim(lines[i]) !== '') {
$.extend(hash, { line:++j, selection:lines[i] } );
@ -436,7 +435,7 @@
if (selection === ''){
start += fixOperaBug(string.replaceWith);
}
//$.extend(hash, { caretPosition:caretPosition, scrollPosition:scrollPosition } );
$.extend(hash, { caretPosition:caretPosition, scrollPosition:scrollPosition } );
if (string.block !== selection && abort === false) {
insert(string.block);
@ -460,9 +459,9 @@
if (previewWindow && options.previewAutoRefresh) {
refreshPreview();
}
// reinit keyevent
shiftKey = altKey = ctrlKey = enterKey = abort = false;
shiftKey = altKey = ctrlKey = abort = false;
}
@ -622,9 +621,11 @@
if (e.keyCode === 17) {e.ctrlKey = true;} // control
if (e.keyCode === 16) {e.shiftKey = true;} // shift
}
shiftKey = e.shiftKey;
altKey = e.altKey;
ctrlKey = (!(e.altKey && e.ctrlKey)) ? e.ctrlKey : false;
if (e.type === 'keydown') {
if (ctrlKey === true) {
li = $("a[accesskey="+String.fromCharCode(e.keyCode)+"]", header).parent('li');
@ -638,7 +639,6 @@
// car il ne prend pas en compte l'arret de ces evenements
if (!$.browser.opera) {
if (e.keyCode === 13 || e.keyCode === 10) { // Enter key
enterKey = true;
if (ctrlKey === true) { // Enter + Ctrl
ctrlKey = false;
markup(options.onCtrlEnter);
@ -654,7 +654,6 @@
}
if (e.keyCode === 9) { // Tab key
// don't know what that is for...
if (shiftKey == true || ctrlKey == true || altKey == true) { // Thx Dr Floob.
return false;
}
@ -691,91 +690,3 @@
};
})(jQuery);
/*
* Corriger les split qui ne fonctionnent pas pareil
* sous IE particulierement. Provient de :
* http://blog.stevenlevithan.com/archives/cross-browser-split
* (ici, remplace par la fonction xSplit)
*/
/*
Cross-Browser Split 0.3
By Steven Levithan <http://stevenlevithan.com>
MIT license
Provides a consistent cross-browser, ECMA-262 v3 compliant split method
*/
//String.prototype._$$split = String.prototype._$$split || String.prototype.split;
//String.prototype.split = function (s /* separator */, limit) {
String.prototype.xSplit = function (s /* separator */, limit) {
// if separator is not a regex, use the native split method
if (!(s instanceof RegExp))
return String.prototype.split.apply(this, arguments);
//return String.prototype._$$split.apply(this, arguments);
var flags = (s.global ? "g" : "") + (s.ignoreCase ? "i" : "") + (s.multiline ? "m" : ""),
s2 = new RegExp("^" + s.source + "$", flags),
output = [],
origLastIndex = s.lastIndex,
lastLastIndex = 0,
i = 0, match, lastLength;
/* behavior for limit: if it's...
- undefined: no limit
- NaN or zero: return an empty array
- a positive number: use limit after dropping any decimal
- a negative number: no limit
- other: type-convert, then use the above rules
*/
if (limit === undefined || +limit < 0) {
limit = false;
} else {
limit = Math.floor(+limit);
if (!limit)
return [];
}
if (s.global)
s.lastIndex = 0;
else
s = new RegExp(s.source, "g" + flags);
while ((!limit || i++ <= limit) && (match = s.exec(this))) {
var emptyMatch = !match[0].length;
// Fix IE's infinite-loop-resistant but incorrect lastIndex
if (emptyMatch && s.lastIndex > match.index)
s.lastIndex--;
if (s.lastIndex > lastLastIndex) {
// Fix browsers whose exec methods don't consistently return undefined for non-participating capturing groups
if (match.length > 1) {
match[0].replace(s2, function () {
for (var j = 1; j < arguments.length - 2; j++) {
if (arguments[j] === undefined)
match[j] = undefined;
}
});
}
output = output.concat(this.slice(lastLastIndex, match.index));
if (1 < match.length && match.index < this.length)
output = output.concat(match.slice(1));
lastLength = match[0].length; // only needed if s.lastIndex === this.length
lastLastIndex = s.lastIndex;
}
if (emptyMatch)
s.lastIndex++; // avoid an infinite loop
}
// since this uses test(), output must be generated before restoring lastIndex
output = lastLastIndex === this.length ?
(s.test("") && !lastLength ? output : output.concat("")) :
(limit ? output : output.concat(this.slice(lastLastIndex)));
s.lastIndex = origLastIndex; // only needed if s.global, else we're working with a copy of the regex
return output;
};

2
javascript/xregexp-min.js vendored

File diff suppressed because one or more lines are too long

21
lang/barre_outils_fr.php

@ -89,8 +89,27 @@ $GLOBALS[$GLOBALS['idx_lang']] = array(
'barre_gestion_anc_nom' => 'Nom de l\'ancre',
'barre_gestion_anc_pointer' => 'Pointer vers une ancre',
'barre_gestion_anc_cible' => 'Ancre cible',
'barre_gestion_anc_bulle' => 'Bulle d\'aide ancre'
'barre_gestion_anc_bulle' => 'Bulle d\'aide ancre',
// E
'explication_barre_outils_public' => "Les scripts CSS et Javascript des barre d'outils
(extension Porte Plume) sont charg&eacute;s sur l'espace public
et permettent d'utiliser ces barres sur les formulaires de forums,
les crayons publics ou pour d'autres plugins, si leurs configurations
respectives le permettent.",
'explication_barre_outils_public_2' => "Vous pouvez choisir de ne pas charger
ces scripts afin d'all&eacute;ger le poids des pages publiques.
D&egrave;s lors quelque soit la configuration des forums, crayons ou plugin,
aucune barre d'outils du Porte Plume ne pourra &ecirc;tre
pr&eacute;sente automatiquement sur l'espace public.",
// I
'info_porte_plume_titre' => "Configurer les barres d'outils",
'info_barre_outils_public' => "Barre d'outils publique",
// L
'label_barre_outils_public_oui' => "Charger les scripts de barre d'outils sur l'espace public",
'label_barre_outils_public_non' => "Ne pas charger les scripts de barre d'outils sur l'espace public",
);
?>

13
plugin.xml

@ -2,7 +2,7 @@
<nom>Porte plume</nom>
<auteur>Matthieu Marcillaud</auteur>
<licence>GNU/GPL</licence>
<version>1.6.4</version>
<version>1.7.0</version>
<description>Une barre d'outil pour bien &eacute;crire
_ Porte plume est une barre d'outil extensible pour SPIP qui
utilise la librairie javascript [MarkItUp->http://markitup.jaysalvat.com/home/]
@ -34,5 +34,16 @@ _ Porte plume est une barre d'outil extensible pour SPIP qui
<action>insert_head_prive</action>
<inclure>porte_plume_pipelines.php</inclure>
</pipeline>
<!-- Pour formulaire de configuration -->
<pipeline>
<nom>affiche_milieu</nom>
<inclure>porte_plume_pipelines.php</inclure>
</pipeline>
<pipeline>
<nom>configurer_liste_metas</nom>
<inclure>porte_plume_pipelines.php</inclure>
</pipeline>
<necessite id="SPIP" version="[2.0.2;]" />
</plugin>

3
porte_plume.js.html

@ -1,3 +0,0 @@
#CACHE{7*24*3600}
#HTTP_HEADER{Content-Type: text/javascript; charset=#CHARSET}
[(#VAL|porte_plume_creer_json_markitup)]

52
porte_plume_pipelines.php

@ -4,11 +4,16 @@
* Licence GPL
* Auteur Matthieu Marcillaud
*/
define('PORTE_PLUME_PUBLIC', true);
#define('PORTE_PLUME_PUBLIC', true);
// autoriser le porte plume dans le public ?
function autoriser_porte_plume_afficher_public_dist($faire, $type, $id, $qui, $opt) {
return PORTE_PLUME_PUBLIC;
// compatibilite d'avant le formulaire de configuration
if (defined('PORTE_PLUME_PUBLIC')) {
return PORTE_PLUME_PUBLIC;
}
return ($GLOBALS['meta']['barre_outils_public'] !== 'non');
// n'autoriser qu'aux identifies :
# return $qui['id_auteur'] ? PORTE_PLUME_PUBLIC : false;
}
@ -28,21 +33,21 @@ function porte_plume_insert_head_prive($flux){
$flux = porte_plume_inserer_head($flux, $GLOBALS['spip_lang'])
. "<script type='text/javascript' src='$js'></script>\n"
. "<link rel='stylesheet' type='text/css' media='all' href='$css' />\n";
return $flux;
}
function porte_plume_inserer_head($flux, $lang){
$js = find_in_path('javascript/jquery.markitup_pour_spip.js');
$xregexp = find_in_path('javascript/xregexp-min.js');
$markitup = find_in_path('javascript/jquery.markitup_pour_spip.js');
$js_previsu = find_in_path('javascript/jquery.previsu_spip.js');
$js_settings = parametre_url(generer_url_public('porte_plume.js'), 'lang', $lang);
$js_start = parametre_url(generer_url_public('porte_plume_start.js'), 'lang', $lang);
$flux
.= porte_plume_insert_head_css() // compat SPIP 2.0
. "<script type='text/javascript' src='$js'></script>\n"
. "<script type='text/javascript' src='$xregexp'></script>\n"
. "<script type='text/javascript' src='$markitup'></script>\n"
. "<script type='text/javascript' src='$js_previsu'></script>\n"
. "<script type='text/javascript' src='$js_settings'></script>\n"
. "<script type='text/javascript' src='$js_start'></script>\n";
return $flux;
@ -52,16 +57,37 @@ function porte_plume_insert_head_css($flux=''){
static $done = false;
if ($done) return $flux;
$done = true;
if (autoriser('afficher_public', 'porte_plume')) {
$css = find_in_path('css/barre_outils.css');
$css_icones = generer_url_public('barre_outils_icones.css');
$css = find_in_path('css/barre_outils.css');
$css_icones = generer_url_public('barre_outils_icones.css');
$flux
.= "<link rel='stylesheet' type='text/css' media='all' href='$css' />\n"
. "<link rel='stylesheet' type='text/css' media='all' href='$css_icones' />\n";
}
return $flux;
}
$flux
.= "<link rel='stylesheet' type='text/css' media='all' href='$css' />\n"
. "<link rel='stylesheet' type='text/css' media='all' href='$css_icones' />\n";
return $flux;
// valeur par defaut des configurations
function porte_plume_configurer_liste_metas($metas){
$metas['barre_outils_public'] = 'oui';
return $metas;
}
function porte_plume_affiche_milieu($flux){
if ($flux['args']['exec']=='config_fonctions'){
// dans la branche 2.1 on utilise l'ancienne interface du compresseur par homogeneite
if (version_compare($GLOBALS['spip_version_branche'], "2.2.0-dev","<")){
$porte_plume = charger_fonction('porte_plume', 'configuration');
$flux['data'] .= $porte_plume();
}
else {
$flux['data'] .= recuperer_fond('prive/configurer/porte_plume',array());
}
}
return $flux;
}
?>

9
porte_plume_start.js.html

@ -1,6 +1,12 @@
#CACHE{7*24*3600}
#HTTP_HEADER{Content-Type: text/javascript; charset=#CHARSET}
[(#REM) chargement des definitions des barres d'outils ]
[(#VAL|porte_plume_creer_json_markitup)]
;(function($){
// 2 fonctions pour appeler le porte plume reutilisables pour d'autres plugins
// on envoie dedans la selection jquery qui doit etre effectuee
// ce qui evite des appels direct a markitup, aucazou on change de lib un jour
@ -14,6 +20,7 @@ $.fn.barre_outils = function(nom, settings) {
.not('.markItUpEditor, .no_barre')
.markItUp(eval('barre_outils_' + nom), {lang:options.lang});
};
$.fn.barre_previsualisation = function(settings) {
options = {
previewParserPath:"[(#URL_PAGE{porte_plume_preview}|url_absolue)]",
@ -27,7 +34,7 @@ $.fn.barre_previsualisation = function(settings) {
.previsu_spip(options);
};
$(document).ready(function(){
$(window).load(function(){
// ajoute les barres d'outils markitup
function barrebouilles(){
// fonction generique appliquee aux classes CSS :

0
porte_plume.js_fonctions.php → porte_plume_start.js_fonctions.php

3
prive/configurer/porte_plume.html

@ -0,0 +1,3 @@
<div class='ajax'>
#FORMULAIRE_CONFIGURER_PORTE_PLUME
</div>
Loading…
Cancel
Save