From 4a47ec816ce751d859d2cbea7b619e557ce9ea57 Mon Sep 17 00:00:00 2001 From: Dmitriy Pavlenko Date: Tue, 4 Aug 2015 16:08:30 +0300 Subject: [PATCH 01/14] Added versions 0.6.3 - 0.6.5 to the project changelog. Signed-off-by: Dmitriy Pavlenko --- CHANGELOG.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a5f7a2..32ae3b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +## 0.6.5 / 2015-08-04 + + + * Configured the Asciidoctor module to use custom document processing attributes from the site configuration + * Updated the RPC executor to handle a map of string key-value pairs in order to pass Asciidoctor attributes + +## 0.6.4 / 2015-06-22 + + + * Enabled Asciidoctor include support + * Added exception dumping for the Asciidoctor + +## 0.6.3 / 2015-01-20 + + + * Updated Asciidoctor version to 1.5.2 + * Enabled syntax highlighting in Asciidoctor using Coderay + ## 0.6.2 / 2014-10-09 From a66626cf68b0f0136d553c78b58f69dba7b9b3a5 Mon Sep 17 00:00:00 2001 From: Dmitriy Pavlenko Date: Wed, 5 Aug 2015 10:11:05 +0300 Subject: [PATCH 02/14] Updated the Asciidoctor feature description. Signed-off-by: Dmitriy Pavlenko --- docs/latest.markdown | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/latest.markdown b/docs/latest.markdown index 77be134..5e24005 100644 --- a/docs/latest.markdown +++ b/docs/latest.markdown @@ -189,10 +189,27 @@ section of the configuration file. There is only one implementation of reStructuredText at this time - via Python docutils. All files having `rst` extension will be rendered using this implementation. -####AsciiDoctor markup feature +####Asciidoctor markup feature All files having `adoc` or `asciidoctor` extensions will be rendered using latest asciidoc Ruby gem. +The files are converted to HTML5 with help of the `Asciidoctor.convert` method: + +```ruby +Asciidoctor.convert(source, :safe => 0, :attributes => attributes) +``` + +You can provide the custom attributes for the document conversion in the following way: + +```groovy +features { + asciidoc { + opts = ['source-highlighter': 'coderay', + 'icons': 'font'] + } +} +``` + ####Syntax highlighting feature `highlight` - code highlighting method (default: none): From bedfbc154dc5eef99007de90d0bce9bc3f7c71f4 Mon Sep 17 00:00:00 2001 From: Dmitriy Pavlenko Date: Wed, 5 Aug 2015 11:14:53 +0300 Subject: [PATCH 03/14] Added the 'Disable Groovy code interpolation' section to the documentation. Signed-off-by: Dmitriy Pavlenko --- docs/latest.markdown | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/latest.markdown b/docs/latest.markdown index 5e24005..d06ab87 100644 --- a/docs/latest.markdown +++ b/docs/latest.markdown @@ -406,6 +406,15 @@ To include large blocks of Groovy code one can use notation below: The `if` above will work as expected, e.g. the span will be rendered into page contents only when the criteria is met. Also note that variables declared in one piece of embedded code will be available anywhere on the page. +####Disable Groovy code interpolation + +To render embedded Groovy code as is, you need to disable Groovy code interpolation by using the following form of +escaping: + +``` +`!`${2 + 2}`!` +``` + ###Variables on a page Grain has several variables reserved, others can be freely introduced on a page. From a181676ab1316f9d42f883f2fbff4568790d5953 Mon Sep 17 00:00:00 2001 From: Dmitriy Pavlenko Date: Mon, 17 Aug 2015 16:30:22 +0300 Subject: [PATCH 04/14] Updated Grain to support dynamic revision numbers in the theme properties, like 0.6.+ Concrete values still must be specified for the major and minor numbers of the Grain version, declarations like 0+, 0.+ or 0.6+, won't accepted by Grain. This is done on purpose to ensure that a theme always uses compatible Grain version. Grain revisions on the other hand (like 0.6.1, 0.6.2, etc.) must be always interchangeable. Signed-off-by: Dmitriy Pavlenko --- .../sysgears/grain/init/CmdlineParser.groovy | 25 +++++-- .../sysgears/grain/init/GrainVersion.groovy | 71 +++++++++++-------- 2 files changed, 60 insertions(+), 36 deletions(-) diff --git a/src/main/groovy/com/sysgears/grain/init/CmdlineParser.groovy b/src/main/groovy/com/sysgears/grain/init/CmdlineParser.groovy index 820dad3..bb4967a 100644 --- a/src/main/groovy/com/sysgears/grain/init/CmdlineParser.groovy +++ b/src/main/groovy/com/sysgears/grain/init/CmdlineParser.groovy @@ -16,6 +16,8 @@ package com.sysgears.grain.init +import groovy.util.logging.Slf4j + import java.util.jar.Manifest /** @@ -23,6 +25,7 @@ import java.util.jar.Manifest *

