diff --git a/hc/front/management/commands/pygmentize.py b/hc/front/management/commands/pygmentize.py index 29835a45..0972692e 100644 --- a/hc/front/management/commands/pygmentize.py +++ b/hc/front/management/commands/pygmentize.py @@ -27,10 +27,12 @@ class Command(BaseCommand): return # Invocation examples - _process("bash", lexers.BashLexer()) + _process("bash_curl", lexers.BashLexer()) + _process("bash_wget", lexers.BashLexer()) _process("browser", lexers.JavascriptLexer()) _process("crontab", lexers.BashLexer()) - _process("python", lexers.PythonLexer()) + _process("python_urllib2", lexers.PythonLexer()) + _process("python_requests", lexers.PythonLexer()) _process("php", lexers.PhpLexer()) _process("powershell", lexers.shell.PowerShellLexer()) _process("node", lexers.JavascriptLexer()) @@ -38,7 +40,8 @@ class Command(BaseCommand): # API examples _process("list_checks_request", lexers.BashLexer()) _process("list_checks_response", lexers.JsonLexer()) - _process("create_check_request", lexers.BashLexer()) + _process("create_check_request_a", lexers.BashLexer()) + _process("create_check_request_b", lexers.BashLexer()) _process("create_check_response", lexers.JsonLexer()) _process("pause_check_request", lexers.BashLexer()) _process("pause_check_response", lexers.JsonLexer()) diff --git a/static/css/docs.css b/static/css/docs.css index 4455b211..c50fc5dd 100644 --- a/static/css/docs.css +++ b/static/css/docs.css @@ -58,4 +58,8 @@ a.section:hover { color: #427d5e; background-color: #f2f9f6; border-radius: 4px; -} \ No newline at end of file +} + +.snippet pre { + border: 1px solid #cccccc; +} diff --git a/static/css/my_checks.css b/static/css/my_checks.css index 6a1a9254..c9f5924d 100644 --- a/static/css/my_checks.css +++ b/static/css/my_checks.css @@ -71,3 +71,12 @@ #show-usage-modal .tab-content { margin-top: 15px; } + + .tab-pane { + border: none; + padding: 0; + } + + .snippet { + margin-bottom: 15px; + } diff --git a/static/css/snippet-copy.css b/static/css/snippet-copy.css new file mode 100644 index 00000000..2e53acfc --- /dev/null +++ b/static/css/snippet-copy.css @@ -0,0 +1,44 @@ +.snippet { + position: relative; + margin-bottom: 3px; +} + +.snippet:last-child { + margin-bottom: 0; +} + +.snippet pre { + border: none; + background: #F6F6F6 !important; + margin: 0; +} + +.snippet:hover .copy-snippet-link { + opacity: 1 +} + +button.copy-snippet-link { + position: absolute; + top: 0; + right: 0; + margin-top: -1px; + margin-right: -1px; + z-index: 10; + display: block; + padding: 5px 8px !important; + font-size: 12px; + cursor: pointer; + border-radius: 0 0 0 4px; + opacity: 0; + background: none!important; + border: none; + outline: none; + font-family: "Open Sans", Arial, sans-serif; + color: #0091ea; + cursor :pointer; + transition: opacity 0.1s linear; +} + +button.copy-snippet-link:hover { + text-decoration: underline; +} diff --git a/static/css/welcome.css b/static/css/welcome.css index 9aca0590..7834726d 100644 --- a/static/css/welcome.css +++ b/static/css/welcome.css @@ -86,4 +86,15 @@ .welcome-integrations img { width: 22px; height: 22px; -} \ No newline at end of file +} + +.tab-pane { + border-left: 1px solid #DDD; + border-right: 1px solid #DDD; + border-bottom: 1px solid #DDD; + padding: 3px; +} + +.tab-pane.tab-pane-email { + border: none; +} diff --git a/static/js/snippet-copy.js b/static/js/snippet-copy.js new file mode 100644 index 00000000..cc8225c2 --- /dev/null +++ b/static/js/snippet-copy.js @@ -0,0 +1,26 @@ +$(function() { + + var reBlankLines = new RegExp("^\\s*[\\r\\n]", "gm"); + var reTrailingWhitespace = new RegExp("\\s+$"); + + var clipboard = new Clipboard("button.copy-snippet-link", { + text: function (trigger) { + var snippetElement = $(trigger).next(".highlight").children().clone(); + /* remove pygmentize comment elements */ + snippetElement.find(".c, .cm, .cp, .c1, .cs").remove(); + /* remove blank lines and trailing whitespace */ + return snippetElement.text().replace(reBlankLines, '').replace(reTrailingWhitespace, ''); + } + }); + + clipboard.on("success", function(e) { + e.trigger.textContent = "copied!"; + e.clearSelection(); + }); + + $("button.copy-snippet-link").mouseout(function(e) { + setTimeout(function() { + e.target.textContent = "copy"; + }, 300); + }) +}); diff --git a/templates/base.html b/templates/base.html index 1d53c866..5f150e34 100644 --- a/templates/base.html +++ b/templates/base.html @@ -17,6 +17,7 @@ + diff --git a/templates/front/docs.html b/templates/front/docs.html index 676864ed..7380450a 100644 --- a/templates/front/docs.html +++ b/templates/front/docs.html @@ -1,5 +1,5 @@ {% extends "front/base_docs.html" %} -{% load staticfiles hc_extras %} +{% load compress staticfiles hc_extras %} {% block title %}Documentation - {% site_name %}{% endblock %} @@ -44,7 +44,10 @@ and your command runs. If it completes successfully (exit code 0), curl or wget runs a HTTP GET call to the ping URL.
-{% include "front/snippets/crontab.html" %} +With this simple modification, you monitor several failure scenarios:
@@ -110,20 +113,41 @@ thing: they fire off a HTTP GET method. Ubuntu, for example, does not have curl installed out of the box. -{% include "front/snippets/bash.html" %} +Save the above to e.g. C:\Scripts\healthchecks.ps1
. Then use
the following command in a Scheduled Task to run the script:
-powershell.exe -ExecutionPolicy bypass -File C:\Scripts\healthchecks.ps1 -+
powershell.exe -ExecutionPolicy bypass -File C:\Scripts\healthchecks.ps1
+ Or, alternatively:
+# using curl:
# (make sure it is installed on your system!)
curl --retry 3 {{ ping_url }}
-
-# using wget:
-wget {{ ping_url }} -O /dev/null
# using wget:
+wget {{ ping_url }} -O /dev/null
+
curl {{ SITE_ROOT }}/api/v1/checks/ \
--header "X-Api-Key: your-api-key" \
--data '{"name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'
-
-# Or, alternatively:
-curl {{ SITE_ROOT }}/api/v1/checks/ \
- --data '{"api_key": "your-api-key", "name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'
curl {{ SITE_ROOT }}/api/v1/checks/ \
+ --data '{"api_key": "your-api-key", "name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'
+
>>> # using urllib2:
->>> import urllib2
->>> urllib2.urlopen("{{ ping_url }}")
-
->>> # using requests:
->>> import requests
->>> requests.get("{{ ping_url }}")
-
# using requests:
+import requests
+requests.get("{{ ping_url }}")
+
# using urllib2:
+import urllib2
+urllib2.urlopen("{{ ping_url }}")
+