[OPEN-ILS-DEV] PATCH: Improve generation of JS prop files from DTDs

Dan Scott denials at gmail.com
Fri Aug 3 17:09:54 EDT 2007


The attached patch:

1) Modifies dtd2js.sh so that it uses relative directories, which are
almost guaranteed to be correct, rather than relying on shell
expansion to point to the specific location of the Subversion checkout
in a home directory

2) Modifies dtd2js.pl to be a little more robust in case of entity
definitions that include mixed quotes

3) Modifies the staff_client/Makefile so that the lang.js file is
generated for both the versionless and the stamped version of the
staff client.

In addition to a general cleanup of the JS prop file generation code,
I believe this patch should enable the successful application of my
previous patch for moving hardcoded strings out of the /main/*.xul
files. Haven't tested it yet, though; I'll let you know how that goes.

Question: as lang.js is a generated file, should we not remove it from
the repository?

-- 
Dan Scott
Laurentian University
-------------- next part --------------
Index: Open-ILS/xul/staff_client/external/dtd2js.sh
===================================================================
--- Open-ILS/xul/staff_client/external/dtd2js.sh	(revision 7620)
+++ Open-ILS/xul/staff_client/external/dtd2js.sh	(working copy)
@@ -1,2 +1,2 @@
 #!/bin/bash
-./dtd2js.pl ~/ILS/Open-ILS/web/opac/locale/en-US/lang.dtd > ../chrome/content/main/lang.js
+./dtd2js.pl ../../../web/opac/locale/en-US/lang.dtd > ../chrome/content/main/lang.js
Index: Open-ILS/xul/staff_client/external/dtd2js.pl
===================================================================
--- Open-ILS/xul/staff_client/external/dtd2js.pl	(revision 7620)
+++ Open-ILS/xul/staff_client/external/dtd2js.pl	(working copy)
@@ -5,11 +5,12 @@
 #<!ENTITY common.series "Series">
 #<!ENTITY common.keyword "Keyword">
 #<!ENTITY common.type "Type">
+#<!ENTITY tricksy.entity 'Some text with "quoted" content'>
 
 print "var entities = {};";
 while( $line = <> ) {
 
-	if ($line =~ /<!ENTITY\s+(\S+)\s+(["'].*["'])\s*>/) {
+	if ($line =~ /<!ENTITY\s+(\S+)\s+((["']).*\3)\s*>\s*$/) {
 		print "entities['$1'] = $2;\n";	
 	} else {
 		chomp $line;
Index: Open-ILS/xul/staff_client/Makefile
===================================================================
--- Open-ILS/xul/staff_client/Makefile	(revision 7620)
+++ Open-ILS/xul/staff_client/Makefile	(working copy)
@@ -74,7 +74,10 @@
 	@echo
 	@echo '********************************************************* Grabbing lang.dtd from the OPAC code '
 	cp ../../../Open-ILS/web/opac/locale/en-US/lang.dtd build/chrome/locale/en-US/
+	# Generate the lang.js file for the stamped build
 	external/dtd2js.pl build/chrome/locale/en-US/lang.dtd > build/chrome/content/main/lang.js
+	# Generate the lang.js file for versionless as well
+	external/dtd2js.pl build/chrome/locale/en-US/lang.dtd > chrome/content/main/lang.js
 
 open-ils:
 	@echo


More information about the Open-ils-dev mailing list