Search in sources :

Example 81 with StringOutput

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;
}
Also used : StringOutput(org.olat.core.gui.render.StringOutput)

Example 82 with StringOutput

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;
}
Also used : StringOutput(org.olat.core.gui.render.StringOutput)

Example 83 with StringOutput

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;
}
Also used : StringOutput(org.olat.core.gui.render.StringOutput)

Example 84 with StringOutput

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));
}
Also used : Path(java.nio.file.Path) VelocityContext(org.apache.velocity.VelocityContext) ParseErrorException(org.apache.velocity.exception.ParseErrorException) FileVisitResult(java.nio.file.FileVisitResult) StringOutput(org.olat.core.gui.render.StringOutput) IOException(java.io.IOException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ResourceNotFoundException(org.apache.velocity.exception.ResourceNotFoundException) File(java.io.File) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes)

Example 85 with StringOutput

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();
}
Also used : StringOutput(org.olat.core.gui.render.StringOutput)

Aggregations

StringOutput (org.olat.core.gui.render.StringOutput)188 IOException (java.io.IOException)48 URLBuilder (org.olat.core.gui.render.URLBuilder)30 Renderer (org.olat.core.gui.render.Renderer)26 Block (uk.ac.ed.ph.jqtiplus.node.content.basic.Block)24 RenderResult (org.olat.core.gui.render.RenderResult)22 Component (org.olat.core.gui.components.Component)10 Translator (org.olat.core.gui.translator.Translator)10 Locale (java.util.Locale)8 Window (org.olat.core.gui.components.Window)8 Form (org.olat.core.gui.components.form.flexible.impl.Form)8 VelocityRenderDecorator (org.olat.core.gui.render.velocity.VelocityRenderDecorator)8 ArrayList (java.util.ArrayList)6 StreamResult (javax.xml.transform.stream.StreamResult)6 Test (org.junit.Test)6 GlobalSettings (org.olat.core.gui.GlobalSettings)6 ComponentRenderer (org.olat.core.gui.components.ComponentRenderer)6 DefaultColumnDescriptor (org.olat.core.gui.components.table.DefaultColumnDescriptor)6 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)6 Matcher (java.util.regex.Matcher)5