## Thème
Sont notées ici les modifications apportées au thème de ce DokuWiki.
J'ai une bonne maîtrise du **CSS**, mais le thème a été développé intégralement avec l'aide de **claude.ai** qui m'a fait gagner un temps énorme dans l'identification des **Classe** et des **ID**.
**Ci-dessous, on trouve :**
- Les fonctions apportées sans plugin :
- Ajout de cinq modèles de citations (inspirée de Typora, l'éditeur de Markdown).
- Choix de l'ombrage, ou pas, des images.
- Centrage de la ligne de navigation en bas et en haut des articles (chapitres) d'un même sujet.
- Les fichiers de personnalisation du thème :
- config/dokuwiki/conf/userscript.js
- config/dokuwiki/conf/userstyle.css
### 1. Extension des citations :
> Citation :
Cinq éléments ont été ajoutés : Note, Astuce, Important, Attention et Avertissement
Pour ce faire, cinq classes ont été ajoutées via le fichier **userscript.js**. Ces classes sont décorées dans le fichier **userstyle.css**.
Il suffit de saisir ''>Note'' ou ''>Astuce'' ou ''>Important'' ... en début de ligne (en Markdown). Le fichier CSS reconnait ces cinq mots (avec ou sans majuscule) et adapte le style.
**Apparence :**
>Note :
>Astuce :
>Important :
>Avertissement :
>Attention :
### 2. Ombrage des images
Les images sont ombrées par défaut. Pour supprimer l'ombrage, il suffit de renommer l'image en ajoutant **-sansfx** au nom. Cette fonction est traitée dans le fichier **userstyle.css**.
#### Exemple :
* Image avec ombrage : **geek.png**
{{ :theme:geek.png?300 |}}
* La même image avec une modification du nom : **geek-sansfx.png**
{{ :theme:geek-sansfx.png?300 |}}
### 3. Fichier userscript.js
Fichier **config/dokuwiki/conf/userscript.js**
```javascript
/* Citations : ajoute une classe selon le premier mot */
jQuery(function () {
jQuery('blockquote').each(function () {
var texte = jQuery(this).text().trim().toLowerCase();
if (texte.indexOf('note') === 0) {
jQuery(this).addClass('quote-note');
} else if (texte.indexOf('astuce') === 0) {
jQuery(this).addClass('quote-astuce');
} else if (texte.indexOf('important') === 0) {
jQuery(this).addClass('quote-important');
} else if (texte.indexOf('avertissement') === 0) {
jQuery(this).addClass('quote-avertissement');
} else if (texte.indexOf('attention') === 0) {
jQuery(this).addClass('quote-attention');
}
});
});
/* Navigation entre chapitres */
jQuery(function () {
jQuery('#dokuwiki__content p').each(function () {
var p = jQuery(this);
if (p.text().trim().length < 200 && /<<|>>/.test(p.text())) {
p.addClass('nav-center');
// Anciennes lignes de points de remplissage : on les supprime
p.contents().filter(function () { return this.nodeType === 3; })
.each(function () {
this.nodeValue = this.nodeValue.replace(/\.{5,}/g, '');
});
// Un seul côté présent : on ajoute l'autre moitié en texte invisible
var t = p.text();
var aPrecedent = /<>/.test(t);
if (aPrecedent && !aSuivant) {
p.append(jQuery('')
.text(' - Chapitre suivant >>'));
} else if (aSuivant && !aPrecedent) {
p.prepend(jQuery('')
.text('<< Chapitre précédent - '));
}
}
});
// Fin du traitement : on affiche la page
jQuery('#dokuwiki__content div.page').addClass('nav-pret');
});
```
### 4. Fichier userstyle.css
Fichier **config/dokuwiki/conf/userstyle.css**
```css
/* ===== Arrière-plan ===== */
/* Fond de la page : une seule image, sur body */
html {
background-color: #E2EAEE;
}
body {
background-color: #E2EAEE;
background-image: url("/lib/exe/fetch.php?media=background.jpeg");
background-size: cover; /* l'image remplit toute la fenêtre */
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed; /* l'image ne défile pas avec la page */
}
/* Les conteneurs du wiki laissent voir le fond de body
et n'affichent ni dégradé ni image */
#dokuwiki__site,
#dokuwiki__top,
#dokuwiki__header,
#dokuwiki__header .group {
background-image: none;
background-color: transparent;
}
/* ===== Polices (contenu des pages) ===== *
#dokuwiki__content h1,
#dokuwiki__content h2,
#dokuwiki__content h3 {
color: #4D87AF;
font-family: Arial, Helvetica, sans-serif;
}
/*h1, h2 {text-transform: uppercase;}*/
#dokuwiki__content h1 {
font-size: 1.9rem;
color: #2E537B;
}
#dokuwiki__content h2 {
font-size: 1.7rem;
color: #2E537B;
}
#dokuwiki__content h3 {
font-size: 1.5rem;
font-weight: 600;
color: #2E537B;
}
#dokuwiki__content h4 {
font-size: 1.3rem;
font-weight: 600;
}
#dokuwiki__content h5 {
font-size: 1.1rem;
font-weight: 600;
color: #CE7A33;
}
#dokuwiki__content p {
color: black;
text-align: justify;
}
/* ===== Puces et numéros des listes (contenu des pages) ===== */
#dokuwiki__content ul li,
#dokuwiki__content ol li,
#dokuwiki__content ul li *:not(a):not(pre):not(code),
#dokuwiki__content ol li *:not(a):not(pre):not(code) {
color: black;
text-align: justify;
}
/* Puces et numéros */
#dokuwiki__content ul li::marker,
#dokuwiki__content ol li::marker {
color: black;
font-weight: bold;
text-align: justify;
}
/* ===== Augmentation de la taille des polices (sauf smartphone) ===== */
@media (min-width: 769px) {
/* Uniquement le contenu des pages à 120 % */
#dokuwiki__content div.page {
font-size: 120%;
}
/* La table des matières garde sa taille d'origine */
#dokuwiki__content #dw__toc {
font-size: 83.33%;
}
}
/* ===== Tableaux ===== */
.mode_show #dokuwiki__content div.page table{
display: table; /* Le bloc épouse la largeur de son contenu */
margin: 0 auto; /* Centrage horizontal */
max-width: 100%;
}
/* ===== Images ===== */
/* Le conteneur se réduit à la taille de l'image et se centre dans la page */
/* Images : uniquement à la lecture des articles */
.mode_show #dokuwiki__content div.page .media {
display: table; /* Le bloc épouse la largeur de son contenu */
margin: 0 auto; /* Centrage horizontal */
max-width: 100%;
}
/* L'ombre et les effets sont appliqués directement sur l'image */
.mode_show #dokuwiki__content div.page .media img {
display: block;
box-shadow: 0px 0px 15px -1px rgba(20, 30, 60, 0.71);
transition: transform 0.3s, box-shadow 0.3s;
}
/* Effet au survol */
.mode_show #dokuwiki__content div.page .media img:hover {
transform: translateY(-3px);
box-shadow: 0px 5px 20px -1px rgba(20, 30, 60, 0.9);
}
/* Images "sans effet" : on annule ombre et survol */
/* Toutes les images qui contiennent "sanfx" dans leur nom */
.mode_show #dokuwiki__content div.page .media img[src*="sansfx"],
.mode_show #dokuwiki__content div.page .media img[src*="sansfx"]:hover {
box-shadow: none;
transform: none;
transition: none;
}
/* ===== Liens ===== */
/* Liens */
a {
color: #FA9A2A;
text-decoration: none;
}
/* visited link */
a:visited {
color: #B07448;
}
/* mouse over link */
a:hover {
color: #B07448;
}
/* selected link */
a:active {
color: #FA9A2A;
}
/* ===== liens vers des pages internes ===== */
/* existing wikipage */
.dokuwiki a.wikilink1 {
color: #B07448;
}
/* not existing wikipage */
.dokuwiki a.wikilink2 {
text-decoration: none;
color: #B07448;
}
.dokuwiki a.wikilink2:link,
.dokuwiki a.wikilink2:visited {
border-bottom: 1px dashed;
color: #B07448;
}
.dokuwiki a.wikilink2:hover,
.dokuwiki a.wikilink2:active,
.dokuwiki a.wikilink2:focus {
border-bottom-width: 0;
color: #B07448;
}
/* any link to current page */
.dokuwiki span.curid a {
font-weight: bold;
color: #B07448;
}
/* ===== Blocs de code : fond et cadre ===== */
.dokuwiki pre,
.dokuwiki pre.code,
.dokuwiki pre.file {
background: #f6f8fa;
color: #24292e;
border: 1px solid #347099;
border-left: 6px solid #89b4fa;
border-radius: 6px;
padding: 0.8em 1em;
font-family: "Fira Code", "Consolas", "DejaVu Sans Mono", monospace;
font-size: 0.9em;
line-height: 1.5;
}
/* Les blocs se distinguent par une autre couleur de bordure */
.dokuwiki pre.file {
border-left-color: #a6e3a1;
}
/* Code en ligne (''texte'' ou court) */
.dokuwiki code {
background: #f6f8fa;
color: #24292e;
padding: 0.1em 0.4em;
border: 1px solid #347099;
border-radius: 4px;
}
.dokuwiki pre code {
background: none;
color: inherit;
padding: 0;
}
/* ===== Coloration syntaxique (GeSHi) ===== */
.dokuwiki pre .kw1,
.dokuwiki pre .kw2,
.dokuwiki pre .kw3,
.dokuwiki pre .kw4 { color: #8F60C7; font-weight: bold; } /* mots-clés */
.dokuwiki pre .co1,
.dokuwiki pre .co2,
.dokuwiki pre .coMULTI { color: #6c7086; font-style: italic; } /* commentaires */
.dokuwiki pre .st0,
.dokuwiki pre .st_h { color: #2DB823; } /* chaînes */
.dokuwiki pre .nu0 { color: #DF7B3D; } /* nombres */
.dokuwiki pre .me1,
.dokuwiki pre .me0 { color: #4677C6; } /* méthodes */
.dokuwiki pre .re0,
.dokuwiki pre .re1 { color: #EC5A82; } /* variables */
.dokuwiki pre .br0,
.dokuwiki pre .sy0 { color: #38CCB4; } /* symboles, parenthèses */
.dokuwiki pre .es0 { color: #CFB06C; } /* caractères échappés */
/* Défilement horizontal pour les longues lignes */
.dokuwiki pre { overflow-x: auto; }
/* ===== Citations ===== */
/* Citations en gris */
#dokuwiki__content blockquote,
#dokuwiki__content blockquote *:not(a):not(pre):not(code) {
color: #4D4D4D;
}
/* Supprime la marge basse du dernier élément dans la citation */
#dokuwiki__content blockquote > :last-child,
#dokuwiki__content blockquote p:last-child,
#dokuwiki__content blockquote div.no:last-child {
margin-bottom: 0;
}
/* Trait vertical à gauche, assorti */
#dokuwiki__content blockquote {
background-color: #E6E6FA;
border: 1px solid #7F7F7F;
border-left: 4px solid #7F7F7F;
border-radius: 4px;
padding: .6em 1em;
}
/* ===== Citations particulières ===== */
/* Déclarées dans : conf/userscript.js */
/* Citation « Note » : Bleu */
#dokuwiki__content blockquote.quote-note,
#dokuwiki__content blockquote.quote-note *:not(a):not(pre):not(code) {
color: #0550ae;
}
#dokuwiki__content blockquote.quote-note {
background-color: rgba(9, 105, 218, 0.08);
border-color: #0969da;
}
/* Citation « Astuce » : Vert */
#dokuwiki__content blockquote.quote-astuce,
#dokuwiki__content blockquote.quote-astuce *:not(a):not(pre):not(code) {
color: #116329;
}
#dokuwiki__content blockquote.quote-astuce {
background-color: rgba(31, 136, 61, 0.08);
border-color: #1f883d;
}
/* Citation « Important » : Violet */
#dokuwiki__content blockquote.quote-important,
#dokuwiki__content blockquote.quote-important *:not(a):not(pre):not(code) {
color: #6f42c1;
}
#dokuwiki__content blockquote.quote-important {
background-color: rgba(130, 80, 223, 0.08);
border-color: #8250df;
}
/* Citation « Avertissement » : Marron */
#dokuwiki__content blockquote.quote-avertissement,
#dokuwiki__content blockquote.quote-avertissement *:not(a):not(pre):not(code) {
color: #7d4e00;
}
#dokuwiki__content blockquote.quote-avertissement {
background-color: rgba(154, 103, 0, 0.08);
border-color: #9a6700;
}
/* Citation « Attention» : Rouge */
#dokuwiki__content blockquote.quote-attention,
#dokuwiki__content blockquote.quote-attention *:not(a):not(pre):not(code) {
color: #a40e26;
}
#dokuwiki__content blockquote.quote-attention {
background-color: rgba(207, 34, 46, 0.08);
border-color: #cf222e;
}
/* ===== Navigation entre chapitres ===== */
/* Classes créées dans userscript.js en détectant << ou >> */
#dokuwiki__content p.nav-center {
text-align: center;
margin: 1em 0 2em;
}
/* Tiret, texte et liens : même couleur, quel que soit l'élément */
#dokuwiki__content p.nav-center,
#dokuwiki__content p.nav-center *,
#dokuwiki__content p.nav-center a,
#dokuwiki__content p.nav-center a:visited,
#dokuwiki__content p.nav-center a:hover {
color: #B07448 !important;
}
/* Moitié manquante de la navigation : invisible, mais prend la place */
#dokuwiki__content p.nav-center span.nav-ghost {
visibility: hidden;
user-select: none;
}
/* Évite l'affichage intermédiaire : la page apparaît quand le script a fini,
ou après 1 seconde au maximum si le script ne s'exécute pas */
/* Cache seulement les paragraphes avec lien tant que le script n'a pas fini
(sécurité : ils réapparaissent après 1 seconde au maximum) */
.mode_show #dokuwiki__content div.page:not(.nav-pret) p:has(a) {
opacity: 0;
animation: page-reveal 0.1s ease 1s forwards;
}
/* Apparition en douceur une fois le script terminé */
.mode_show #dokuwiki__content div.page p {
transition: opacity 0.1s ease;
}
@keyframes page-reveal {
to { opacity: 1; }
}
@keyframes page-reveal {
to { opacity: 1; }
}
```