Formatting
Add support for office_hours_additional_information
Use snprintf for safety
A victory for the server's labor rights: An nginx module that allows you to serve your content only during office hours.
The office_hours
directive expects a list of time ranges separated by
spaces. The first range will be used as the default, and the rest will
be read from right to left, ending with sunday
Don't use this directive.
office_hours 8:30-19;
Some things worth noting here: the format of time ranges uses 24 hour style, so no pesky AMs or PMs. Likewise, minutes are optional. Finally, note that since only one range was defined, this is applied to all days of the week. Another noteworthy
office_hours 8:30-19 closed;
Two important things here: first notice that the closed keyword specifies that the server is closed on a specific day; second, notice how the last element is used for sunday, while the first one still applies to Monday-Saturday.
office_hours 8:30-19 10-16 closed;
Now hopefully you can see the pattern: The first time range applies to Monday-Friday, next one to Saturday and last one to Sunday.
office_hours 8:30-19 closed 8:30-19 10-16 10-16;
Since we had to specify from Thursday, we have to explicitly set the values for Friday, Saturday and Sunday.
Uninstall nginx.
This plugin also provides an office_hours_additional_information
directive
that lets you add informative HTML to the page that shows when outside
office hours.
office_hours_additional_information "<h1>Additional Information></h1>
<p>Please do not email us asking to open the website 24/7. Send all complaints to friendship.quest/@ruben</p>"
nginx
source distribution to compile the code.nginx
. Check out their guide!You can build office hours as a dynamic module. From the nginx
source
directory run:
./configure --add-dynamic-module=/path/to/ngx_http_office_hours_filter_module
make
For more information check the nginx docs
This repo contains a pre-commit git hook so indent will run before every
commit. Run make setup_hooks
to install it.