From 2a850757ee5f9c1a2119c562cf6caba3eda7ceba Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Thu, 20 Nov 2014 22:37:10 -0500 Subject: Add Markdown preview for textarea, see #407 --- app/Controller/App.php | 19 +++++++++++++++++++ app/Locale/da_DK/translations.php | 3 +++ app/Locale/de_DE/translations.php | 3 +++ app/Locale/es_ES/translations.php | 3 +++ app/Locale/fi_FI/translations.php | 3 +++ app/Locale/fr_FR/translations.php | 3 +++ app/Locale/it_IT/translations.php | 3 +++ app/Locale/ja_JP/translations.php | 3 +++ app/Locale/pl_PL/translations.php | 3 +++ app/Locale/pt_BR/translations.php | 3 +++ app/Locale/ru_RU/translations.php | 3 +++ app/Locale/sv_SE/translations.php | 3 +++ app/Locale/th_TH/translations.php | 3 +++ app/Locale/zh_CN/translations.php | 3 +++ app/Model/Acl.php | 2 +- app/Template/comment_create.php | 19 ++++++++++++++++++- app/Template/comment_edit.php | 20 +++++++++++++++++++- app/Template/task_edit.php | 19 ++++++++++++++++++- app/Template/task_edit_description.php | 20 ++++++++++++++++++-- app/Template/task_new.php | 19 ++++++++++++++++++- app/helpers.php | 1 - 21 files changed, 150 insertions(+), 8 deletions(-) (limited to 'app') diff --git a/app/Controller/App.php b/app/Controller/App.php index 86b06076..56124da2 100644 --- a/app/Controller/App.php +++ b/app/Controller/App.php @@ -4,6 +4,7 @@ namespace Controller; use Model\Project as ProjectModel; use Model\SubTask; +use Helper; /** * Application controller @@ -153,4 +154,22 @@ class App extends Base ) ); } + + /** + * Render Markdown Text and reply with the HTML Code + * + * @access public + */ + public function preview() + { + $payload = $this->request->getJson(); + + if (empty($payload['text'])) { + $this->response->html('

'.t('Nothing to preview...').'

