From 30e3e5047a212f2a17dd9ee8d0431980d3c74c34 Mon Sep 17 00:00:00 2001 From: magnus Date: Tue, 9 Sep 2025 23:58:13 +0200 Subject: [PATCH 1/4] Add README.md --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..fd32773 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +# Calendar + +```lua +generate_calendar(idString, fixedYear, fixedMonth) +``` + +## Aktuell månad +Genererar en kalender med dagens datum, eller sparar senaste månaden med namnet "foo". Genereras en till kalender med samma namn visar den samma månad. + +```lua +generate_calendar("foo", 0, 0) +``` + +## Specifik månad +För att visa en kalender med enbart september 2025: +```lua +generate_calendar("fixed:1", 2025, 9) +``` \ No newline at end of file From e08667ef1175a248ecda15796fb449e200ac6782 Mon Sep 17 00:00:00 2001 From: magnus Date: Tue, 9 Sep 2025 23:59:24 +0200 Subject: [PATCH 2/4] Update README.md --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index fd32773..ac043f3 100644 --- a/README.md +++ b/README.md @@ -15,4 +15,17 @@ generate_calendar("foo", 0, 0) För att visa en kalender med enbart september 2025: ```lua generate_calendar("fixed:1", 2025, 9) +``` + +## Events + +Events läggs till med: +```plaintext +* En text för eventet [at: 2025-09-10] #event +``` + +eller + +```plaintext +* En text för eventet [at: 2025-09-10 08:00] #event ``` \ No newline at end of file From 6cdb1c9bd837e329c286b47085d2504ed87b9b6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20=C3=85hall?= Date: Thu, 6 Nov 2025 19:38:03 +0100 Subject: [PATCH 3/4] Fixed december in calendar and modernized CSS --- Library/Widgets/Calendar.md | 145 ++++++++++++++++++------------------ 1 file changed, 71 insertions(+), 74 deletions(-) diff --git a/Library/Widgets/Calendar.md b/Library/Widgets/Calendar.md index 8dae9f3..941368f 100644 --- a/Library/Widgets/Calendar.md +++ b/Library/Widgets/Calendar.md @@ -18,10 +18,10 @@ function generate_calendar(calendarID, year, month) year = (wantedMonth - (wantedMonth % 12)) / 12 month = wantedMonth % 12 if month == 0 then - month = 1 + month = 12 end end - + local events = query[[ from index.tag "event" where @@ -73,12 +73,12 @@ function generate_calendar(calendarID, year, month) for _, e in pairs(events) do local datematch = e.at.match( string.format("^%d-%02d-%02d( +[0-9]+:[0-9]+)?", year, month, day)) - if #datematch >= 2 and not datematch[2] then + if datematch and #datematch >= 2 and not datematch[2] then cellcontent = cellcontent .. string.format( [[
%s
]], e.ref, e.name ) - elseif #datematch >= 2 and datematch[2] then + elseif datematch and #datematch >= 2 and datematch[2] then cellcontent = cellcontent .. string.format( [[ @@ -166,75 +166,72 @@ end ```space-style .calendartable { border-collapse: collapse; - /* width: 500px; */ + + table { + border-color: var(--panel-border-color); + border: 2px solid #444; + border-collapse: collapse; + + th { + width: 14%; + padding: 3px; + text-align: left; + background-color: var(--panel-background-color); + color: #852624; + border: 1px solid #aaa; + } + + td { + width: 14%; + padding: 3px; + text-align: left; + vertical-align: top; + border: 1px solid #aaa; + + &.today { + background-color: #f6f3c2; + } + } + } + + a { + text-decoration-line: none; + color: var(--root-color); + + &.mark { + text-decoration-line: none; + color: var(--ui-accent-text-color); + } + } + + span.extramarker { + background-color: yellow; + } + + .event { + background-color: #2ca05a; + color: #fff; + border-radius: 4px; + padding: 4px 8px; + margin-top: 8px; + max-width: 200px; + white-space: normal; + overflow-wrap: normal !important; + word-break: normal !important; + + &.all-day { + background-color: #852624; + } + + .time { + font-weight: bold; + } + } + + .month-prev, + .month-next, + .month-now { + cursor: pointer; + } } - -.calendartable table { - border-color: var(--panel-border-color); - border: 2px solid #444; - border-collapse: collapse; -} - -.calendartable th { - width: 14%; - padding: 3px; - text-align: left; - background-color: var(--panel-background-color); - color: #852624; - border: 1px solid #aaa; -} - - -.calendartable td { - width: 14%; - padding: 3px; - text-align: left; - vertical-align: top; - border: 1px solid #aaa; -} - -.calendartable td.today { - background-color: #f6f3c2; -} - -.calendartable a { - text-decoration-line: none; - color: var(--root-color); -} - -.calendartable a.mark { - text-decoration-line: none; - color: var(--ui-accent-text-color); -} - -.calendartable span.extramarker { - background-color: yellow; -} - -.calendartable .event { - background-color: #2ca05a; - color: #fff; - border-radius: 4px; - padding: 4px 8px; - margin-top: 8px; - max-width: 200px; - white-space: normal; - overflow-wrap: normal !important; - word-break: normal !important; -} - -.calendartable .event.all-day { - background-color: #852624; -} - -.calendartable .event .time { - font-weight: bold; -} - -.calendartable .month-prev, -.calendartable .month-next, -.calendartable .month-now { - cursor: pointer; -} - ``` From f825acc8c03c40db057e8bb6ca1bb86c0ca80c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20=C3=85hall?= Date: Mon, 17 Nov 2025 10:32:46 +0100 Subject: [PATCH 4/4] Ironed out another december bug --- Library/Widgets/Calendar.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Library/Widgets/Calendar.md b/Library/Widgets/Calendar.md index 941368f..417f9b8 100644 --- a/Library/Widgets/Calendar.md +++ b/Library/Widgets/Calendar.md @@ -11,15 +11,13 @@ function generate_calendar(calendarID, year, month) -- A specified year and month will always display that calendar. if year == 0 and month == 0 then local wantedMonth = clientStore.get("calendar:" .. calendarID) + editor.flashNotification(wantedMonth) -- Calculate year and month from the current date plus a month offset. if wantedMonth == nil then - wantedMonth = tonumber(os.date("%Y")) * 12 + tonumber(os.date("%m")) + wantedMonth = tonumber(os.date("%Y")) * 12 + (tonumber(os.date("%m"))-1) end year = (wantedMonth - (wantedMonth % 12)) / 12 - month = wantedMonth % 12 - if month == 0 then - month = 12 - end + month = wantedMonth % 12 + 1 end local events = query[[