Browse Source

Indentation et mise en place d'outils "qualité"

dev_crayons
bricebou 3 weeks ago
parent
commit
cea80eff3d
  1. 3
      .gitattributes
  2. 1
      .gitignore
  3. 68
      css/prism-live-spip.css
  4. 290
      css/prism-spip.css
  5. 24
      js/prism-live-spip.js.html
  6. 2
      js/prism-spip-typo.js
  7. 96
      lib/prism-live-modifie.css
  8. 96
      lib/prism-live.css
  9. 12
      phpcs.xml.dist
  10. 72
      prism_pipelines.php
  11. 2
      prive/squelettes/contenu/configurer_prism.html

3
.gitattributes vendored

@ -1,2 +1,5 @@
.gitattributes export-ignore
.gitignore export-ignore
/phpstan.neon.dist export-ignore
/phpstan-baseline.neon export-ignore

1
.gitignore vendored

@ -0,0 +1 @@
.vscode/

68
css/prism-live-spip.css

@ -3,64 +3,64 @@
.prism-live code.language-spip_typo,
pre.prism-live,
textarea.prism-live {
white-space: pre-wrap !important;
overflow-wrap: break-word;
white-space: pre-wrap !important;
overflow-wrap: break-word;
}
.prism-live textarea.prism-live,
.prism-live pre.prism-live
{
--scrollbar-width: 17px;
margin: 0;
padding: 1em !important;
padding-bottom: var(--scrollbar-width) !important;
padding-right: var(--scrollbar-width) !important;
border: 1px solid var(--spip-form-input-border-color);
border-radius: var(--spip-form-border-radius);
border-top-left-radius: 0;
border-top-right-radius: 0;
--scrollbar-width: 17px;
margin: 0;
padding: 1em !important;
padding-bottom: var(--scrollbar-width) !important;
padding-right: var(--scrollbar-width) !important;
border: 1px solid var(--spip-form-input-border-color);
border-radius: var(--spip-form-border-radius);
border-top-left-radius: 0;
border-top-right-radius: 0;
}
.prism-live pre.prism-live {
height: 100% !important;
width: 100%;
position: absolute;
left: 0;
top: 0;
height: 100% !important;
width: 100%;
position: absolute;
left: 0;
top: 0;
}
.prism-live textarea.prism-live {
position: relative;
padding-bottom: 0!important;
position: relative;
padding-bottom: 0!important;
}
.prism-live .token.cadre {
border: 0;
border: 0;
}
.editer .fullscreen .markItUpHeader {
z-index: 100;
z-index: 100;
}
.editer .fullscreen > .prism-live {
height: 95%;
width: 50%;
position: absolute;
right: 50%;
height: 95%;
width: 50%;
position: absolute;
right: 50%;
}
.editer .fullscreen > .prism-live > textarea,
.editer .fullscreen > .prism-live > pre {
height: 100%;
width: 100%;
position: relative;
left: unset;
right: 0;
border: 1px solid var(--spip-form-input-border-color);
border-radius: var(--spip-form-border-radius);
border-top-left-radius: 0;
border-top-right-radius: 0;
height: 100%;
width: 100%;
position: relative;
left: unset;
right: 0;
border: 1px solid var(--spip-form-input-border-color);
border-radius: var(--spip-form-border-radius);
border-top-left-radius: 0;
border-top-right-radius: 0;
}
.markitup-fullscreen pre.prism-live {
background-color: #fff;
background-color: #fff;
}

290
css/prism-spip.css

