← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5808: Added script which cleans up messy custom data entry forms eg produced by word

 

------------------------------------------------------------
revno: 5808
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-01-26 15:58:59 +0100
message:
  Added script which cleans up messy custom data entry forms eg produced by word
added:
  resources/util/clean_cde.sh


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== added file 'resources/util/clean_cde.sh'
--- resources/util/clean_cde.sh	1970-01-01 00:00:00 +0000
+++ resources/util/clean_cde.sh	2012-01-26 14:58:59 +0000
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+# Removes verbose html from custom entry form e.g. produced by ms word.
+
+# First argument is name of html form.
+
+# Remove all tr attributes
+
+sed -i 's/<tr[^>]*>/<tr>/g' $1
+
+# Remove p open/end tags
+
+sed -i 's/<p[^>]*>//g' $1
+sed -i 's/<\/p>//g' $1
+
+# Remove b open/end tags
+
+sed -i 's/<b[^>]*>//g' $1
+sed -i 's/<\/b>//g' $1
+
+# Remove span open/end tags
+
+sed -i 's/<span[^>]*>//g' $1
+sed -i 's/<\/span>//g' $1
+
+# Remove all style, width, nowrap, valign, view attributes
+
+sed -i 's/style="[^"]*"//g' $1
+sed -i 's/width="[^"]*"//g' $1
+sed -i 's/nowrap="[^"]*"//g' $1
+sed -i 's/valign="[^"]*"//g' $1
+sed -i 's/view="[^"]*"//g' $1
+
+# Remove weird stuff
+
+sed -i 's/<!--1-->"//g' $1
+sed -i 's/&nbsp;//g' $1
+
+# Put back correct style for input elements
+
+sed -i 's/<input/<input style="width:7em;text-align:center;"/g' $1