Recently I saw some Top10 pages on different sites and I discussed it with a meteo enthusiast close by, who pointed me to the site top10 page and PHP/SQL function serving it, made by Mark Crossley. I appreciate the result but while studying the PHP and SQL code, I could not help noticing that the query's are fetched every time the page is loaded (apart maybe for some caching advantage). Beside that, this type of PHP/SQL combination brings a complexity to displaying of data which I increasingly see on websites, but which I personally do not really like. As Cumulus itself has a very clean text database and as such the handling of the data is not complex and straightforward, I took another approach, described below. PHP/SQL, I think, is a bit of overkill.
I wrote a small program (in C) which reads dayfile.txt once per day just after midnight and for all measurements it creates a sorted top10-list. From that list it creates a HTML-table and writes that to a text-file. That file can be included by the user on a website wherever he wants simply by a PHP-include (which is the easy way to include I think).
You will find attached, the program compiled for the Raspberry 3B+ in a zip-archive, for other environments it needs to be recompiled (which I think can be done without modifications). I submitted the code to github in a private repository. Please note: the initial name top10 has been changed to add2cumulus because there will be more functionality than only the top10. Current functions implemented (linked to example) are:
Let me know if you are interested, have a problem or question.
How to use (for a daily new version of the table):
- Copy the executable to the CumulusMX executable directory, the data-directory is assumed one directory below. If not, it fails;
- In "CumulusMX->InternetSettings->External programs->Daily program" fill in: "./add2cumulus";
- In Daily Program Parameters use values for the commandline parameters "-NrOfColumns 2 -bgcHdr Red -bgcTbl yellow -txtHdr purple -accTbl " (any value you want);
- In "Extra webfiles" create two new entries for "top10TableStyle.txt" and "top10Table.txt"; Set these for FTP, if you want to debug and have quick result: set realtime and run the program by hand, otherwise just FTP is enough.
- Make a page for your website to display the table.This is done by including the txt files in respectively the <HEAD> and the <BODY> section. A likely method could be e.g. PHP: "<?php include('top10TableStyle.txt');?>"
Please check the readme for the commandline parameters and modifications.