Trunk Notes, Night and Day
The Trunk Notes manual gives a partial example of using Lua to automatically switch your wiki to a night mode. The idea is that at night your wiki will use light text on a dark background to make reading easier. This blog post is going to give a more complete description of how to achieve this.
To start with you need to create a special stylesheet to use at night. Anything defined here will be added to the default stylesheet.
Create a new page in Trunk Notes called Night.css with the following text:
body {
background-color: black;
color: white;
}
The next step is to create the Lua script. Add a new page called DayNight.lua:
hour = tonumber(os.date('%H'))
if hour > 20 or hour < 7 then
return "{{stylesheet Night.css}}"
end
Finally we need to ensure the script is run on each page load. Use the search in Trunk Notes to find the page Special:Header and add:
{{lua DayNight.lua}}
We’re done! You’ll now find that between 8pm and 7am that Trunk Notes uses white text on a black background.