use of org.olat.core.gui.render.StringOutput in project OpenOLAT by OpenOLAT.
the class WikiMarkupRenderer method render.
/**
* @see org.olat.core.gui.components.ComponentRenderer#render(org.olat.core.gui.render.Renderer,
* org.olat.core.gui.render.StringOutput,
* org.olat.core.gui.components.Component,
* org.olat.core.gui.render.URLBuilder,
* org.olat.core.gui.translator.Translator,
* org.olat.core.gui.render.RenderResult, java.lang.String[])
*/
@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
WikiMarkupComponent wikiComp = (WikiMarkupComponent) source;
AJAXFlags flags = renderer.getGlobalSettings().getAjaxFlags();
boolean iframePostEnabled = flags.isIframePostEnabled();
ParserInput input = new ParserInput();
input.setWikiUser(null);
input.setAllowSectionEdit(false);
input.setDepth(10);
input.setContext("");
// input.setTableOfContents(null);
input.setLocale(new Locale("en"));
// input.setVirtualWiki(Long.toString(wikiComp.getOres().getResourceableId()));
input.setTopicName("dummy");
input.setUserIpAddress("0.0.0.0");
OlatWikiDataHandler dataHandler = new OlatWikiDataHandler(wikiComp.getOres(), wikiComp.getImageBaseUri());
input.setDataHandler(dataHandler);
StringOutput out = new StringOutput(100);
ubu.buildURI(out, null, null, iframePostEnabled ? AJAXFlags.MODE_TOBGIFRAME : AJAXFlags.MODE_NORMAL);
String uri = out.toString();
ParserDocument parsedDoc = null;
String uniqueId = "o_wiki".concat(wikiComp.getDispatchID());
try {
uri = URLDecoder.decode(uri, "utf-8");
input.setVirtualWiki(uri.substring(1, uri.length() - 1));
if (iframePostEnabled) {
String targetUrl = " onclick=\"o_XHREvent(jQuery(this).attr('href'),false,true); return false;\"";
input.setURLTarget(targetUrl);
}
sb.append("<div style=\"min-height:" + wikiComp.getMinHeight() + "px\" id=\"");
sb.append(uniqueId);
sb.append("\">");
JFlexParser parser = new JFlexParser(input);
parsedDoc = parser.parseHTML(wikiComp.getWikiContent());
} catch (UnsupportedEncodingException e) {
// encoding utf-8 should be ok
} catch (Exception e) {
throw new OLATRuntimeException(this.getClass(), "error while rendering wiki page with content:" + wikiComp.getWikiContent(), e);
}
// Use global js math formatter for latex formulas
sb.append(Formatter.formatLatexFormulas(parsedDoc.getContent()));
sb.append("</div>");
// set targets of media, image and external links to target "_blank"
sb.append("<script type=\"text/javascript\">/* <![CDATA[ */ ");
String instanceUrl = Settings.getServerContextPathURI();
sb.append("changeAnchorTargets('").append(uniqueId).append("','").append(instanceUrl).append("');");
sb.append("/* ]]> */</script>");
}
use of org.olat.core.gui.render.StringOutput in project OpenOLAT by OpenOLAT.
the class ExportBinderAsCPResource method renderVelocityContainer.
private String renderVelocityContainer(VelocityContainer mainVC) {
StringOutput sb = new StringOutput(32000);
URLBuilder ubu = new URLBuilder("auth", "1", "0");
Renderer renderer = Renderer.getInstance(mainVC, translator, ubu, new RenderResult(), new EmptyGlobalSettings());
VelocityRenderDecorator vrdec = new VelocityRenderDecorator(renderer, mainVC, sb);
mainVC.contextPut("r", vrdec);
renderer.render(sb, mainVC, null);
return sb.toString();
}
use of org.olat.core.gui.render.StringOutput in project OpenOLAT by OpenOLAT.
the class ExportBinderAsPDFResource method createResultHTML.
private String createResultHTML(Component content) {
String pagePath = Util.getPackageVelocityRoot(this.getClass()) + "/export.html";
VelocityContainer mainVC = new VelocityContainer("html", pagePath, translator, null);
mainVC.put("cmp", content);
mainVC.contextPut("bodyCssClass", "o_portfolio_export");
StringOutput sb = new StringOutput(32000);
URLBuilder ubu = new URLBuilder("auth", "1", "0");
Renderer renderer = Renderer.getInstance(mainVC, translator, ubu, new RenderResult(), new EmptyGlobalSettings());
VelocityRenderDecorator vrdec = new VelocityRenderDecorator(renderer, mainVC, sb);
mainVC.contextPut("r", vrdec);
renderer.render(sb, mainVC, null);
return sb.toString();
}
use of org.olat.core.gui.render.StringOutput in project OpenOLAT by OpenOLAT.
the class CPPrintMapper method injectJavascriptAndCss.
private void injectJavascriptAndCss(StringBuilder output) {
StringOutput sb = new StringOutput();
sb.append("<!--[if lt IE 9]>");
sb.append("<script type=\"text/javascript\" src=\"");
StaticMediaDispatcher.renderStaticURI(sb, "js/jquery/jquery-1.9.1.min.js");
sb.append("\")'></script>");
sb.append("<![endif]-->");
sb.append("<!--[if gte IE 9]><!-->");
sb.append("<script type=\"text/javascript\" src=\"");
StaticMediaDispatcher.renderStaticURI(sb, "js/jquery/jquery-2.1.3.min.js");
sb.append("\")'></script>");
sb.append("<!--<![endif]-->");
output.append(sb.toString());
output.append("<link href=\"").append(themeBaseUri).append("all/content.css\" rel=\"stylesheet\" type=\"text/css\" />\n");
}
use of org.olat.core.gui.render.StringOutput in project OpenOLAT by OpenOLAT.
the class RESTDispatcher method getRedirectToURL.
private String getRedirectToURL(UserSession usess) {
ChiefController cc = Windows.getWindows(usess).getChiefController();
Window w = cc.getWindow();
URLBuilder ubu = new URLBuilder(WebappHelper.getServletContextPath() + DispatcherModule.PATH_AUTHENTICATED, w.getInstanceId(), String.valueOf(w.getTimestamp()));
StringOutput sout = new StringOutput(30);
ubu.buildURI(sout, null, null);
return sout.toString();
}
Aggregations