if (!(velocityContext instanceof ToolContext)) {
return;
}
ToolContext ctxt = (ToolContext) velocityContext;
Object projectObj = ctxt.get("project");
if (projectObj instanceof MavenProject) {
MavenProject project = (MavenProject) projectObj;
String artifactId = project.getArtifactId();
// use artifactId "sluggified" as the projectId
projectId = HtmlTool.slug(artifactId);
}
// calculate the page ID from the current file name
Object currentFileObj = ctxt.get("currentFileName");
if (currentFileObj instanceof String) {
String currentFile = (String) currentFileObj;
// drop the extension
int lastDot = currentFile.lastIndexOf(".");
if (lastDot >= 0) {
currentFile = currentFile.substring(0, lastDot);
}
// get the short ID (in case of nested files)
// String fileName = new File(currentFile).getName();
// fileShortId = HtmlTool.slug(fileName);
// full file ID includes the nested dirs
// replace nesting "/" with "-"
fileId = HtmlTool.slug(currentFile.replace("/", "-").replace("\\", "-"));
}
Object decorationObj = ctxt.get("decoration");
if (!(decorationObj instanceof DecorationModel)) {
return;
}