[Rt-commit] rt branch, html-templates, updated. rt-3.9.6-34-g5dfee3f
Thomas Sibley
trs at bestpractical.com
Wed Nov 24 13:23:45 EST 2010
The branch, html-templates has been updated
via 5dfee3f8fadc214dd062dad78cad0f6b1882d294 (commit)
via 1f09659246a5f217d6062e8c5f1a4488ab025c45 (commit)
from 7ab5afe3ce32f023d2494994bc9f242ae91af27b (commit)
Summary of changes:
.gitignore | 2 +-
UPGRADING | 7 +++-
configure.ac | 2 +-
etc/initialdata | 3 +-
...to-html-templates.in => switch-templates-to.in} | 45 ++++++++++++++++----
5 files changed, 46 insertions(+), 13 deletions(-)
rename etc/upgrade/{switch-to-html-templates.in => switch-templates-to.in} (74%)
- Log -----------------------------------------------------------------
commit 1f09659246a5f217d6062e8c5f1a4488ab025c45
Author: Thomas Sibley <trs at bestpractical.com>
Date: Wed Nov 24 10:42:08 2010 -0500
Make the HTML admin comment subject match the plain text one
This also fixes a typo where $comment was used for output rather than
$s.
diff --git a/etc/initialdata b/etc/initialdata
index 7ae4762..32073c8 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -348,7 +348,8 @@ This is a comment. It is not sent to the Requestor(s):
{ Queue => '0',
Name => 'Admin Comment in HTML', # loc
Description => 'HTML admin comment template', # loc
- Content => 'Subject: [Comment] {my $s=($Transaction->Subject||$Ticket->Subject); $s =~ s/\[Comment\]//g; $comment =~ s/^Re//i; $s;}
+ Content =>
+'Subject: [Comment] {my $s=($Transaction->Subject||$Ticket->Subject); $s =~ s/\\[Comment\\]\\s*//g; $s =~ s/^Re:\\s*//i; $s;}
RT-Attach-Message: yes
Content-Type: text/html
commit 5dfee3f8fadc214dd062dad78cad0f6b1882d294
Author: Thomas Sibley <trs at bestpractical.com>
Date: Wed Nov 24 12:12:41 2010 -0500
Tweak the template upgrading script to go both ways
This lets users try out the HTML templates and then decide to go back to
plain text. It also will be useful for testing both sets of templates.
diff --git a/.gitignore b/.gitignore
index 1b0d1b2..ec8c699 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,7 +12,7 @@ etc/upgrade/3.8-branded-queues-extension
etc/upgrade/3.8-ical-extension
etc/upgrade/split-out-cf-categories
etc/upgrade/generate-rtaddressregexp
-etc/upgrade/switch-to-html-templates
+etc/upgrade/switch-templates-to
lib/RT/Generated.pm
Makefile
t/data/gnupg/keyrings/random_seed
diff --git a/UPGRADING b/UPGRADING
index 6e2885c..43d01a0 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -43,7 +43,12 @@ with
upgrades from older versions don't automatically switch to the HTML versions.
To switch existing scrips, run:
- /opt/rt3/etc/upgrade/switch-to-html-templates
+ /opt/rt3/etc/upgrade/switch-templates-to html
+
+ To switch from HTML back to text, run:
+
+ /opt/rt3/etc/upgrade/switch-templates-to text
+
*******
diff --git a/configure.ac b/configure.ac
index a36d584..1231320 100755
--- a/configure.ac
+++ b/configure.ac
@@ -399,7 +399,7 @@ AC_CONFIG_FILES([
etc/upgrade/3.8-ical-extension
etc/upgrade/split-out-cf-categories
etc/upgrade/generate-rtaddressregexp
- etc/upgrade/switch-to-html-templates
+ etc/upgrade/switch-templates-to
sbin/rt-attributes-viewer
sbin/rt-session-viewer
sbin/rt-dump-database
diff --git a/etc/upgrade/switch-to-html-templates.in b/etc/upgrade/switch-templates-to.in
similarity index 74%
rename from etc/upgrade/switch-to-html-templates.in
rename to etc/upgrade/switch-templates-to.in
index 8098bd4..8f9eff1 100644
--- a/etc/upgrade/switch-to-html-templates.in
+++ b/etc/upgrade/switch-templates-to.in
@@ -53,8 +53,21 @@ use lib "@LOCAL_LIB_PATH@";
use lib "@RT_LIB_PATH@";
use RT;
+
+my $to = shift || '';
+my $from;
+
+if ($to =~ /html|text/i) {
+ $to = $to =~ /html/i ? 'html' : 'text';
+ $from = $to eq 'html' ? 'text' : 'html';
+} else {
+ print "Usage: $0 [html|text]\n";
+ warn "Please specify if you'd like to switch to HTML or text templates.\n";
+ exit 1;
+}
+
RT::LoadConfig();
-RT->Config->Set('LogToScreen' => 'debug');
+RT->Config->Set('LogToScreen' => 'info');
RT::Init();
$| = 1;
@@ -91,19 +104,25 @@ for (@templates) {
$scrips->Limit(
ALIAS => $templates,
FIELD => 'Name',
- VALUE => $_,
+ VALUE => ($to eq 'html' ? $_ : "$_ in HTML"),
ENTRYAGGREGATOR => 'OR'
);
}
my $switched = 0;
while ( my $s = $scrips->Next ) {
- my $html = $s->TemplateObj->Name . ' in HTML';
+ my $new = $s->TemplateObj->Name;
+
+ if ($to eq 'html') {
+ $new .= ' in HTML';
+ } else {
+ $new =~ s/ in HTML$//;
+ }
print $s->id, ": ", $s->Description, "\n";
- print " ", $s->TemplateObj->Name, " -> $html\n\n";
+ print " ", $s->TemplateObj->Name, " -> $new\n\n";
- my ($ok, $msg) = $s->SetTemplate($html);
+ my ($ok, $msg) = $s->SetTemplate($new);
if ($ok) {
$switched++;
@@ -116,14 +135,22 @@ $RT::Handle->Commit;
if ($switched) {
print <<" EOT";
-Switched $switched scrips to HTML templates. You should now manually port your
-customizations from the old templates to the new HTML templates.
+Switched $switched scrips to $to templates. You should now manually port any
+customizations from the old templates to the new templates.
+ EOT
+ exit 1 if $switched != $scrips->Count;
+}
+elsif ($scrips->Count) {
+ print <<" EOT";
+@{[$scrips->Count]} scrips using $from templates were found, but none were
+successfully switched to $to. See the errors above.
EOT
+ exit 1;
}
else {
print <<" EOT";
-No scrips were found using the plain text templates, so none were switched to
-the HTML templates.
+No scrips were found using the $from templates, so none were switched to
+$to templates.
EOT
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list