public String render(final RenderContext renderContext, final String linkText, final String url) { final StringBuilder sb = new StringBuilder(); sb.append("<a wysiwyg=\"macro:_appLink\" href=\""); sb.append(url); sb.append("\">"); sb.append(linkText); sb.append("</a>"); if (renderContext.isRenderingForWysiwyg()) { sb.append(" "); } return sb.toString(); } }
private boolean renderAsEditable(Map params, RenderContext renderContext) { String outputType = renderContext.getOutputType(); return !( RenderContext.PDF.equals(outputType) || RenderContext.WORD.equals(outputType) || RenderContext.EMAIL.equals(outputType) || RenderContext.FEED.equals(outputType) || RenderContext.HTML_EXPORT.equals(outputType) || ConfluenceRenderContextOutputType.PAGE_GADGET.toString().equals(outputType) || STATIC_RENDER_MODE.equals(params.get(RENDER_MODE_PARAM)) ); } }
@Nonnull RenderContext getRenderContext(@Nullable IssueRenderContext context) { RenderContext renderContext = new RenderContext(); // Add params from the jira render context if (context != null) { renderContext.getParams().putAll(context.getParams()); renderContext.addParam(ISSUE_CONTEXT_KEY, context.getIssue()); } renderContext.setBaseUrl(velocityRequestContextFactory.getJiraVelocityRequestContext().getCanonicalBaseUrl()); renderContext.pushRenderMode(buildConfiguredRenderMode(context)); return renderContext; }
@Override protected Object getBaseObject( String name ) { return renderContext.getParam( name ); }
@Override protected void setBaseObject( String name, Object value ) { renderContext.addParam( name, value ); }
context.setOutputType(RenderContext.EMAIL); ConversionContext conversionContext = new DefaultConversionContext(context);
buff.append(context.getRenderedContentStore().addInline(render(context, util.group(2), assoc.getInstance(), assoc.getRemoteKey())));
@Override protected Set<String> baseNameSet() { Map<Object, Object> params = renderContext.getParams(); if ( params != null ) { Set<String> names = new java.util.HashSet<String>(); for ( Object o : params.keySet() ) { if ( o instanceof String ) names.add( ( String ) o ); } return names; } return Collections.EMPTY_SET; }
/** * @inheritDoc */ public String locate(RenderContext context) { return searchIssueForKey((Issue) context.getParam(AtlassianWikiRenderer.ISSUE_CONTEXT_KEY)); }
renderContext.setOutputType(RenderContext.EMAIL);
assoc.getRemoteKey()); url = RendererUtils.substituteMatchGroups(url, matcher); buff.append(context.getRenderedContentStore().addInline(render(context, key, url)));
public String execute(Map parameters, String body, RenderContext renderContext) throws MacroException if (renderContext.getParam("com.atlassian.plugin.repository.plugin.RepositoryMacro:running") != null) renderContext.addParam("com.atlassian.plugin.repository.plugin.RepositoryMacro:running", Boolean.TRUE);
public JiraAttachmentLink(GenericLinkParser parser, RenderContext context) throws ParseException { super(parser); Issue issue = (Issue) context.getParam(AtlassianWikiRenderer.ISSUE_CONTEXT_KEY); if(issue == null || issue.getGenericValue() == null) { throw new ParseException("Can not resolve attachment with name " + parser.getAttachmentName() + " no issue in context.", 0); } try { attachment = getAttachment(issue, parser.getAttachmentName()); if (attachment != null) { url = buildAttachmentUrl(context, attachment); setTitle(attachment.getFilename() + " attached to " + issue.getKey()); iconName = ATTACHMENT_ICON; } if (linkBody.startsWith("^") && linkBody.length() > 1) linkBody = linkBody.substring(1); } catch(Exception e) { // just don't create a link attachment = null; } }
public String render(RenderContext renderContext, String linkText, ApplicationInstance app, String remoteKey) { StringBuilder sb = new StringBuilder(); sb.append("<a wysiwyg=\"macro:_appLink\" href=\""); sb.append(buildUrl(linkText, app, remoteKey)); sb.append("\">"); sb.append(linkText); sb.append("</a>"); if (renderContext.isRenderingForWysiwyg()) { sb.append(" "); } return sb.toString(); }
private Option<String> content(ContentEntityObject entity, ContentEntityObject lastVersion, final BodyContent bodyContent) { if (entity.isVersionCommentAvailable()) { return some(blockquote(escapeHtml4(entity.getVersionComment()))); } //we handle multiple page versions but only the latest comment version else if (lastVersion != null && entity instanceof AbstractPage) { boolean renamed = !entity.getTitle().equals(lastVersion.getTitle()); return getEditedPageContent(entity, lastVersion, renamed); } else { RenderContext renderContext = entity.toPageContext(); renderContext.setOutputType(RenderContextOutputType.FEED); if (BodyType.XHTML.equals(bodyContent.getBodyType())) { String xml = stripGadgetMacros(entity, entity.getBodyAsString()); return some(replaceNbsp(xhtmlRenderer.render(xml, new DefaultConversionContext(renderContext)))); } else { return none(); } } }
buff.append(context.getRenderedContentStore().addInline(new LinkDecorator(link)));
public String execute(Map params, String body, RenderContext renderContext) throws MacroException { @SuppressWarnings("unchecked") Map<String, String> typeSafeMacroParams = (Map<String, String>) params; if (!isThumbnailSupported()) { return "<p><span class=\"error\">" + getConfluenceActionSupport().getText("gallery.error.thumbnails-not-supported") + "</span></p>"; } Integer galleryId = nextGalleryId(renderContext); String title = typeSafeMacroParams.get("title"); Thumbnails thumbnails = findThumbnails(typeSafeMacroParams, renderContext); boolean slideshow = renderContext.getOutputType().equals(RenderContextOutputType.DISPLAY); String template = getTemplate(null); VelocityContext contextMap = createVelocityContext(galleryId, title, thumbnails, slideshow); try { return getRenderedTemplateWithoutSwallowingErrors(template, contextMap); } catch (ResourceNotFoundException e) { return "<p><span class='error'>" + getConfluenceActionSupport().getText("gallery.error.unable-to-find-render-template", new String[]{escapeHtml4(typeSafeMacroParams.get("theme"))}) + "</span></p>"; } catch (Exception exception) { log.error("Error while trying to draw the image gallery", exception); return "<p><span class='error'>" + getConfluenceActionSupport().getText("gallery.error.unable-to-render", new String[]{escapeHtml4(exception.toString())}) + "</span></p>"; } }
public RendererAttachment getAttachment(RenderContext context, EmbeddedResource resource) { // Make sure we have an issue and a usable issueGV from the issue Issue issue = (Issue) context.getParam(AtlassianWikiRenderer.ISSUE_CONTEXT_KEY); if (resource.isInternal() && issue == null || issue.getGenericValue() == null) { log.debug("No usable issue stored in the context, unable to resolve filename '" + resource.getFilename() + "'"); throw new RuntimeException("No usable issue stored in the context, unable to resolve filename '" + resource.getFilename() + "'"); } Attachment attachment = null; Collection<Attachment> attachments; attachments = issue.getAttachments(); for (final Attachment tempAttachement : attachments) { if (tempAttachement.getFilename().equals(resource.getFilename())) { // Since the list is sorted by filename and date we know the first is the most recent attachment = tempAttachement; break; } } if (attachment == null) { return null; } else { return convertToRendererAttachment(attachment, context, resource); } }
private static void writeHeader(RenderContext renderContext, StringBuilder buffer, String title, String borderStyle, String borderColor, int borderWidth, String titleBackgroundColor, String panelHeaderCSSClass) { buffer.append("<div class=\"").append(panelHeaderCSSClass).append("\"").append( renderContext.isRenderingForWysiwyg() ? " wysiwyg=\"ignore\" " : ""); buffer.append(" style=\""); buffer.append("border-bottom-width: ").append(borderWidth).append("px;"); if (borderWidth > 0) { if (isNotBlank(borderStyle)) buffer.append("border-bottom-style: ").append(borderStyle).append(";"); if (isNotBlank(borderColor)) buffer.append("border-bottom-color: ").append(borderColor).append(";"); } if (isNotBlank(titleBackgroundColor)) buffer.append("background-color: ").append(titleBackgroundColor).append(";"); buffer.append("\""); buffer.append("><b>"); buffer.append(StringEscapeUtils.escapeHtml4(title)); buffer.append("</b></div>"); }