# HG changeset patch
# User František Kučera <franta-hg@frantovo.cz>
# Date 1318801264 -7200
# Node ID 668014315a54eafbfdc70c65cc3ee2c8bf775eb0
# Parent  21f41354135721e7aa001fcaddb9fec14eae2908
Drupal: odstavce – volitelná css třída a zbavení se zytečného xmlns

diff -r 21f413541357 -r 668014315a54 helpers/mimeXhtmlPart-make-paragraphs.xsl
--- a/helpers/mimeXhtmlPart-make-paragraphs.xsl	Sun Oct 16 22:36:46 2011 +0200
+++ b/helpers/mimeXhtmlPart-make-paragraphs.xsl	Sun Oct 16 23:41:04 2011 +0200
@@ -7,22 +7,14 @@
 	xmlns:svg="http://www.w3.org/2000/svg"
 	xmlns:xs="http://www.w3.org/2001/XMLSchema"
 	xmlns:o="https://trac.frantovo.cz/odstavcovac-TODO-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-/wiki/xmlns/odstavcovac"
-	exclude-result-prefixes="fn h xs">
+	exclude-result-prefixes="fn h xs o">
 	<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
 	
+	<xsl:param name="cssTřída"/>
 	
 	<!-- Celý dokument -->
 	<xsl:template match="/">
 		<html>
-			<head>
-				<style type="text/css">
-					.mešuge {
-						background-color: #afa;
-						border: 1px solid #55f;
-					}
-				</style>
-			</head>
-
 			<body>
 			
 				<xsl:variable name="prvníKolo">
@@ -38,6 +30,15 @@
 			</body>
 		</html>
 	</xsl:template>
+	
+	
+	<!-- Kopírujeme elementy, ale vynecháme nepoužité xmlns deklarace: -->
+	<xsl:template match="*" mode="kopíruj">
+		<xsl:element name="{name()}">
+			<xsl:copy-of select="@*"/>
+			<xsl:apply-templates/>
+		</xsl:element>
+    </xsl:template>
     
     
     <!-- Mezi odstavci je prázdný řádek, můžou být mezery/tabulátory. -->
@@ -157,7 +158,7 @@
 					<xsl:copy-of select="."/>
 				</xsl:element>
 			</xsl:when>
-			<xsl:otherwise>
+			<xsl:otherwise>				
 				<xsl:copy-of select="."/>
 			</xsl:otherwise>		
 		</xsl:choose>
@@ -214,9 +215,12 @@
 	</xsl:template>
 	<!-- Převedeme z <o:odstavec/> na <p/> -->
 	<xsl:template match="o:odstavec" mode="třetíKolo">
-		<p class="mešuge">
-			<xsl:copy-of select="child::node()"/>
-		</p>
+		<xsl:element name="p">
+			<xsl:if test="$cssTřída">
+				<xsl:attribute name="class"><xsl:value-of select="$cssTřída"/></xsl:attribute>
+			</xsl:if>
+			<xsl:apply-templates select="child::node()" mode="kopíruj"/>
+		</xsl:element>
 	</xsl:template>
 	<!-- Všechno ostatní zkopírujeme, jak je. -->
 	<xsl:template match="*" mode="třetíKolo">
diff -r 21f413541357 -r 668014315a54 helpers/mimeXhtmlPart.xsl
--- a/helpers/mimeXhtmlPart.xsl	Sun Oct 16 22:36:46 2011 +0200
+++ b/helpers/mimeXhtmlPart.xsl	Sun Oct 16 23:41:04 2011 +0200
@@ -16,6 +16,7 @@
 	
 		
 	<xsl:param name="title"/>
+	<xsl:param name="headComment"/>
 	<xsl:param name="isRoot"/>
 	<xsl:param name="urlBase"/>
 	<xsl:param name="wwwRead"/>
@@ -27,13 +28,15 @@
 		<html>
 			<head>
 				<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
-				<meta http-equiv="X-NNTP-Generated" content="{fn:current-dateTime()}" />
 				<xsl:if test="$urlBase">
 					<base href="{$urlBase}"/>
 				</xsl:if>
 				<xsl:if test="$title">
 					<title><xsl:value-of select="$title"/></title>
 				</xsl:if>
