Add rendered markdown preview
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Родитель
4cc06665bf
Коммит
e9efd1f1cb
|
@ -25,6 +25,8 @@ return [
|
|||
'routes' => [
|
||||
['name' => 'API#components', 'url' => '/components', 'verb' => 'GET'],
|
||||
['name' => 'API#sections', 'url' => '/sections/{app}', 'verb' => 'GET'],
|
||||
['name' => 'API#details', 'url' => '/details/{app}/{sectionIdentifier}', 'verb' => 'GET']
|
||||
['name' => 'API#details', 'url' => '/details/{app}/{sectionIdentifier}', 'verb' => 'GET'],
|
||||
['name' => 'API#render', 'url' => '/render', 'verb' => 'POST'],
|
||||
|
||||
],
|
||||
];
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"require": {
|
||||
"erusev/parsedown": "^1.6"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "df5dbbabef6cd996a6408ac2035b6459",
|
||||
"packages": [
|
||||
{
|
||||
"name": "erusev/parsedown",
|
||||
"version": "1.6.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/erusev/parsedown.git",
|
||||
"reference": "fbe3fe878f4fe69048bb8a52783a09802004f548"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/erusev/parsedown/zipball/fbe3fe878f4fe69048bb8a52783a09802004f548",
|
||||
"reference": "fbe3fe878f4fe69048bb8a52783a09802004f548",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8.35"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Parsedown": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Emanuil Rusev",
|
||||
"email": "hello@erusev.com",
|
||||
"homepage": "http://erusev.com"
|
||||
}
|
||||
],
|
||||
"description": "Parser for Markdown.",
|
||||
"homepage": "http://parsedown.org",
|
||||
"keywords": [
|
||||
"markdown",
|
||||
"parser"
|
||||
],
|
||||
"time": "2017-11-14T20:44:03+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": []
|
||||
}
|
10
js/init.js
10
js/init.js
|
@ -41,6 +41,7 @@ new Vue({
|
|||
data: {
|
||||
tabs: [],
|
||||
model: {},
|
||||
preview: 'preview',
|
||||
formOptions: {
|
||||
validationErrorClass: "has-error",
|
||||
validationSuccessClass: "has-success",
|
||||
|
@ -134,11 +135,20 @@ new Vue({
|
|||
return this.$refs.firstTabForm.validate();
|
||||
},
|
||||
validateDetails: function(tab){
|
||||
var self = this;
|
||||
var updates = this.$refs[tab.identifier][0].fetchUpdates();
|
||||
if (updates === false) {
|
||||
return false;
|
||||
}
|
||||
this.model.details[tab.identifier] = updates[tab.identifier];
|
||||
$.ajax({
|
||||
url: OC.generateUrl('/apps/issuetemplate/render'),
|
||||
data: this.model,
|
||||
method: 'POST',
|
||||
success: function (data) {
|
||||
self.preview = data;
|
||||
}
|
||||
});
|
||||
return true;
|
||||
},
|
||||
prettyJSON: function(json) {
|
||||
|
|
|
@ -21,16 +21,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: jus
|
||||
* Date: 19.01.18
|
||||
* Time: 21:44
|
||||
*/
|
||||
|
||||
namespace OCA\IssueTemplate\Controller;
|
||||
|
||||
|
||||
use OCA\IssueTemplate\DetailManager;
|
||||
use OCA\IssueTemplate\IDetail;
|
||||
use OCA\IssueTemplate\ISection;
|
||||
|
@ -42,6 +34,7 @@ use OCP\AppFramework\Controller;
|
|||
use OCP\AppFramework\Http\JSONResponse;
|
||||
use OCP\AppFramework\QueryException;
|
||||
use OCP\IRequest;
|
||||
use Parsedown;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||
|
||||
|
@ -131,4 +124,10 @@ class APIController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$markdown = $this->detailManager->getRenderedDetails();
|
||||
$parser = new Parsedown();
|
||||
return $parser->text($markdown);
|
||||
}
|
||||
|
||||
}
|
|
@ -40,6 +40,10 @@
|
|||
<p>
|
||||
<strong><?php p($l->t("This report will be submitted to nextcloud/server")); ?></strong>
|
||||
</p>
|
||||
|
||||
<div v-html="preview">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</tab-content>
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче