From 0ee6cdb897722726e012e86aac443a47d291927f Mon Sep 17 00:00:00 2001
From: Camil Staps
Date: Mon, 10 Feb 2020 12:14:58 +0100
Subject: Improve formatting on list.php
---
list.php | 32 ++++++++++++++++++++++++++------
style.css | 12 ++++++++++++
2 files changed, 38 insertions(+), 6 deletions(-)
diff --git a/list.php b/list.php
index 90e6084..3210aff 100644
--- a/list.php
+++ b/list.php
@@ -16,6 +16,20 @@ function htmlid ($str)
return preg_replace ('/\W/','-',$str);
}
+function format_date_range ($start,$end)
+{
+ $dates=date ('D j',$start);
+ if (date ('Y',$start) != date ('Y',$end))
+ $dates.=date (' M Y',$start).' to '.date ('j M',$end);
+ else if (date ('M',$start) != date ('M',$end))
+ $dates.=date (' M',$start).' to '.date ('j M',$end);
+ else
+ $dates.='–'.date ('j M',$end);
+ if (date ('Y') != date ('Y',$end))
+ $dates.=date (' Y',$end);
+ return $dates;
+}
+
$selected_keywords=isset ($_GET['keywords']) ? explode(',',$_GET['keywords']) : null;
$keywords=get_keywords();
@@ -48,14 +62,19 @@ if (isset ($_GET['keywords']) && count ($_GET['keywords']) != count ($keywords))
';
- echo '
'.date ('D j M Y',strtotime ($event['start_date']));
- if ($event['end_date']!=$event['start_date'])
- echo ' to '.date ('j M',strtotime ($event['end_date']));
- echo ' | ';
+ $start_date=strtotime ($event['start_date']);
+ $end_date=strtotime ($event['end_date']);
+
+ $month=date ('m',$start_date);
+ echo $month==$last_month ? '' : '
';
+ $last_month=$month;
+
+ echo ''.format_date_range ($start_date,$end_date).' | ';
echo ''.htmlspecialchars ($event['location']).' | ';
- echo ''.htmlspecialchars ($event['title']).' | ';
+ echo ''.htmlspecialchars ($event['title']).' | ';
+
foreach ($event['keywords'] as $i => $kw){
if (!is_null ($selected_keywords) && !in_array ($kw,$selected_keywords))
$event['keywords'][$i]=''.htmlspecialchars ($kw).'';
@@ -63,6 +82,7 @@ foreach ($events as $event){
$event['keywords'][$i]=htmlspecialchars ($kw);
}
echo ''.implode (', ',$event['keywords']).' | ';
+
echo '
';
}
?>
diff --git a/style.css b/style.css
index d9ad143..647250e 100644
--- a/style.css
+++ b/style.css
@@ -14,12 +14,24 @@ tr:first-child {
border-bottom: 1px solid black;
}
+tr.new-month {
+ border-top: 1px dotted #888;
+}
+
th, td {
padding-right: 1em;
text-align: left;
vertical-align: top;
}
+td {
+ font-size: 90%;
+}
+
+td.large {
+ font-size: initial;
+}
+
.description {
font-size: 85%;
}
--
cgit v1.2.3