Skip to content

Populating a fake website

Glen Larsen edited this page Nov 22, 2015 · 4 revisions

#Overview In order to test the look of the MutopiaProject website, you will first have to create a fake website on your local machine and then you will have to populate it with all of the web site code and a subset of the archive.

n.b., This is linux-centric as that is what I know and use. If you are developing using another OS please feel free to add a new section.

##Prerequisites You will need

  • a Java compiler and runtime.
  • perl, available by default on most linux machines.
  • some passing familiarity with the bash command line.
  • the apache2 server is installed and you have a virtual host pointing to /var/www/fake-mutopia

##The scripts Before we populate the data portion of the website you will need compile the java code that does the publishing work. Build the perl scripts by following the instructions in src/README. The java libraries and utilities are now located in a folder called mpcore and their build instructions are in mpcore/README. Note that the default java build does not move files into their final location so you will have to do that manually. The simple way is using tar,

export MUTOPIA_WEB=<path-to-your-cloned-workspace>
cd $MUTOPIA_WEB
(cd mpcore/Mutopia/build/install/Mutopia; tar cf - .) | tar xf -
PATH=$PATH:$MUTOPIA_WEB/bin

If you are not a command-line linux user that might look like gibberish but it is simply using a standard archive utility, tar, to move a tree of files from one location to another. Here you are moving the built Mutopia utility and all of its libraries (bin and lib) to the bin and lib folders under your workspace hierarchy.

##A minimal archive The full MutopiaProject website has almost 2000 published pieces but we only need a minimum of 25 to build a local working website. The MutopiaWeb project only contains the site code and not data so you will have to clone the main site to publish some pieces. Let's assume your clone is in $HOME/Mutopia. First, let's set a convenient environment variable to point to that location.

export MUTOPIA_BASE=$HOME/Mutopia
cd $MUTOPIA_BASE

Defining$MUTOPIA_BASE can also be accomplished by sourcing UsefulScripts/mutopia-env.sh if you follow specific naming conventions for your folder hierarchy. In addition you want to set your path so the various utilities and scripts can be resolved,

PATH=$PATH:$MUTOPIA_WEB/bin
PATH=$PATH:$MUTOPIA_WEB/UsefulScripts

n.b. At some point we may want to install UsefulScripts into bin.

##Putting it together Now we are going to take a little shortcut to build our mini-archive. In the real world the entire archive is kept in a built state and the website references pieces within it. New pieces are added with new LilyPond versions but the archive isn't automatically updated when the compiler advances. This means the archive represents a large number of LilyPond versions and, if you are like most people, it is likely you only have one or two versions of the compiler handy. Basically, we aren't going to worry about trying to build the piece with its specified LilyPond version, we're simply going to build it with the latest compiler we have. The compiler version you choose for this purpose should be as high as you are willing to deal with. If it is not high enough you will have to do some manually filtering. This will become obvious as you go through these steps.

So pick at least 25 pieces to build. And, because we are testing the site, do yourself a favor and don't pick orchestral pieces. Think Gershwin, not Debussy or Chopin, piano or guitar studies if possible. I'm partial to guitar since it is a single staff and usually just one or two pages. Until you are familiar with the build process, I would recommend doing the simpler single file builds --- those not in -lys folders.

You can pick and choose yourself but here is a relatively easy, script-y way of building a small-ish list of files to build. It uses find to select LilyPond files, removes any that reference -lys folders, then trims the list to no more than 7. The output of each command is appended to a file called fake-archive.lis which we'll use later for input to other commands.

cd $MUTOPIA_BASE
touch fake-archive.lis
find ftp/ChopinFF -name \*.ly -print | sed /-lys/d | head -7 >>fake-archive.lis
find ftp/AguadoD -name \*.ly -print | sed /-lys/d | head -7 >>fake-archive.lis
find ftp/Traditional -name \*.ly -print | sed /-lys/d | head -7 >>fake-archive.lis
find ftp/CzernyC -name \*.ly -print | sed /-lys/d | head -7 >>fake-archive.lis
wc -l fake-archive.lis

That last command gives a count of the lines and you want it to be over 25. You might need a few extra just in case some are really old versions and are difficult to compile. And you could easily have contributions that are newer than your compiler and you might have to temporarily update your LilyPond compiler. You can try these searches to see what you've got.

# the number of files at version 2.something
$ for i in `cat fake-archive.lis`; do grep "\"2\." $i ; done | wc -l
# at 2.18
$ for i in `cat fake-archive.lis`; do grep "\"2\.18" $i ; done | wc -l

You get the picture. To get an idea of how many are at 2.19 and see how high our compiler version has to be:

$ for i in `cat fake-archive.lis`; do grep "\"2\.19" $i && echo $i; done
\version "2.19.7"
ftp/Traditional/JPM007-O-Edo-Nihonbashi/JPM007-O-Edo-Nihonbashi.ly
\version "2.19.7"
ftp/Traditional/JPM077-OkiNoTaisen/JPM077-OkiNoTaisen.ly

All of them should compile with a 2.19.7 compiler or better. You could either process these with a 2.19.7+ compiler or edit the two 2.19.7 entries from fake-archive.lis. Your choice. Ready?

for i in `cat fake-archive.lis`; do (cd $(dirname $i); mutopia-compile.sh $(basename $i) ) ; done

Almost there. If all compilations completed you will have all of the assets you need except for the RDF files. This is done with the Mutopia command which should be in your path,

for i in `cat fake-archive.lis`; do (cd $(dirname $i); Mutopia -r $(basename $i) ) ; done

If you encountered any failures it is not that important as long as you end up with 25 completed builds. Now all that is left is to move them to the mini-archive to our $MUTOPIA_WEB location. I'll do this in 2 steps instead a unix one-liner for the sake of simplicity.

for i in `cat fake-archive.lis`; do echo $(dirname $i) >> tmp.lis; done
tar cf - `cat tmp.lis` | (cd $MUTOPIA_WEB; tar xvf -)
rm tmp.lis

You could clean up afterwards if you want,

for i in `cat fake-archive.lis`; do (cd $(dirname $i); mutopia-clean.sh ) ; done
rm fake-archive.lis tmp.lis

Clone this wiki locally