#
# Groups BOOTIE
# Join the Bootie group on Facebook.
#
#
# Note that, in a month that has 5 Saturdays, they are numbered "first",
# "second", "third", "fourth/fifth", "last", because the 5th, "extra"
# Saturday goes before the "last" saturday. I think this is a pretty
# stupid way to go about it, but I'm told that's how it's done.
#
# Specifying the day of the week on the line for static entries isn't
# strictly necessary, but it functions as a checksum (we can error if
# the dotm and dotw don't match.)
#
############################################################################
#
# Markdown in event descriptions:
#
# The event descriptions use an even-more-abbreviated variant of Markdown,
# (http://daringfireball.net/projects/markdown/) to save typing and make
# it easier to cut-and-paste things into the calendar with a minimum of
# editing. Example syntax:
#
# [anchor](url) -- The usual Markdown way.
# anchor url -- The anchor is all of the text between the URL
# and the beginning of the line, except that
# punctuation is left outside of the link.
# [anchor] url -- The URL is placed on the bracketed text, even
# if it contains punctuation. There can be other
# text between the ] and the URL.
#
# Paragraphs are separated by blank lines.
#
# A paragraph of one line ending with a colon is a heading.
#
# A paragraph following a heading has hard line breaks.
# If a line ends in a colon, it is a subheading.
# Backslashes at end of line mean "no break after this line".
#
# Lines in such a paragraph are assumed to be "performers",
# unless they are italic. Line beginning with * are bands,+ are DJs,
# and - are "other".
#
# If the line does not begin with one of those characters, we guess
# based on the heading. If the heading contains "main room", "lounge"
# or "dj", the default is DJ. If it contains "performing live", the
# default is band. Otherwise the default is "other".
#
# A paragraph not directly following a heading is not assumed to
# contain "performers", and any links in it are simple A links.
# Such paragraphs are also filled.
#
# If there are different performers with the same name, they can
# be written as "Foo", "Foo|2", and "Foo|3". The part after "|" will
# not be displayed, but stats will be kept separately for them.
#
############################################################################
require 5;
use diagnostics;
use strict;
use POSIX (qw(mktime strftime));
use LWP::Simple (qw($ua));
use LWP::UserAgent;
use Text::Wrap;
use HTML::Entities;
#use open ":encoding(utf8)"; # costs 50% speed
BEGIN { push @INC, ("utils/", "calendar/"); }
use Menuify; # DNA::Menuify
use Markdown; # DNA::Markdown
DNA::Menuify->import (qw(error url_quote url_unquote html_quote html_unquote
cgi_exec image_size));
##############################################################################
#
# Configuration and stuff
#
##############################################################################
my $progname = $0; $progname =~ s@.*/@@g;
my ($version) = ('$Revision: 1.1025 $' =~ m/\s(\d[.\d]+)\s/s);
my $exec_dir = $0; $exec_dir =~ s@/[^/]*$@@;
my $exec_dir2 = "$exec_dir/../utils/";
my $data_dir = $exec_dir;
my $verbose = 1;
my $debug_p = 0; # this means "don't alter any files, print diffs instead"
my $calendar_data_file = "$data_dir/calendar.txt";
my $calendar_eventid_file = "$data_dir/ids.txt";
my $calendar_store_file = "$data_dir/tickets.txt";
my $calendar_thumbs_file = "thumbs.html";
my $calendar_rss_file = "dnalounge.rss";
my $calendar_ical_file = "dnalounge.ics";
my $calendar_videos_file = "videos.rss";
my $calendar_crontab_file = "crontab.txt";
my $calendar_weekly_file = "weekly.txt";
my $calendar_weekly_prolog = "prolog.txt";
my $calendar_topten_file = "topten.txt";
my $calendar_infoline_file = "infoline.txt";
my $calendar_ledger_file = "ledger.html";
my $calendar_names_file = "names.txt";
my $calendar_eighties_file = "1985-1999.txt";
my $calendar_tickets_file = "../tickets/index.html";
my $store_file = "../store/index.html";
my $gallery_file = "../gallery/names.txt";
my $suspension_file = "suspension.html";
my $warnings_file = "warnings.html";
my $posters_file = "../store/posters.html";
my $calendar_date_block_bg = "#004400"; # for the box with the date in it
my $calendar_grid_dim_fg = "#666"; # de-emphasized dotms in cal overview
my $fill_column = 70; # no plain-text lines longer than this
# For the calendar html pages.
my $page_title = "DNA Lounge Calendar";
my $url_base = "http://www.dnalounge.com/";
my $ticket_form_url = "https://www.dnalounge.com/order/";
my $ticket_url_base = "$ticket_form_url?item=";
my $age_text = '+ with ID.';
my $age_aa_text = 'all ages.';
my $xml_link_tag =
" \n";
my $tickets_vip_blurb =
("Having a birthday party?\n" .
"VIP table service is" .
" available every night!\n" .
"

\n");
my $eighties_top_blurb =
("The list of bands who have performed at DNA Lounge since we re-opened\n" .
"in 2001 is well documented on our\n" .
"calendar. However, DNA Lounge has existed since\n" .
"1985, and I've been making an effort to document the bands that played\n" .
"here before I was running things. This is the list I've been able\n" .
"to construct so far.\n" .
"

\n" .
"This is a list of all of the bands and DJs who have\n" .
"performed at DNA Lounge since we re-opened in 2001\n" .
"(including a very incomplete\n" .
"sampling of bands who performed here as far back as\n" .
"1985). Clicking on a name will take you to that performer's\n" .
"web site (if we know it) and clicking on a date will take\n" .
"you to the appropriate entry in the\n" .
"calendar.\n" .
"From there, you can find the corresponding\n" .
"flyers,\n" .
"photo galleries,\n" .
"etc.\n" .
"

\n" .
"If you have any corrections to the URLs or names below,\n" .
" please \n" .
"let us know!\n" .
"

\n");
# If this is a ticket that went on sale this week, save it for
# later so that we can move it to the top of the list.
#
if ($onsale_lastweek_p) {
$lastweek_html .= $tr;
$twit_onsale_lastweek .= $event->{key} . "\n";
$twit_onsale_yesterday.= $event->{key} . "\n" if ($onsale_yesterday_p);
next;
}
#
# Insert the "Upcoming" headings into $body if it's now time.
#
if (!$heading_inserted_p) {
# Heading goes on its own line
$body .= ("

\n" .
"It's that time of year again! Reserve a date now to host your " .
"company's holiday party here at DNA Lounge. Wouldn't you rather " .
"have it here than in the company cafeteria? Of course you would! " .
"We can provide any level of support for your party, from a simple " .
"room rental, to catering and start-to-finish entertainment. " .
"Please check out our " .
"Rentals page, and contact us at " .
"" .
"booking\@dnalounge.com for more information or to schedule" .
" a tour.

")) .
"

" .
"

\n" .
"

\n" .
"\n" .
"

\n" .
"DNA Pizza is " .
"open 24/7!\n" .
"Join us right next door for a slice before or after your night " .
"of clubbing, or for espresso and pastries early in the morning! " .
"We also serve deli sandwiches and have a full bar. " .
"Free delivery, free wifi!" .
"