'); + } + else { + $this->response->html(Helper\markdown($payload['text'])); + } + } + } diff --git a/app/Locale/da_DK/translations.php b/app/Locale/da_DK/translations.php index 5c2002ec..c4fcc1c4 100644 --- a/app/Locale/da_DK/translations.php +++ b/app/Locale/da_DK/translations.php @@ -599,4 +599,7 @@ return array( // 'Daily project summary export for "%s"' => '', // 'Exports' => '', // 'This export contains the number of tasks per column grouped per day.' => '', + // 'Nothing to preview...' => '', + // 'Preview' => '', + // 'Write' => '', ); diff --git a/app/Locale/de_DE/translations.php b/app/Locale/de_DE/translations.php index b304fc18..7ff2258a 100644 --- a/app/Locale/de_DE/translations.php +++ b/app/Locale/de_DE/translations.php @@ -599,4 +599,7 @@ return array( // 'Daily project summary export for "%s"' => '', // 'Exports' => '', // 'This export contains the number of tasks per column grouped per day.' => '', + // 'Nothing to preview...' => '', + // 'Preview' => '', + // 'Write' => '', ); diff --git a/app/Locale/es_ES/translations.php b/app/Locale/es_ES/translations.php index 5740279c..a2618326 100644 --- a/app/Locale/es_ES/translations.php +++ b/app/Locale/es_ES/translations.php @@ -599,4 +599,7 @@ return array( // 'Daily project summary export for "%s"' => '', // 'Exports' => '', // 'This export contains the number of tasks per column grouped per day.' => '', + // 'Nothing to preview...' => '', + // 'Preview' => '', + // 'Write' => '', ); diff --git a/app/Locale/fi_FI/translations.php b/app/Locale/fi_FI/translations.php index 9565178f..c0bc4bbe 100644 --- a/app/Locale/fi_FI/translations.php +++ b/app/Locale/fi_FI/translations.php @@ -599,4 +599,7 @@ return array( // 'Daily project summary export for "%s"' => '', // 'Exports' => '', // 'This export contains the number of tasks per column grouped per day.' => '', + // 'Nothing to preview...' => '', + // 'Preview' => '', + // 'Write' => '', ); diff --git a/app/Locale/fr_FR/translations.php b/app/Locale/fr_FR/translations.php index b6735322..4eb0dc72 100644 --- a/app/Locale/fr_FR/translations.php +++ b/app/Locale/fr_FR/translations.php @@ -599,4 +599,7 @@ return array( 'Daily project summary export for "%s"' => 'Export du résumé quotidien du projet pour « %s »', 'Exports' => 'Exports', 'This export contains the number of tasks per column grouped per day.' => 'Cet export contient le nombre de tâches par colonne groupé par jour.', + 'Nothing to preview...' => 'Rien à prévisualiser...', + 'Preview' => 'Prévisualiser', + 'Write' => 'Écrire', ); diff --git a/app/Locale/it_IT/translations.php b/app/Locale/it_IT/translations.php index 9a0fd02e..b7132bc2 100644 --- a/app/Locale/it_IT/translations.php +++ b/app/Locale/it_IT/translations.php @@ -599,4 +599,7 @@ return array( // 'Daily project summary export for "%s"' => '', // 'Exports' => '', // 'This export contains the number of tasks per column grouped per day.' => '', + // 'Nothing to preview...' => '', + // 'Preview' => '', + // 'Write' => '', ); diff --git a/app/Locale/ja_JP/translations.php b/app/Locale/ja_JP/translations.php index 1885d779..7a59ec05 100644 --- a/app/Locale/ja_JP/translations.php +++ b/app/Locale/ja_JP/translations.php @@ -599,4 +599,7 @@ return array( // 'Daily project summary export for "%s"' => '', // 'Exports' => '', // 'This export contains the number of tasks per column grouped per day.' => '', + // 'Nothing to preview...' => '', + // 'Preview' => '', + // 'Write' => '', ); diff --git a/app/Locale/pl_PL/translations.php b/app/Locale/pl_PL/translations.php index 34ea087f..edc696b8 100644 --- a/app/Locale/pl_PL/translations.php +++ b/app/Locale/pl_PL/translations.php @@ -599,4 +599,7 @@ return array( // 'Daily project summary export for "%s"' => '', // 'Exports' => '', // 'This export contains the number of tasks per column grouped per day.' => '', + // 'Nothing to preview...' => '', + // 'Preview' => '', + // 'Write' => '', ); diff --git a/app/Locale/pt_BR/translations.php b/app/Locale/pt_BR/translations.php index 9aa52bc3..f249a5e6 100644 --- a/app/Locale/pt_BR/translations.php +++ b/app/Locale/pt_BR/translations.php @@ -599,4 +599,7 @@ return array( // 'Daily project summary export for "%s"' => '', // 'Exports' => '', // 'This export contains the number of tasks per column grouped per day.' => '', + // 'Nothing to preview...' => '', + // 'Preview' => '', + // 'Write' => '', ); diff --git a/app/Locale/ru_RU/translations.php b/app/Locale/ru_RU/translations.php index b584b759..a1cc7cfe 100644 --- a/app/Locale/ru_RU/translations.php +++ b/app/Locale/ru_RU/translations.php @@ -599,4 +599,7 @@ return array( // 'Daily project summary export for "%s"' => '', // 'Exports' => '', // 'This export contains the number of tasks per column grouped per day.' => '', + // 'Nothing to preview...' => '', + // 'Preview' => '', + // 'Write' => '', ); diff --git a/app/Locale/sv_SE/translations.php b/app/Locale/sv_SE/translations.php index e1997f6c..ece0b2a2 100644 --- a/app/Locale/sv_SE/translations.php +++ b/app/Locale/sv_SE/translations.php @@ -599,4 +599,7 @@ return array( // 'Daily project summary export for "%s"' => '', // 'Exports' => '', // 'This export contains the number of tasks per column grouped per day.' => '', + // 'Nothing to preview...' => '', + // 'Preview' => '', + // 'Write' => '', ); diff --git a/app/Locale/th_TH/translations.php b/app/Locale/th_TH/translations.php index a5c7a251..42a1bcb3 100644 --- a/app/Locale/th_TH/translations.php +++ b/app/Locale/th_TH/translations.php @@ -599,4 +599,7 @@ return array( // 'Daily project summary export for "%s"' => '', // 'Exports' => '', // 'This export contains the number of tasks per column grouped per day.' => '', + // 'Nothing to preview...' => '', + // 'Preview' => '', + // 'Write' => '', ); diff --git a/app/Locale/zh_CN/translations.php b/app/Locale/zh_CN/translations.php index d176b081..0fc3b2a8 100644 --- a/app/Locale/zh_CN/translations.php +++ b/app/Locale/zh_CN/translations.php @@ -599,4 +599,7 @@ return array( // 'Daily project summary export for "%s"' => '', // 'Exports' => '', // 'This export contains the number of tasks per column grouped per day.' => '', + // 'Nothing to preview...' => '', + // 'Preview' => '', + // 'Write' => '', ); diff --git a/app/Model/Acl.php b/app/Model/Acl.php index 4a161714..d96d5deb 100644 --- a/app/Model/Acl.php +++ b/app/Model/Acl.php @@ -31,7 +31,7 @@ class Acl extends Base * @var array */ private $user_actions = array( - 'app' => array('index'), + 'app' => array('index', 'preview'), 'board' => array('index', 'show', 'save', 'check', 'changeassignee', 'updateassignee', 'changecategory', 'updatecategory', 'movecolumn', 'edit', 'update', 'add', 'confirm', 'remove'), 'project' => array('index', 'show', 'exporttasks', 'exportdaily', 'share', 'edit', 'update', 'users', 'remove', 'duplicate', 'disable', 'enable', 'activity', 'search', 'tasks', 'create', 'save'), 'user' => array('edit', 'forbidden', 'logout', 'show', 'external', 'unlinkgoogle', 'unlinkgithub', 'sessions', 'removesession', 'last', 'notifications', 'password'), diff --git a/app/Template/comment_create.php b/app/Template/comment_create.php index 11772f75..5590b77d 100644 --- a/app/Template/comment_create.php +++ b/app/Template/comment_create.php @@ -6,7 +6,24 @@ -
+ +
+ +
+ +
+
+
+
+
+
diff --git a/app/Template/comment_edit.php b/app/Template/comment_edit.php index 4ce48964..96b7a872 100644 --- a/app/Template/comment_edit.php +++ b/app/Template/comment_edit.php @@ -7,7 +7,25 @@ -
+ +
+
    +
  • + +
  • +
  • + +
  • +