+				<xsl:if test="$headComment">
+					<xsl:comment><xsl:value-of select="$headComment"/></xsl:comment>
+				</xsl:if>
 				<style type="text/css">
 					body {
 						font-family: sans-serif;
@@ -68,21 +71,14 @@
 					a img {
 						border: none;
 					}
-					
-					/** TODO: smazat */
-					.mešuge {
-						background-color: #afa;
-						border: 1px solid #55f;
-					}
 				</style>
 			</head>
 			<body>
 				<xsl:if test="$title and $isRoot">
 					<h1><xsl:value-of select="$title"/></h1>			
 				</xsl:if>
-				<xsl:call-template name="zpracujTělo">
-					<xsl:with-param name="prvek" select="h:html/h:body/node()[1]"/>
-				</xsl:call-template>
+								
+				<xsl:apply-templates select="h:html/h:body"/>
 				
 				<xsl:if test="$wwwRead or $wwwPost">
 					<div class="wwwLinks">
@@ -140,153 +136,13 @@
 				name() = 'code' or
 				name() = 'blockquote'">
 				<xsl:element name="{name()}">
-					<xsl:apply-templates/>
+					<xsl:copy-of select="."/>
 				</xsl:element>
 			</xsl:when>
 			<xsl:otherwise>
-				<xsl:value-of select="."/>
+				<xsl:apply-templates/>
 			</xsl:otherwise>
 		</xsl:choose>		
     </xsl:template>
-    
-    <!-- 
-    	Z neuzavřeného (nevalidně se vyskytujícího v body) textu uděláme odstavce.
-    -->
-	<xsl:template name="zpracujTělo">
-		<xsl:param name="prvek"/>
-		<xsl:param name="vnořeno" select="false()"/>
-		<xsl:if test="$prvek">
-			<xsl:choose>
-				<xsl:when test="$prvek/self::text()">
-					<!--
-						Textový uzel → budeme dělat odstavce
-						(rekurzivně se opět zavolá šablona zpracujTělo)
-					-->
-					<xsl:call-template name="dělejOdstavce">
-						<xsl:with-param name="blokTextu" select="$prvek"/>
-						<xsl:with-param name="vnořeno" select="$vnořeno"/>
-					</xsl:call-template>
-					
-					<!-- 
-					<xsl:variable name="navázat" as="xs:boolean">
-						<xsl:call-template name="navázat">
-							<xsl:with-param name="blokTextu" select="$prvek"/>
-						</xsl:call-template>
-					</xsl:variable>
-					
-					Někdy zpracujTělo dalšího prvku 
-					<xsl:if test="not($navázat)">[další:]
-						<xsl:call-template name="zpracujTělo">
-							<xsl:with-param name="prvek" select="$prvek/following-sibling::node()[1]"/>
-							<xsl:with-param name="vnořeno" select="$vnořeno"/>
-						</xsl:call-template>
-					</xsl:if>
-					-->
-					
-				</xsl:when>
-				<xsl:otherwise>
-					<!--
-						Jiný uzel → aplikujeme obecné šablony
-						a zpracujeme následující uzel.
-					-->
-					<xsl:apply-templates select="$prvek"/>
-					<xsl:call-template name="zpracujTělo">
-						<xsl:with-param name="prvek" select="$prvek/following-sibling::node()[1]"/>
-						<xsl:with-param name="vnořeno" select="$vnořeno"/>
-					</xsl:call-template>
-				</xsl:otherwise>					
-			</xsl:choose>				
-		</xsl:if>
-	</xsl:template>
-	
-	<xsl:variable name="oddělovač" select="'\n\s*\n\s*'"/>
-	
-	<xsl:template name="navázat" as="xs:boolean">
-		<xsl:param name="blokTextu"/>
-		<xsl:variable name="dalšíUzel" select="$blokTextu/following-sibling::node()[1]"/>
-		<xsl:sequence select="
-			not(fn:matches($blokTextu, concat('.*', $oddělovač ,'$'))) and
-			$dalšíUzel and
-			not(
-				$dalšíUzel/name() = 'p' or
-				$dalšíUzel/name() = 'div' or								
-				$dalšíUzel/name() = 'h1' or								
-				$dalšíUzel/name() = 'h2' or								
-				$dalšíUzel/name() = 'h3' or								
-				$dalšíUzel/name() = 'h4' or								
-				$dalšíUzel/name() = 'h5' or								
-				$dalšíUzel/name() = 'h6' or								
-				$dalšíUzel/name() = 'pre' or								
-				$dalšíUzel/name() = 'table' or								
-				$dalšíUzel/name() = 'blockquote' or								
-				$dalšíUzel/name() = 'hr'								
-			)
-		"/>
-	</xsl:template>
-	
-	<xsl:template name="dělejOdstavce">
-		<xsl:param name="blokTextu"/>
-		<xsl:param name="vnořeno" select="false()"/>
-		
-		<xsl:variable name="dalšíUzel" select="$blokTextu/following-sibling::node()[1]"/>
-		
-		<xsl:variable name="navázat" as="xs:boolean">
-			<xsl:call-template name="navázat">
-				<xsl:with-param name="blokTextu" select="$blokTextu"/>
-			</xsl:call-template>
-		</xsl:variable>
-		
-		<xsl:for-each select="fn:tokenize($blokTextu, $oddělovač)">
-			<!-- TODO: ošetřit prázdné odstavce -->
-			<xsl:if test="normalize-space(.) or true()">
-				<xsl:choose>
-					<xsl:when test="$vnořeno">
-						[
-							<xsl:value-of select="."/>
-							<xsl:if test="$navázat and position() = last()">
-								→
-								<xsl:call-template name="zpracujTělo">
-									<xsl:with-param name="prvek" select="$dalšíUzel"/>
-									<xsl:with-param name="vnořeno" select="true()"/>
-								</xsl:call-template>
-							</xsl:if>
-						]
-						[Avril:]
-						<xsl:if test="not($navázat) and position() = last()">
-							a→
-								<xsl:call-template name="zpracujTělo">
-									<xsl:with-param name="prvek" select="$dalšíUzel"/>
-									<xsl:with-param name="vnořeno" select="true()"/>
-								</xsl:call-template>
-						</xsl:if>
-					</xsl:when>
-					<xsl:otherwise>
-						<p class="mešuge">
-						{
-							<xsl:value-of select="."/>
-							<xsl:if test="$navázat and position() = last()">
-								s→
-								<xsl:call-template name="zpracujTělo">
-									<xsl:with-param name="prvek" select="$dalšíUzel"/>
-									<xsl:with-param name="vnořeno" select="true()"/>
-								</xsl:call-template>
-							</xsl:if>
-						}
-						</p>
-						[sk8:]
-						<xsl:if test="not($navázat) and position() = last()">
-							→
-								<xsl:call-template name="zpracujTělo">
-									<xsl:with-param name="prvek" select="$dalšíUzel"/>
-									<xsl:with-param name="vnořeno" select="false()"/>
-								</xsl:call-template>
-						</xsl:if>
-					</xsl:otherwise>
-				</xsl:choose>
-			</xsl:if>
-		</xsl:for-each>
-		
-	</xsl:template>
-    
 	
 </xsl:stylesheet>