From 3ae02b9d82a2be29a6202594dcd7dce0a7800bfa Mon Sep 17 00:00:00 2001
From: "Edgar P. Burkhart" <git@edgarpierre.fr>
Date: Sat, 29 Jan 2022 09:30:59 +0100
Subject: [PATCH] Added origin calendar indicator

---
 saturn/calendar/__init__.py                   |   2 +-
 saturn/calendar/event.py                      |  14 ++++++++++++++
 saturn/server/static/icons/remixicon.css      |  13 +++++++------
 saturn/server/static/icons/remixicon.eot      | Bin 2224 -> 2384 bytes
 saturn/server/static/icons/remixicon.less     |  13 +++++++------
 saturn/server/static/icons/remixicon.svg      |   4 +++-
 .../server/static/icons/remixicon.symbol.svg  |   2 +-
 saturn/server/static/icons/remixicon.ttf      | Bin 2052 -> 2212 bytes
 saturn/server/static/icons/remixicon.woff     | Bin 1316 -> 1436 bytes
 saturn/server/static/icons/remixicon.woff2    | Bin 928 -> 1004 bytes
 saturn/server/templates/index.html            |   6 +++++-
 11 files changed, 38 insertions(+), 16 deletions(-)

diff --git a/saturn/calendar/__init__.py b/saturn/calendar/__init__.py
index b6c8e70..4c7abcc 100644
--- a/saturn/calendar/__init__.py
+++ b/saturn/calendar/__init__.py
@@ -19,7 +19,7 @@ def get_events(davclient):
     events = []
 
     for cal in pri.calendars():
-        events += [Event(event)
+        events += [Event(event, cal)
             for event in cal.date_search(start=date.today())]
     
     return sorted(events)
diff --git a/saturn/calendar/event.py b/saturn/calendar/event.py
index c022b2d..59df18a 100644
--- a/saturn/calendar/event.py
+++ b/saturn/calendar/event.py
@@ -2,12 +2,16 @@ import re
 import datetime
 import html
 
+import caldav.elements.ical
+
 
 class Event:
     def __init__(
                 self,
                 event,
+                calendar,
             ):
+        self._calendar = calendar
         self._v = event.instance.vevent
 
     @property
@@ -40,6 +44,16 @@ class Event:
             return self._v.rrule.value
         return None
 
+    @property
+    def calendar(self):
+        return self._calendar
+
+    @property
+    def color(self):
+        return self._calendar.get_properties(
+            [caldav.elements.ical.CalendarColor()]
+        )['{http://apple.com/ns/ical/}calendar-color']
+
 
     def fdescription(self):
         if self.description is None: return None
diff --git a/saturn/server/static/icons/remixicon.css b/saturn/server/static/icons/remixicon.css
index 5e8ae8f..26921d0 100644
--- a/saturn/server/static/icons/remixicon.css
+++ b/saturn/server/static/icons/remixicon.css
@@ -8,12 +8,12 @@
 
 @font-face {
     font-family: "remixicon";
-    src: url('remixicon.eot?t=1643377622508'); /* IE9*/
-    src: url('remixicon.eot?t=1643377622508#iefix') format('embedded-opentype'), /* IE6-IE8 */
-    url("remixicon.woff2?t=1643377622508") format("woff2"),
-    url("remixicon.woff?t=1643377622508") format("woff"),
-    url('remixicon.ttf?t=1643377622508') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
-    url('remixicon.svg?t=1643377622508#remixicon') format('svg'); /* iOS 4.1- */
+    src: url('remixicon.eot?t=1643444096731'); /* IE9*/
+    src: url('remixicon.eot?t=1643444096731#iefix') format('embedded-opentype'), /* IE6-IE8 */
+    url("remixicon.woff2?t=1643444096731") format("woff2"),
+    url("remixicon.woff?t=1643444096731") format("woff"),
+    url('remixicon.ttf?t=1643444096731') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
+    url('remixicon.svg?t=1643444096731#remixicon') format('svg'); /* iOS 4.1- */
     font-display: swap;
 }
 
@@ -43,3 +43,4 @@
 
 .ri-map-pin-line:before { content: "\ef14"; }
 .ri-repeat-line:before { content: "\f074"; }
+.ri-calendar-line:before { content: "\eb27"; }
diff --git a/saturn/server/static/icons/remixicon.eot b/saturn/server/static/icons/remixicon.eot
index c670a9159ed858893f6bf9c42847f9942f572420..909c339d8513bd8a6e1d4ccafc5cf541998d84aa 100644
GIT binary patch
diff --git a/saturn/server/static/icons/remixicon.less b/saturn/server/static/icons/remixicon.less
index f7653fc..f7753bf 100644
--- a/saturn/server/static/icons/remixicon.less
+++ b/saturn/server/static/icons/remixicon.less
@@ -8,12 +8,12 @@
 
 @font-face {
     font-family: "remixicon";
-    src: url('remixicon.eot?t=1643377622508'); /* IE9*/
-    src: url('remixicon.eot?t=1643377622508#iefix') format('embedded-opentype'), /* IE6-IE8 */
-    url("remixicon.woff2?t=1643377622508") format("woff2"),
-    url("remixicon.woff?t=1643377622508") format("woff"),
-    url('remixicon.ttf?t=1643377622508') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
-    url('remixicon.svg?t=1643377622508#remixicon') format('svg'); /* iOS 4.1- */
+    src: url('remixicon.eot?t=1643444096731'); /* IE9*/
+    src: url('remixicon.eot?t=1643444096731#iefix') format('embedded-opentype'), /* IE6-IE8 */
+    url("remixicon.woff2?t=1643444096731") format("woff2"),
+    url("remixicon.woff?t=1643444096731") format("woff"),
+    url('remixicon.ttf?t=1643444096731') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
+    url('remixicon.svg?t=1643444096731#remixicon') format('svg'); /* iOS 4.1- */
     font-display: swap;
 }
 
@@ -44,4 +44,5 @@
 
 .ri-map-pin-line:before { content: "\ef14"; }
 .ri-repeat-line:before { content: "\f074"; }
+.ri-calendar-line:before { content: "\eb27"; }
 }
