Skip to main content

Posts

Showing posts with the label jinja

Things I Learned: Including Jinja Templates

 Having learned how to make timestamps again, I'd wound up with quite a lot of lines of template that didn't really do anything too, too awe inspiring. In short, I needed a twelve line block of kml to display a single digit of a time or a date. I decided the spiffy thing to do would be to move this kml template into a file that I'd include from the base kml map jinja template. It was more difficult than I originally thought it would be. Turns out that simply adding the include line did not do the trick. I got back the error message: no loader for this environment specified A little bit of research led to a solution. Jinja template objects in Python needs to have an Environment that is properly setup if you plan to include other templates from inside a template. That led to this line tmpl = Template(f.read()) changing to this line tmpl = Environment(loader=FileSystemLoader("./plugins/templates")).from_string(f.read()) At which point the template was located. Then,...

Things I Learned: Time Stamps on QSO Maps using the Google Charts API, Datasette, and KML

 I'm still using that API that was deprecated. I know I should give it up, but it just keeps being useful. It's possibly the best Google product ever. (In that it just keeps on existing rather than falling into the deprecation void.) Specifically, I used the dynamic icon portion of the Google Charts API.  The Google Earth Pro animations of our QSO are missing something. (OK, maybe lots of things, but one thing I saw that I could add on this iteration.) They don't have a way to easily view the time of each QSO, or the progression of time during the POTA or SOTA session. Thanks to a suggestion  from a StackOverlow user , dynamic bubble icons have provided that! I've added icons that appear with each QSO on the map, displaying the callsign, received RST, and and time of the QSO, as well as a different set of time icons that simply update each minute of map time to display the UTC time as the map animates. Using the Google Dynamic Icon API The following address gives b...

Things I Learned: I Wrote my First Datasette Plugin

 I needed to learn Jinja and/or brush up on my Django skills for work. I decided to go the Jinja route because that template engine is used in other tools at work, plus I could write a Datasette plugin while I learned my way around. It's always bugged me a bit that map_qsos.py programatically writes out the kml files that I use to display our ham radio outings on Google Earth. Print statements are the wrong tool for the job, which—at the end of the day—is to create the same kml lines and points substituting in different station names and locations in a loop. The process fairly screams template engine. Another issue is that even though the data is available in a database after its initial entry, with the previous usage model, I had to collect the versions of qso_update.csv I wanted to map and then combine their calls into a single file. This file was then operated on by map_qsos.py. The whole process was cumbersome, and did not lead to me wanting to explore maps of the log unless t...