Confluences bugfixes, Fix documentation
Make it easier to spot where an error comes from when uploading to confluence. Allow to upload documentation without a prefix.
This commit is contained in:
parent
8e7340da3d
commit
59b8c04161
@ -63,7 +63,7 @@ Preformatted blocks are useful for ASCII art:
|
|||||||
,-.
|
,-.
|
||||||
, ,-. ,-.
|
, ,-. ,-.
|
||||||
/ \ ( )-( )
|
/ \ ( )-( )
|
||||||
\ | ,.>-( )-<
|
\ | ,.>-( )-<
|
||||||
\|,' ( )-( )
|
\|,' ( )-( )
|
||||||
Y ___`-' `-'
|
Y ___`-' `-'
|
||||||
|/__/ `-'
|
|/__/ `-'
|
||||||
|
@ -16,3 +16,7 @@ Code Highlight | √ | X (Planned) | √ (Using macros)
|
|||||||
Live Mode | √ | X | X
|
Live Mode | √ | X | X
|
||||||
Pages Ordering | √ | √ | X (API Limitation)
|
Pages Ordering | √ | √ | X (API Limitation)
|
||||||
Google / Piwik analytics | √ | √ | √ (Configured on Conflence)
|
Google / Piwik analytics | √ | √ | √ (Configured on Conflence)
|
||||||
|
|
||||||
|
## Confluence Example
|
||||||
|
|
||||||
|
You can see this documentation uploaded to Confluence : https://dauxio.atlassian.net/wiki/spaces/DOC/overview
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<div class=row>
|
<div class="row">
|
||||||
<div class=col-third>
|
<div class="col-third">
|
||||||
|
|
||||||
#### For Authors
|
#### For Authors
|
||||||
|
|
||||||
@ -24,7 +24,7 @@
|
|||||||
* [Table of Contents](01_Features/Table_of_contents.md)
|
* [Table of Contents](01_Features/Table_of_contents.md)
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class=col-third>
|
<div class="col-third">
|
||||||
|
|
||||||
#### For Developers
|
#### For Developers
|
||||||
|
|
||||||
@ -34,7 +34,7 @@
|
|||||||
* Work with pages metadata
|
* Work with pages metadata
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class=col-third>
|
<div class="col-third">
|
||||||
|
|
||||||
#### For Marketing
|
#### For Marketing
|
||||||
|
|
||||||
|
@ -29,5 +29,10 @@
|
|||||||
"GitHub Repo": "https://github.com/dauxio/daux.io",
|
"GitHub Repo": "https://github.com/dauxio/daux.io",
|
||||||
"Help/Support/Bugs": "https://github.com/dauxio/daux.io/issues"
|
"Help/Support/Bugs": "https://github.com/dauxio/daux.io/issues"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"confluence": {
|
||||||
|
"base_url": "https://dauxio.atlassian.net/wiki/",
|
||||||
|
"space_id": "DOC",
|
||||||
|
"root_id": 196610
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,9 +60,9 @@ class Api
|
|||||||
}
|
}
|
||||||
|
|
||||||
$message = $label .
|
$message = $label .
|
||||||
' [url] ' . $request->getUri() .
|
"\n [url] " . $request->getUri() .
|
||||||
' [status code] ' . $response->getStatusCode() .
|
"\n [status code] " . $response->getStatusCode() .
|
||||||
' [message] ';
|
"\n [message] ";
|
||||||
|
|
||||||
$body = $response->getBody();
|
$body = $response->getBody();
|
||||||
$json = json_decode($body, true);
|
$json = json_decode($body, true);
|
||||||
@ -201,8 +201,45 @@ class Api
|
|||||||
try {
|
try {
|
||||||
$this->getClient()->put("content/$page_id", ['json' => $body]);
|
$this->getClient()->put("content/$page_id", ['json' => $body]);
|
||||||
} catch (BadResponseException $e) {
|
} catch (BadResponseException $e) {
|
||||||
throw $this->handleError($e);
|
$error = $this->handleError($e);
|
||||||
|
|
||||||
|
$re = '/\[([0-9]*),([0-9]*)\]$/';
|
||||||
|
preg_match($re, $error->getMessage(), $matches, PREG_OFFSET_CAPTURE, 0);
|
||||||
|
|
||||||
|
if (count($matches) == 3) {
|
||||||
|
echo "\nContent: \n";
|
||||||
|
echo $this->showSourceCode($content, $matches[1][0], $matches[2][0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throw $error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showSourceCode($css, $lineNumber, $column)
|
||||||
|
{
|
||||||
|
$lines = preg_split("/\r?\n/", $css);
|
||||||
|
$start = max($lineNumber - 3, 0);
|
||||||
|
$end = min($lineNumber + 2, count($lines));
|
||||||
|
|
||||||
|
$maxWidth = strlen("$end");
|
||||||
|
|
||||||
|
$filtered = array_slice($lines, $start, $end - $start);
|
||||||
|
|
||||||
|
$prepared = [];
|
||||||
|
foreach ($filtered as $index => $line) {
|
||||||
|
|
||||||
|
$number = $start + 1 + $index;
|
||||||
|
$gutter = substr(' ' . (' ' . $number), -$maxWidth) . ' | ';
|
||||||
|
|
||||||
|
if ($number == $lineNumber) {
|
||||||
|
$spacing = str_repeat(" ", strlen($gutter) + $column - 2);
|
||||||
|
$prepared[] = '>' . $gutter . $line . "\n " . $spacing . '^';
|
||||||
|
} else {
|
||||||
|
$prepared[] = ' ' . $gutter . $line;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode("\n", $prepared);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
<?php namespace Todaymade\Daux\Format\Confluence\ContentTypes\Markdown;
|
||||||
|
|
||||||
|
use League\CommonMark\Block\Renderer\BlockRendererInterface;
|
||||||
|
use League\CommonMark\HtmlElement;
|
||||||
|
|
||||||
|
abstract class CodeRenderer implements BlockRendererInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function escapeCDATA($content)
|
||||||
|
{
|
||||||
|
return str_replace("]]>", "]]]]><![CDATA[>", $content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHTMLElement($body, $language)
|
||||||
|
{
|
||||||
|
$body = '<![CDATA[' . $this->escapeCDATA($body) . ']]>';
|
||||||
|
|
||||||
|
$content = [];
|
||||||
|
|
||||||
|
if ($language) {
|
||||||
|
$content[] = new HtmlElement('ac:parameter', ['ac:name' => 'language'], $language);
|
||||||
|
}
|
||||||
|
|
||||||
|
$content[] = new HtmlElement('ac:plain-text-body', [], $body);
|
||||||
|
|
||||||
|
return new HtmlElement(
|
||||||
|
'ac:structured-macro',
|
||||||
|
['ac:name' => 'code'],
|
||||||
|
$content
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -2,11 +2,10 @@
|
|||||||
|
|
||||||
use League\CommonMark\Block\Element\AbstractBlock;
|
use League\CommonMark\Block\Element\AbstractBlock;
|
||||||
use League\CommonMark\Block\Element\FencedCode;
|
use League\CommonMark\Block\Element\FencedCode;
|
||||||
use League\CommonMark\Block\Renderer\BlockRendererInterface;
|
|
||||||
use League\CommonMark\ElementRendererInterface;
|
use League\CommonMark\ElementRendererInterface;
|
||||||
use League\CommonMark\HtmlElement;
|
use League\CommonMark\HtmlElement;
|
||||||
|
|
||||||
class FencedCodeRenderer implements BlockRendererInterface
|
class FencedCodeRenderer extends CodeRenderer
|
||||||
{
|
{
|
||||||
protected $supported_languages = [
|
protected $supported_languages = [
|
||||||
'actionscript3',
|
'actionscript3',
|
||||||
@ -48,19 +47,9 @@ class FencedCodeRenderer implements BlockRendererInterface
|
|||||||
throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
|
throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = [];
|
$language = $this->getLanguage($block->getInfoWords(), $htmlRenderer);
|
||||||
|
|
||||||
if ($language = $this->getLanguage($block->getInfoWords(), $htmlRenderer)) {
|
return $this->getHTMLElement($block->getStringContent(), $language);
|
||||||
$content[] = new HtmlElement('ac:parameter', ['ac:name' => 'language'], $language);
|
|
||||||
}
|
|
||||||
|
|
||||||
$content[] = new HtmlElement('ac:plain-text-body', [], '<![CDATA[' . $block->getStringContent() . ']]>');
|
|
||||||
|
|
||||||
return new HtmlElement(
|
|
||||||
'ac:structured-macro',
|
|
||||||
['ac:name' => 'code'],
|
|
||||||
$content
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLanguage($infoWords, ElementRendererInterface $htmlRenderer)
|
public function getLanguage($infoWords, ElementRendererInterface $htmlRenderer)
|
||||||
|
@ -2,11 +2,10 @@
|
|||||||
|
|
||||||
use League\CommonMark\Block\Element\AbstractBlock;
|
use League\CommonMark\Block\Element\AbstractBlock;
|
||||||
use League\CommonMark\Block\Element\IndentedCode;
|
use League\CommonMark\Block\Element\IndentedCode;
|
||||||
use League\CommonMark\Block\Renderer\BlockRendererInterface;
|
|
||||||
use League\CommonMark\ElementRendererInterface;
|
use League\CommonMark\ElementRendererInterface;
|
||||||
use League\CommonMark\HtmlElement;
|
use League\CommonMark\HtmlElement;
|
||||||
|
|
||||||
class IndentedCodeRenderer implements BlockRendererInterface
|
class IndentedCodeRenderer extends CodeRenderer
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param AbstractBlock $block
|
* @param AbstractBlock $block
|
||||||
@ -21,10 +20,6 @@ class IndentedCodeRenderer implements BlockRendererInterface
|
|||||||
throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
|
throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new HtmlElement(
|
return $this->getHTMLElement($block->getStringContent(), "");
|
||||||
'ac:structured-macro',
|
|
||||||
['ac:name' => 'code'],
|
|
||||||
new HtmlElement('ac:plain-text-body', [], '<![CDATA[' . $block->getStringContent() . ']]>')
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ class LinkRenderer extends \Todaymade\Daux\ContentTypes\Markdown\LinkRenderer
|
|||||||
$file = $this->resolveInternalFile($url);
|
$file = $this->resolveInternalFile($url);
|
||||||
|
|
||||||
$link_props = [
|
$link_props = [
|
||||||
'ri:content-title' => trim($this->daux['confluence']['prefix']) . ' ' . $file->getTitle(),
|
'ri:content-title' => trim(trim($this->daux['confluence']['prefix']) . ' ' . $file->getTitle()),
|
||||||
'ri:space-key' => $this->daux['confluence']['space_id'],
|
'ri:space-key' => $this->daux['confluence']['space_id'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -73,6 +73,9 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
|
|||||||
|
|
||||||
$confluence = $params['confluence'];
|
$confluence = $params['confluence'];
|
||||||
$this->prefix = trim($confluence['prefix']) . ' ';
|
$this->prefix = trim($confluence['prefix']) . ' ';
|
||||||
|
if ($this->prefix == ' ') {
|
||||||
|
$this->prefix = '';
|
||||||
|
}
|
||||||
|
|
||||||
$tree = $this->runAction(
|
$tree = $this->runAction(
|
||||||
'Generating Tree ...',
|
'Generating Tree ...',
|
||||||
|
@ -48,7 +48,7 @@ class Publisher
|
|||||||
try {
|
try {
|
||||||
return $this->runAction($title, $this->output, $this->width, $closure);
|
return $this->runAction($title, $this->output, $this->width, $closure);
|
||||||
} catch (BadResponseException $e) {
|
} catch (BadResponseException $e) {
|
||||||
$this->output->writeLn(' <error>' . $e->getMessage() . '</error>');
|
$this->output->writeLn('<fg=red>' . $e->getMessage() . '</>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user