diff --git a/hc/front/management/commands/pygmentize.py b/hc/front/management/commands/pygmentize.py index 82055540..4de60672 100644 --- a/hc/front/management/commands/pygmentize.py +++ b/hc/front/management/commands/pygmentize.py @@ -31,12 +31,13 @@ class Command(BaseCommand): _process("bash_wget", lexers.BashLexer()) _process("browser", lexers.JavascriptLexer()) _process("crontab", lexers.BashLexer()) + _process("node", lexers.JavascriptLexer()) _process("python_urllib2", lexers.PythonLexer()) _process("python_requests", lexers.PythonLexer()) _process("php", lexers.PhpLexer()) _process("powershell", lexers.shell.PowerShellLexer()) _process("powershell_inline", lexers.shell.BashLexer()) - _process("node", lexers.JavascriptLexer()) + _process("ruby", lexers.RubyLexer()) # API examples _process("list_checks_request", lexers.BashLexer()) diff --git a/templates/front/base_docs.html b/templates/front/base_docs.html index 8490d46b..978a731e 100644 --- a/templates/front/base_docs.html +++ b/templates/front/base_docs.html @@ -12,6 +12,7 @@
  • Crontab
  • Bash
  • Python
  • +
  • Ruby
  • Node
  • PHP
  • Browser
  • diff --git a/templates/front/docs.html b/templates/front/docs.html index 484788dd..527a7e7e 100644 --- a/templates/front/docs.html +++ b/templates/front/docs.html @@ -115,9 +115,24 @@ thing: they fire off a HTTP GET method.

    Python

    -{% include "front/snippets/python_urllib2.html" %} + +

    + If you are already using the + requests library, + it's convenient to also use it here: +

    {% include "front/snippets/python_requests.html" %} +

    + Otherwise, you can use the urllib standard module. +

    + +{% include "front/snippets/python_urllib2.html" %} + + +

    Ruby

    +{% include "front/snippets/ruby.html" %} +

    Node

    {% include "front/snippets/node.html" %} diff --git a/templates/front/my_checks.html b/templates/front/my_checks.html index 0a6039ad..f3271db3 100644 --- a/templates/front/my_checks.html +++ b/templates/front/my_checks.html @@ -286,6 +286,9 @@
  • Python
  • +
  • + Ruby +
  • @@ -318,6 +321,9 @@ {% include "front/snippets/python_urllib2.html" %} {% include "front/snippets/python_requests.html" %} +
    + {% include "front/snippets/ruby.html" %} +
    {% include "front/snippets/node.html" %}
    diff --git a/templates/front/snippets/python_urllib2.html b/templates/front/snippets/python_urllib2.html index 7fd2b041..6cfcaae2 100644 --- a/templates/front/snippets/python_urllib2.html +++ b/templates/front/snippets/python_urllib2.html @@ -1,4 +1,8 @@ -
    # using urllib2:
    -import urllib2
    -urllib2.urlopen("{{ ping_url }}")
    +
    # urllib with python 3.x:
    +import urllib.request
    +urllib.request.urlopen("{{ ping_url }}")
    +
    +# urllib with python 2.x:
    +import urllib
    +urllib.urlopen("{{ ping_url }}")
     
    diff --git a/templates/front/snippets/python_urllib2.txt b/templates/front/snippets/python_urllib2.txt index 44c514c8..e4b89638 100644 --- a/templates/front/snippets/python_urllib2.txt +++ b/templates/front/snippets/python_urllib2.txt @@ -1,3 +1,7 @@ -# using urllib2: -import urllib2 -urllib2.urlopen("PING_URL") +# urllib with python 3.x: +import urllib.request +urllib.request.urlopen("PING_URL") + +# urllib with python 2.x: +import urllib +urllib.urlopen("PING_URL") diff --git a/templates/front/snippets/ruby.html b/templates/front/snippets/ruby.html new file mode 100644 index 00000000..6826abf6 --- /dev/null +++ b/templates/front/snippets/ruby.html @@ -0,0 +1,5 @@ +
    require 'net/http'
    +require 'uri'
    +
    +Net::HTTP.get(URI.parse('{{ ping_url }}'))
    +
    diff --git a/templates/front/snippets/ruby.txt b/templates/front/snippets/ruby.txt new file mode 100644 index 00000000..7a3fdd91 --- /dev/null +++ b/templates/front/snippets/ruby.txt @@ -0,0 +1,4 @@ +require 'net/http' +require 'uri' + +Net::HTTP.get(URI.parse('PING_URL')) \ No newline at end of file diff --git a/templates/front/welcome.html b/templates/front/welcome.html index 4de550ac..bbdf970d 100644 --- a/templates/front/welcome.html +++ b/templates/front/welcome.html @@ -41,6 +41,9 @@
  • Python
  • + @@ -69,6 +72,9 @@ {% include "front/snippets/python_urllib2.html" %} {% include "front/snippets/python_requests.html" %}
    +
    + {% include "front/snippets/ruby.html" %} +
    {% include "front/snippets/node.html" %}