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 @@
+ 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.
+
# 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 @@