diff options
author | Christian Franke <nobody@nowhere.ws> | 2017-09-08 13:24:06 +0200 |
---|---|---|
committer | Christian Franke <nobody@nowhere.ws> | 2017-09-08 13:24:06 +0200 |
commit | f1dd175f1e4c9449a30704ea2df422f76f269c46 (patch) | |
tree | 9230d228c0bfbe6d2e03b7b8b820a23007459fdb | |
parent | 294c9d64dd16f5a892dca23ff177839fceb71bd6 (diff) |
Remove calendar references
-rw-r--r-- | scripts/calendar_plugin.py | 48 | ||||
-rw-r--r-- | scripts/calendar_plugin2.py | 124 | ||||
-rw-r--r-- | scripts/template.conf | 2 | ||||
-rw-r--r-- | template/pages/index2/content.html | 7 | ||||
-rw-r--r-- | template/pages/termine/content.html | 16 |
5 files changed, 2 insertions, 195 deletions
diff --git a/scripts/calendar_plugin.py b/scripts/calendar_plugin.py deleted file mode 100644 index c277a9f..0000000 --- a/scripts/calendar_plugin.py +++ /dev/null @@ -1,48 +0,0 @@ -import template -import plugin -import string -import os - -import locale -from datetime import datetime,timedelta -import jinja2 -import json - -class CalendarPlugin: - def __init__(self): - calpath = os.path.join(template.path, 'calendar.json') - with open(calpath, 'r') as calfile: - events = json.load(calfile) - for event in events: - event['start'] = datetime.strptime(event['start'], '%Y-%m-%dT%H:%M:%S') - event['end'] = datetime.strptime(event['end'], '%Y-%m-%dT%H:%M:%S') - event['multiday'] = (event['end'] - event['start']) > timedelta(days=1) - self.events = sorted(events, key=lambda x:x['start']) - template_loader = jinja2.FileSystemLoader(searchpath=os.path.join(template.path)) - self.template_env = jinja2.Environment(loader=template_loader) - locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8') - - def _get_calendar(self): - return self.template_env.get_template('calendar.j2').render({ - 'events': self.events, - 'class': 'calendar-main' - }).encode('utf-8') - - def _get_calendar_head(self): - return self.template_env.get_template('calendar_head.j2').render({ - 'events': self.events, - 'class': 'calendar-head', - 'cutoff': datetime.now() + timedelta(days=7) - }).encode('utf-8') - - def process_content(self, page_content): - return_value = {} - for filename, content in page_content.iteritems(): - t = string.Template(content) - return_value[filename] = t.safe_substitute( - calendar = self._get_calendar(), - calendar_head = self._get_calendar_head() - ) - return return_value - -plugin.plugin_manager.register(CalendarPlugin()) diff --git a/scripts/calendar_plugin2.py b/scripts/calendar_plugin2.py deleted file mode 100644 index 62a68aa..0000000 --- a/scripts/calendar_plugin2.py +++ /dev/null @@ -1,124 +0,0 @@ -import template -import plugin -import string -import os - -import locale -from datetime import datetime,timedelta,date -import jinja2 -import json - -class TabularCalendarPlugin: - def __init__(self): - calpath = os.path.join(template.path, 'tabcalendar.json') - - with open(calpath, 'r') as calfile: - events = json.load(calfile) - for event in events: - event['start'] = datetime.strptime(event['start'], '%Y-%m-%dT%H:%M:%S') - event['end'] = datetime.strptime(event['end'], '%Y-%m-%dT%H:%M:%S') - event['multiday'] = (event['end'] - event['start']) > timedelta(days=1) - events = sorted(events, key=lambda x:x['start']) - - i = 0 - for event in events: - event['id'] = i - i += 1 - - first = events[0]['start'] - last = events[-1]['end'] - - calendar_start = first - timedelta(days=first.weekday()) - if calendar_start.month != first.month: - calendar_start = date(first.year, first.month, 1) - else: - calendar_start = date(calendar_start.year, - calendar_start.month, - calendar_start.day) - calendar_end = last + timedelta(days=6 - last.weekday()) - if calendar_end.month != last.month: - calendar_end = date(last.year,last.month,last.day) - while True: - next_end = calendar_end + timedelta(days=1) - if next_end.month != calendar_end.month: - break - calendar_end = next_end - else: - calendar_end = date(calendar_end.year, - calendar_end.month, - calendar_end.day) - - months = [] - cur_day = calendar_start - active_month = None - active_week = None - today = date.today() - while cur_day <= calendar_end: - cur_month = cur_day.month - cur_week = cur_day.isocalendar()[1] - - if cur_month != active_month: - months.append({ - 'year': cur_day.year, - 'month': cur_day.month, - 'date': date(cur_day.year, cur_day.month, 1), - 'weeks': [[]] - }) - active_week = cur_week - active_month = cur_month - if cur_week != active_week: - months[-1]['weeks'].append([]) - active_week = cur_week - - week_list = months[-1]['weeks'][-1] - week_list.append({ - 'year': cur_day.year, - 'month': cur_day.month, - 'day': cur_day.day, - 'today': cur_day == today, - 'weekday': cur_day.weekday(), - 'events': [] - }) - event_list = week_list[-1]['events'] - day_start = datetime(cur_day.year, cur_day.month, cur_day.day) - day_end = day_start + timedelta(days=1) - - for event in events: - if event['start'] >= day_end \ - or event['end'] <= day_start: - continue - event_list.append(event) - - cur_day += timedelta(days=1) - - self.months = months - self.events = events - template_loader = jinja2.FileSystemLoader(searchpath=os.path.join(template.path)) - self.template_env = jinja2.Environment(loader=template_loader) - locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8') - - def _get_calendar_tabs(self): - return self.template_env.get_template('tabcalendar.j2').render({ - 'months': self.months, - 'events': self.events, - 'class': 'expanded' - }).encode('utf-8') - - def _get_calendar_events(self): - return self.template_env.get_template('tabcalendar_list.j2').render({ - 'months': self.months, - 'events': self.events, - 'class': 'expanded' - }).encode('utf-8') - - def process_content(self, page_content): - return_value = {} - for filename, content in page_content.iteritems(): - t = string.Template(content) - return_value[filename] = t.safe_substitute( - tabcalendar_tabs = self._get_calendar_tabs(), - tabcalendar_events = self._get_calendar_events(), - ) - return return_value - -plugin.plugin_manager.register(TabularCalendarPlugin()) diff --git a/scripts/template.conf b/scripts/template.conf index 8e6192a..2f9ee42 100644 --- a/scripts/template.conf +++ b/scripts/template.conf @@ -7,6 +7,4 @@ path = ../template target = ../public/ [Plugins] -calendar_plugin=load -calendar_plugin2=load news=load diff --git a/template/pages/index2/content.html b/template/pages/index2/content.html index 0ebe4d8..bfaf548 100644 --- a/template/pages/index2/content.html +++ b/template/pages/index2/content.html @@ -59,11 +59,4 @@ Die breite Unterstützung verschiedener Zugänge zu Technik ist erklärtes Ziel Germany </p> </div> - <div class="col-sm-4"> -<h2> - Nächste Termine -</h2> -$calendar_head -<p><a href="/termine" class="btn btn-primary btn-default">mehr »</a></p> - </div> </div> diff --git a/template/pages/termine/content.html b/template/pages/termine/content.html index a06399e..3d35593 100644 --- a/template/pages/termine/content.html +++ b/template/pages/termine/content.html @@ -3,17 +3,10 @@ Termine </h1> <div class="row"> -<div class="col-md-12"> +<div class="col-md-8"> <p> - Hier findest du regelmäßige, unregelmäßige und nur einmal stattfindende Veranstaltungen im sublab und Umgebung. Die Veranstaltungen stehen allen offen. + Das sublab gibt es leider nicht mehr. Daher finden sich hier auch keine Termimne. </p> - $tabcalendar_tabs -</div> -</div> -<div class="row"> -<div class="col-md-8"> -<h2>Details</h2> -$tabcalendar_events </div> <div class="col-md-4"> <a href="img/hallway.jpg"><img class="img-responsive" src="img/hallway_klein.jpg" alt="Unser Flur mit Buero, Lager, Hacklab."></a> @@ -22,8 +15,3 @@ $tabcalendar_events </p> </div> </div> -<div class="row"> -<div class="col-md-12"> -<p>Ebenso gibt es einen <a href="/calendar.ics">iCAL Kalender</a> der die Veranstalungen enthaelt.</p> -</div> -</div> |