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 <p> 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 %].

This commit is contained in:
zach%zachlipton.com 2006-06-15 18:54:15 +00:00
Родитель 7d9ac3faef
Коммит 4c8ae817f4
5 изменённых файлов: 65 добавлений и 6 удалений

Просмотреть файл

@ -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!

Просмотреть файл

@ -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);

Просмотреть файл

@ -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 %]
<div id="page">
[% INCLUDE sidebar/sidebar.tmpl %]
@ -81,6 +83,9 @@ test information
rows="15" cols="40"></textarea></div>
</td>
</tr>
<tr><td class="content" colspan="2"><u><a name="showFormattingHelp"
onclick="toggleHelp(formattingHelpTitle,formattingHelpText);">
Formatting Help</a></u></td></tr>
</table>
<br />
<input type="submit" name="submit" value="Add Testcase" />

Просмотреть файл

@ -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 <zach@zachlipton.com>
#
# ***** END LICENSE BLOCK *****
#%]
[%# INTERFACE:
#%]
<script language="JavaScript" type="text/Javascript">
var formattingHelpTitle = 'Formatting Help';
var formattingHelpText = '<p>To make it easier to edit testcase data, Litmus uses the <a href="http://daringfireball.net/projects/markdown/">Markdown text formatting engine.</a> Markdown makes it easy to create paragraphs, numbered and bulleted lists, and other formatted text in testcases.. The formatter works in addition to standard HTML, which means that you can still use normal HTML tags instead of, or in addition to, Markdown formatting. While you can read <a href="http://daringfireball.net/projects/markdown/basics">a complete description of Markdown\'s syntax</a>, the basic tips below should cover most common needs:</p><ul><li><b>Paragraphs:</b> Creating new paragraphs is easy. Just leave a blank line between each paragraph, and Litmus will add the &lt;p&gt; tags for you. Any special characters you use will automatically be escaped.</li><li><b>Lists:</b> To create a <b>bulleted list</b>, add asterisks before each item:<br> * First item<br> * Second item<br>To create a <b>numbered list</b>, just put numbers before each item:<br> 1. First item<br> 2. Second item<br>Litmus will automatically generate the proper html for the list display.</li><li><b>Links:</b> Creating links is easy too. You can use traditional &lt;a href=""&gt; formatting, or the simplified syntax: [link text](http://the.url.com). Or you can use the really simple syntax: &lt;the.url.com&gt;.</li><li><b>Text Formatting:</b> Simple text formatting, such as bold and italics, can be done with html tags, or as follows:<br><b>Italics:</b> *text*<br><b>Bold:</b> **text**</li></ul>';
</script>

Просмотреть файл

@ -37,6 +37,11 @@
[% PROCESS global/selects.none.tmpl %]
[% IF showedit %]
<script language="JavaScript" type="text/Javascript" src="js/Help.js"></script>
[% INCLUDE test/formattingHelp.js.tmpl %]
[% END %]
[% IF show_config %]
<table cellspacing="0" cellpadding="0" class="tcm">
<tr>
@ -85,7 +90,7 @@
<table cellspacing="0" cellpadding="0" class="tcm">
<tr>
<td width="50%" class="content"><div class="dh">Steps to Perform:</div>
<div class="dv" id ="steps_text_[%testcase.testcase_id | html%]">[% testcase.steps %]</div>
<div class="dv" id="steps_text_[%testcase.testcase_id | html%]">[% testcase.steps | markdown | testdata %]</div>
[% IF showedit %]
<div class="dv" id="steps_edit_[%testcase.testcase_id | html%]" style="display: none;">
<textarea name="steps_edit_[%testcase.testcase_id | html%]"
@ -94,7 +99,7 @@
[% END %]
</td>
<td width="50%" class="content"><div class="dh">Expected Results:</div>
<div class="dv" id="results_text_[%testcase.testcase_id | html%]">[% testcase.expected_results %]</div>
<div class="dv" id="results_text_[%testcase.testcase_id | html%]">[% testcase.expected_results | markdown | testdata %]</div>
[% IF showedit %]
<div class="dv" id="results_edit_[%testcase.testcase_id | html%]" style="display: none;">
<textarea name="results_edit_[%testcase.testcase_id | html%]"
@ -103,6 +108,14 @@
[% END %]
</td>
</tr>
[% IF showedit %]
<tr><td class="content" colspan="2"><div id="formatting_edit_[% testcase.testcase_id | html %]"
class="dv" style="display: none;">
<u><a name="showFormattingHelp"
onclick="toggleHelp(formattingHelpTitle,formattingHelpText);">
Formatting Help</a></u>
</div></td></tr>
[% END %]
[% IF defaultemail OR sysconfig %]
<!-- Only allow the user to submit a single result if they are already