현재 부모의 모든 자식 페이지를 렌더링하는 간단한 confluence 매크로를 구축하려고합니다. 기본적으로 기존 매크로 사이의 교차 : 하위 표시 및 포함 페이지. 매크로 에 대한 소스 코드 를 살펴 봤지만 confluence에서 처음 개발 한 것이기 때문에 도움이되기보다는 혼란 스러웠습니다.
지금은 execute 메서드를 작업 중이며 confluence 개발이 처음이기 때문에 정확히 무엇이 필요한지 100 % 확신 할 수 없습니다.
이미 Atlassian의 새 Confluence 매크로 만들기 가이드를 읽었 지만 기존 매크로의 속성 목록을 래핑하기 위해 html을 사용한 것 같습니다.
그래서 저는 API , 특히 페이지 를보기로 결정했습니다 . 페이지의 본문을 복사하면 페이지에있는 어린이의 매크로와 스타일이 표시되지 않는다는 것입니다.
@Override
public String execute(Map<String, String> parameters, String body,
ConversionContext context) throws MacroExecutionException {
//loop through each child page and get its content
StringBuilder sb = new StringBuilder();
ContentEntityObject ceo = context.getPageContext().getEntity();
Page parent =(Page) ceo ;
List<Page> children = parent.getChildren();
for(Page child:children)
{
sb.append(child.getBodyAsString());
}
return sb.toString();
}
텍스트뿐만 아니라 모든 것을 어떻게 얻습니까?
또한 플러그인이 작성된 것이므로 Java로 태그를 지정합니다.
우리가 알아 냈습니다.
매크로를 렌더링하기 위해 저장 형식에서보기 형식으로 변환해야했습니다.
{
String converted = xhtmlUtils.convertStorageToView(child.getBodyAsString(), context);
sb.append(converted);
}
튜토리얼을 따르는 경우 xhtmlUtils가 생성자에서 초기화되었습니다.
private final XhtmlContent xhtmlUtils;
public ExampleMacro(XhtmlContent xhtmlUtils)
{
this.xhtmlUtils = xhtmlUtils;
}
또한 Atlassian 답변 의 제안에 따라 주석을 추가했습니다.
@RequiresFormat(Format.Storage)
public String execute(Map<String, String> params, String body, ConversionContext conversionContext) throws MacroExecutionException {
여기서 Format 및 requiresFormat은 이러한 클래스 / 주석입니다.
import com.atlassian.confluence.content.render.xhtml.macro.annotation.Format;
import com.atlassian.confluence.content.render.xhtml.macro.annotation.RequiresFormat
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다