* In case of facing wrong cmdline arguments dumps help and shutdowns the application */ +@Slf4j @javax.inject.Singleton class CmdlineParser { @@ -191,9 +194,9 @@ Options: /** * Validates Grain version specified in theme. * - * @param grainVersion current running Grain version + * @param version current running Grain version */ - private static validateGrainVersion(String grainVersion) { + private static validateGrainVersion(String version) { def propertiesFile = new File(PROPERTIES_FILE_NAME) if (!propertiesFile.exists() || !propertiesFile.isFile()) { throw new RuntimeException("Unable to locate properties file: ${propertiesFile.canonicalPath}") @@ -201,15 +204,23 @@ Options: def themeProps = new Properties() themeProps.load(new FileInputStream(propertiesFile)) - def themeGrainVersion = themeProps.getProperty('grain.version') - if (!themeGrainVersion) { + if (!themeProps.getProperty('grain.version')) { throw new RuntimeException("Grain version not specified in properties file: ${propertiesFile.canonicalPath}") } - if (!new GrainVersion(grainVersion).isBackwardCompatibleTo(new GrainVersion(themeGrainVersion))) { - throw new RuntimeException("""Grain versions are not compatible: \nGrain version of the theme: ${themeGrainVersion}. -Current Grain version: ${grainVersion}.""") + def currentVersion = new GrainVersion(version) + def themeVersion = new GrainVersion(themeProps.getProperty('grain.version')) + + if (!currentVersion.isBackwardCompatible(themeVersion)) { + throw new RuntimeException("Current Grain version is not compatible with the theme version: " + + "found ${currentVersion}, required ${themeVersion}.") + } + + // warn users if the versions are compatible but not interchangeable + if (!currentVersion.isInterchangeable(themeVersion)) { + log.warn("Current Grain version does not match the theme version: " + + "found ${currentVersion}, required ${themeVersion}. Please continue with caution.") } } diff --git a/src/main/groovy/com/sysgears/grain/init/GrainVersion.groovy b/src/main/groovy/com/sysgears/grain/init/GrainVersion.groovy index 552a1f8..86a0249 100644 --- a/src/main/groovy/com/sysgears/grain/init/GrainVersion.groovy +++ b/src/main/groovy/com/sysgears/grain/init/GrainVersion.groovy @@ -1,47 +1,60 @@ package com.sysgears.grain.init /** - * Representation of Grain version + * Representation of Grain version. */ class GrainVersion { - - /** Major Grain version */ - private int major - - /** Middle Grain version */ - private int middle - - /** Minor Grain version */ - private int minor - + + /* The version numbers. */ + private Map numbers = [major: '', minor: '', revision: ''] + + /** + * Initializes Grain version object.
+ * Valid version numbers: '0.5.1', '0.5.+' or '0.5.1-SNAPSHOT'. + * + * @param version the string representation of the version number + */ public GrainVersion(String version) { - def m = version =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)/ - if (!m.find()) { - throw new IllegalArgumentException("Wrong Grain version ${version}, expected format: x.y.z with optional -SNAPSHOT ending") - } else { - major = m[0][1] - middle = m[0][2] - minor = m[0][3] + def groups = [major: 1, minor: 2, revision: 3] + def matcher = (version =~ /^([0-9]+)\.([0-9]+)\.(([0-9]+)|([0-9]+(-SNAPSHOT)?)|(\+))$/) + + // throws the exception if the version doesn't match the x.y.[z+] format + if (!matcher) { throw new IllegalArgumentException("Wrong Grain version ${version}, " + + "expected format: x.y.z, where z can be a number or + sign.") } + + // fills in the version numbers + groups.each { name, number -> + numbers[name] = matcher[0][number] } } /** - * Checks whether current Grain version is backward compatible to the given one - * - * @param version Grain version to check with - * - * @return is current Grain version backward compatible to the given one + * Checks if the versions are interchangeable by comparing the major and minor version numbers. + * + * @param version version object to compare this version against + * @return true if the versions are interchangeable, false otherwise + */ + public boolean isInterchangeable(GrainVersion version) { + return numbers.major == version.numbers.major && numbers.minor == version.numbers.minor + } + + /** + * Checks if the current version is backward compatible with the specified version. + * + * @param version version object to check against + * @return true if the current version is backward compatible with the specified version, false otherwise */ - public boolean isBackwardCompatibleTo(GrainVersion version) { - return major == version.major && middle >= version.middle + public boolean isBackwardCompatible(GrainVersion version) { + return numbers.major == version.numbers.major && + numbers.minor.toInteger() >= version.numbers.minor.toInteger() } /** * Returns String representation of Grain version - * - * @return String representation of Grain version + * + * @return String representation of Grain version */ public String toString() { - "${major}.${middle}.${minor}" + "${numbers.major}.${numbers.minor}.${numbers.revision}" } -} +} \ No newline at end of file From 323cc981088499fe3532d93e2738246bbe5470cb Mon Sep 17 00:00:00 2001 From: Dmitriy Pavlenko Date: Mon, 17 Aug 2015 16:40:22 +0300 Subject: [PATCH 05/14] Updated the framework description in the README. Signed-off-by: Dmitriy Pavlenko --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1920f4f..e16fc42 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,9 @@ Grain ===== Grain is a lightweight and yet powerful static website generator for [Groovy][Groovy] which purpose is -to make demanding site implementation an intuitive and enjoyable. Grain framework is equally -well-suited for any static website, whether it is a complex and sophisticated company site -or a simple and neat blog. The framework applies elegant website building concepts and allows to -develop rapidly by making and seeing changes on the fly. +to make demanding site implementation intuitive and enjoyable. Grain framework is equally well-suited +for any static website, whether it is a complex company site or a neat blog. The framework applies +simple website building concepts and allows to develop rapidly by making and seeing changes on the fly. Getting Started =============== From 9547b4afda43f19223ff36a2c38755b9d68fb3ef Mon Sep 17 00:00:00 2001 From: Dmitriy Pavlenko Date: Wed, 19 Aug 2015 17:11:18 +0300 Subject: [PATCH 06/14] Added the 'source processing configuration' section to the documentation. Expanded the 'filesystem layout' section to include information on customizing site directories. Signed-off-by: Dmitriy Pavlenko --- docs/latest.markdown | 102 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 91 insertions(+), 11 deletions(-) diff --git a/docs/latest.markdown b/docs/latest.markdown index d06ab87..3c51a6d 100644 --- a/docs/latest.markdown +++ b/docs/latest.markdown @@ -148,25 +148,105 @@ may use set of pre-defined variables. These variables are: Though in many situations you wouldn't touch default conventions, in some cases it is still beneficial to have the possibility for more fine-grained control over Grain website structure on the filesystem. -You can control website filesystem layout by modifying the following parameters in `SiteConfig.Groovy`: +> Default configuration settings can be found in the +[src/main/resources/DefaultConfig.groovy](https://github.com/sysgears/grain/blob/master/src/main/resources/DefaultConfig.groovy) +file. -`cache_dir` - directory where cache files of various Grain subsystems are stored (default: ".cache") +You can control website filesystem layout by modifying the following parameters in the `/SiteConfig.groovy`: -`source_dir` - directory or list of directories with website sources. The directories are handled sequentially +`destination_dir` - destination directory for generated website files, default:
+ +``` groovy +destination_dir = "${base_dir}/target" +``` + +`cache_dir` - directory where cache files of various Grain subsystems are stored, default:
+ +``` groovy +cache_dir = "${base_dir}/.cache" +``` + +`source_dir` - directory or a list of directories with website sources. The directories are handled sequentially by Grain and if the same files with same relative locations appear in each directory, then the file from the directory -listed later takes precedence (default: ["content", "theme", ".cache/compass"]) +listed later takes precedence. Default:
+ +``` groovy +source_dir = ["${base_dir}/content", "${base_dir}/theme", "${cache_dir}/compass"] +``` + +`include_dir` - directory or a list of directories with includes, default:
+ +``` groovy +include_dir = ["${theme_dir}/includes"] +``` + +`layout_dir` - directory or a list of directories with layouts, default:
+ +``` groovy +layout_dir = ["${theme_dir}/layouts"] +``` + +####Customizing filesystem layout + +Custom destination and cache folders can be specified as the following: + +``` groovy +destination_dir = "${base_dir}/site" -`include_dir` - directory or list of directories with includes (default: ["includes"]) +cache_dir = "${base_dir}/.site_cache" +``` + +To redefine the source, include or layout folders, you should provide a list of directories, or, +if you want to keep the default settings, add your directories to the existing list loaded from +the default configuration: + +``` groovy +// adding a directory to the predefined list +source_dir << "${base_dir}/assets" + +// redefining the folders altogether: +source_dir = ["${base_dir}/content", "${base_dir}/theme", "${base_dir}/assets"] +``` -`layout_dir` - directory or list of directories with layouts (default: ["layouts"]) +###Source processing configuration -`destination_dir` - destination directory for generated website files (default: "target") +This settings can be used for excluding files or directories located in the source folders, or for +defining assets that must be copied to the destination folder without additional processing. -`excludes` - a list of regular expressions, that match locations of files or directories to be excluded - from final website: ['/sass/.*', '/src/.*', '/target/.*']) +`excludes` - a list of regular expressions that match locations of files or directories that must be completely +excluded from processing. These files are ignored by Grain and won't be copied to the destination directory. Default: + +``` groovy +excludes = ['/sass/.*', '/src/.*', '/target/.*'] +``` -`binary_files` - a list of regular expressions, that match locations of
-binary files (default: [/(?i).*\.(png|jpg|jpeg|gif|ico|bmp|swf|avi|mkv|ogg|mp3|mp4)$/]) +`binary_files` - a list of regular expressions that match locations of binary files. Binary files are excluded from +processing, but, contrary to the files from the excludes list, will be copied to the destination directory. Default: + +``` groovy +binary_files = [/(?i).*\.(png|jpg|jpeg|gif|ico|bmp|swf ... eot|otf|ttf|woff)$/] +``` + +`non_script_files` - a list of regular expressions that match locations of files which content +(see [file source](http://localhost:4000/grain/docs/latest/#page-file-source)) must be left +unprocessed. The file headers still will be parsed, which is useful when you need to pass +some configuration options, but do not want Grain to process the content and run embedded Groovy +code. Default: + +``` groovy +non_script_files = [/(?i).*\.(js|css)$/] +``` + +####Customizing source processing settings + +It is generally recommended to add new regular expressions to the default processing configuration instead of +overwriting the settings with new values: + +``` groovy +excludes << '/misc/.*' // additionally excludes the 'misc' directory + +excludes = ['/src/.*', '/target/.*'] // overwrites the default configuration +``` ###Preview configuration From 35439b6504c817c536f6fe46a884f2c5e5481e80 Mon Sep 17 00:00:00 2001 From: Dmitriy Pavlenko Date: Wed, 19 Aug 2015 17:22:16 +0300 Subject: [PATCH 07/14] Added defaults for non_script_files parameter to the site configuration. Signed-off-by: Dmitriy Pavlenko --- src/main/resources/DefaultConfig.groovy | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/resources/DefaultConfig.groovy b/src/main/resources/DefaultConfig.groovy index ebb38d5..69d06b3 100644 --- a/src/main/resources/DefaultConfig.groovy +++ b/src/main/resources/DefaultConfig.groovy @@ -5,22 +5,26 @@ jetty_port = 4000 // Project directories. base_dir = System.getProperty('user.dir') +destination_dir = "${base_dir}/target" cache_dir = "${base_dir}/.cache" content_dir = "${base_dir}/content" theme_dir = "${base_dir}/theme" -source_dir = [content_dir, theme_dir, "${cache_dir}/compass", "${cache_dir}/less"] +source_dir = [content_dir, theme_dir, "${cache_dir}/compass"] include_dir = ["${theme_dir}/includes"] layout_dir = ["${theme_dir}/layouts"] -destination_dir = "${base_dir}/target" -// Binary files + +// Excluded files or directories. +excludes = ['/sass/.*', '/src/.*', '/target/.*'] + +// Binary files or directories that contain binary files. binary_files = [/(?i).*\.(png|jpg|jpeg|gif|ico|bmp|swf|avi|mkv|ogg|mp3|mp4|eot|otf|ttf|woff)$/] +// Non-script files or directories with non-script files. +non_script_files = [/(?i).*\.(js|css)$/] + // Absolute links generate_absolute_links = false // Date time format datetime_format = 'yyyy-MM-dd HH:mm' - -// Excluded files or directories. -excludes = ['/sass/.*', '/src/.*', '/target/.*'] From a4322bb20ac471bea3c02781beb5b31916832cb1 Mon Sep 17 00:00:00 2001 From: Dmitriy Pavlenko Date: Wed, 19 Aug 2015 17:40:22 +0300 Subject: [PATCH 08/14] Fixed an issue when the script header key was overwritten during file processing. Signed-off-by: Dmitriy Pavlenko --- src/main/groovy/com/sysgears/grain/registry/Registry.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/com/sysgears/grain/registry/Registry.groovy b/src/main/groovy/com/sysgears/grain/registry/Registry.groovy index 8044212..35dfee8 100644 --- a/src/main/groovy/com/sysgears/grain/registry/Registry.groovy +++ b/src/main/groovy/com/sysgears/grain/registry/Registry.groovy @@ -170,7 +170,8 @@ class Registry implements FileChangeListener, Service { } resourceConfig.dateCreated = resourceFile.dateCreated() resourceConfig.lastUpdated = resourceFile.lastModified() - resourceConfig.script = nonScriptFiles.every { !resourceFile.canonicalPath.matches(it as String) } + resourceConfig.script = resourceConfig.script != null ? resourceConfig.script : + nonScriptFiles.every { !resourceFile.canonicalPath.matches(it as String) } resourceConfig.url = defaultUrl resourceConfig.location = location resourceConfig.markup = markup From 7960da948769f15d9bd163f4db875dc979ff94b4 Mon Sep 17 00:00:00 2001 From: Dmitriy Pavlenko Date: Fri, 21 Aug 2015 13:27:55 +0300 Subject: [PATCH 09/14] Added the 'Disabling code processing' section to the documentation. Signed-off-by: Dmitriy Pavlenko --- docs/latest.markdown | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/docs/latest.markdown b/docs/latest.markdown index 3c51a6d..d5a310b 100644 --- a/docs/latest.markdown +++ b/docs/latest.markdown @@ -137,7 +137,7 @@ Grain has the following conventions for website files and directories: Grain provides `SiteConfig.groovy` file for general configuration. For specifying configuration in this file, use [ConfigSlurper](http://groovy.codehaus.org/ConfigSlurper) syntax. When working with `SiteConfig.groovy`, you -may use set of pre-defined variables. These variables are: +may use a set of pre-defined variables. These variables are: `site` - access point to website resources and configuration @@ -230,8 +230,7 @@ binary_files = [/(?i).*\.(png|jpg|jpeg|gif|ico|bmp|swf ... eot|otf|ttf|woff)$/] `non_script_files` - a list of regular expressions that match locations of files which content (see [file source](http://localhost:4000/grain/docs/latest/#page-file-source)) must be left unprocessed. The file headers still will be parsed, which is useful when you need to pass -some configuration options, but do not want Grain to process the content and run embedded Groovy -code. Default: +some configuration options, but do not want Grain to run embedded Groovy code. Default: ``` groovy non_script_files = [/(?i).*\.(js|css)$/] @@ -239,8 +238,8 @@ non_script_files = [/(?i).*\.(js|css)$/] ####Customizing source processing settings -It is generally recommended to add new regular expressions to the default processing configuration instead of -overwriting the settings with new values: +It is generally recommended to add new regular expressions to the default processing configuration and keep +the default settings, but, if required, you can completely redefine the configuration: ``` groovy excludes << '/misc/.*' // additionally excludes the 'misc' directory @@ -486,7 +485,7 @@ To include large blocks of Groovy code one can use notation below: The `if` above will work as expected, e.g. the span will be rendered into page contents only when the criteria is met. Also note that variables declared in one piece of embedded code will be available anywhere on the page. -####Disable Groovy code interpolation +####Disabling Groovy code interpolation To render embedded Groovy code as is, you need to disable Groovy code interpolation by using the following form of escaping: @@ -526,6 +525,8 @@ Grain generates the following header keys on initial loading of resource from so - `lastUpdated` - resource file last update time in milliseconds - `text` - text contents of resource file - `bytes` - byte contents of resource file + - `script` - indicates whether the embedded Groovy code processing is enabled for the file (false if the file location + matches an expression from the `non_script_files` configuration list, true otherwise) `page` variable is just a Groovy map. You can add keys to this map in the page code or make other changes, but these changes are only visible to the page itself, @@ -548,6 +549,25 @@ defined in every site page one could do: <%= site.pages.collect { it.title } %> ``` +###Disabling code processing + +Besides defining whether the page content will be processed using the `non_script_files` configuration setting: + +``` groovy:nl +non_script_files = [/(?i).*\.(js|css)$/] +``` + +You can overwrite the configuration for a single file by changing the value of the `script` key in the header: + +``` yaml:nl +--- +script: true # true - evaluate embedded Groovy expressions, false - render the page content as is +#... +--- +``` + +This usually comes in handy when you need to pass variables to stylesheet or javascript files. + ##Layouts ###Concept From 6da8b9f770dadd0ef72ab6662dbb25e679867350 Mon Sep 17 00:00:00 2001 From: Dmitriy Pavlenko Date: Fri, 21 Aug 2015 13:37:04 +0300 Subject: [PATCH 10/14] Disabled the line numbers for some code examples in the documentation. Signed-off-by: Dmitriy Pavlenko --- docs/latest.markdown | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/latest.markdown b/docs/latest.markdown index d5a310b..23d5dc3 100644 --- a/docs/latest.markdown +++ b/docs/latest.markdown @@ -156,13 +156,13 @@ You can control website filesystem layout by modifying the following parameters `destination_dir` - destination directory for generated website files, default:
-``` groovy +``` groovy:nl destination_dir = "${base_dir}/target" ``` `cache_dir` - directory where cache files of various Grain subsystems are stored, default:
-``` groovy +``` groovy:nl cache_dir = "${base_dir}/.cache" ``` @@ -170,19 +170,19 @@ cache_dir = "${base_dir}/.cache" by Grain and if the same files with same relative locations appear in each directory, then the file from the directory listed later takes precedence. Default:
-``` groovy +``` groovy:nl source_dir = ["${base_dir}/content", "${base_dir}/theme", "${cache_dir}/compass"] ``` `include_dir` - directory or a list of directories with includes, default:
-``` groovy +``` groovy:nl include_dir = ["${theme_dir}/includes"] ``` `layout_dir` - directory or a list of directories with layouts, default:
-``` groovy +``` groovy:nl layout_dir = ["${theme_dir}/layouts"] ``` @@ -190,7 +190,7 @@ layout_dir = ["${theme_dir}/layouts"] Custom destination and cache folders can be specified as the following: -``` groovy +``` groovy:nl destination_dir = "${base_dir}/site" cache_dir = "${base_dir}/.site_cache" @@ -200,7 +200,7 @@ To redefine the source, include or layout folders, you should provide a list of if you want to keep the default settings, add your directories to the existing list loaded from the default configuration: -``` groovy +``` groovy:nl // adding a directory to the predefined list source_dir << "${base_dir}/assets" @@ -216,14 +216,14 @@ defining assets that must be copied to the destination folder without additional `excludes` - a list of regular expressions that match locations of files or directories that must be completely excluded from processing. These files are ignored by Grain and won't be copied to the destination directory. Default: -``` groovy +``` groovy:nl excludes = ['/sass/.*', '/src/.*', '/target/.*'] ``` `binary_files` - a list of regular expressions that match locations of binary files. Binary files are excluded from processing, but, contrary to the files from the excludes list, will be copied to the destination directory. Default: -``` groovy +``` groovy:nl binary_files = [/(?i).*\.(png|jpg|jpeg|gif|ico|bmp|swf ... eot|otf|ttf|woff)$/] ``` @@ -232,7 +232,7 @@ binary_files = [/(?i).*\.(png|jpg|jpeg|gif|ico|bmp|swf ... eot|otf|ttf|woff)$/] unprocessed. The file headers still will be parsed, which is useful when you need to pass some configuration options, but do not want Grain to run embedded Groovy code. Default: -``` groovy +``` groovy:nl non_script_files = [/(?i).*\.(js|css)$/] ``` @@ -241,7 +241,7 @@ non_script_files = [/(?i).*\.(js|css)$/] It is generally recommended to add new regular expressions to the default processing configuration and keep the default settings, but, if required, you can completely redefine the configuration: -``` groovy +``` groovy:nl excludes << '/misc/.*' // additionally excludes the 'misc' directory excludes = ['/src/.*', '/target/.*'] // overwrites the default configuration @@ -274,13 +274,13 @@ All files having `adoc` or `asciidoctor` extensions will be rendered using lates The files are converted to HTML5 with help of the `Asciidoctor.convert` method: -```ruby +```ruby:nl Asciidoctor.convert(source, :safe => 0, :attributes => attributes) ``` You can provide the custom attributes for the document conversion in the following way: -```groovy +```groovy:nl features { asciidoc { opts = ['source-highlighter': 'coderay', From b97514e820b66e19522d39dd41f8222061de7180 Mon Sep 17 00:00:00 2001 From: Dmitriy Pavlenko Date: Fri, 21 Aug 2015 14:43:16 +0300 Subject: [PATCH 11/14] Fixed the broken link in the documentation. Signed-off-by: Dmitriy Pavlenko --- docs/latest.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/latest.markdown b/docs/latest.markdown index 23d5dc3..47858c2 100644 --- a/docs/latest.markdown +++ b/docs/latest.markdown @@ -136,8 +136,8 @@ Grain has the following conventions for website files and directories: ###Predefined variables Grain provides `SiteConfig.groovy` file for general configuration. For specifying configuration in this file, use -[ConfigSlurper](http://groovy.codehaus.org/ConfigSlurper) syntax. When working with `SiteConfig.groovy`, you -may use a set of pre-defined variables. These variables are: +ConfigSlurper +syntax. When working with `SiteConfig.groovy`, you may use a set of pre-defined variables. These variables are: `site` - access point to website resources and configuration From bc0707f4af0b919135cb1af923f3f9584c3b4814 Mon Sep 17 00:00:00 2001 From: Dmitriy Pavlenko Date: Fri, 21 Aug 2015 17:12:28 +0300 Subject: [PATCH 12/14] Fixed a misleading typo in the documentation. Signed-off-by: Dmitriy Pavlenko --- docs/latest.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/latest.markdown b/docs/latest.markdown index 47858c2..94e0571 100644 --- a/docs/latest.markdown +++ b/docs/latest.markdown @@ -167,8 +167,8 @@ cache_dir = "${base_dir}/.cache" ``` `source_dir` - directory or a list of directories with website sources. The directories are handled sequentially -by Grain and if the same files with same relative locations appear in each directory, then the file from the directory -listed later takes precedence. Default:
+by Grain, and if the same files with same relative locations appear in each directory, then the file from the directory +listed first takes precedence. Default:
``` groovy:nl source_dir = ["${base_dir}/content", "${base_dir}/theme", "${cache_dir}/compass"] From 9cc8179ed42fbda83672f205bb7a09907742fd5d Mon Sep 17 00:00:00 2001 From: Dmitriy Pavlenko Date: Wed, 26 Aug 2015 16:12:42 +0300 Subject: [PATCH 13/14] Fixed a broken link in the docs. Signed-off-by: Dmitriy Pavlenko --- docs/latest.markdown | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/latest.markdown b/docs/latest.markdown index 94e0571..01ff35d 100644 --- a/docs/latest.markdown +++ b/docs/latest.markdown @@ -149,8 +149,8 @@ Though in many situations you wouldn't touch default conventions, in some cases to have the possibility for more fine-grained control over Grain website structure on the filesystem. > Default configuration settings can be found in the -[src/main/resources/DefaultConfig.groovy](https://github.com/sysgears/grain/blob/master/src/main/resources/DefaultConfig.groovy) -file. + +src/main/resources/DefaultConfig.groovy file. You can control website filesystem layout by modifying the following parameters in the `/SiteConfig.groovy`: @@ -228,9 +228,9 @@ binary_files = [/(?i).*\.(png|jpg|jpeg|gif|ico|bmp|swf ... eot|otf|ttf|woff)$/] ``` `non_script_files` - a list of regular expressions that match locations of files which content -(see [file source](http://localhost:4000/grain/docs/latest/#page-file-source)) must be left -unprocessed. The file headers still will be parsed, which is useful when you need to pass -some configuration options, but do not want Grain to run embedded Groovy code. Default: +(see [file source](#page-file-source)) must be left unprocessed. The file headers still will be parsed, +which is useful when you need to pass some configuration options, but do not want Grain to run embedded +Groovy code. Default: ``` groovy:nl non_script_files = [/(?i).*\.(js|css)$/] From f561be8194e96bf4509cf512a93df5f73cc3f495 Mon Sep 17 00:00:00 2001 From: Dmitriy Pavlenko Date: Thu, 27 Aug 2015 12:15:42 +0300 Subject: [PATCH 14/14] Updated the build script to use a version number from the application.properties Signed-off-by: Dmitriy Pavlenko --- build.gradle | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/build.gradle b/build.gradle index 117943a..5b69d08 100644 --- a/build.gradle +++ b/build.gradle @@ -4,14 +4,6 @@ apply plugin: 'maven' apply plugin: 'groovy' apply plugin: 'idea' apply plugin: 'signing' -group = 'com.sysgears.grain' -version = '0.7.0-SNAPSHOT' -defaultTasks 'build' - -def mainClassName = 'com.sysgears.grain.Main' -def compatibilityVersion = 1.6 -sourceCompatibility = compatibilityVersion -targetCompatibility = compatibilityVersion buildscript { repositories { mavenCentral() } @@ -19,14 +11,29 @@ buildscript { } ext { + applicationProperties = new Properties() + applicationProperties.load(new FileInputStream("$project.projectDir/src/main/resources/application.properties")) + + grainVersion = applicationProperties.getProperty('grain.version') + if (!grainVersion) { throw new RuntimeException('Grain version is not set in the properties file') } + title = 'Grain Static Website Building Framework' url = 'http://www.sysgears.com/grain' licenseName = 'Apache License, Version 2.0' licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' localGHPagesRepoDir = '../grain.gh-pages' localGHPagesRepoCanonicalPath = new File(localGHPagesRepoDir).canonicalPath + javaCompatibilityVersion = 1.6 + mainClassName = 'com.sysgears.grain.Main' } +group = 'com.sysgears.grain' +version = project.grainVersion +sourceCompatibility = project.javaCompatibilityVersion +targetCompatibility = project.javaCompatibilityVersion + +defaultTasks 'build' + configurations.all { exclude group: 'commons-logging' exclude group: 'rhino' @@ -38,9 +45,6 @@ configurations { repositories { mavenCentral() - maven { - url 'http://repo.sysgears.com/releases/' - } } dependencies { @@ -128,7 +132,7 @@ task createSharedManifest(dependsOn: getToolsMD5Checksum) { 'Built-Rev': project.toolsMD5, 'Built-Date': new Date(), 'Built-JDK': System.getProperty('java.version'), - 'Main-Class': mainClassName + 'Main-Class': project.mainClassName } }