Aiuto:Poem: differenze tra le versioni

Da Wikisource.
Contenuto cancellato Contenuto aggiunto
Riga 285: Riga 285:


Lo stesso codice, aggiunto a MediaWiki:Common.css, è inefficace (unica cosa che mi viene in mente, provare a spostarlo DOPO la definizione di .testi p)
Lo stesso codice, aggiunto a MediaWiki:Common.css, è inefficace (unica cosa che mi viene in mente, provare a spostarlo DOPO la definizione di .testi p)

Su fr.source trovo nel Common.css:
<pre>/*************** Fin de Infobox V2 ***************/
.poem {
margin-bottom: 0em;
margin-top: 0em;
line-height: 1.6em;
margin-left: 2.5em;
text-indent: 0em;
}
.poem p {
margin-top: 0em ! important;
margin-bottom: 0em ! important;
text-indent: 0em !important;
}</pre>

e su de.source:
<pre>.poem {
margin-bottom: 0em;
margin-top: 0em;
line-height: 1.6em;
margin-left: 2.5em;
}
.poem p {
margin-top: 0em ! important;
margin-bottom: 0em ! important;
}
.poem .zeilennummer {
left:-5.5em;
}
.poem .seitennummer {
left:-0.5em;
}</pre>


== Installation ==
== Installation ==

Versione delle 14:47, 29 gen 2010

Questa traduzione è tratta dalla versione attuale della documentazione di poem su http://www.mediawiki.org

Template Extension:

{{Extension
| name=Poem
| author=[[m:User:Nikola Smolenski|Nikola Smolenski]]
| status=stable
| type=tag
| image=
| version=
| update=
| mediawiki=1.7+
| download={{WikimediaDownload|Poem}}
| readme=
| description=adds <poem> tag for poem formatting
| parameters=
| rights=
| hook1=ParserFirstCallInit
}}

L’estensione Poem permette una facile inclusione di poesie e materiale simile nelle pagine MediaWiki, delimitandole semplicemente fra tag <poem></poem> invece di aggiungere il tag <br> alla fine, o il carattere  : all’inizio di ogni verso, come facciamo adesso. Nonostante sia una piccola estensione, può essere utile, soprattutto sui progetti Wikisource o simili (ci sono poesie con migliaia di versi, e quindi la soluzione tradizionale non è comoda). L’estensione conserva i wikilink, la formattazione ecc. eventualmente presenti nelle strofe, e indenta correttamente i versi che iniziano con spazi bianchi.

Nikola Smolenski ha scritto l’estensione come esercizio per il lavoro sulle estensioni, sviluppando un’idea di Yann Forget[1].

È stata implementata su wikisource e sperimentata nel giugno 2006, e sui siti rimanenti dal febbraio 2007.

Riservato agli smanettoni

In realtà <poem> fa solo tre cose.

  1. apre un <div class="poem">
  2. aggiunge un <br /> alla fine di ogni verso
  3. sostituisce tutti gli spazi all’inizio del verso con uno spazio html "duro", codice &nspb;

Purtroppo è impossibile ottenere questo risultato con un template.

Esempio

Input text Output
<poem>
In [[Wikipedia:Xanadu|Xanadu]] did Kubla Khan
A stately pleasure-dome decree:
Where Alph, the sacred river, ran
Through caverns measureless to man
Down to a sunless sea.

So twice five miles of fertile ground
With walls and towers were girdled round:
And there were gardens bright with sinuous rills,
Where blossomed many an incense-bearing tree;
And here were forests ancient as the hills,
Enfolding sunny spots of greenery.
</poem>

In Xanadu did Kubla Khan
A stately pleasure-dome decree:
Where Alph, the sacred river, ran
Through caverns measureless to man
Down to a sunless sea.

So twice five miles of fertile ground
With walls and towers were girdled round:
And there were gardens bright with sinuous rills,
Where blossomed many an incense-bearing tree;
And here were forests ancient as the hills,
Enfolding sunny spots of greenery.

Nota di alex: e come mai non indenta il primo verso, nemmeno per sogno? Senza lo spazio magico e l’a capo? :-(

In Xanadu did Kubla Khan
A stately pleasure-dome decree:
Where Alph, the sacred river, ran
Through caverns measureless to man
Down to a sunless sea.

So twice five miles of fertile ground
With walls and towers were girdled round:
And there were gardens bright with sinuous rills,
Where blossomed many an incense-bearing tree;
And here were forests ancient as the hills,
Enfolding sunny spots of greenery.

Ecco perchè: l’identico codice lo mettiamo dentro un <div class="testi">...

In Xanadu did Kubla Khan
A stately pleasure-dome decree:
Where Alph, the sacred river, ran
Through caverns measureless to man
Down to a sunless sea.

So twice five miles of fertile ground
With walls and towers were girdled round:
And there were gardens bright with sinuous rills,
Where blossomed many an incense-bearing tree;
And here were forests ancient as the hills,
Enfolding sunny spots of greenery.

.... quindi il problema delle bizzarrie di poem su it.source sta nella classe "testi" con cui Intestazione marchia tutte le opere in ns0.... ;-)


Style

Il testo identificato da poem è incluso in un div, che per default non ha uno un attributo style; ma che eredita qualsiasi style o class passato al tag poem.

