diff options
author | Julius Härtl <jus@bitgrid.net> | 2018-02-15 12:01:30 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2018-08-15 18:39:16 +0300 |
commit | e9efd1f1cb88a80f6c0e4fa6cc67de3054b45108 (patch) | |
tree | 3efc125dc67137862893612e40dfbe75d6246b69 | |
parent | 4cc06665bf16966d203c8cc7cabb796c9b8ea16f (diff) |
Add rendered markdown preview
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-rw-r--r-- | appinfo/routes.php | 4 | ||||
-rw-r--r-- | composer.json | 5 | ||||
-rw-r--r-- | composer.lock | 63 | ||||
-rw-r--r-- | js/init.js | 10 | ||||
-rw-r--r-- | lib/Controller/APIController.php | 15 | ||||
-rw-r--r-- | templates/settings-admin.php | 4 |
6 files changed, 92 insertions, 9 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php index 5037b34..d7b9c55 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -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'], + ], ];
\ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..f407d20 --- /dev/null +++ b/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "erusev/parsedown": "^1.6" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..e035ae5 --- /dev/null +++ b/composer.lock @@ -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": [] +} @@ -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) { diff --git a/lib/Controller/APIController.php b/lib/Controller/APIController.php index ad4537f..692c775 100644 --- a/lib/Controller/APIController.php +++ b/lib/Controller/APIController.php @@ -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); + } + }
\ No newline at end of file diff --git a/templates/settings-admin.php b/templates/settings-admin.php index 5fdf204..4690379 100644 --- a/templates/settings-admin.php +++ b/templates/settings-admin.php @@ -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> |