Alright, the previous part shows you the script that allows to randomly display a banner image. Now, this would quickly end up being a bit messy to manage, if you want to add a new banner, then update the page with the list of all panoramas.
I wrote a Ruby script to semi-automate the process. The source can be found on github.
We first start with a database of images, called images.db. It is a YAML file, with this format:
The fields are:
It will also read pagecode.html.template, and generate pagecode.html for the list of images.
That's it! Looking at the code should be somehow self-documenting, if you want to modify it. I release the code in public domain, do whatever you want with it!
I wrote a Ruby script to semi-automate the process. The source can be found on github.
We first start with a database of images, called images.db. It is a YAML file, with this format:
- url: https://lh4.googleusercontent.com/.../s{}/xx.jpg
width: 800
repeat: true
offset: -30
text: Krabi - Thailand
date: 2012.12
I like to use YAML, because it is easy to parse in Ruby, without being as wordy as XML, but more structured than a simple text file.width: 800
repeat: true
offset: -30
text: Krabi - Thailand
date: 2012.12
The fields are:
- url: source image location. s{} in the URL will be replaced by the proper image width
- width: width to display
- repeat: if the panorama is a full 360° that can be repeated
- offset: vertical offset to center the image
- text: Text that will appear in the banner, and in the image description
- date: year and month when the image was taken
It will also read pagecode.html.template, and generate pagecode.html for the list of images.
That's it! Looking at the code should be somehow self-documenting, if you want to modify it. I release the code in public domain, do whatever you want with it!
No comments:
Post a Comment