Overview
Scalate can be used to create a static website reusing all of the various Scalate template languages, filters, wiki markups and pipelines.
Creating a Site
The quickest way to get started is to install the Scalate Tool then run
scalate create sitegen mygroup myartifactid
This creates an example sitegen project in the myartifactid directory.
Inside the project run the following
mvn jetty:run
Then open http://localhost:8080/ and you should see the styled website.
The source for the site in wiki markup or templates are all in the src
directory.
However you can also use the Console to edit the templates directly.
Just open the console via the top right icon. You will then see links to the page you are looking at along with the layout template used to render the current page. Clicking on the link will open the wiki page or template in your editor. Refer to the Console for details of changing your default editor.
When you change a file and hit save you can hit reload in your browser to see the newly rendered page. Whether you change a wiki page, an include or a template you will always see the most up to date page in your browser.
Generating the static site
To generate the static site run
mvn install
This will invoke the scalate:sitegen plugin which generates the static website to the target/sitegen directory.
There's also a scalate:sitegen-no-fork plugin goal available that can be used to configure additional/different executions of the goal in an existing build.
Deploying the static site
Before you start trying to deploy you need to add a distributionManagement
section
to your pom.xml. For example projects hosted on the
FuseForge tend to use something like this
<distributionManagement>
<site>
<id>website.fusesource.org</id>
<name>website</name>
<url>dav:http://fusesource.com/forge/dav/myproject</url>
</site>
</distributionManagement>
Any of the Maven Wagon transport mechanisms should be supported (file, scp, dav etc).
Then to actually deploy the static site to some remote system you can use the following:
mvn scalate:deploy
This will deploy the site generated by the scalate:sitegen
goal to the website
location you have provided in the site
area of the distributionManagement
section of
your pom.xml
If you also want to deploy a regular maven website too then you can reuse the same
site configuration as above but just specify a remoteDirectory
property on the
plugin (which defaults to “..” to avoid including the maven project name in the deploy url)
You will need to add the project's Web server to your Maven configuration:
<server>
<id>website.fusesource.org</id>
<username>xxxx</username>
<password>xxxxx</password>
</server>
Link Checking
Its easy to make a mistake in your wiki files and create a bad link. So we have a linkcheck report you can add to your pom.xml if you want to generate a report of any bad links that are created as part of your statically generated HTML.
Just add the following to your pom.xml
and you'll get a nice LinkCheck report.
<reporting>
<plugins>
<plugin>
<groupId>org.fusesource.scalate</groupId>
<artifactId>maven-scalate-plugin</artifactId>
<version>1.4.0</version>
</plugin>
</plugins>
</reporting>
Using LiveReload
LiveReload is a tool and a browser plugin for Safari and Chrome.
runlivereload
LiveReload watches the files on your machine so that as you change a template, CSS or JavaScript file it will force a reload in the web browser. This means you can sit in your editor changing files and have a browser window open and you don't have to keep changing focus between the editor and browser and hitting reload in the browser. You can just hit save in your editor and see the results in your browser.
Or you can use the livereload script directly…
livereload src
This works thanks to the src/.livereload
configuration file knowing about the scalate
template files.
Exporting Confluence Wikis
If you have a legacy site you want to port over from Confluence you can run the following command.
For example if your Confluence space is called FOO at Apache then the following command will dump its content as wiki text files…
scalate confexport --user user --password pass \
https://cwiki.apache.org/confluence/rpc/xmlrpc FOO ./out
Bootstrapping
When generating static sites you often need a little bit of bootstrap code
to configure things such that you can configure some filters (for example
the {snippet}
macros inside Confluence wiki files) which are then setup
and used whether you run Scalate using mvn jetty:run
for the live website
or use mvn scalate:sitegen
to generate the static site.
Thankfully there's a really simple way to add in any custom initialisation
code in Scalate. Just add a class called scalate.Boot
which should be a
class with a method called run()
which can then do whatever you need to
configure things before the template engine starts to render your templates
and wiki files.