use of org.olat.core.gui.render.StringOutput in project openolat by klemens.
the class VelocityRenderDecorator method relLink.
/**
* Note: use only rarely - e.g. for static redirects to login screen or to a
* special dispatcher. Renders a uri which is mounted to the webapp/ directory
* of your webapplication.
* <p>
* For static references (e.g. images which cannot be delivered using css):
* use renderStaticURI instead!
*/
public StringOutput relLink(String URI) {
StringOutput sb = new StringOutput(100);
Renderer.renderNormalURI(sb, URI);
return sb;
}
use of org.olat.core.gui.render.StringOutput in project openolat by klemens.
the class VelocityRenderDecorator method commandURI.
/**
* @param command
* @return
*/
public StringOutput commandURI(String command) {
StringOutput sb = new StringOutput(100);
renderer.getUrlBuilder().buildURI(sb, new String[] { VelocityContainer.COMMAND_ID }, new String[] { command });
return sb;
}
use of org.olat.core.gui.render.StringOutput in project openolat by klemens.
the class VelocityRenderDecorator method staticLink.
/**
* e.g. "images/somethingicannotdowithcss.jpg" -> /olat/raw/61x/images/somethingicannotdowithcss.jpg"
* with /olat/raw/61x/ mounted to webapp/static directory of your webapp
*
* @param URI
* @return
*/
public StringOutput staticLink(String URI) {
StringOutput sb = new StringOutput(100);
Renderer.renderStaticURI(sb, URI);
return sb;
}
use of org.olat.core.gui.render.StringOutput in project openolat by klemens.
the class VelocityTemplatesPreWarm method run.
@Override
public void run() {
long start = System.nanoTime();
log.info("Start filling the velocity template cache");
final VelocityContext context = new VelocityContext();
final AtomicInteger numOfTemplates = new AtomicInteger(0);
final File root = new File(WebappHelper.getContextRoot(), "WEB-INF/classes");
final Path fPath = root.toPath();
try {
if (Files.exists(fPath)) {
Files.walkFileTree(fPath, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
try {
String path = fPath.relativize(file).toString();
if (path.endsWith(".html") && path.contains("/_content/")) {
StringOutput writer = new StringOutput();
VelocityHelper.getInstance().mergeContent(path, context, writer, null);
numOfTemplates.incrementAndGet();
}
} catch (ResourceNotFoundException e) {
log.error("", e);
} catch (ParseErrorException e) {
log.error("", e);
}
return FileVisitResult.CONTINUE;
}
});
}
} catch (IOException e) {
log.error("", e);
}
log.info("Velocity cache filled with " + numOfTemplates + " templates in (ms): " + CodeHelper.nanoToMilliTime(start));
}
use of org.olat.core.gui.render.StringOutput in project openolat by klemens.
the class Theme method init.
/**
* Update values in this theme with the values from the given identifyer.
*
* @param theme
*/
public void init(String themeIdentifyer) {
this.identifyer = themeIdentifyer;
// Themes are delivered as static resources by StaticMediaDispatcher
this.relPathToThemesDir = "themes/" + themeIdentifyer + "/";
StringOutput themePath = new StringOutput();
StaticMediaDispatcher.renderStaticURI(themePath, relPathToThemesDir);
this.baseURI = themePath.toString();
// Check if theme has a custom JS file to tweak UI on JS level
hasCustomJSFile = getCustomJSFile().exists();
}
Aggregations