Hi, I’ve really liked the power of Space Lua, and also the many snippets of scripts in the community channel. I’ve been using this solution: (Script) Display a calendar for Journal entries , and I am wondering how do I create a simple loop to show the annotated calendar for the whole year. This is planned to go into an archive page, where all the year’s journals can be easily browsed, while the current month’s Journal calendar goes to the home page.
Right now, I just call generate_calendar(tonumber(os.date("%Y")),tonumber(os.date("%m"))) and it generates the current month’s calendar for me
Well - I’m afraid there is no way to use the calendar widget within a loop, as it currently generates only one output/month at a time.
However, I think the easiest way to workaround that, is to create one page with the commandline for each of the 12 month below each other:
${generate_calendar(2025,1)}
${generate_calendar(2025,2)}
${generate_calendar(2025,3)}
(and so on)
Of course, not the most elegant solution, but easy
More elegant, but more work at the beginning, is to alter my code and change the main loop to generate not only one output for one month, but to generate more month in one output.
If I find some time, I’ll work on that (should not be that hard to add an additional parameter to generate multiple month at once).
I do have multiple ideas to enhance the script, anyway
But an additional tip:
For displaying the current month, you could just enter ${generate_calendar()} (without any parameter), too
function generate_calendar_year(year)
-- The `generate_calendar` function checks both year and month, so we can't just leave on nil
year = year or tonumber(os.date("%Y"))
local html = ""
for month=1,12 do
html = html .. generate_calendar(year, month).html
end
-- just to keep stuff like css classes and display mode
local tmpl = generate_calendar(year, month)
tmpl.html = html
return tmpl
end
Hello,
Found this tool and first of all it is amazing
I was wondering if there would be a way to link to creation of page with a page template for instance ?