+
+ +
+
+
+
+
+ +
diff --git a/app/Template/task_edit.php b/app/Template/task_edit.php index 73e00a31..701bd08e 100644 --- a/app/Template/task_edit.php +++ b/app/Template/task_edit.php @@ -12,7 +12,24 @@
-
+ +
+
    +
  • + +
  • +
  • + +
  • +
+
+ +
+
+
+
+
+
diff --git a/app/Template/task_edit_description.php b/app/Template/task_edit_description.php index 09dca30a..f805c034 100644 --- a/app/Template/task_edit_description.php +++ b/app/Template/task_edit_description.php @@ -5,9 +5,25 @@
- -
+ +
+
    +
  • + +
  • +
  • + +
  • +
+
+ +
+
+
+
+
+
diff --git a/app/Template/task_new.php b/app/Template/task_new.php index 43916551..ee8aed7c 100644 --- a/app/Template/task_new.php +++ b/app/Template/task_new.php @@ -14,7 +14,24 @@
-
+ +
+
    +
  • + +
  • +
  • + +
  • +
+
+ +
+
+
+
+
+
diff --git a/app/helpers.php b/app/helpers.php index ac5b788f..6c8e8955 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -445,7 +445,6 @@ function form_textarea($name, $values = array(), array $errors = array(), array $html .= implode(' ', $attributes).'>'; $html .= isset($values->$name) ? escape($values->$name) : isset($values[$name]) ? $values[$name] : ''; $html .= ''; - if (in_array('required', $attributes)) $html .= '*'; $html .= error_list($errors, $name); return $html; -- cgit v1.2.3