Compare commits
No commits in common. "c72738eda2b37de4b424d4fe6edc9ce4e499ec88" and "60fcd8bee14fb8c42e00eae217a1218373c1f4a2" have entirely different histories.
c72738eda2
...
60fcd8bee1
19
README.md
Normal file
19
README.md
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
|
||||||
|
# Kobo Calendar Server
|
||||||
|
|
||||||
|
Small calendar web-server pulling from ICAL files, and presenting events in
|
||||||
|
a lightweight html frontend.
|
||||||
|
|
||||||
|
The motivation was to create a lightweight wall calendar to use with an old Kobo
|
||||||
|
Aura e-reader, to take advantage of the it's e-ink screen.
|
||||||
|
|
||||||
|
## Example usage
|
||||||
|
|
||||||
|
1. Edit `config.py` to include links to your ICAL files. (Google Calendar hidden
|
||||||
|
ICAL links works great here.)
|
||||||
|
2. Launch server using something like: `python main.py --port 8082 --hostname 192.168.87.197`
|
||||||
|
3. Navigate to [192.168.87.197:8082](http://192.168.87.197:8082/).
|
||||||
|
4. Enjoy
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ logger = logging.getLogger(__name__)
|
||||||
SESSION = requests_cache.CachedSession('calendar')
|
SESSION = requests_cache.CachedSession('calendar')
|
||||||
|
|
||||||
@functools.cache
|
@functools.cache
|
||||||
def get_events_for_month(ical_link: str, today: datetime.date):
|
def get_events_for_month(ical_link, today):
|
||||||
logger.warning('Downloading ical from Google')
|
logger.warning('Downloading ical from Google')
|
||||||
response = SESSION.get(ical_link)
|
response = SESSION.get(ical_link)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
|
@ -1,24 +0,0 @@
|
||||||
"""# Kobo Calendar Server
|
|
||||||
|
|
||||||
Small calendar web-server pulling from ICAL files, and presenting events in
|
|
||||||
a lightweight HMTL frontend.
|
|
||||||
|
|
||||||
The motivation was to create a lightweight wall calendar to use with an old
|
|
||||||
[Kobo Aura e-reader](https://en.wikipedia.org/wiki/Kobo_Aura), to take
|
|
||||||
advantage of the its e-ink screen, but I had problems getting it to run 24/7.
|
|
||||||
|
|
||||||
## Example usage
|
|
||||||
|
|
||||||
1. Add ICAL links to any [SecretLoader
|
|
||||||
compatible](https://gitfub.space/Jmaa/secret_loader) location, for the key
|
|
||||||
`ical_links`. Simplest approach is to add them to a file under
|
|
||||||
`secrets/ical_links`. ([Google Calendar hidden ICAL
|
|
||||||
links](https://support.google.com/calendar/answer/37648) works great here.)
|
|
||||||
2. Launch server using something like: `python -m kobo_wall_calendar`
|
|
||||||
3. Navigate to <http://localhost:8080/>.
|
|
||||||
4. Enjoy
|
|
||||||
"""
|
|
||||||
|
|
||||||
__all__ = ['__version__']
|
|
||||||
|
|
||||||
from ._version import __version__
|
|
|
@ -1 +0,0 @@
|
||||||
__version__ = '0.1.0'
|
|
|
@ -2,7 +2,9 @@ import argparse
|
||||||
import bottle
|
import bottle
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from . import (google_calendar, config)
|
import google_calendar
|
||||||
|
|
||||||
|
import config
|
||||||
|
|
||||||
TEMPLATE_INDEX = bottle.SimpleTemplate(name = "templates/index.html")
|
TEMPLATE_INDEX = bottle.SimpleTemplate(name = "templates/index.html")
|
||||||
|
|
||||||
|
@ -37,11 +39,16 @@ def render_calendar(events_map, today):
|
||||||
header = today.strftime('%B %Y')
|
header = today.strftime('%B %Y')
|
||||||
return TEMPLATE_INDEX.render(days = days, header = header)
|
return TEMPLATE_INDEX.render(days = days, header = header)
|
||||||
|
|
||||||
def get_events_map() -> tuple[dict[datetime.date, list[str]], datetime.date]:
|
## Paths
|
||||||
|
|
||||||
|
@bottle.route('/static/<path:path>')
|
||||||
|
def static(path):
|
||||||
|
return bottle.static_file(path, root = './static')
|
||||||
|
|
||||||
|
def get_events_map():
|
||||||
today = datetime.date.today()
|
today = datetime.date.today()
|
||||||
events_map = { }
|
events_map = { }
|
||||||
for url in config.get_ical_links():
|
for prefix, url in config.ICAL_LINKS.items():
|
||||||
prefix = 'J '
|
|
||||||
for date, event in google_calendar.get_events_for_month(url, today):
|
for date, event in google_calendar.get_events_for_month(url, today):
|
||||||
text = '{}: {}'.format(prefix, event.summary)
|
text = '{}: {}'.format(prefix, event.summary)
|
||||||
events_map.setdefault(date, []).append(text)
|
events_map.setdefault(date, []).append(text)
|
||||||
|
@ -49,28 +56,19 @@ def get_events_map() -> tuple[dict[datetime.date, list[str]], datetime.date]:
|
||||||
|
|
||||||
return events_map, today
|
return events_map, today
|
||||||
|
|
||||||
## Paths
|
|
||||||
|
|
||||||
@bottle.route('/static/<path:path>')
|
|
||||||
def static(path):
|
|
||||||
return bottle.static_file(path, root = './static')
|
|
||||||
|
|
||||||
@bottle.route('/')
|
@bottle.route('/')
|
||||||
def month_calendar():
|
def reddit_index():
|
||||||
events_map, today = get_events_map()
|
events_map, today = get_events_map()
|
||||||
return render_calendar(events_map, today)
|
return render_calendar(events_map, today)
|
||||||
|
|
||||||
|
## Argument parsing
|
||||||
|
|
||||||
def main():
|
parser = argparse.ArgumentParser()
|
||||||
## Argument parsing
|
parser.add_argument('--hostname', action='store', default = 'localhost', dest='hostname')
|
||||||
parser = argparse.ArgumentParser()
|
parser.add_argument('--port', action='store', default = 8080, dest='port', type = int)
|
||||||
parser.add_argument('--hostname', action='store', default = 'localhost', dest='hostname')
|
|
||||||
parser.add_argument('--port', action='store', default = 8080, dest='port', type = int)
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
# Initialization
|
|
||||||
bottle.run(host=args.hostname, port=args.port)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
args = parser.parse_args()
|
||||||
|
bottle.run(host=args.hostname, port=args.port)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
ical
|
|
||||||
requests_cache
|
|
||||||
secret_loader @ git+https://gitfub.space/Jmaa/secret_loader@main
|
|
||||||
bottle
|
|
Loading…
Reference in New Issue
Block a user