@ -1,146 +1,146 @@
/**
* prism.js default theme for JavaScript, CSS and HTML
* Based on dabblet (http://dabblet.com)
* @author Lea Verou
*/
code[class*="language-"],
pre[class*="language-"] {
color: var(--prism-color-texte);
background: none;
/* text-shadow: 0 1px white; */
text-shadow: none;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
font-size: 1em;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
text-shadow: none;
background: var(--prism-color-selection);
}
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
code[class*="language-"]::selection, code[class*="language-"] ::selection {
text-shadow: none;
background: var(--prism-color-selection);
}
@media print {
code[class*="language-"],
pre[class*="language-"] {
text-shadow: none;
}
}
/* Code blocks */
pre[class*="language-"] {
padding: 1em;
/* margin: .5em 0; */
margin: 0;
overflow: auto;
}
/* :not(pre) > code[class*="language-"], */
pre[class*="language-"] {
background: var(--prism-color-fond);
}
/* Inline code */
/* :not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
} */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: var(--prism-color-comment);
}
.token.punctuation {
color: var(--prism-color-ponctuation);
}
.token.namespace {
opacity: .7;
}
.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
color: var(--prism-color-tag);
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
color: var(--prism-color-attribut-nom);
}
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
color: var(--prism-color-url);
/* This background color was intended by the author of this theme. */
/* background: hsla(0, 0%, 100%, .5); */
}
.token.atrule,
.token.attr-value,
.token.keyword {
color: var(--prism-color-attribut-valeur);
}
.token.function,
.token.class-name {
color: var(--prism-color-fonction);
}
.token.regex,
.token.important,
.token.variable {
color: var(--prism-color-variable);
}
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
.token.entity {
cursor: help;
}
.token.spip-titre {
color: var(--prism-color-spip-titre);
}
* prism.js default theme for JavaScript, CSS and HTML
* Based on dabblet (http://dabblet.com)
* @author Lea Verou
*/
code[class*="language-"],
pre[class*="language-"] {
color: var(--prism-color-texte);
background: none;
/* text-shadow: 0 1px white; */
text-shadow: none;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
font-size: 1em;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
text-shadow: none;
background: var(--prism-color-selection);
}
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
code[class*="language-"]::selection, code[class*="language-"] ::selection {
text-shadow: none;
background: var(--prism-color-selection);
}
@media print {
code[class*="language-"],
pre[class*="language-"] {
text-shadow: none;
}
}
/* Code blocks */
pre[class*="language-"] {
padding: 1em;
/* margin: .5em 0; */
margin: 0;
overflow: auto;
}
/* :not(pre) > code[class*="language-"], */
pre[class*="language-"] {
background: var(--prism-color-fond);
}
/* Inline code */
/* :not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
} */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: var(--prism-color-comment);
}
.token.punctuation {
color: var(--prism-color-ponctuation);
}
.token.namespace {
opacity: .7;
}
.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
color: var(--prism-color-tag);
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
color: var(--prism-color-attribut-nom);
}
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
color: var(--prism-color-url);
/* This background color was intended by the author of this theme. */
/* background: hsla(0, 0%, 100%, .5); */
}
.token.atrule,
.token.attr-value,
.token.keyword {
color: var(--prism-color-attribut-valeur);
}
.token.function,
.token.class-name {
color: var(--prism-color-fonction);
}
.token.regex,
.token.important,
.token.variable {
color: var(--prism-color-variable);
}
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
.token.entity {
cursor: help;
}
.token.spip-titre {
color: var(--prism-color-spip-titre);
}

24
js/prism-live-spip.js.html

@ -1,14 +1,14 @@
$(window).on('load', function() {
const start_prism_live_spip = function() {
setTimeout(() => {
Bliss.$(".formulaire_spip .edition textarea:not(.prism-live)").forEach(source => {
if (!Prism.Live.all.get(source)) {
source.classList.add("language-#ENV{grammaire, spip_typo}");
new Prism.Live(source);
}
});
}, 1000);
}
onAjaxLoad(start_prism_live_spip);
start_prism_live_spip();
const start_prism_live_spip = function() {
setTimeout(() => {
Bliss.$(".formulaire_spip .edition textarea:not(.prism-live)").forEach(source => {
if (!Prism.Live.all.get(source)) {
source.classList.add("language-#ENV{grammaire, spip_typo}");
new Prism.Live(source);
}
});
}, 1000);
}
onAjaxLoad(start_prism_live_spip);
start_prism_live_spip();
});

