8.4 KiB
Changelog
All notable changes to SSG will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.1.0
Added
-
Templates, SpecialPages, and Parts all have access to two related objects:
tasks
andtaskTypes
. The first is an instance ofTaskContainer
and can be used to access all of theTask
instances for a given build. The second is in an instance ofTaskTypeContainer
and can be used to access the variousTaskType
instances for a given build. For example, one could use these together to obtain the output path of an html file from another task (assume one is in a.gsp
file):def otherTask = tasks.findAllByType(taskTypes.textToHtmlFile).find { it.input.path == 'someText.md' } assert otherTask.output.htmlPath == 'someText.html'
This is a complicated and experimental feature and may be changed frequently depending on future developments. 92c8108.
-
Templates, SpecialPages, and Parts all have access to a
logger
of typeorg.slf4j.Logger
. 64f342a. -
There is now the notion of a
siteSpec
, an object of type ofSiteSpec
. It is simmilar to theglobals
object in that it contains properties that are available in all Templates, SpecialPages, and Parts. Unlikeglobals
, which contains user-defined keys,siteSpec
contains (for now) the pre-defined keysbaseUrl
andtitle
. To configure thesiteSpec
, add the following block to abuild
block inssgBuilds.groovy
:siteSpec { baseUrl = 'https://test.com' // or whatever, defaults to an empty string title = 'My Great Website' // or whatever, defaults to an empty string }
Then use it in any Template, SpecialPage, or part like so:
<% assert siteSpec.baseUrl == 'https://test.com' && siteSpec.title == 'My Great Website' %>
-
Templates, SpecialPages, and Parts all have access to
targetPath
of typeString
representing the path of the 'output' file. For now, this is always a.html
file.<% // in a template where the source text is 'foo/bar.md' assert targetPath == 'foo/bar.html' // in a special page whose path is 'special.gsp' assert targetPath == 'special.html' // in a part with a source text of 'foo/bar/hello.md' assert targetPath == 'foo/bar/hello.html' // in a part with a source special page of 'foo/bar/baz/special.gsp' assert targetParth == 'foo/bar/baz/special.html' %>
-
Templates, SpecialPages, and Parts all have access to
sourcePath
of typeString
representing the path of the 'source' file: either a text file or a special page. In Templates, the 'source' comes from the path of the Text being rendered; in SpecialPages, this comes from the path of the SpecialPage being rendered (i.e., itself); in Parts, this comes from either the Template or SpecialPage which called (i.e., embedded) the Part.<% // in a template or part when rendering a text at 'home.md' assert sourcePath == 'home.md' // in a template or part when rendering a text at 'posts/helloWorld.md' assert sourcePath == 'posts/helloWorld.md' // in a special page or part when rendering a special page at 'foo/bar/specialPage.gsp' assert sourcePath == 'foo/bar/specialPage.gsp' %>
-
Templates, SpecialPages, and Parts all have access to a
urlBuilder
of typePathBasedUrlBuilder
(implementingUrlBuilder
). It can be used to obtain both absolute (usingsiteSpec.baseUrl
) and relative urls (to the currenttargetPath
). Use it like so:<% // when targetPath == 'simple.html' assert urlBuilder.relative('images/test.jpg') == 'images/test.jpg' // when targetPath == 'nested/post.html' assert urlBuilder.relative('images/test.jpg') == '../images/test.jpg' // when baseUrl is 'https://test.com' and targetPath is 'simple.html' assert urlBuilder.absolute == 'https://test.com/simple.html // when baseUrl is 'https://test.com' and we want an absolute to another file assert urlBuilder.absolute('images/test.jpg') == 'https://test.com/images/test.jpg' %>
Nota bene: likely will break on Windows since
PathBasedUrlBuilder
currently uses Java'sPath
api and paths would be thusly rendered using Windows-style backslashes. This will be explored in the future. 0371d41, 0762dc6, 60f4c14. -
Parts have access to all other parts now via
parts
, an object of typeEmbeddablePartsMap
. For example:<% // myPart.gsp out << parts['otherPart.gsp'].render() %>
-
A
tagBuilder
object of typeDynamicTagBuilder
(implementingTagBuilder
) is available in Templates, SpecialPages, and Parts.<% def simpleTag = tagBuilder.test() assert simpleTag == '<test />' def tagWithBody = tagBuilder.title 'Hello, World!' assert tagWithBody == '<title>Hello, World!</title>' def tagWithAttributes = tagBuilder.meta name: 'og:title', content: 'Hello, World!' assert tagWithAttributes == '<meta name="og:title" content="Hello, World!" />' def tagWithAttributesAndBody = tagBuilder.p([id: 'my-paragraph'], 'Hello, World!') assert tagWithAttributesAndBody == '<p id="my-paragraph">Hello, World!</p>' %>
This is likely most useful for building simple, one-line html/xml tags. 93687d.
-
Parts have a
text
object of typeEmbeddableText
. If one is rendering a Part called from anything other than a Template (which has an associated text), this will benull
. 34d9cd5.
Breaking Changes
- The path of a file was stripped of its extension when previously referring to Texts or SpecialPages; now, the extension is present. For example:
0371d41.<% // suppose we have a text called 'test.md' and we are in a template, special page, or part assert texts['test'] == null assert texts['test.md'] != null %>
- The
text
object in Templates is now an instance ofEmbeddableText
instead ofString
. Thus, one must usetext.render()
to obtain the rendered text. 34d9cd5. - The
frontMatter
object is no longer available. Usetext.frontMatter
instead. eafc8cd, c5ac810.