\ No newline at end of file
diff --git a/saturn/server/static/icons/remixicon.svg b/saturn/server/static/icons/remixicon.svg
index 291b05d..47fdd7c 100644
--- a/saturn/server/static/icons/remixicon.svg
+++ b/saturn/server/static/icons/remixicon.svg
@@ -9,4 +9,6 @@
             unicode="&#xEF14;"
             horiz-adv-x="1200" d="M600 155L847.5 402.5A350 350 0 1 1 352.5 402.5L600 155zM600 13.6000000000001L281.8 331.8000000000002A450 450 0 1 0 918.2 331.8000000000002L600 13.5999999999999zM600 550A100 100 0 1 1 600 750A100 100 0 0 1 600 550zM600 450A200 200 0 1 0 600 850A200 200 0 0 0 600 450z" /><glyph glyph-name="repeat-line"
             unicode="&#xF074;"
-            horiz-adv-x="1200" d="M300 1000H1050A50 50 0 0 0 1100 950V600H1000V900H300V750L50 950L300 1150V1000zM900 200H150A50 50 0 0 0 100 250V600H200V300H900V450L1150 250L900 50V200z" /></font></defs></svg>
\ No newline at end of file
+            horiz-adv-x="1200" d="M300 1000H1050A50 50 0 0 0 1100 950V600H1000V900H300V750L50 950L300 1150V1000zM900 200H150A50 50 0 0 0 100 250V600H200V300H900V450L1150 250L900 50V200z" /><glyph glyph-name="calendar-line"
+            unicode="&#xEB27;"
+            horiz-adv-x="1200" d="M850 1050H1050A50 50 0 0 0 1100 1000V200A50 50 0 0 0 1050 150H150A50 50 0 0 0 100 200V1000A50 50 0 0 0 150 1050H350V1150H450V1050H750V1150H850V1050zM750 950H450V850H350V950H200V750H1000V950H850V850H750V950zM1000 650H200V250H1000V650z" /></font></defs></svg>
\ No newline at end of file
diff --git a/saturn/server/static/icons/remixicon.symbol.svg b/saturn/server/static/icons/remixicon.symbol.svg
index e6d167e..e0008c9 100644
--- a/saturn/server/static/icons/remixicon.symbol.svg
+++ b/saturn/server/static/icons/remixicon.symbol.svg
@@ -1 +1 @@
-<svg xmlns="http://www.w3.org/2000/svg" xlink="http://www.w3.org/1999/xlink" width="0" height="0" style="display:none;"><symbol viewBox="0 0 24 24" id="map-pin-line"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 20.9l4.95-4.95a7 7 0 1 0-9.9 0L12 20.9zm0 2.828l-6.364-6.364a9 9 0 1 1 12.728 0L12 23.728zM12 13a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm0 2a4 4 0 1 1 0-8 4 4 0 0 1 0 8z"/></symbol><symbol viewBox="0 0 24 24" id="repeat-line"><path fill="none" d="M0 0h24v24H0z"/><path d="M6 4h15a1 1 0 0 1 1 1v7h-2V6H6v3L1 5l5-4v3zm12 16H3a1 1 0 0 1-1-1v-7h2v6h14v-3l5 4-5 4v-3z"/></symbol></svg>
\ No newline at end of file
+<svg xmlns="http://www.w3.org/2000/svg" xlink="http://www.w3.org/1999/xlink" width="0" height="0" style="display:none;"><symbol viewBox="0 0 24 24" id="map-pin-line"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 20.9l4.95-4.95a7 7 0 1 0-9.9 0L12 20.9zm0 2.828l-6.364-6.364a9 9 0 1 1 12.728 0L12 23.728zM12 13a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm0 2a4 4 0 1 1 0-8 4 4 0 0 1 0 8z"/></symbol><symbol viewBox="0 0 24 24" id="repeat-line"><path fill="none" d="M0 0h24v24H0z"/><path d="M6 4h15a1 1 0 0 1 1 1v7h-2V6H6v3L1 5l5-4v3zm12 16H3a1 1 0 0 1-1-1v-7h2v6h14v-3l5 4-5 4v-3z"/></symbol><symbol viewBox="0 0 24 24" id="calendar-line"><path fill="none" d="M0 0h24v24H0z"/><path d="M17 3h4a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h4V1h2v2h6V1h2v2zm-2 2H9v2H7V5H4v4h16V5h-3v2h-2V5zm5 6H4v8h16v-8z"/></symbol></svg>
\ No newline at end of file
diff --git a/saturn/server/static/icons/remixicon.ttf b/saturn/server/static/icons/remixicon.ttf
index 243b0221ff3f059d4553973df77b234a95d63649..43af91b5c2c9d6b1838ef21caecfff2353dcefe6 100644
GIT binary patch
diff --git a/saturn/server/static/icons/remixicon.woff b/saturn/server/static/icons/remixicon.woff
index a8a6e761ef8f3230c57d27641e17e7ed329ac215..e431a2956dfe17ce43ce5ee3f2ed41081279ddcc 100644
GIT binary patch
diff --git a/saturn/server/static/icons/remixicon.woff2 b/saturn/server/static/icons/remixicon.woff2
index 183b8bef50cd201c83cbb861258ee19833bba51d..fc1b74ca70b4c3030e5d0bfc534f1b6077fff952 100644
GIT binary patch
diff --git a/saturn/server/templates/index.html b/saturn/server/templates/index.html
index 3648ad2..35a0ab9 100644
--- a/saturn/server/templates/index.html
+++ b/saturn/server/templates/index.html
@@ -12,7 +12,7 @@
 
 <div id="events">
 	{% for event in events %}
-	<div class="event">
+	<div class="event" style="border-left: 5px solid {{event.color}}">
 		<div class="summary">{{ event.summary }}</div>
 		{% if event.is_one_day() and event.is_full_day() %}
 		<div class="date only-one">
@@ -77,6 +77,10 @@
 					{{ event.freq() }}
 				</div>
 				{% endif %}
+				<div>
+					<i class="ri-calendar-line ri-fw ri-sm"></i>
+					{{ event.calendar.name }}
+				</div>
 			</div>
 		</div>
 	</div>
