-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add details and details summary macro (#126)
* Add processors for "details" and "detailsummary" macros Fixes - #101 - #103 * Register macros * Add new templates to README --------- Co-authored-by: Robert Vogel <[email protected]>
- Loading branch information
Showing
13 changed files
with
199 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{{SimplePanel | ||
|type=info | ||
|title={{{headings|}}} | ||
|body={{{cql|}}} | ||
}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{| class="mw-collapsible mw-collapsed wikitable" | ||
! {{{title|}}} | ||
|- | ||
| | ||
{{{body|}}} | ||
|} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{| class="mw-collapsible mw-collapsed wikitable" | ||
! {{{title|}}} | ||
|- | ||
| | ||
{{{body|}}} | ||
|} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace HalloWelt\MigrateConfluence\Converter\Processor; | ||
|
||
/** | ||
* <ac:structured-macro ac:name="details" ac:schema-version="1" ac:macro-id="..."> | ||
* <ac:parameter ac:name="id">control</ac:parameter> | ||
* <ac:rich-text-body> | ||
* <h3>Control details</h3> | ||
* <table class="wrapped"> | ||
*/ | ||
class DetailsMacro extends ConvertMacroToTemplateBase { | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function getMacroName(): string { | ||
return 'details'; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function getWikiTextTemplateName(): string { | ||
return 'Details'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace HalloWelt\MigrateConfluence\Converter\Processor; | ||
|
||
/** | ||
* <ac:structured-macro ac:name="detailssummary" ac:schema-version="3" ac:macro-id="..."> | ||
* <ac:parameter ac:name="firstcolumn">...</ac:parameter> | ||
* <ac:parameter ac:name="headings">...</ac:parameter> | ||
* <ac:parameter ac:name="sortBy">Title</ac:parameter> | ||
* <ac:parameter ac:name="cql">label = "..." and parent = currentContent ( )</ac:parameter> | ||
* </ac:structured-macro> | ||
*/ | ||
class DetailsSummaryMacro extends ConvertMacroToTemplateBase { | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function getMacroName(): string { | ||
return 'detailssummary'; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function getWikiTextTemplateName(): string { | ||
return 'DetailsSummary'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace HalloWelt\MigrateConfluence\Tests\Converter\Processor; | ||
|
||
use DOMDocument; | ||
use HalloWelt\MigrateConfluence\Converter\Processor\DetailsMacro; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class DetailsMacroTest extends TestCase { | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $dir = ''; | ||
|
||
/** | ||
* @covers HalloWelt\MigrateConfluence\Converter\Processor\DetailsMacro::process | ||
* @return void | ||
*/ | ||
public function testProcess() { | ||
$this->dir = dirname( dirname( __DIR__ ) ) . '/data'; | ||
|
||
$input = file_get_contents( "$this->dir/details-macro-input.xml" ); | ||
|
||
$dom = new DOMDocument(); | ||
$dom->loadXML( $input ); | ||
|
||
$processor = new DetailsMacro(); | ||
$processor->process( $dom ); | ||
|
||
$actualOutput = $dom->saveXML( $dom->documentElement ); | ||
$expectedOutput = file_get_contents( "$this->dir/details-macro-output.xml" ); | ||
|
||
$this->assertEquals( $expectedOutput, $actualOutput ); | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
tests/phpunit/Converter/Processor/DetailsSummaryMacroTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace HalloWelt\MigrateConfluence\Tests\Converter\Processor; | ||
|
||
use DOMDocument; | ||
use HalloWelt\MigrateConfluence\Converter\Processor\DetailsSummaryMacro; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class DetailsSummaryMacroTest extends TestCase { | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $dir = ''; | ||
|
||
/** | ||
* @covers HalloWelt\MigrateConfluence\Converter\Processor\DetailsSummaryMacro::process | ||
* @return void | ||
*/ | ||
public function testProcess() { | ||
$this->dir = dirname( dirname( __DIR__ ) ) . '/data'; | ||
|
||
$input = file_get_contents( "$this->dir/detailssummary-macro-input.xml" ); | ||
|
||
$dom = new DOMDocument(); | ||
$dom->loadXML( $input ); | ||
|
||
$processor = new DetailsSummaryMacro(); | ||
$processor->process( $dom ); | ||
|
||
$actualOutput = $dom->saveXML( $dom->documentElement ); | ||
$expectedOutput = file_get_contents( "$this->dir/detailssummary-macro-output.xml" ); | ||
|
||
$this->assertEquals( $expectedOutput, $actualOutput ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<xml xmlns:ac="sample_namespace"> | ||
<ac:structured-macro ac:name="details"> | ||
<ac:parameter ac:name="id">Lorem</ac:parameter> | ||
<ac:rich-text-body> | ||
<h3>Ipsum dolor</h3> | ||
</ac:rich-text-body> | ||
</ac:structured-macro> | ||
</xml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<xml xmlns:ac="sample_namespace"> | ||
{{Details###BREAK### | ||
|id = Lorem###BREAK### | ||
|body = ###BREAK### | ||
|
||
<h3>Ipsum dolor</h3> | ||
}}###BREAK### | ||
|
||
</xml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<xml xmlns:ac="sample_namespace"> | ||
<ac:structured-macro ac:name="detailssummary"> | ||
<ac:parameter ac:name="firstcolumn">Col 1</ac:parameter> | ||
<ac:parameter ac:name="headings">Heading 1, Heading 2, Heading 3, Heading 4</ac:parameter> | ||
<ac:parameter ac:name="sortBy">Title</ac:parameter> | ||
<ac:parameter ac:name="cql">label = "Label 1" and parent = currentContent ( )</ac:parameter> | ||
</ac:structured-macro> | ||
</xml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<xml xmlns:ac="sample_namespace"> | ||
{{DetailsSummary###BREAK### | ||
|firstcolumn = Col 1###BREAK### | ||
|headings = Heading 1, Heading 2, Heading 3, Heading 4###BREAK### | ||
|sortBy = Title###BREAK### | ||
|cql = label = "Label 1" and parent = currentContent ( )###BREAK### | ||
}}###BREAK### | ||
|
||
</xml> |