Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix/improvements for documentation. Now the external URLs can be cent…
…ralized into Config.groovy
- Loading branch information
Showing
9 changed files
with
58 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,55 @@ | ||
import grails.util.Holders | ||
|
||
eventDocStart = { kind -> | ||
println "Started $kind" | ||
|
||
if (kind == "refdocs") { | ||
//the purpose of this custom macro is to centralize external URLs | ||
//into Config.groovy Usage: | ||
//{externalink:urlPropertyId@additional/path} | ||
//If no content is provide the generated URL is used in its place. | ||
|
||
org.radeox.macro.MacroLoader.newInstance().add( | ||
org.radeox.macro.MacroRepository.instance, | ||
new org.radeox.macro.Preserved() { | ||
|
||
@Override | ||
String getName() { | ||
'externalink' | ||
} | ||
|
||
@Override | ||
void setInitialContext(org.radeox.api.engine.context.InitialRenderContext context) { | ||
super.setInitialContext(context) | ||
} | ||
|
||
@Override | ||
void execute(Writer writer, org.radeox.macro.parameter.MacroParameter params) { | ||
def content = params.content | ||
def tagValue = params.get("0") | ||
def tagSplitted = tagValue.split("@") | ||
def propertyId = tagSplitted[0] | ||
def urlSegments = tagSplitted.length > 1 ? tagSplitted[1] : '' | ||
def baseUrl = Holders.config.flatten().get(propertyId) | ||
|
||
if (content == null) { | ||
content = baseUrl + "/" + urlSegments | ||
} | ||
|
||
writer << "<span class=\"nobr\">" | ||
writer << "<a href=\"" | ||
writer << baseUrl + "/" + urlSegments | ||
writer << "\" target=\"blank\">" | ||
writer << content | ||
writer << "</a></span>" | ||
} | ||
}) | ||
|
||
println "macro externalink added" | ||
} | ||
} | ||
|
||
eventDocEnd = { kind -> | ||
println "Completed $kind" | ||
/*new File("../img").eachFile() { file -> | ||
println file.getName() | ||
}*/ | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters