forked from gg/WeatherNews.jl
2eccd4a454 | ||
---|---|---|
.. | ||
caster | ||
css | ||
ranking | ||
segment | ||
xslate | ||
README.md | ||
Utils.pm | ||
WNDB.pm | ||
index.cgi | ||
vid.cgi |
README.md
/wn/
a site for querying wn.db
Designing in the context of vern.cc's CGI capabilities
- Executable scripts anywhere under ~/public_html are run as CGI scripts.
- If it's named index.cgi, it gets special treatment in that it's the
default handler for the directory.
- For example, ~/public_html/wn/index.cgi will handle a request for https://gg.vern.cc/wn/.
- It's not necessary to say https://gg.vern.cc/wn/index.cgi although you still may if you want.
Layout
Header
- Links to
- Home
- Casters
- Segments
- Rankings
Footer
- Links to
- git
- SQLite Database
/wn/ – Home
- The default page should show a reverse chronological list of shows.
- There should be a lot of rows before pagination kicks in.
- TODO: Figure out pagination.
/wn/caster/ – List of all casters
?n=$caster
- List of every appearance of caster
n
in reverse chronological order - Segment distribution (all time)
/wn/segment/ – List of all segments
?n=$segment
- List of every caster who has hosted the show
n
in reverse chronological order - Caster distribution (all time)
/wn/ranking/ – Count appearances by caster
?begin=$date1&end=$date2
- Count appearances by caster between the
begin
andend
dates.
Development
Create config.pl
and set appropriate values for base
and database
.
(
base => "/", # base request path for site
database => '/path/to/wn.db'
)
In the production deployment base
is "/wn/"
, because I didn't
want the site to take over /
.
Web Server
Then, while in the www
directory, run a web server that can run CGI scripts.
thttpd -p 4444 -c '**.cgi'
REPL
Reply is a good Perl REPL.
Assuming you've created config.pl
, you can start up reply
and
paste the following code to bootstrap the REPL session into this
project.
use DBI;
do "./Utils.pm";
do "./WNDB.pm";
my %config = do "./config.pl";
my $dbh = DBI->connect($config{database});
my ($sql, $do) = sql_fn($dbh);
I wish there were a better way to preload those variables into the REPL session, but it will do for now.
# Example: render the home page from the REPL
my @r = WNDB::schedule_default $sql;
my $html = page(schedule => { base => $config{base}, r => \@r })