Let users send misprints from your website to Slack using lua script via nginx. lua-resty-http and lua cjson is required.
Library contains nginx lua file and Javascript front-end file. You should use both of them to make misprint reporter works.
When user selects text on a page and presses Ctrl+Enter, the Newrphus sends POST request to url with selected text and contextbefore and after selected text . Right after the keypress event, it calls callback function, where you can tell user that report was sent.
-
Create new Incoming webhook in Slack.
-
Configure your nginx file
http { lua_shared_dict misprint_fixed 5m; # sahred dict to not send misprints twice lua_package_path "/path/to/lua-resty-http/lib/?.lua;;"; limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s; # flood protection server { location / { # your default backend (php, python, ruby) include /usr/local/etc/nginx/proxy_params; proxy_pass http://127.0.0.1:8000/; } location /lua_script/ { resolver 8.8.8.8; # dns resolver for resty.http limit_req zone=one burst=2; # antiflood content_by_lua_file /path/to/src/script.lua; } }
-
Modify
slack_configdict insrc/script.luafile. -
Include js to the page, where you want to track misprints.
<script src="js/newrphus.js"></script> <script> newrphus.init({ url: '/lua_script/', callback: function() { alert('Misprint sent'); } }); </script>
-
Tell users to select text and press Ctrl+Enter to send report.