/** * Generate the footnote reference (link) that should be inserted at the location of the macro, and should point to * the actual footnote at the end of the document. * * @param counter the current footnote counter * @return the generated reference element, displayed as {@code (superscript(link(footnote index)))} */ private Block createFootnoteReferenceBlock(int counter) { Block result = new WordBlock(String.valueOf(counter)); DocumentResourceReference reference = new DocumentResourceReference(null); reference.setAnchor(FOOTNOTE_ID_PREFIX + counter); result = new LinkBlock(Collections.singletonList(result), reference, false); result = new FormatBlock(Collections.singletonList(result), Format.SUPERSCRIPT); result.setParameter(ID_ATTRIBUTE_NAME, FOOTNOTE_REFERENCE_ID_PREFIX + counter); result.setParameter(CLASS_ATTRIBUTE_NAME, "footnoteRef"); return result; }
@Override public Block execute(BlockAsyncRenderer renderer, AsyncRendererConfiguration configuration) throws JobException, RenderingException { // Start renderer execution if there is none already running/available AsyncRendererExecutorResponse response = this.executor.render(renderer, configuration); // Get result BlockAsyncRendererResult result = (BlockAsyncRendererResult) response.getStatus().getResult(); if (result != null) { return result.getBlock(); } // Return a placeholder waiting for the result Block placeholder; if (renderer.isInline()) { placeholder = new FormatBlock(); } else { placeholder = new GroupBlock(); } placeholder.setParameter("class", "xwiki-async"); // Provide it directly as it's going to be used in the client side (the URL fragment to use in the ajax request) placeholder.setParameter("data-xwiki-async-id", response.getJobIdHTTPPath()); placeholder.setParameter("data-xwiki-async-client-id", response.getAsyncClientId().toString()); return placeholder; } }
String oldClass = container.getParameter(CLASS_ATTRIBUTE); String newClass = "container-columns container-columns-" + count; container.setParameter(CLASS_ATTRIBUTE, StringUtils.isEmpty(oldClass) ? newClass : oldClass + " " + newClass); container.addChild(new GroupBlock(clearFloatsParams));
reference.setAnchor(FOOTNOTE_REFERENCE_ID_PREFIX + counter); result = new LinkBlock(Collections.singletonList(result), reference, false); result.setParameter(ID_ATTRIBUTE_NAME, FOOTNOTE_ID_PREFIX + counter); result.setParameter(CLASS_ATTRIBUTE_NAME, "footnoteBackRef"); result = new ListItemBlock(Collections.singletonList(result)); result.addChild(new SpaceBlock());