This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-fluido-skin.git


The following commit(s) were added to refs/heads/master by this push:
     new ac51aea  Avoid duplicate charset, viewport and generator meta elements
ac51aea is described below

commit ac51aead487672234696fc84814a6150befbd6bd
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Sat Oct 31 17:17:48 2026 +0000

    Avoid duplicate charset, viewport and generator meta elements
    
    A page head can bring its own; the skin's charset stays the only one, the 
page's viewport and generator replace the skin's.
---
 src/it/mskins-323/pom.xml                 | 53 +++++++++++++++++++++++++++++++
 src/it/mskins-323/src/site/site.xml       | 40 +++++++++++++++++++++++
 src/it/mskins-323/src/site/xdoc/index.xml | 34 ++++++++++++++++++++
 src/it/mskins-323/verify.groovy           | 32 +++++++++++++++++++
 src/main/resources/META-INF/maven/site.vm |  9 +++++-
 5 files changed, 167 insertions(+), 1 deletion(-)

diff --git a/src/it/mskins-323/pom.xml b/src/it/mskins-323/pom.xml
new file mode 100644
index 0000000..17eb8ed
--- /dev/null
+++ b/src/it/mskins-323/pom.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.maven.skins</groupId>
+    <artifactId>maven-skins</artifactId>
+    <version>@project.parent.version@</version>
+  </parent>
+
+  <groupId>org.apache.maven.skins.its</groupId>
+  <artifactId>@project.artifactId@-mskins-323</artifactId>
+  <version>@project.version@</version>
+  <packaging>jar</packaging>
+
+  <name>@project.name@ IT, #323</name>
+  <url>https://maven.apache.org/skins/@project.artifactId@/mskins-323/</url>
+
+  <properties>
+    <skinName>@project.name@</skinName>
+    <skinDescription>@project.description@</skinDescription>
+    <skinGroupId>@project.groupId@</skinGroupId>
+    <skinArtifactId>@project.artifactId@</skinArtifactId>
+    <skinVersion>@project.version@</skinVersion>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-site-plugin</artifactId>
+        <version>@sitePluginVersion@</version>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/src/it/mskins-323/src/site/site.xml 
b/src/it/mskins-323/src/site/site.xml
new file mode 100644
index 0000000..dde448f
--- /dev/null
+++ b/src/it/mskins-323/src/site/site.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ -->
+
+<site xmlns="http://maven.apache.org/SITE/2.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/SITE/2.0.0 
https://maven.apache.org/xsd/site-2.0.0.xsd";
+  name="${skinName}">
+
+  <skin>
+    <groupId>${skinGroupId}</groupId>
+    <artifactId>${skinArtifactId}</artifactId>
+    <version>${skinVersion}</version>
+  </skin>
+
+  <body>
+    <breadcrumbs>
+      <item name="Apache Maven Fluido Skin"  
href="https://maven.apache.org/skins/maven-fluido-skin/index.html"; />
+      <item name="Maven Fluido Skin ITs"  
href="https://maven.apache.org/skins/maven-fluido-skin/ITs.html"; />
+    </breadcrumbs>
+  </body>
+</site>
diff --git a/src/it/mskins-323/src/site/xdoc/index.xml 
b/src/it/mskins-323/src/site/xdoc/index.xml
new file mode 100644
index 0000000..feba324
--- /dev/null
+++ b/src/it/mskins-323/src/site/xdoc/index.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<document xmlns="http://maven.apache.org/XDOC/2.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 
https://maven.apache.org/xsd/xdoc-2.0.xsd";>
+  <properties>
+    <title>Page head meta elements</title>
+  </properties>
+  <head>
+    <meta charset="ISO-8859-1" />
+    <meta name="viewport" content="width=device-width, initial-scale=2" />
+    <meta name="generator" content="Hand written" />
+    <meta name="description" content="Meta elements from the page head" />
+  </head>
+  <body>
+    <section name="Page head meta elements">
+      <p>The page head brings its own charset, viewport, generator and 
description meta elements.</p>
+    </section>
+  </body>
+</document>
diff --git a/src/it/mskins-323/verify.groovy b/src/it/mskins-323/verify.groovy
new file mode 100644
index 0000000..3646011
--- /dev/null
+++ b/src/it/mskins-323/verify.groovy
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+String html = new File( basedir, "target/site/index.html" ).text
+def count = { String pattern -> ( html =~ pattern ).size() }
+
+// the skin writes the charset of the output encoding, the page cannot declare 
a second one
+assert count( /<meta charset=/ ) == 1
+assert html.contains( '<meta charset="UTF-8" />' )
+// a viewport or generator from the page replaces the skin's own
+assert count( /<meta name="viewport"/ ) == 1
+assert html.contains( 'content="width=device-width, initial-scale=2"' )
+assert count( /<meta name="generator"/ ) == 1
+assert html.contains( '<meta name="generator" content="Hand written" />' )
+// everything else from the page head is kept
+assert html.contains( '<meta name="description" content="Meta elements from 
the page head" />' )
diff --git a/src/main/resources/META-INF/maven/site.vm 
b/src/main/resources/META-INF/maven/site.vm
index 0b59b21..310aba7 100644
--- a/src/main/resources/META-INF/maven/site.vm
+++ b/src/main/resources/META-INF/maven/site.vm
@@ -32,9 +32,16 @@
 <html xmlns="http://www.w3.org/1999/xhtml"; lang="#if ( $locale.toString() 
)$locale.toLanguageTag()#{else}en#end">
   <head>
     <meta charset="${outputEncoding}" />
+## the page head may not declare a second charset; its viewport and generator 
replace the skin's own
+#**##set( $pageHead = "$!headContent" )
+#**##set( $pageHead = $pageHead.replaceAll( 
'(?i)<meta\s+charset\s*=[^>]*>\s*', '' ) )
+#**##if( !$pageHead.matches( '(?is).*<meta\s[^>]*name\s*=\s*.?viewport\b.*' ) )
     <meta name="viewport" content="width=device-width, initial-scale=1" />
+#**##end
 ## put meta together
+#**##if( !$pageHead.matches( '(?is).*<meta\s[^>]*name\s*=\s*.?generator\b.*' ) 
)
     <meta name="generator" content="#generatedBy()" />
+#**##end
 #foreach( $author in $authors )
     <meta name="author" content="$esc.xml( $author )" />
 #end
@@ -50,7 +57,7 @@
 #**##if( $site.body.head )
 #*  *#$render.eval( $site.body.head )
 #**##end
-#**##if( $headContent )$headContent#end
+#**#$pageHead
 #**##googleAnalytics()
 #**##matomo()
 #**##forkMeOnGitHubHead()

Reply via email to