2
js/prism-spip-typo.js

@ -190,4 +190,4 @@
Prism.languages.spip_typo['spip-titre'].inside.rest = Prism.languages.spip_typo;
Prism.languages.spip_typo['bold'].inside.rest = Prism.languages.spip_typo;
Prism.languages.spip_typo['italic'].inside.rest = Prism.languages.spip_typo;
}(Prism));
}(Prism));

96
lib/prism-live-modifie.css

@ -1,66 +1,66 @@
div.prism-live {
position: relative;
box-sizing: border-box;
display: flex;
flex-flow: column;
position: relative;
box-sizing: border-box;
display: flex;
flex-flow: column;
}
textarea.prism-live,
pre.prism-live {
padding: .2rem .5rem;
box-sizing: border-box;
margin: 0;
padding: .2rem .5rem;
box-sizing: border-box;
margin: 0;
}
textarea.prism-live {
position: absolute;
top: 0;
right: 0;
width: 100%;
height: 100%;
z-index: 1;
color: transparent;
/* color: hsla(0,0%,50%,.4); */
cursor: text;
white-space: pre;
/* border: 0; */
outline: none;
background: transparent;
resize: none;
--selection-background: hsl(320, 80%, 25%);
--selection-color: hsla(0, 0%, 100%, .8);
position: absolute;
top: 0;
right: 0;
width: 100%;
height: 100%;
z-index: 1;
color: transparent;
/* color: hsla(0,0%,50%,.4); */
cursor: text;
white-space: pre;
/* border: 0; */
outline: none;
background: transparent;
resize: none;
--selection-background: hsl(320, 80%, 25%);
--selection-color: hsla(0, 0%, 100%, .8);
}
@supports (not (caret-color: black)) and (-webkit-text-fill-color: black) {
textarea.prism-live {
color: inherit;
-webkit-text-fill-color: transparent;
}
textarea.prism-live {
color: inherit;
-webkit-text-fill-color: transparent;
}
}
/* Setting specific colors is needed
* because otherwise Firefox shows blank text */
textarea.prism-live::-moz-selection {
background: var(--selection-background);
color: var(--selection-color);
}
/* Setting specific colors is needed
* because otherwise Firefox shows blank text */
textarea.prism-live::-moz-selection {
background: var(--selection-background);
color: var(--selection-color);
}
textarea.prism-live::selection {
background: var(--selection-background);
color: var(--selection-color);
}
textarea.prism-live::selection {
background: var(--selection-background);
color: var(--selection-color);
}
pre.prism-live {
flex: 1;
position: relative;
pointer-events: none;
overflow: hidden;
max-height: 100%;
--scrollbar-width: 17px;
padding-bottom: var(--scrollbar-width);
padding-right: var(--scrollbar-width);
flex: 1;
position: relative;
pointer-events: none;
overflow: hidden;
max-height: 100%;
--scrollbar-width: 17px;
padding-bottom: var(--scrollbar-width);
padding-right: var(--scrollbar-width);
}
pre.prism-live > code:empty::before {
content: " "
}
pre.prism-live > code:empty::before {
content: " "
}

96
lib/prism-live.css

