remove unnecessary config
This commit is contained in:
@@ -66,22 +66,6 @@ class Today(inkycal_module):
|
|||||||
name = "Today - Show today's date and events from iCalendars"
|
name = "Today - Show today's date and events from iCalendars"
|
||||||
|
|
||||||
optional = {
|
optional = {
|
||||||
"week_starts_on": {
|
|
||||||
"label": "When does your week start? (default=Monday)",
|
|
||||||
"options": ["Monday", "Sunday"],
|
|
||||||
"default": "Monday",
|
|
||||||
},
|
|
||||||
"show_events": {
|
|
||||||
"label": "Show parsed events? (default = True)",
|
|
||||||
"options": [True, False],
|
|
||||||
"default": True,
|
|
||||||
},
|
|
||||||
"ical_urls": {
|
|
||||||
"label": "iCalendar URL/s, separate multiple ones with a comma",
|
|
||||||
},
|
|
||||||
"ical_files": {
|
|
||||||
"label": "iCalendar filepaths, separated with a comma",
|
|
||||||
},
|
|
||||||
"date_format": {
|
"date_format": {
|
||||||
"label": "Use an arrow-supported token for custom date formatting "
|
"label": "Use an arrow-supported token for custom date formatting "
|
||||||
+ "see https://arrow.readthedocs.io/en/stable/#supported-tokens, e.g. D MMM",
|
+ "see https://arrow.readthedocs.io/en/stable/#supported-tokens, e.g. D MMM",
|
||||||
@@ -92,6 +76,22 @@ class Today(inkycal_module):
|
|||||||
+ "see https://arrow.readthedocs.io/en/stable/#supported-tokens, e.g. HH:mm",
|
+ "see https://arrow.readthedocs.io/en/stable/#supported-tokens, e.g. HH:mm",
|
||||||
"default": "HH:mm",
|
"default": "HH:mm",
|
||||||
},
|
},
|
||||||
|
"webdav_hostname": {
|
||||||
|
"label": "WebDAV Hostname (e.g. https://webdav.server.com)",
|
||||||
|
"default": "",
|
||||||
|
},
|
||||||
|
"webdav_login": {
|
||||||
|
"label": "WebDAV Login Username",
|
||||||
|
"default": "",
|
||||||
|
},
|
||||||
|
"webdav_password": {
|
||||||
|
"label": "WebDAV Login Password",
|
||||||
|
"default": "",
|
||||||
|
},
|
||||||
|
"webdav_file_path": {
|
||||||
|
"label": "WebDAV File Path to Super Productivity JSON file",
|
||||||
|
"default": "",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
@@ -112,31 +112,24 @@ class Today(inkycal_module):
|
|||||||
self.time_format = config['time_format']
|
self.time_format = config['time_format']
|
||||||
self.language = config['language']
|
self.language = config['language']
|
||||||
|
|
||||||
if config['ical_urls'] and isinstance(config['ical_urls'], str):
|
# webdav configuration
|
||||||
self.ical_urls = config['ical_urls'].split(',')
|
self.webdav_options = {
|
||||||
else:
|
'webdav_hostname': config.get('webdav_hostname', ''),
|
||||||
self.ical_urls = config['ical_urls']
|
'webdav_login': config.get('webdav_login', ''),
|
||||||
|
'webdav_password': config.get('webdav_password', ''),
|
||||||
if config['ical_files'] and isinstance(config['ical_files'], str):
|
'webdav_file_path': config.get('webdav_file_path', ''),
|
||||||
self.ical_files = config['ical_files'].split(',')
|
}
|
||||||
else:
|
|
||||||
self.ical_files = config['ical_files']
|
|
||||||
|
|
||||||
# additional configuration
|
# additional configuration
|
||||||
self.timezone = get_system_tz()
|
self.timezone = get_system_tz()
|
||||||
|
|
||||||
# 选择字体:优先使用支持中文的 NotoSansCJK,否则使用 NotoSans
|
# 选择字体:优先使用支持中文的 NotoSansCJK,否则使用 NotoSans
|
||||||
self._font_family = self._select_font_family()
|
self._font_family = self._select_font_family()
|
||||||
self.num_font = ImageFont.truetype(
|
|
||||||
fonts[self._font_family], size=self.fontsize
|
|
||||||
)
|
|
||||||
|
|
||||||
# give an OK message
|
# give an OK message
|
||||||
logger.debug(f'{__name__} loaded')
|
logger.debug(f'{__name__} loaded')
|
||||||
|
|
||||||
def _select_font_family(self) -> str:
|
def _select_font_family(self) -> str:
|
||||||
"""选择合适的字体族(支持中文优先)"""
|
|
||||||
# 优先级:NotoSansCJKsc (支持中文) > NotoSans
|
|
||||||
preferred_fonts = [
|
preferred_fonts = [
|
||||||
'NotoSansCJKsc-Regular',
|
'NotoSansCJKsc-Regular',
|
||||||
'NotoSans-SemiCondensed'
|
'NotoSans-SemiCondensed'
|
||||||
@@ -147,11 +140,9 @@ class Today(inkycal_module):
|
|||||||
logger.debug(f'Selected font: {font_name}')
|
logger.debug(f'Selected font: {font_name}')
|
||||||
return font_name
|
return font_name
|
||||||
|
|
||||||
# 如果都不存在,使用第一个可用字体
|
|
||||||
return list(fonts.keys())[0]
|
return list(fonts.keys())[0]
|
||||||
|
|
||||||
def _get_font(self, size: int) -> ImageFont.FreeTypeFont:
|
def _get_font(self, size: int) -> ImageFont.FreeTypeFont:
|
||||||
"""获取指定大小的字体"""
|
|
||||||
return ImageFont.truetype(fonts[self._font_family], size=size)
|
return ImageFont.truetype(fonts[self._font_family], size=size)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -272,6 +263,16 @@ class Today(inkycal_module):
|
|||||||
|
|
||||||
from inkycal.modules.super_productivity_utils import get_today_tasks
|
from inkycal.modules.super_productivity_utils import get_today_tasks
|
||||||
|
|
||||||
|
import requests
|
||||||
|
url = self.webdav_options['webdav_hostname'] + self.webdav_options['webdav_file_path']
|
||||||
|
response = requests.get(url, auth=(
|
||||||
|
self.webdav_options['webdav_login'],
|
||||||
|
self.webdav_options['webdav_password']
|
||||||
|
))
|
||||||
|
content = response.content
|
||||||
|
content = content[8:]
|
||||||
|
with open('/workspaces/Inkycal/inkycal/modules/super_productivity.json', 'wb') as f:
|
||||||
|
f.write(content)
|
||||||
|
|
||||||
json_file_path = '/workspaces/Inkycal/inkycal/modules/super_productivity.json'
|
json_file_path = '/workspaces/Inkycal/inkycal/modules/super_productivity.json'
|
||||||
task_list = get_today_tasks(json_file_path)
|
task_list = get_today_tasks(json_file_path)
|
||||||
@@ -327,7 +328,7 @@ class Today(inkycal_module):
|
|||||||
else:
|
else:
|
||||||
# 没有事件时显示提示
|
# 没有事件时显示提示
|
||||||
write(
|
write(
|
||||||
im_black,
|
im_colour,
|
||||||
(right_x, int(im_height / 2)),
|
(right_x, int(im_height / 2)),
|
||||||
(right_usable_width, line_height),
|
(right_usable_width, line_height),
|
||||||
"No events today",
|
"No events today",
|
||||||
|
|||||||
Reference in New Issue
Block a user