Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
 - Created project with AEM archetype
 - Added "overlayed" Sightly clientlib components
 - Added "overlayed" clientlib Java
 - Added clientlib-async-sample.async-sample client lib with test function
 - Added async clientlib to headlibs.html with onload function
 - Added README.md
 - Added .gitignore
  • Loading branch information
nateyolles committed May 16, 2015
0 parents commit 9a795eb
Show file tree
Hide file tree
Showing 116 changed files with 3,734 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
target
.idea
.classpath
.project
.settings
.vlt
.DS_Store
.vlt-sync-config.properties
.vlt-sync.log
.brackets.json
.metadata/
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Clientlib Async Sample project

This project demonstrates how to create AEM clientlibs that can output 'async', 'defer' and 'onload' attributes on your HTML script elements.

## Project

This project was created using the [AEM project archetype](https://github.com/Adobe-Marketing-Cloud/aem-project-archetype). See the archetype's documentation for further information on modules, building, testing and Maven settings. The archetype may be a little heavy handed for this small example. The files you should pay attention to are as follows:

* /core/src/main/java/com/nateyolles/aem/clientlib/ClientLibUseObject.java
* /ui.apps/src/main/content/jcr_root/apps/clientlib-async-sample/components/structure/page/partials/headlibs.html
* /ui.apps/src/main/content/jcr_root/apps/clientlib-async-sample/sightly/templates/clientlib.html
* /ui.apps/src/main/content/jcr_root/apps/clientlib-async-sample/sightly/templates/graniteClientLib.html
* /ui.apps/src/main/content/jcr_root/etc/designs/clientlib-async-sample/clientlib-async-sample/js.txt
* /ui.apps/src/main/content/jcr_root/etc/designs/clientlib-async-sample/clientlib-async-sample/script.js

This project will work with or without [clientlib minification](http://localhost:4502/system/console/configMgr/com.day.cq.widget.impl.HtmlLibraryManagerImpl).

## How to build

You can build and deploy to a running AEM instance with default values of port *4502*, user *admin* and password *admin* with:

mvn clean install -PautoInstallPackage

## View sample

After building and deploying, navigate to [the sample page](http://localhost:4502/content/clientlib-async-sample/en.html). View the source to verify that the *clientlib-async-sample.js* script element has the *async* void attribute and the *onload* attribute with a value of *sayHello()*.

## Using the updated clientlibs

Use the clientlibs in your Sightly markup just as you would before (see [Sightly intro part 5: FAQ](http://blogs.adobe.com/experiencedelivers/experience-management/sightly-intro-part-5-faq/)), however, you will update the value of the data-sly-use parameter to point to the new clientlib components.

```
<head data-sly-use.clientLib="${'/apps/clientlib-async-sample/sightly/templates/clientlib.html'}">
<!--/* for css+js */-->
<meta data-sly-call="${clientLib.all @ categories='your.clientlib'}" data-sly-unwrap></meta>
<!--/* only js */-->
<meta data-sly-call="${clientLib.js @ categories='your.clientlib'}" data-sly-unwrap></meta>
<!--/* only css */-->
<meta data-sly-call="${clientLib.css @ categories='your.clientlib'}" data-sly-unwrap></meta>
</head>
```

## TODO:

* Write unit tests
* Test with Themes
* Test with Channels
141 changes: 141 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
| Copyright 2015 Adobe Systems Incorporated
|
| Licensed 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>com.nateyolles.aem</groupId>
<artifactId>clientlib-async-sample</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>clientlib-async-sample.core</artifactId>
<packaging>bundle</packaging>
<name>clientlib-async-sample - Core</name>
<description>Core bundle for clientlib-async-sample</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<!--
<Embed-Dependency>
artifactId1,
artifactId2;inline=true
</Embed-Dependency>
-->
<Sling-Model-Packages>
com.nateyolles.aem.core
</Sling-Model-Packages>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<!-- Development profile: install only the bundle -->
<profile>
<id>autoInstallBundle</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.sling</groupId>
<artifactId>maven-sling-plugin</artifactId>
<configuration>
<!-- Note that this requires /apps/clientlib-async-sample/install to exist!! -->
<!-- This is typically the case when ui.apps is deployed first -->
<!-- Otherwise, create /apps/clientlib-async-sample/install manually (CRXDE|Lite) -->
<slingUrlSuffix>/apps/clientlib-async-sample/install/</slingUrlSuffix>
<failOnError>true</failOnError>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<!-- OSGi Dependencies -->
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr</artifactId>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
</dependency>
<dependency>
<groupId>biz.aQute</groupId>
<artifactId>bndlib</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
</dependency>
<!-- Other Dependencies -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>javax.jcr</groupId>
<artifactId>jcr</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>aem-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.models.api</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
</dependency>
<dependency>
<groupId>junit-addons</groupId>
<artifactId>junit-addons</artifactId>
</dependency>
<!-- Added beyond archetype -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>
</project>
Loading

0 comments on commit 9a795eb

Please sign in to comment.