@ -1,66 +1,66 @@
div.prism-live {
position: relative;
box-sizing: border-box;
display: flex;
flex-flow: column;
position: relative;
box-sizing: border-box;
display: flex;
flex-flow: column;
}
textarea.prism-live,
pre.prism-live {
padding: .2rem .5rem;
box-sizing: border-box;
margin: 0;
padding: .2rem .5rem;
box-sizing: border-box;
margin: 0;
}
textarea.prism-live {
position: absolute;
top: 0;
right: 0;
width: 100%;
height: 100%;
z-index: 1;
color: transparent;
/* color: hsla(0,0%,50%,.4); */
cursor: text;
white-space: pre;
border: 0;
outline: none;
background: transparent;
resize: none;
--selection-background: hsl(320, 80%, 25%);
--selection-color: hsla(0, 0%, 100%, .8);
position: absolute;
top: 0;
right: 0;
width: 100%;
height: 100%;
z-index: 1;
color: transparent;
/* color: hsla(0,0%,50%,.4); */
cursor: text;
white-space: pre;
border: 0;
outline: none;
background: transparent;
resize: none;
--selection-background: hsl(320, 80%, 25%);
--selection-color: hsla(0, 0%, 100%, .8);
}
@supports (not (caret-color: black)) and (-webkit-text-fill-color: black) {
textarea.prism-live {
color: inherit;
-webkit-text-fill-color: transparent;
}
textarea.prism-live {
color: inherit;
-webkit-text-fill-color: transparent;
}
}
/* Setting specific colors is needed
* because otherwise Firefox shows blank text */
textarea.prism-live::-moz-selection {
background: var(--selection-background);
color: var(--selection-color);
}
/* Setting specific colors is needed
* because otherwise Firefox shows blank text */
textarea.prism-live::-moz-selection {
background: var(--selection-background);
color: var(--selection-color);
}
textarea.prism-live::selection {
background: var(--selection-background);
color: var(--selection-color);
}
textarea.prism-live::selection {
background: var(--selection-background);
color: var(--selection-color);
}
pre.prism-live {
flex: 1;
position: relative;
pointer-events: none;
overflow: hidden;
max-height: 100%;
--scrollbar-width: 17px;
padding-bottom: var(--scrollbar-width);
padding-right: var(--scrollbar-width);
flex: 1;
position: relative;
pointer-events: none;
overflow: hidden;
max-height: 100%;
--scrollbar-width: 17px;
padding-bottom: var(--scrollbar-width);
padding-right: var(--scrollbar-width);
}
pre.prism-live > code:empty::before {
content: " "
}
pre.prism-live > code:empty::before {
content: " "
}

