GeoNetwork, Me, and a Rubber Mallet (Pt. 3)
Getting back to this GeoNetwork business. We’re moving along at a decent clip given who we are and the fact that my GA is .5, student worker is .25 time, and I’m 1.89 time with 1.8 going to other projects. So this entry starts with work we did near the end of the summer and will be limited to the method we’re using to inject pretty severe edits into a checked-out GeoNetwork source in a way that will make at as easy as possible to maintain our live edits along with the checked-out GeoNetwork. The next entry will get into the edit of the default home page itself — later will come the search results, the addition of elements like OpenLayers or the styling of full metadata pulled in by ajax, etc. — but this one will explain away some strange things you would see if you checked out our version today.
Starting out I knew that if we made any progress at all there would come a time when the real GeoNetwork is updated and we would want to fold our changes right into the improved version. In an attempt to ease this process, one decision made right away was to alternatize the stuff we changed. And since that really isn’t a word, I’ll explain:
Most of the changes to the home page happen in file “main-page.xsl,” which gets called by the main.home service (defined in config.xml). I’ll get into the changes to this file below, but let’s jump ahead to us having a (severely) altered “main-page.xsl.” In order to not have to keep original copies around and start changing filenames in order to safely roll back to native GeoNetwork, I saved a copy of main-page.xsl with a pseudo extension that could be used to mark all of the files we change (or add). So “main-page.xsl” becomes “main-page_pugo.xsl,” and in fact this pseudoextension will be the norm for changes the rest of the way out. So we do two things; add “pugo” pseudoextension to the file to make an obvious copy and simultaneously mark edits inside of the files with “pugo” comments. For those files in GN whose file name could not be changed, it was obviously especially important for us to mark our edits with “pugo” comments. Worse comes to worse we can do searches for “pugo” to locate all of our edits, elisions, and additions.
So to begin live-editing and testing main-page.xsl we make a copy and name it “main-page_pugo.xsl.” Then to make GN actually use this file we need to configure the main.home service to load ours instead of the native. In config.xml, then, we change that service’s block from

to

This results in two distinct benefits. 1) we avoid having to diff twenty files (or more) every time the main GeoNetwork is updated, and 2) we can easily swap out our altered GeoNetwork with the native, allowing us to test how things are supposed to work and how they are (or more likely are not) working in ours. What it also means, however, is that any time we change a file to add a “_pugo” pseudoextension to a file, we need to be damned sure that all of the files that call the original now call our new copy. This is tedious one time for each file, but will save us a lot of heartache in the future. Get a text editor with file search or use Spotlight or something similar if you want it to be easy to find all files that call a given file. If you always make copies of files you edit (when possible) and point all files that use that file to your new copy, you end up with a cascading effect which is perfect — to turn on “our” GeoNetwork with all of the _pugo versions of files working together, we use config.xml as described above. To remove practically every change we make and run GeoNetwork natively, we remove the pseudoextension “_pugo” from the config.xml block quoted above, and everything is instantly back to normal.
…Not a thrilling entry, but so far this method is serving us very well. In the next entry we start really slicing up that home page, so don’t give up.



