Publick Apache Sling + Sightly Blog
Publick is named after Publick Occurrences Both Forreign and Domestick, the first newspaper in the American colonies.
View a custom implementation of Publick with custom styling and components at https://github.com/nateyolles/publick-nateyolles and the live implementation at nateyolles.com. You can log into nateyolles.com/admin with user demo and password demo.
View the Trello Board.
Download and start Apache Sling
This project requires Apache Sling 7.
- Download the Apache Sling self runnable jar.
- Start the Apache Sling instance by running the following from the command line:
java -jar org.apache.sling.launchpad-7-standalone.jar
Install Apache Maven
Apache Maven is used to build the project.
Install static asset build tools (optional)
The frontend-maven-plugin installs NodeJS and NPM locally then runs Bower and Grunt. The following steps are not required.
- Navigate to /ui bundle.
- Install NodeJS and NPM
- Install Grunt CLI:
npm install -g grunt-cli
- Install Grunt plugins:
- Run Grunt:
Install external dependencies to a running Sling instance with default values of port 8080, user admin and password admin:
mvn clean install -PautoInstallDependencies
Build and deploy to a running Sling instance with default values of port 8080, user admin and password admin:
mvn clean install -PautoInstallBundle
Navigate to http://localhost:8080/admin/login.html. The default credentials are admin/admin.
- Navigate to http://localhost:8080/admin/users.html
- Change admin password
- Create an Author account
Configurations can be set in any of three ways:
- The Publick dashboard http://localhost:8080/admin.html
- The Apache Felix (OSGi) console http://localhost:8080/system/console/configMgr
- Create preconfigured sling:OsgiConfig nodes. View examples under /publick/ui/src/main/resources/jcr_root/libs/publick/install
Setup reCAPTCHA (prevent automated comment spam)
- Sign up for free at https://www.google.com/recaptcha
- Navigate to http://localhost:8080/admin/config/recaptcha.html
- Insert site key and secret key
Setup Akismet (prevent comment spam)
- Sign up for free at http://akismet.com
- Navigate to http://localhost:8080/admin/config/akismet.html
- Insert your API key and domain name
Setup your SMTP server
- Setup your email server using something like Amazon Simple Email Service (SES), Postfix or Gmail
- Navigate to http://localhost:8080/admin/config/email.html
- Insert your server information
Setup your System Settings
- Navigate to http://localhost:8080/admin/config/system.html
- Insert your blog name.
- Turn extensionless URLs on/off and setup your web server rewrites accordingly.
- Declare a temporary directory on your file system. This is needed to create backup packages.
Attach a debugger to the Apache Sling instance by running the following from the command line:
java -Xmx2048M \ -agentlib:jdwp=transport=dt_socket,address=30303,server=y,suspend=n \ -jar org.apache.sling.launchpad-7-standalone.jar
Apache Web Server setup
- Serve your address on port 80 and proxy to Apache Sling on port 8080.
- Redirect paths to remove "/content".
- Redirect for extentionless URLs.
<VirtualHost *:80> ProxyPreserveHost On ProxyPass / http://localhost:8080/ ProxyPassReverse / http://localhost:8080/ ServerName www.yourdomain.com </VirtualHost>
Dealing with Sling bugs
/var node is incorrect jcr:primaryType
If you start getting errors in the log about
/var/discovery or the
org.apache.sling.discovey.impl framework, it's because of a bug in Sling. You can fix the problem by changing the
jcr:primaryType of the
/var node from
sling:Folder. Run the following cURL command:
curl -u admin:admin -F"jcr:primaryType=sling:Folder" http://localhost:8080/var
Updating groups doesn't work with JSON
The post servlet that handles updating user groups doesn't work when posting to JSON in Sling 7. It has been fixed in Sling 8, however, this project is using the latest version of Sling's downloadable JAR, which is 7. The workaround is for the UserService in admin.js to post to HTML rather than JSON to update groups. The side effect is that in order to use extensionless URLs, you need to account for this in your web server redirects. See above.
Two Maven Archetypes where used to begin the project, one for the core Java bundle and one for the UI bundle. This is purely informational; you do not need to run the following commands.
- Create parent pom
- Create sub projects using the following archetypes:
mvn archetype:generate \ -DarchetypeGroupId=org.apache.sling \ -DarchetypeArtifactId=sling-initial-content-archetype \ -DgroupId=com.nateyolles.sling.publick \ -DartifactId=ui \ -Dversion=1.0.0-SNAPSHOT \ -Dpackage=com.nateyolles.sling.publick.ui \ -DappsFolderName=publick \ -DartifactName="ui" \ -DpackageGroup="ui"
mvn archetype:generate \ -DarchetypeGroupId=org.apache.sling \ -DarchetypeArtifactId=sling-bundle-archetype \ -DgroupId=com.nateyolles.sling.publick \ -DartifactId=core \ -Dversion=1.0.0-SNAPSHOT \ -Dpackage=com.nateyolles.sling.publick.core \ -DappsFolderName=publick \ -DartifactName="core" \ -DpackageGroup="core"