]> git.r.bdr.sh - rbdr/ngx_http_office_hours_filter_module/blame - README.md
Formatting
[rbdr/ngx_http_office_hours_filter_module] / README.md
CommitLineData
0312f226
RBR
1# Nginx Office Hours
2
31993a16
BB
3A victory for the server's labor rights: An nginx module that allows you to serve your content only during office hours.
4
5## Using the directive
6
fa2b280d 7The `office_hours` directive expects a list of time ranges separated by
31993a16
BB
8spaces. The first range will be used as the default, and the rest will
9be read from right to left, ending with *sunday*
10
11### Example 1: Open 24 hours
12
13Don't use this directive.
14
15### Example 2: Open every day from 08:30 AM to 7:00 PM
16
17```
18office_hours 8:30-19;
19```
20
21Some things worth noting here: the format of time ranges uses 24 hour
22style, so no pesky AMs or PMs. Likewise, minutes are optional. Finally,
23note that since only one range was defined, this is applied to all days
24of the week. Another noteworthy
25
26### Example 3: Open every day from 08:30 AM to 7:00 PM, but closed sundays
27
28```
29office_hours 8:30-19 closed;
30```
31
32Two important things here: first notice that the closed keyword
33specifies that the server is closed on a specific day; second, notice
34how the last element is used for sunday, while the first one still
35applies to Monday-Saturday.
36
37### Example 4: Open weekdays from 08:30 AM to 7:00 PM, Saturdays 10:00 AM to 4:00 PM, closed on sundays
38
39```
40office_hours 8:30-19 10-16 closed;
41```
42
43Now hopefully you can see the pattern: The first time range applies to
44Monday-Friday, next one to Saturday and last one to Sunday.
45
46### Example 5: Open weekdays from 08:30 AM to 7:00 PM, closed on thursdays, reduced hours on weekends.
47
48```
49office_hours 8:30-19 closed 8:30-19 10-16 10-16;
50```
51
52Since we had to specify from Thursday, we have to explicitly set the
53values for Friday, Saturday and Sunday.
54
55### Example 6: Closed every day.
56
57Uninstall nginx.
58
8b830d84
RBR
59## Adding more information
60
61This plugin also provides an `office_hours_additional_information` directive
62that lets you add informative HTML to the page that shows when outside
63office hours.
64
65```
66office_hours_additional_information "<h1>Additional Information></h1>
67<p>Please do not email us asking to open the website 24/7. Send all complaints to friendship.quest/@ruben</p>"
68```
69
31993a16
BB
70## What you will need to get started
71
fa2b280d
BB
72* [astyle][astyle]: Used to format the code
73* An `nginx` [source distribution][nginx] to compile the code.
e7564a5b 74* A way to compile `nginx`. Check out [their guide][nginx-guide]!
fa2b280d
BB
75
76## Building the module
77
e7564a5b 78You can build office hours as a dynamic module. From the `nginx` source
fa2b280d
BB
79directory run:
80
81```
82./configure --add-dynamic-module=/path/to/ngx_http_office_hours_filter_module
83make
84```
85
86For more information check the [nginx docs][nginx-module-docs]
87
900e0f4a
BB
88## Installing git hooks
89
90This repo contains a pre-commit git hook so indent will run before every
91commit. Run `make setup_hooks` to install it.
92
31993a16
BB
93## Further Improvements
94
8b830d84
RBR
95* Add support for double shifts in the same day
96* Add support for serving custom HTML when server is closed
d6a66c48 97* Add support for timezones (currently only GMT)
31993a16
BB
98* Add support for public holidays
99* Add support to respect the time zone of the visitor and not just the
100 server
fa2b280d
BB
101
102[astyle]: http://astyle.sourceforge.net
103[nginx]: https://nginx.org/en/download.html
e7564a5b 104[nginx-guide]: https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source/#sources
fa2b280d 105[nginx-module-docs]: https://www.nginx.com/resources/wiki/extending/