Skip to content

Commit

Permalink
Merge branch 'release/7.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
Build Pipeline committed Mar 23, 2023
2 parents d6f4ef7 + e2bf264 commit c537baa
Show file tree
Hide file tree
Showing 24 changed files with 344 additions and 96 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ It is a **Maven plugin** that generates **project's documentation directly to co
## Examples

For pratical samples refer to folder/module [test-publishing](https://github.com/bsorrentino/maven-confluence-plugin/tree/master/test-publishing)
For practical samples refer to folder/module [test-publishing](https://github.com/bsorrentino/maven-confluence-plugin/tree/master/test-publishing)

## News

Date | Release | Info
------------------|-------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| **Mar 23, 2023** | [Release 7.11](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.11) | Support of Confluence `Excerpt` macro. Refer to [#285](https://github.com/bsorrentino/maven-confluence-plugin/issues/285) |
| **Mar 4, 2023** | [Release 7.10](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.10) | Allow to skip html tags in markdown processing. Refer to [#284](https://github.com/bsorrentino/maven-confluence-plugin/issues/284) |
| **Jan 4, 2023** | [Release 7.9](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.9) | Fix problem Problem parsing `%` character from markdown to wiki. Refer to [#282](https://github.com/bsorrentino/maven-confluence-plugin/issues/282) |
| **Dec 9, 2022** | [Release 7.8](https://github.com/bsorrentino/maven-confluence-plugin/releases/tag/v7.8) | Merged PR [#281](https://github.com/bsorrentino/maven-confluence-plugin/pull/281) that fix [#280](https://github.com/bsorrentino/maven-confluence-plugin/issue/280) "**allows specifying additional HTTP headers in the servers section of settings.xml**". Thanks to [DirkMahler](https://github.com/DirkMahler) for contribution. |
Expand Down
2 changes: 1 addition & 1 deletion addon-scrollversions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>maven-confluence-parent</artifactId>
<groupId>org.bsc.maven</groupId>
<version>7.10</version>
<version>7.11</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>maven-confluence-parent</artifactId>
<groupId>org.bsc.maven</groupId>
<version>7.10</version>
<version>7.11</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
40 changes: 21 additions & 19 deletions core/src/main/java/org/bsc/confluence/model/SiteProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,18 @@ public static <T> T processUri(
*
* @param site
* @param child
* @param page
* @param page - Nullable
* @param uri
* @param pagePrefixToApply
* @param pagePrefixToApply - Nullable
* @param <P>
* @return
*/
public static <P extends Site.Page> CompletableFuture<PageContent> processPageUri(
final Site site,
final P child,
final Optional<Model.Page> page,
final Model.Page page,
final java.net.URI uri,
final Optional<String> pagePrefixToApply)
final String pagePrefixToApply)
{
requireNonNull(uri, "uri is null!");

Expand Down Expand Up @@ -196,20 +196,22 @@ public static <P extends Site.Page> CompletableFuture<PageContent> processPageUr
return result;
}


/**
*
* @param uri
* @return
* @throws Exception
*/
*
* @param site
* @param child
* @param uri
* @param homePageTitle - Nullable
* @return
* @param <P>
*/
public static
<P extends Site.Page> CompletableFuture<PageContent>
processUriContent(
final Site site,
final P child,
final java.net.URI uri,
final Optional<String> homePageTitle )
final String homePageTitle )
{
requireNonNull(uri, "uri is null!");

Expand Down Expand Up @@ -243,7 +245,7 @@ public static <P extends Site.Page> CompletableFuture<PageContent> processPageUr
try {
final String candidateContent = IOUtils.toString(is.get(), Charset.defaultCharset());

content = (isMarkdown) ? processMarkdown(site, child, empty(), candidateContent, homePageTitle) : candidateContent;
content = (isMarkdown) ? processMarkdown(site, child, null, candidateContent, homePageTitle) : candidateContent;

} catch (IOException e) {
result.completeExceptionally( new Exception( format("error processing page [%s] ", source)));
Expand All @@ -260,7 +262,7 @@ public static <P extends Site.Page> CompletableFuture<PageContent> processPageUr
final String candidateContent = IOUtils.toString(is, Charset.defaultCharset());

content = (isMarkdown) ?
processMarkdown( site, child, empty(), candidateContent, homePageTitle) :
processMarkdown( site, child, null, candidateContent, homePageTitle) :
candidateContent;

} catch (IOException e) {
Expand All @@ -277,18 +279,18 @@ public static <P extends Site.Page> CompletableFuture<PageContent> processPageUr
*
* @param site
* @param child
* @param page
* @param page - Nullable
* @param content
* @param pagePrefixToApply
* @param pagePrefixToApply - Nullable
* @return
* @throws IOException
*/
public static String processMarkdown(
final Site site,
final Site.Page child,
final Optional<ConfluenceService.Model.Page> page,
final ConfluenceService.Model.Page page,
final String content,
final Optional<String> pagePrefixToApply) throws IOException {
final String pagePrefixToApply) throws IOException {

return MarkdownProcessor.shared.processMarkdown(new MarkdownParserContext() {
@Override
Expand All @@ -308,14 +310,14 @@ public Optional<Site.Page> getPage() {

@Override
public Optional<String> getPagePrefixToApply() {
return pagePrefixToApply;
return Optional.of(pagePrefixToApply);
}

@Override
public boolean isLinkPrefixEnabled() {
if( child.isIgnoreVariables() ) return false;

return page.map( p -> !p.getTitle().contains("[") ).orElse(true);
return Optional.of(page).map( p -> !p.getTitle().contains("[") ).orElse(true);

}
}, content);
Expand Down
37 changes: 31 additions & 6 deletions core/src/main/java/org/bsc/markdown/MarkdownVisitorHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.nio.file.Paths;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -141,11 +140,23 @@ public static String processLinkUrl( String url, MarkdownParserContext parseCont
// }

/**
*
* [Match multiline text using regular expression](https://stackoverflow.com/a/3652392/521197)
*/
private static Pattern isConfluenceMacroPattern = Pattern.compile( "^[\\s]*\\{([\\w-]+)(([:][\\w-]+(=(.+))?)([|].+)*)?\\}[\\s]*$" );
private static Pattern isConfluenceVariable = Pattern.compile( "^[\\s]*\\$\\{([\\w-\\.]+)\\}[\\s]*$" );
private static Pattern isConfluenceMacroPattern = Pattern.compile( "^[\\s]*\\{([\\w-]+)(([:][\\w-]+(=(.+))?)([|].+)*)?\\}[\\s]*$", Pattern.DOTALL );
private static Pattern confluenceMacroWithContentPattern = Pattern.compile("^\\s*(\\{.+\\})(.+)(\\{.+\\})\\s*$", Pattern.DOTALL );
private static Pattern isConfluenceVariablePattern = Pattern.compile( "^[\\s]*\\$\\{([\\w-\\.]+)\\}[\\s]*$" );

/**
*
* @param text
* @return
*/
public static boolean isConfluenceMacroOrVariable( String text ) {
// GUARD
if( text == null || text.isEmpty() ) return false;
return isConfluenceMacroPattern.matcher(text).matches() ||
isConfluenceVariablePattern.matcher(text).matches();
}
/**
*
* @param text
Expand All @@ -154,8 +165,22 @@ public static String processLinkUrl( String url, MarkdownParserContext parseCont
public static boolean isConfluenceMacro( String text ) {
// GUARD
if( text == null || text.isEmpty() ) return false;
return isConfluenceMacroPattern.matcher(text).matches() ||
isConfluenceVariable.matcher(text).matches();
return isConfluenceMacroPattern.matcher(text).matches();
}

public static boolean isConfluenceVariable( String text ) {
// GUARD
if( text == null || text.isEmpty() ) return false;
return isConfluenceVariablePattern.matcher(text).matches();
}

/**
*
* @param text
* @return
*/
public static Matcher parseConfluenceMacro( @NonNull String text ) {
return confluenceMacroWithContentPattern.matcher(text);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions core/src/test/kotlin/org/bsc/markdown/MacroParsingTest.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.bsc.markdown

import org.bsc.markdown.MarkdownVisitorHelper.isConfluenceMacro
import org.bsc.markdown.MarkdownVisitorHelper.isConfluenceMacroOrVariable
import org.junit.Test
import org.junit.jupiter.api.Assertions.assertTrue

Expand Down Expand Up @@ -44,7 +44,7 @@ class MacroParsingTest {

for( literal in macros ) {
println( "evaluate macro $literal")
assertTrue( isConfluenceMacro(literal) )
assertTrue( isConfluenceMacroOrVariable(literal) )
}

}
Expand Down
2 changes: 1 addition & 1 deletion gitlog+jira/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>maven-confluence-parent</artifactId>
<groupId>org.bsc.maven</groupId>
<version>7.10</version>
<version>7.11</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion plugin-reporting/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>maven-confluence-parent</artifactId>
<groupId>org.bsc.maven</groupId>
<version>7.10</version>
<version>7.11</version>
</parent>

<prerequisites>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,21 +278,21 @@ protected <S extends Site.Source> String getPrintableStringForResource(S source)
/**
*
* @param <T>
* @param pageToUpdate
* @param pageToUpdate - Nullable
* @param site
* @param source
* @param child
* @param pageTitleToApply
* @return
*/
private <T extends Site.Page> CompletableFuture<Storage> getPageContent(
final Optional<Model.Page> pageToUpdate,
final Model.Page pageToUpdate,
final Site site,
final java.net.URI source,
final T child,
final String pageTitleToApply)
{
final Optional<String> pagePrefixToApply = (isChildrenTitlesPrefixed()) ? ofNullable(this.getPageTitle()) : empty();
final String pagePrefixToApply = (isChildrenTitlesPrefixed()) ? this.getPageTitle() : null;

return processPageUri(site, child, pageToUpdate, source, pagePrefixToApply)
.thenCompose( content -> {
Expand Down Expand Up @@ -413,13 +413,13 @@ protected <T extends Site.Page> Model.Page generateChild(final ConfluenceService
// Update Page Inline Function
final AsyncProcessPageFunc updatePageFunction = p ->
updatePageIfNeeded(child,p,
() -> getPageContent( ofNullable(p), site, uri, child, pageTitleToApply )
() -> getPageContent( p, site, uri, child, pageTitleToApply )
.thenCompose( storage -> confluence.storePage(p, storage))
.thenCompose( page -> saveAttributesToDeployStateManager(child, page )));

// Create Page Function
final AsyncPageSupplier createPageFunction = () ->
getPageContent( empty(), site, uri, child, pageTitleToApply )
getPageContent( null, site, uri, child, pageTitleToApply )
.thenCompose( storage -> confluence.createPage(parentPage, pageTitleToApply, storage))
.thenCompose( page -> saveAttributesToDeployStateManager(child, page ));

Expand Down Expand Up @@ -549,10 +549,10 @@ private void processProperties(Site site) {
*/
private CompletableFuture<String> processUriContent(Site site, Site.Page child, java.net.URI uri, final Charset charset) {

final Optional<String> pagePrefixToApply =
final String pagePrefixToApply =
(isChildrenTitlesPrefixed()) ?
ofNullable(this.getPageTitle()) :
empty();
this.getPageTitle() :
null;

return SiteProcessor.processUriContent(site, child, uri, pagePrefixToApply)
.thenApply( pageContent -> pageContent.getContent(charset) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,17 +491,24 @@ private CompletableFuture<Boolean> removeSnaphot(

}

/**
*
* @param site
* @param homePage - Nullable
* @param locale
* @return
*/
private CompletableFuture<Storage> getHomeContent(
final Site site,
final Optional<Model.Page> homePage,
final Model.Page homePage,
final Locale locale )
{

final Site.Page home = site.getHome();
final java.net.URI uri = home.getUri();
final Optional<String> pagePrefixToApply = (isChildrenTitlesPrefixed())
? ofNullable(this.getPageTitle())
: Optional.empty();
final String pagePrefixToApply = (isChildrenTitlesPrefixed())
? this.getPageTitle()
: null;

return processPageUri( site, home, homePage, uri, pagePrefixToApply)
.thenCompose( content -> {
Expand Down Expand Up @@ -545,11 +552,11 @@ private void generateProjectReport(

final AsyncProcessPageFunc updateHomePage = p ->
updatePageIfNeeded(site.getHome(), p, () ->
getHomeContent(site, Optional.of(p), locale)
getHomeContent(site, p, locale)
.thenCompose( content -> confluence.storePage(p, content )));

final AsyncProcessPageFunc createHomePage = _parentPage ->
getHomeContent( site, Optional.empty(), locale )
getHomeContent( site, null, locale )
.thenCompose( content -> confluence.createPage(_parentPage, _homePageTitle,content) );


Expand Down Expand Up @@ -803,14 +810,14 @@ void generateGoalsPages(final ConfluenceService confluence,
/**
*
* @param site
* @param homePage
* @param homePage - Nullable
* @param pluginDescriptor
* @param locale
* @return
*/
private CompletableFuture<Storage> getHomeContent(
final Site site,
final Optional<Model.Page> homePage,
final Model.Page homePage,
final PluginDescriptor pluginDescriptor,
final Locale locale)
{
Expand All @@ -826,9 +833,9 @@ private CompletableFuture<Storage> getHomeContent(
}

final String title = getPageTitle();
final Optional<String> pagePrefixToApply = (isChildrenTitlesPrefixed())
? ofNullable(getPageTitle())
: Optional.empty();
final String pagePrefixToApply = (isChildrenTitlesPrefixed())
? getPageTitle()
: null ;

return processPageUri(site, site.getHome(), homePage, site.getHome().getUri(), pagePrefixToApply )
.thenCompose( content -> {
Expand Down Expand Up @@ -930,11 +937,11 @@ private CompletableFuture<Model.Page> updateHomeContent(
}

final String title = getPageTitle();
final Optional<String> pagePrefixToApply = (isChildrenTitlesPrefixed())
? ofNullable(getPageTitle())
: Optional.empty();
final String pagePrefixToApply = (isChildrenTitlesPrefixed())
? getPageTitle()
: null ;

return processPageUri(site, site.getHome(), Optional.of(homePage), site.getHome().getUri(), pagePrefixToApply )
return processPageUri(site, site.getHome(), homePage, site.getHome().getUri(), pagePrefixToApply )
.thenCompose( content -> {

try {
Expand Down Expand Up @@ -1042,11 +1049,11 @@ public Model.Page processMojoDescriptors(

final Function<Model.Page, CompletableFuture<Model.Page>> updatePage = (p) ->
updatePageIfNeeded( site.getHome(),p,
() -> getHomeContent( site, Optional.of(p), pluginDescriptor, locale)
() -> getHomeContent( site, p, pluginDescriptor, locale)
.thenCompose( content -> confluence.storePage(p, content)));

final Function<Model.Page, CompletableFuture<Model.Page>> createPage = (parent) ->
getHomeContent(site, Optional.empty(), pluginDescriptor, locale)
getHomeContent(site, null, pluginDescriptor, locale)
.thenCompose( content ->confluence.createPage(parent, title, content));

return removeSnaphot(confluence, parentPage, title)
Expand Down
Loading

0 comments on commit c537baa

Please sign in to comment.