Per esempio, mentre il testo senza a capo automatico può essere utilizzato per evitare il ridimensionamento automatico di un riquadro, in alcuni casi il risultato è fastidioso da leggere, perchè le righe lunghe non sono spezzate automaticamente. Un risultato simile, ma in qualche modo migliore può essere utilizzato con il codice

<poem style="border: 1px dashed #2f6fab; background-color: #f9f9f9; padding: 1em;">

Applicato all’esempio precedente, il risultato è il seguente:

In Xanadu did Kubla Khan
A stately pleasure-dome decree:
Where Alph, the sacred river, ran
Through caverns measureless to man
Down to a sunless sea.

So twice five miles of fertile ground
With walls and towers were girdled round:
And there were gardens bright with sinuous rills,
Where blossomed many an incense-bearing tree;
And here were forests ancient as the hills,
Enfolding sunny spots of greenery.

L’opzione "compact"

Nota di Alex: ma prima occorre ritoccare la class "testi", altrimenti c’hai voglia di vederne l’effetto...

Normalmente, il parser restituisce ogni testo delimitato dai tag poem in un paragrafo. Talora questo non è l’effetto desiderato; l’utilizzo dell’opzione compact sopprime le righe bianche automatiche fra paragrafi successivi, permettendo a segmenti continui di poesie senza spazi tra i versi di fondersi insieme.

Input Output Input Output
<poem>
One,
Two.
</poem>
<poem>
Three?
Four!
</poem>

One,
Two.

Three?
Four!

<poem compact>
One,
Two.
</poem>
<poem compact>
Three?
Four!
</poem>
One,
Two.
Three?
Four!

Nota di Alex: quanti improperi perchè questo trucco si rifiutava di funzionare.... vediamo ilmalefico effetto del codice div class=testi" sull'identico codice:

Input Output Input Output
<poem>
One,
Two.
</poem>
<poem>
Three?
Four!
</poem>

One,
Two.

Three?
Four!

<poem compact>
One,
Two.
</poem>
<poem compact>
Three?
Four!
</poem>
One,
Two.
Three?
Four!

Nota di Alex: Sorpresa! Carino!!! Ma TUTTI i poem devono essere marchiati con compact... :-)

Problemi e soluzioni

  • le Variabili e le ParserFunctions funzionano all'interno del testo racchiuso da <poem> ... </poem> ma NON FUNZIONANO all'interno dello stesso tag <poem ... >; questo impedisce la costruzione di templates tipo <poem style="{{{1}}}"> (nota di Alex: ci avevo giusto sbattuto la capa).
  • un modo di aggirare il problema è di utilizzare un div esterno: <div style="{{{1}}}"><poem> ... </poem></div> (nota di Alex: questo l'avevo capito... ;-)).
  • un altro sstema è di utilizzare la magic word #tag : {{#tag:poem| ... |style="{{{1}}}"}}. (nota di Alex: questa mi giunge nuova, ma non mi piace così com'è perche viola la nuova regola dei "template ben conformati": tutto il testo della poesia va "passato come parametro").
    • NB: tuttavia questa opzione non sembra funzionare con l'opzione "compact" (nota di Alex: ... e questo chiude il discorso, compact LO VOGLIO!). .
Input (dentro il testo OK, dentro il tag NO) Output
<poem style="{{{1|border: 1px solid Black;}}}">
One,
{{{2|Two.}}}
</poem>

One,
Two.
Notare che il bordo nero NON è visualizzato:

Input (both inside and within OK) Output
<div style="{{{1|border: 1px solid Black;}}}"><poem>
One,
{{{2|Two.}}}
</poem></div>

One,
Two.

{{#tag:poem|
One,
{{{2|Two.}}}
|style="{{{1|border: 1px solid Black;}}}"
}}

One,
Two.

Note sulle classi testi e poem

La class testi è descritta in common.js:

.testi {
  width: 33em;
  text-align:justify;
  margin:0px auto;
  font-family: Georgia, Times New Roman, Times, serif;
}
.testi p { text-indent: 2em
}

e il problema sta in .testi p.


La class poem è introvabile e potrebbe essere vuota.

Test: aggiunto a monobook.css il codice:

/* tentativo di "uccisione" di .testi p */
.poem p {text-indent: 0em
}


Lo stesso codice, aggiunto a MediaWiki:Common.css, è inefficace (unica cosa che mi viene in mente, provare a spostarlo DOPO la definizione di .testi p)

Su fr.source trovo nel Common.css:

/*************** Fin de Infobox V2 ***************/
 
 
.poem { 
	margin-bottom: 0em; 
	margin-top: 0em; 
	line-height: 1.6em;
	margin-left: 2.5em;
	text-indent: 0em;
}
.poem p { 
	margin-top: 0em ! important; 
	margin-bottom: 0em ! important; 
	text-indent: 0em !important;
}

e su de.source:

.poem { 
 		margin-bottom: 0em; 
 		margin-top: 0em; 
 		line-height: 1.6em;
 		margin-left: 2.5em;
 	}
 	.poem p { 
 		margin-top: 0em ! important; 
 		margin-bottom: 0em ! important; 
 	}
 	.poem .zeilennummer { 
 		left:-5.5em; 
 	}
 
 	.poem .seitennummer {
 	        left:-0.5em; 
 	}

Installation

Download the source files into your extensions/ directory, then add the following to your LocalSettings.php:

require_once($IP./extensions/Poem/Poem.php’);