From 4c8ae817f412dd8329726406bbaedbd5efa09dae Mon Sep 17 00:00:00 2001 From: "zach%zachlipton.com" Date: Thu, 15 Jun 2006 18:54:15 +0000 Subject: [PATCH] Add a simple formatting engine for testcase data using Text::Markdown. Normal HTML is passed through the filter unchanged, but now paragraphs will automatically be tagged with

and lists will automatically be converted to the proper html. A formatting help pane provides a description. The formatter is triggered with the 'markdown' filter in templates (e.g. [% expectedResults | markdown | testdata %]. --- webtools/litmus/Litmus/Template.pm | 12 +++++-- webtools/litmus/js/EditTests.js | 2 +- .../en/default/enter/enter.html.tmpl | 7 +++- .../en/default/test/formattingHelp.js.tmpl | 33 +++++++++++++++++++ .../templates/en/default/test/test.html.tmpl | 17 ++++++++-- 5 files changed, 65 insertions(+), 6 deletions(-) create mode 100755 webtools/litmus/templates/en/default/test/formattingHelp.js.tmpl diff --git a/webtools/litmus/Litmus/Template.pm b/webtools/litmus/Litmus/Template.pm index cf621dcce978..f2af1f6a5059 100755 --- a/webtools/litmus/Litmus/Template.pm +++ b/webtools/litmus/Litmus/Template.pm @@ -48,6 +48,7 @@ use strict; use Litmus::Config; use HTML::StripScripts::Parser; +use Text::Markdown; use base qw(Template); @@ -68,8 +69,8 @@ $constants{litmus_version} = $Litmus::Config::version; my $strip = HTML::StripScripts::Parser->new( { AllowHref => 1, - BanAllBut => ['a', 'b', 'br', 'em', 'p', 'i', 'hr', - 'ul', 'ol', 'li'], + AllowSrc => 1, + Context => 'Flow' }, strict_names => 1, ); @@ -150,6 +151,13 @@ sub create { return $strip->filtered_document(); }, + # process the text with the markdown text processor + markdown => sub { + my ($data) = @_; + $data = Text::Markdown::markdown($data); + return $data; + }, + # Returns the text with backslashes, single/double quotes, # and newlines/carriage returns escaped for use in JS strings. # thanks to bugzilla! diff --git a/webtools/litmus/js/EditTests.js b/webtools/litmus/js/EditTests.js index f2c52eabc49b..32ee534f5fd9 100755 --- a/webtools/litmus/js/EditTests.js +++ b/webtools/litmus/js/EditTests.js @@ -1,6 +1,6 @@ var editedtests = new Array(); var fields = ["product", "summary", "testgroup", "subgroup", - "steps", "results", "admin"]; + "steps", "results", "admin", "formatting"]; function MM_findObj(n) { var x = document.getElementById(n); diff --git a/webtools/litmus/templates/en/default/enter/enter.html.tmpl b/webtools/litmus/templates/en/default/enter/enter.html.tmpl index 50c8ce71a668..00a32d350e7e 100755 --- a/webtools/litmus/templates/en/default/enter/enter.html.tmpl +++ b/webtools/litmus/templates/en/default/enter/enter.html.tmpl @@ -25,10 +25,12 @@ [% PROCESS global/selects.none.tmpl %] [% includeselects=1 %] -[% INCLUDE global/html_header.tmpl js_files=['js/SelectBoxes.js'] +[% INCLUDE global/html_header.tmpl js_files=['js/SelectBoxes.js', 'js/Help.js'] title='Enter Testcase' %] [% INCLUDE global/litmus_header.tmpl %] +[% INCLUDE test/formattingHelp.js.tmpl %] +

[% INCLUDE sidebar/sidebar.tmpl %] @@ -81,6 +83,9 @@ test information rows="15" cols="40">
+ + Formatting Help
diff --git a/webtools/litmus/templates/en/default/test/formattingHelp.js.tmpl b/webtools/litmus/templates/en/default/test/formattingHelp.js.tmpl new file mode 100755 index 000000000000..97f7415a01e6 --- /dev/null +++ b/webtools/litmus/templates/en/default/test/formattingHelp.js.tmpl @@ -0,0 +1,33 @@ +[%# ***** BEGIN LICENSE BLOCK ***** + # Version: MPL 1.1 + # + # The contents of this file are subject to the Mozilla Public License Version + # 1.1 (the "License"); you may not use this file except in compliance with + # the License. You may obtain a copy of the License at + # http://www.mozilla.org/MPL/ + # + # Software distributed under the License is distributed on an "AS IS" basis, + # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + # for the specific language governing rights and limitations under the + # License. + # + # The Original Code is Litmus. + # + # The Initial Developer of the Original Code is + # The Mozilla Corporation. + # Portions created by the Initial Developer are Copyright (C) 2006 + # the Initial Developer. All Rights Reserved. + # + # Contributor(s): + # Zach Lipton + # + # ***** END LICENSE BLOCK ***** +#%] + +[%# INTERFACE: +#%] + + \ No newline at end of file diff --git a/webtools/litmus/templates/en/default/test/test.html.tmpl b/webtools/litmus/templates/en/default/test/test.html.tmpl index fbc5de60724f..9f4bbb953065 100755 --- a/webtools/litmus/templates/en/default/test/test.html.tmpl +++ b/webtools/litmus/templates/en/default/test/test.html.tmpl @@ -37,6 +37,11 @@ [% PROCESS global/selects.none.tmpl %] +[% IF showedit %] + + [% INCLUDE test/formattingHelp.js.tmpl %] +[% END %] + [% IF show_config %] @@ -85,7 +90,7 @@
Steps to Perform:
-
[% testcase.steps %]
+
[% testcase.steps | markdown | testdata %]
[% IF showedit %]