Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSKINS-226] Add custom option to explicitly enable AnchorJS along with options #51

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions src/it/mskins-226-anchorjs-no-options/pom.xml
Original file line number Diff line number Diff line change
@@ -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>
36 changes: 36 additions & 0 deletions src/it/mskins-226-anchorjs-no-options/src/site/apt/index.apt.vm
Original file line number Diff line number Diff line change
@@ -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}
50 changes: 50 additions & 0 deletions src/it/mskins-226-anchorjs-no-options/src/site/site.xml
Original file line number Diff line number Diff line change
@@ -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>
23 changes: 23 additions & 0 deletions src/it/mskins-226-anchorjs-no-options/verify.groovy
Original file line number Diff line number Diff line change
@@ -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.')
57 changes: 57 additions & 0 deletions src/it/mskins-226-anchorjs-options/pom.xml
Original file line number Diff line number Diff line change
@@ -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>
36 changes: 36 additions & 0 deletions src/it/mskins-226-anchorjs-options/src/site/apt/index.apt.vm
Original file line number Diff line number Diff line change
@@ -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}
56 changes: 56 additions & 0 deletions src/it/mskins-226-anchorjs-options/src/site/site.xml
Original file line number Diff line number Diff line change
@@ -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>
24 changes: 24 additions & 0 deletions src/it/mskins-226-anchorjs-options/verify.groovy
Original file line number Diff line number Diff line change
@@ -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"')
21 changes: 14 additions & 7 deletions src/main/resources/META-INF/maven/site-macros.vm
Original file line number Diff line number Diff line change
Expand Up @@ -557,12 +557,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
##
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/maven/site.vm
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,6 @@
#* *##end
</div>
</footer>
#**##anchorJS()
#**##anchorJs()
</body>
</html>
Loading
Loading