12
phpcs.xml.dist

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<ruleset>
<file>./ecrire</file>
<file>./prive</file>
<exclude-pattern>ecrire/lang/*</exclude-pattern>
<exclude-pattern>ecrire/inc/idna_convert.class.php</exclude-pattern>
<rule ref="SPIP41"/>
<config name="ignore_warnings_on_exit" value="1"/>
<arg value="s"/>
</ruleset>

72
prism_pipelines.php

@ -8,42 +8,42 @@ include_spip('inc/config');
include_spip('inc/filtres');
/**
* Inserer des styles et des scripts dans l'espace privé
*
* @param string $flux
*
* @return string
*/
* Inserer des styles et des scripts dans l'espace privé
*
* @param string $flux
*
* @return string
*/
function prism_header_prive($flux) {
// On charge la librairie PrismJS ainsi que le thème par défaut
$flux .= "\n" . '<script type="text/javascript" src="' . _DIR_PLUGIN_PRISM . 'lib/prism.js' . '"></script>';
$flux .= "\n" . '<link rel="stylesheet" href="' . direction_css(_DIR_PLUGIN_PRISM . 'css/prism-spip-variables.css') . '" type="text/css" media="all" />';
$flux .= "\n" . '<link rel="stylesheet" id="prism-theme" href="' . direction_css(_DIR_PLUGIN_PRISM . 'css/prism-spip.css') . '" type="text/css" media="all" />';
// Si plugin Markdown activé et si Markdown comme syntaxe par défaut
$configmd = lire_config('markdown/syntaxe_par_defaut') ?? '';
if (test_plugin_actif('markdown') && $configmd === 'markdown') {
$flux .= "\n" . '<script type="text/javascript" src="' . _DIR_PLUGIN_PRISM . 'lib/prism-markup.js' . '"></script>';
$flux .= "\n" . '<script type="text/javascript" src="' . _DIR_PLUGIN_PRISM . 'lib/prism-markdown-modifie.js' . '"></script>';
$grammaire = 'markdown';
}
else {
// Grammaire SPIP Typo
$flux .= "\n" . '<script type="text/javascript" src="' . _DIR_PLUGIN_PRISM . 'js/prism-spip-typo.js' . '"></script>';
$grammaire = 'spip_typo';
}
// PrismLive précédée de Bliss
$flux .= "\n" . '<script type="text/javascript" src="' . _DIR_PLUGIN_PRISM . 'lib/bliss.shy.min.js' . '"></script>';
$paires = lire_config('prism/paires') ?? [];
$pl = produire_fond_statique('lib/prism-live-modifie.js', ['paires' => $paires]);
$flux .= "\n" . '<script type="text/javascript" src="' . $pl . '"></script>';
$plg = produire_fond_statique('js/prism-live-spip.js', ['grammaire' => $grammaire]);
$flux .= "\n" . '<script type="text/javascript" src="' . $plg . '"></script>';
$flux .= "\n" . '<link rel="stylesheet" href="' . _DIR_PLUGIN_PRISM . 'lib/prism-live-modifie.css' . '" type="text/css" media="all" />';
$flux .= "\n" . '<link rel="stylesheet" href="' . _DIR_PLUGIN_PRISM . 'css/prism-live-spip.css' . '" type="text/css" media="all" />';
return $flux;
// On charge la librairie PrismJS ainsi que le thème par défaut
$flux .= "\n" . '<script type="text/javascript" src="' . _DIR_PLUGIN_PRISM . 'lib/prism.js' . '"></script>';
$flux .= "\n" . '<link rel="stylesheet" href="' . direction_css(_DIR_PLUGIN_PRISM . 'css/prism-spip-variables.css') . '" type="text/css" media="all" />';
$flux .= "\n" . '<link rel="stylesheet" id="prism-theme" href="' . direction_css(_DIR_PLUGIN_PRISM . 'css/prism-spip.css') . '" type="text/css" media="all" />';
// Si plugin Markdown activé et si Markdown comme syntaxe par défaut
$configmd = lire_config('markdown/syntaxe_par_defaut') ?? '';
if (test_plugin_actif('markdown') && $configmd === 'markdown') {
$flux .= "\n" . '<script type="text/javascript" src="' . _DIR_PLUGIN_PRISM . 'lib/prism-markup.js' . '"></script>';
$flux .= "\n" . '<script type="text/javascript" src="' . _DIR_PLUGIN_PRISM . 'lib/prism-markdown-modifie.js' . '"></script>';
$grammaire = 'markdown';
}
else {
// Grammaire SPIP Typo
$flux .= "\n" . '<script type="text/javascript" src="' . _DIR_PLUGIN_PRISM . 'js/prism-spip-typo.js' . '"></script>';
$grammaire = 'spip_typo';
}
// PrismLive précédée de Bliss
$flux .= "\n" . '<script type="text/javascript" src="' . _DIR_PLUGIN_PRISM . 'lib/bliss.shy.min.js' . '"></script>';
$paires = lire_config('prism/paires') ?? [];
$pl = produire_fond_statique('lib/prism-live-modifie.js', ['paires' => $paires]);
$flux .= "\n" . '<script type="text/javascript" src="' . $pl . '"></script>';
$plg = produire_fond_statique('js/prism-live-spip.js', ['grammaire' => $grammaire]);
$flux .= "\n" . '<script type="text/javascript" src="' . $plg . '"></script>';
$flux .= "\n" . '<link rel="stylesheet" href="' . _DIR_PLUGIN_PRISM . 'lib/prism-live-modifie.css' . '" type="text/css" media="all" />';
$flux .= "\n" . '<link rel="stylesheet" href="' . _DIR_PLUGIN_PRISM . 'css/prism-live-spip.css' . '" type="text/css" media="all" />';
return $flux;
}

2
prive/squelettes/contenu/configurer_prism.html

@ -1,5 +1,5 @@
[(#AUTORISER{configurer,prism}|sinon_interdire_acces)]
<h1 class="grostitre"><:prism:configurer:></h1>
<div class="ajax">
#FORMULAIRE_CONFIGURER_PRISM
#FORMULAIRE_CONFIGURER_PRISM
</div>
Loading…
Cancel
Save