/scalate-website/src/documentation/siteGen.page
http://github.com/scalate/scalate · Visualforce Page · 230 lines · 163 code · 67 blank · 0 comment · 0 complexity · d7f437e650a16900c5b129228e0a5d34 MD5 · raw file
- ---
- title: Site Generator
- in_menu: false
- sort_info: 2
- --- name:overview
- # Site Generator
- Create that static website with Scalate
- --- name:content pipeline:jade
- .left
- :markdown
- # Overview
- .right
- :markdown
- Scalate can be used to create a static website reusing all of the various
- Scalate template languages, filters, wiki markups and pipelines.
- .left
- :markdown
- # Creating a Site
- .right
- :markdown
-
- The quickest way to get started is to [install the Scalate Tool](installing.html) 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/](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](console.html) 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](console.html) 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.
- .left
- :markdown
- # Generating the static site
- .right
- :markdown
- ### Maven
-
- 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.
- ### sbt
- To create a sitegen project in sbt, first add the plugin dependency to
- `project/plugins/Plugins.scala`:
- {pygmentize:: scala}
- lazy val scalate_plugin = "org.fusesource.scalate" % "sbt-scalate-plugin_${scala_compat_tag}" % "${project_version}"
- {pygmentize}
- Then mix the `org.fusesource.scalate.sbt.SiteGenWebProject` into your
- web project, along with the Scalate dependencies. For example:
- {pygmentize:: scala}
- import org.scalate.fusesource.sbt.SiteGenWebProject
- class MySiteGenProject(info: ProjectInfo) extends
- DefaultWebProject(info) with
- SiteGenWebProject {
- lazy val scalate_core = "org.fusesource.scalate" % "scalate-core_${scala_compat_tag}" % "${project_version}"
- lazy val servlet = "javax.servlet" % "servlet-api"% "2.5"
- lazy val logback = "ch.qos.logback" % "logback-classic" % "0.9.26"
- }
- {pygmentize}
- This creates a ***generate-site*** action, which is run as a dependency of
- the ***package*** action. The static web site is generated to the
- ***target/sitegen*** directory.
- .left
- :markdown
- <h1 id="deploy">Deploying the static site</h1>
-
- .right
- :markdown
- Before you start trying to deploy you need to add a `distributionManagement` section
- to your pom.xml. For example projects hosted on the
- [FuseForge](http://fusesource.com/forge/) tend to use something like this
- {pygmentize:: xml}
- <distributionManagement>
- <site>
- <id>website.fusesource.org</id>
- <name>website</name>
- <url>dav:http://fusesource.com/forge/dav/myproject</url>
- </site>
- </distributionManagement>
- {pygmentize}
- 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:
-
- {pygmentize:: xml}
- <server>
- <id>website.fusesource.org</id>
- <username>xxxx</username>
- <password>xxxxx</password>
- </server>
- {pygmentize}
- .left
- :markdown
- <h1 id="linkCheck">Link Checking</h1>
- .right
- :markdown
- 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.
- {pygmentize:: xml}
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.fusesource.scalate</groupId>
- <artifactId>maven-scalate-plugin_#{scala_compat_tag}</artifactId>
- <version>${project_version}</version>
- </plugin>
- </plugins>
- </reporting>
- {pygmentize}
- .left
- :markdown
- <h1 id="livereload">Using LiveReload</h1>
- .right
- :markdown
-
- [LiveReload](http://github.com/mockko/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.
- .left
- :markdown
- <h1 id="export">Exporting Confluence Wikis</h1>
- .right
- :markdown
-
- 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
- .left
- :markdown
- <h1 id="bootstrapping">Bootstrapping</h1>
-
- .right
- :markdown
-
- 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.