[opencms-dev] a poor man's edit compromise
Marko Riedel
markoriedelde at yahoo.de
Mon Jun 13 00:45:53 CEST 2011
Hi folks,
I sometimes have to edit OpenCMS files over a slow line and that can get quite frustrating using the HTML/JavaScript-programmed built-in editor. The fact is that using Emacs in nxhtml mode remains one of the fastest edit experiences if all you have is a terminal window. (What if you are used to having multiple buffers and transferring chunks of text between them?) I am sending two Perl scripts that make this process a bit easier (importing and exporting files). Now if only someone would help me hook the import script into the function that Emacs uses to save files! Any takers?
My Perl is a bit rusty. I suspect these scripts can be reduced to a few lines. I'd be keen to see any improvements you might offer. The hexadecimal suffix is to distinguish one manifest from another.
The argument to the script is the complete path to the file being checked out/in.
Have fun!
####import-ocms.pl###############################################
#! /usr/bin/perl
my $hex = unpack "H*", $ARGV[0];
open MANIF, "manifest-$hex.xml";
open NEWMANIF, ">manifest.xml";
while(<MANIF>){
if(/^(.+)<datelastmodified>(.+)<\/datelastmodified>/){
my $dstr = `date -R`; chomp $dstr;
print NEWMANIF "$1<datelastmodified>$dstr<\/datelastmodified>\n";
}
else{
print NEWMANIF;
}
}
close NEWMANIF;
close MANIF;
unlink "/tmp/target.zip" if(-e "/tmp/target.zip") ;
system "zip /tmp/target.zip manifest.xml $ARGV[0]";
$ENV{'CATALINA_HOME'} = '/usr/share/tomcat5.5';
open TOSHELL, "| /var/lib/tomcat5.5/webapps/opencms/WEB-INF/cmsshell.sh";
print TOSHELL "login \"Admin\" \"XXXXXX\"\n";
print TOSHELL "setSiteRoot \"/sites/default/\"\n";
print TOSHELL "setCurrentProject \"Offline\"\n";
print TOSHELL "importResources \"/tmp/target.zip\" \"\"\n";
print TOSHELL "exit\n";
close TOSHELL;
rename "manifest.xml", "manifest-$hex.xml";
#################################################################
####export-ocms.pl###############################################
#! /usr/bin/perl
unlink "/tmp/target.zip" if(-e "/tmp/target.zip");
$ENV{'CATALINA_HOME'} = '/usr/share/tomcat5.5';
open TOSHELL, "| /var/lib/tomcat5.5/webapps/opencms/WEB-INF/cmsshell.sh";
print TOSHELL "login \"Admin\" \"XXXXXX\"\n";
print TOSHELL "setSiteRoot \"/sites/default/\"\n";
print TOSHELL "setCurrentProject \"Offline\"\n";
print TOSHELL "exportResources \"/tmp/target\" \"$ARGV[0]\"\n";
print TOSHELL "exit\n";
close TOSHELL;
system "unzip -o /tmp/target.zip";
my $hex = unpack "H*", $ARGV[0];
rename "manifest.xml", "manifest-$hex.xml";
#################################################################
Best regards,
Marko
+---------------------------------------------------+
| Marko Riedel, markoriedelde at yahoo.de |
| http://www.mathematik.uni-stuttgart.de/~riedelmo/ |
+---------------------------------------------------+
More information about the opencms-dev
mailing list