]> git.r.bdr.sh - rbdr/ngx_http_office_hours_filter_module/commitdiff
Merge branch 'feature/rbdr-initial-scaffolding' into develop
authorBen Beltran <redacted>
Mon, 12 Nov 2018 22:16:57 +0000 (23:16 +0100)
committerBen Beltran <redacted>
Mon, 12 Nov 2018 23:28:41 +0000 (00:28 +0100)
.gitignore [new file with mode: 0644]
.indent.pro [new file with mode: 0644]
CHANGELOG.md [new file with mode: 0644]
CONTRIBUTING.md [new file with mode: 0644]
Makefile [new file with mode: 0644]
README.md
doc/example_configuration [new file with mode: 0644]
ngx_office_hours.c [new file with mode: 0644]
scripts/git-hooks/pre-commit [new file with mode: 0755]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..cc43c10
--- /dev/null
@@ -0,0 +1 @@
+*.BAK
diff --git a/.indent.pro b/.indent.pro
new file mode 100644 (file)
index 0000000..97cfdee
--- /dev/null
@@ -0,0 +1,13 @@
+-bacc
+-bad
+-bap
+-bbb
+-nbc
+-br
+-cdb
+-nce
+-nfbs
+-i4
+-l120
+-nlp
+-nut
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644 (file)
index 0000000..e0f6ead
--- /dev/null
@@ -0,0 +1,17 @@
+# Changelog
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](http://keepachangelog.com/)
+and this project adheres to [Semantic Versioning](http://semver.org/).
+
+## [Unreleased]
+### Added
+- This CHANGELOG
+- A README
+- A CONTRIBUTING guide
+- indent.pro file for automatic formatting
+- Git hook to format code before commit
+- Makefile with tasks to format and install git hooks
+- A gitignore file
+
+[Unreleased]: https://gitlab.com/rbdr/ngx_office_hours/compare/master...develop
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644 (file)
index 0000000..4a7aded
--- /dev/null
@@ -0,0 +1,25 @@
+# Contributing to ngx_office_hours
+
+This NGINX module has the simple goal of allowing you to specify office
+hours for your server, any contributions are welcome especially if it
+makes that goal easier to achieve.
+
+## The objective of Sumo
+
+Give your web server the benefit of a regulated work schedule, and
+notify the consumers of the appropriate office hours to visit the
+website.
+
+A big factor currently not considered is to serve the site in the time
+zone of the visitor, currently it is tied to server time.
+
+## How to contribute
+
+Above All: Be nice, always.
+
+* Ensure the style checker shows no warnings or errors
+* Don't break the CI
+* Make the PRs according to [Git Flow][gitflow]: (features go to
+  develop, hotfixes go to master)
+
+[gitflow]: https://github.com/nvie/gitflow
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..2dad03f
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,5 @@
+setup_hooks:
+       ln -s ../../scripts/git-hooks/pre-commit .git/hooks/pre-commit
+
+format:
+       indent ngx_office_hours.c
index a56c1e0d0d19d0f9ed7887581f7cc7d6c2ee906d..01ab92772d1441423889182478797525eb84d32a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,3 +1,74 @@
 # Nginx Office Hours
 
-A victory for the server's labor rights: An nginx module that allows you to serve your content only during office hours.
\ No newline at end of file
+A victory for the server's labor rights: An nginx module that allows you to serve your content only during office hours.
+
+## Using the directive
+
+The `office_hours` directive expects a list of time ranges sepaarated by
+spaces. The first range will be used as the default, and the rest will
+be read from right to left, ending with *sunday*
+
+### Example 1: Open 24 hours
+
+Don't use this directive.
+
+### Example 2: Open every day from 08:30 AM to 7:00 PM
+
+```
+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 
+
+### Example 3: Open every day from 08:30 AM to 7:00 PM, but closed sundays
+
+```
+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.
+
+### Example 4: Open weekdays from 08:30 AM to 7:00 PM, Saturdays 10:00 AM to 4:00 PM, closed on sundays
+
+```
+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.
+
+### Example 5: Open weekdays from 08:30 AM to 7:00 PM, closed on thursdays, reduced hours on weekends.
+
+```
+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.
+
+### Example 6: Closed every day.
+
+Uninstall nginx.
+
+## What you will need to get started
+
+I'm still not sure! I'm learning how to build this nginx module, so I'll
+figure it out as I go and add it here.
+
+## Installing git hooks
+
+This repo contains a pre-commit git hook so indent will run before every
+commit. Run `make setup_hooks` to install it.
+
+## Further Improvements
+
+* Add support for public holidays
+* Add support to respect the time zone of the visitor and not just the
+  server
+* Add support for double shifts in the same day
diff --git a/doc/example_configuration b/doc/example_configuration
new file mode 100644 (file)
index 0000000..136f7b8
--- /dev/null
@@ -0,0 +1,15 @@
+server {
+
+        listen 80;
+
+        root /var/www/blog;
+        index index.html index.htm;
+
+        server_name blog.unlimited.pizza;
+
+        office_hours 8:30-20 10-16 closed;
+
+        location / {
+                try_files $uri $uri/ =404;
+        }
+}
diff --git a/ngx_office_hours.c b/ngx_office_hours.c
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/scripts/git-hooks/pre-commit b/scripts/git-hooks/pre-commit
new file mode 100755 (executable)
index 0000000..6a9ebca
--- /dev/null
@@ -0,0 +1,3 @@
+#!/usr/bin/env sh
+
+make format