Add a cache-munging script-generating script
authorDan Scott <dan@coffeecode.net>
Mon, 23 May 2011 15:02:37 +0000 (11:02 -0400)
committerDan Scott <dan@coffeecode.net>
Mon, 23 May 2011 15:14:36 +0000 (11:14 -0400)
Quickly pulled together a script to munge the CSS and JavaScript
for a given skin so that upgrades don't result in painful mismatches.

Warning: this Perl script generates a shell script which you must
then execute. It's not elegant in any way, it's based on the shell
commands that I issued by hand in a hurry. However, it does give
you the opportunity to examine what the script is going to do before
it munges your skin(s).

Signed-off-by: Dan Scott <dscott@laurentian.ca>
tools/migration-scripts/cache-munger.pl [new file with mode: 0644]

diff --git a/tools/migration-scripts/cache-munger.pl b/tools/migration-scripts/cache-munger.pl
new file mode 100644 (file)
index 0000000..aa2a49a
--- /dev/null
@@ -0,0 +1,37 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+# Doesn't need to be a datestamp; could be anything that uniquely
+# qualifies the path
+my $datestamp = "2011-05-22";
+
+# List the skins here that you want to munge
+my @skins = qw(
+    default
+);
+
+print "# Create date-stamped opac\/common path:\n";
+print "cd \/openils\/var\/web\/opac\n";
+print "ln -sf common common.$datestamp\n";
+print "\n";
+
+print "# Create date-stamped dojo path:\n";
+print "cd \/openils\/var\/web\/js\n";
+print "ln -sf dojo dojo.$datestamp\n";
+print "\n";
+
+foreach my $skin (@skins) {
+    print "# Munging skin $skin:\n";
+    print "cd \/openils\/var\/web\/opac\/theme\/$skin\n";
+    print "ln -sf css css.$datestamp\n";
+    print "cd \/openils\/var\/web\/opac\/skin\/$skin\/xml\n";
+    print "ln -sf common common.$datestamp\n";
+    print "cd \/openils\/var\/web\/opac\/skin\/$skin\n";
+    print "ln -sf js js.$datestamp; ln -sf css css.$datestamp;\n";
+    print "for i in `ack-grep -l \"\/$skin\/js\/\"`; do sed -i -e \"s\/\\/$skin\\/js\\/\/\\/$skin\\/js.$datestamp\\/\/\" \$i; done\n";
+    print "for i in `ack-grep -l \"\/$skin\/css\/\"`; do sed -i -e \"s\/\\/$skin\\/css\\/\/\\/$skin\\/css.$datestamp\\/\/\" \$i; done\n";
+    print "for i in `ack-grep -l '\/common\/'`; do sed -i -e \"s\/\\/common\\/\/\\/common.$datestamp\\/\/\" \$i; done\n";
+    print "for i in `ack-grep -l '\/js\/dojo\/'`; do sed -i -e \"s\/\\/js\\/dojo\\/\/\\/js\\/dojo.$datestamp\\/\/\" \$i; done\n";
+    print "\n";
+}