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.
Dieser Commit ist enthalten in:
Ursprung
8e7340da3d
Commit
59b8c04161
@ -63,7 +63,7 @@ Preformatted blocks are useful for ASCII art:
|
||||
,-.
|
||||
, ,-. ,-.
|
||||
/ \ ( )-( )
|
||||
\ | ,.>-( )-<
|
||||
\ | ,.>-( )-<
|
||||
\|,' ( )-( )
|
||||
Y ___`-' `-'
|
||||
|/__/ `-'
|
||||
|
@ -16,3 +16,7 @@ Code Highlight | √ | X (Planned) | √ (Using macros)
|
||||
Live Mode | √ | X | X
|
||||
Pages Ordering | √ | √ | X (API Limitation)
|
||||
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=col-third>
|
||||
<div class="row">
|
||||
<div class="col-third">
|
||||
|
||||
#### For Authors
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
* [Table of Contents](01_Features/Table_of_contents.md)
|
||||
|
||||
</div>
|
||||
<div class=col-third>
|
||||
<div class="col-third">
|
||||
|
||||
#### For Developers
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
* Work with pages metadata
|
||||
|
||||
</div>
|
||||
<div class=col-third>
|
||||
<div class="col-third">
|
||||
|
||||
#### For Marketing
|
||||
|
||||
|
@ -29,5 +29,10 @@
|
||||
"GitHub Repo": "https://github.com/dauxio/daux.io",
|
||||
"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 .
|
||||
' [url] ' . $request->getUri() .
|
||||
' [status code] ' . $response->getStatusCode() .
|
||||
' [message] ';
|
||||
"\n [url] " . $request->getUri() .
|
||||
"\n [status code] " . $response->getStatusCode() .
|
||||
"\n [message] ";
|
||||
|
||||
$body = $response->getBody();
|
||||
$json = json_decode($body, true);
|
||||
@ -201,10 +201,47 @@ class Api
|
||||
try {
|
||||
$this->getClient()->put("content/$page_id", ['json' => $body]);
|
||||
} 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a page
|
||||
*
|
||||
|
32
libs/Format/Confluence/ContentTypes/Markdown/CodeRenderer.php
Normale Datei
32
libs/Format/Confluence/ContentTypes/Markdown/CodeRenderer.php
Normale Datei
@ -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\FencedCode;
|
||||
use League\CommonMark\Block\Renderer\BlockRendererInterface;
|
||||
use League\CommonMark\ElementRendererInterface;
|
||||
use League\CommonMark\HtmlElement;
|
||||
|
||||
class FencedCodeRenderer implements BlockRendererInterface
|
||||
class FencedCodeRenderer extends CodeRenderer
|
||||
{
|
||||
protected $supported_languages = [
|
||||
'actionscript3',
|
||||
@ -48,19 +47,9 @@ class FencedCodeRenderer implements BlockRendererInterface
|
||||
throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
|
||||
}
|
||||
|
||||
$content = [];
|
||||
$language = $this->getLanguage($block->getInfoWords(), $htmlRenderer);
|
||||
|
||||
if ($language = $this->getLanguage($block->getInfoWords(), $htmlRenderer)) {
|
||||
$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
|
||||
);
|
||||
return $this->getHTMLElement($block->getStringContent(), $language);
|
||||
}
|
||||
|
||||
public function getLanguage($infoWords, ElementRendererInterface $htmlRenderer)
|
||||
|
@ -2,11 +2,10 @@
|
||||
|
||||
use League\CommonMark\Block\Element\AbstractBlock;
|
||||
use League\CommonMark\Block\Element\IndentedCode;
|
||||
use League\CommonMark\Block\Renderer\BlockRendererInterface;
|
||||
use League\CommonMark\ElementRendererInterface;
|
||||
use League\CommonMark\HtmlElement;
|
||||
|
||||
class IndentedCodeRenderer implements BlockRendererInterface
|
||||
class IndentedCodeRenderer extends CodeRenderer
|
||||
{
|
||||
/**
|
||||
* @param AbstractBlock $block
|
||||
@ -21,10 +20,6 @@ class IndentedCodeRenderer implements BlockRendererInterface
|
||||
throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
|
||||
}
|
||||
|
||||
return new HtmlElement(
|
||||
'ac:structured-macro',
|
||||
['ac:name' => 'code'],
|
||||
new HtmlElement('ac:plain-text-body', [], '<![CDATA[' . $block->getStringContent() . ']]>')
|
||||
);
|
||||
return $this->getHTMLElement($block->getStringContent(), "");
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class LinkRenderer extends \Todaymade\Daux\ContentTypes\Markdown\LinkRenderer
|
||||
$file = $this->resolveInternalFile($url);
|
||||
|
||||
$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'],
|
||||
];
|
||||
|
||||
|
@ -73,6 +73,9 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
|
||||
|
||||
$confluence = $params['confluence'];
|
||||
$this->prefix = trim($confluence['prefix']) . ' ';
|
||||
if ($this->prefix == ' ') {
|
||||
$this->prefix = '';
|
||||
}
|
||||
|
||||
$tree = $this->runAction(
|
||||
'Generating Tree ...',
|
||||
|
@ -48,7 +48,7 @@ class Publisher
|
||||
try {
|
||||
return $this->runAction($title, $this->output, $this->width, $closure);
|
||||
} catch (BadResponseException $e) {
|
||||
$this->output->writeLn(' <error>' . $e->getMessage() . '</error>');
|
||||
$this->output->writeLn('<fg=red>' . $e->getMessage() . '</>');
|
||||
}
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren