You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2023/04/09 16:17:50 UTC
[maven-fluido-skin] 01/01: [MSKINS-226] Add custom option to enable/disable AnchorJS along with options
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch MSKINS-226
in repository https://gitbox.apache.org/repos/asf/maven-fluido-skin.git
commit 27fab641291c8cca18e8effc6472375bbf585d74
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sun Apr 9 18:16:34 2023 +0200
[MSKINS-226] Add custom option to enable/disable AnchorJS along with options
This closes #51
---
src/it/mskins-226-anchorjs-no-options/pom.xml | 57 ++++++++++++++++++++++
.../src/site/apt/index.apt.vm | 36 ++++++++++++++
.../src/site/site.xml | 50 +++++++++++++++++++
.../mskins-226-anchorjs-no-options/verify.groovy | 23 +++++++++
src/it/mskins-226-anchorjs-options/pom.xml | 57 ++++++++++++++++++++++
.../src/site/apt/index.apt.vm | 36 ++++++++++++++
.../mskins-226-anchorjs-options/src/site/site.xml | 56 +++++++++++++++++++++
src/it/mskins-226-anchorjs-options/verify.groovy | 24 +++++++++
src/main/resources/META-INF/maven/site-macros.vm | 21 +++++---
src/main/resources/META-INF/maven/site.vm | 2 +-
src/site/apt/index.apt.vm | 36 ++++++++++++++
11 files changed, 390 insertions(+), 8 deletions(-)
diff --git a/src/it/mskins-226-anchorjs-no-options/pom.xml b/src/it/mskins-226-anchorjs-no-options/pom.xml
new file mode 100644
index 0000000..6e71e98
--- /dev/null
+++ b/src/it/mskins-226-anchorjs-no-options/pom.xml
@@ -0,0 +1,57 @@
+<?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>
+
+ <groupId>org.apache.maven.skins.its</groupId>
+ <artifactId>mskins-226_anchorjs-no-options</artifactId>
+ <version>@project.version@</version>
+
+ <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>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>@projectInfoReportsPluginVersion@</version>
+ <configuration>
+ <dependencyDetailsEnabled>false</dependencyDetailsEnabled>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
+</project>
diff --git a/src/it/mskins-226-anchorjs-no-options/src/site/apt/index.apt.vm b/src/it/mskins-226-anchorjs-no-options/src/site/apt/index.apt.vm
new file mode 100644
index 0000000..ee74913
--- /dev/null
+++ b/src/it/mskins-226-anchorjs-no-options/src/site/apt/index.apt.vm
@@ -0,0 +1,36 @@
+ ------
+ ${project.name}
+ ------
+ Jens Reimann
+ ------
+ 2018-03-23
+ ------
+
+~~ 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.
+
+~~ NOTE: For help with the syntax of this file, see:
+~~ http://maven.apache.org/doxia/references/apt-format.html
+
+${project.name}
+
+ This is a test for ${skinName} with no (default) AnchorJS options.
+ ${skinDescription}
+
+* Actual configuration
+
+%{snippet|id=skin-anchorjs|file=${project.basedir}/src/site/site.xml}
diff --git a/src/it/mskins-226-anchorjs-no-options/src/site/site.xml b/src/it/mskins-226-anchorjs-no-options/src/site/site.xml
new file mode 100644
index 0000000..9d23020
--- /dev/null
+++ b/src/it/mskins-226-anchorjs-no-options/src/site/site.xml
@@ -0,0 +1,50 @@
+<?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/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd"
+ name="${skinName}">
+
+ <skin>
+ <groupId>${skinGroupId}</groupId>
+ <artifactId>${skinArtifactId}</artifactId>
+ <version>${skinVersion}</version>
+ </skin>
+
+ <!-- START SNIPPET: skin-anchorjs -->
+ <custom>
+ <fluidoSkin>
+ <anchorJs />
+ </fluidoSkin>
+ </custom>
+ <!-- END SNIPPET: skin-anchorjs -->
+
+ <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>
+ <head/>
+ </body>
+
+</project>
diff --git a/src/it/mskins-226-anchorjs-no-options/verify.groovy b/src/it/mskins-226-anchorjs-no-options/verify.groovy
new file mode 100644
index 0000000..e87484c
--- /dev/null
+++ b/src/it/mskins-226-anchorjs-no-options/verify.groovy
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+File index = new File( basedir, "target/site/index.html" )
+assert index.exists()
+assert index.text.contains( 'anchors.add()')
+assert !index.text.contains( 'anchors.options.')
diff --git a/src/it/mskins-226-anchorjs-options/pom.xml b/src/it/mskins-226-anchorjs-options/pom.xml
new file mode 100644
index 0000000..afabf03
--- /dev/null
+++ b/src/it/mskins-226-anchorjs-options/pom.xml
@@ -0,0 +1,57 @@
+<?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>
+
+ <groupId>org.apache.maven.skins.its</groupId>
+ <artifactId>mskins-226_anchorjs-options</artifactId>
+ <version>@project.version@</version>
+
+ <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>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>@projectInfoReportsPluginVersion@</version>
+ <configuration>
+ <dependencyDetailsEnabled>false</dependencyDetailsEnabled>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
+</project>
diff --git a/src/it/mskins-226-anchorjs-options/src/site/apt/index.apt.vm b/src/it/mskins-226-anchorjs-options/src/site/apt/index.apt.vm
new file mode 100644
index 0000000..4c515ff
--- /dev/null
+++ b/src/it/mskins-226-anchorjs-options/src/site/apt/index.apt.vm
@@ -0,0 +1,36 @@
+ ------
+ ${project.name}
+ ------
+ Jens Reimann
+ ------
+ 2018-03-23
+ ------
+
+~~ 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.
+
+~~ NOTE: For help with the syntax of this file, see:
+~~ http://maven.apache.org/doxia/references/apt-format.html
+
+${project.name}
+
+ This is a test for ${skinName} with custom AnchorJS options.
+ ${skinDescription}
+
+* Actual configuration
+
+%{snippet|id=skin-anchorjs|file=${project.basedir}/src/site/site.xml}
diff --git a/src/it/mskins-226-anchorjs-options/src/site/site.xml b/src/it/mskins-226-anchorjs-options/src/site/site.xml
new file mode 100644
index 0000000..f50b607
--- /dev/null
+++ b/src/it/mskins-226-anchorjs-options/src/site/site.xml
@@ -0,0 +1,56 @@
+<?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/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd"
+ name="${skinName}">
+
+ <skin>
+ <groupId>${skinGroupId}</groupId>
+ <artifactId>${skinArtifactId}</artifactId>
+ <version>${skinVersion}</version>
+ </skin>
+
+ <!-- START SNIPPET: skin-anchorjs -->
+ <custom>
+ <fluidoSkin>
+ <anchorJs>
+ <cssSelector>h1, h2, h3, h4, h5</cssSelector>
+ <options>
+ <class>.anchor</class>
+ <titleText>foo</titleText>
+ </options>
+ </anchorJs>
+ </fluidoSkin>
+ </custom>
+ <!-- END SNIPPET: skin-anchorjs -->
+
+ <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>
+ <head/>
+ </body>
+
+</project>
diff --git a/src/it/mskins-226-anchorjs-options/verify.groovy b/src/it/mskins-226-anchorjs-options/verify.groovy
new file mode 100644
index 0000000..a7ea7a7
--- /dev/null
+++ b/src/it/mskins-226-anchorjs-options/verify.groovy
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+File index = new File( basedir, "target/site/index.html" )
+assert index.exists()
+assert index.text.contains( 'anchors.add("h1, h2, h3, h4, h5")')
+assert index.text.contains( 'anchors.options.class = ".anchor"')
+assert index.text.contains( 'anchors.options.titleText = "foo"')
diff --git a/src/main/resources/META-INF/maven/site-macros.vm b/src/main/resources/META-INF/maven/site-macros.vm
index e5563f4..75c2287 100644
--- a/src/main/resources/META-INF/maven/site-macros.vm
+++ b/src/main/resources/META-INF/maven/site-macros.vm
@@ -772,12 +772,19 @@ $indent </ul>##
Apache Maven Doxia Site Renderer#if( $doxiaSiteRendererVersion ) $doxiaSiteRendererVersion#end##
#end
##
-##
-#macro( anchorJS )
-<script>
- if(anchors) {
- anchors.add();
- }
-</script>
+#macro( anchorJs )
+#**##if ( $decoration.getCustomChild( 'fluidoSkin.anchorJs' ) )
+ <script>
+#* *##if ( $decoration.getCustomValue( 'fluidoSkin.anchorJs.cssSelector' ) && $decoration.getCustomValue( 'fluidoSkin.anchorJs.cssSelector' ) != '' )
+#* *##set ( $cssSelector = '"' + $decoration.getCustomValue( 'fluidoSkin.anchorJs.cssSelector' ) + '"' )
+#* *##end
+#* *##foreach( $option in $decoration.getCustomChild( 'fluidoSkin.anchorJs.options' ).getChildren() )
+#* *##if( $option.value && $option.value != "" )
+ anchors.options.$option.name = "$option.value";
+#* *##end
+#* *##end
+ anchors.add($!cssSelector);
+ </script>
+#**##end
#end
##
diff --git a/src/main/resources/META-INF/maven/site.vm b/src/main/resources/META-INF/maven/site.vm
index c711d11..3315c7f 100644
--- a/src/main/resources/META-INF/maven/site.vm
+++ b/src/main/resources/META-INF/maven/site.vm
@@ -278,6 +278,6 @@
#* *##end
</div>
</footer>
-#**##anchorJS()
+#**##anchorJs()
</body>
</html>
diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm
index 8160fad..5d9941b 100644
--- a/src/site/apt/index.apt.vm
+++ b/src/site/apt/index.apt.vm
@@ -463,6 +463,42 @@ Welcome to ${project.name}!
By default, it is rendered in the sidebar, if the topbar only is available it will be rendered there.
+** {AnchorJS}
+
+ You can optionally enable anchor ID generation with {{{https://www.bryanbraun.com/anchorjs/}AnchorJS}}:
+
++-----+
+<project name="xxx">
+ [...]
+ <custom>
+ <fluidoSkin>
+ <anchorJs />
+ </fluidoSkin>
+ </custom>
+ [...]
+</project>
++-----+
+
+ Additionally you can provide a CSS selector for the <<<add()>>> function and options:
+
+ +-----+
+<project name="xxx">
+ [...]
+ <custom>
+ <fluidoSkin>
+ <anchorJs>
+ <cssSelector>h1, h2, h3, h4, h5</cssSelector>
+ <options>
+ <class>.anchor</class>
+ <titleText>foo</titleText>
+ </options>
+ </anchorJs>
+ </fluidoSkin>
+ </custom>
+ [...]
+</project>
++-----+
+
** {Skip generation date}
Since version <<1.3.1>>, you can skip generation date from the line "Generated by Apache Maven Doxia at \<date\>"