From 556e8c67c5a489777c8ccfbcde0217926ee3c091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Fri, 17 Jul 2020 19:55:11 +0300 Subject: [PATCH] Syntax highlighting for PHP examples. --- hc/front/management/commands/pygmentize.py | 2 +- hc/front/management/commands/render_docs.py | 2 +- templates/docs/api.html | 44 +++++++++---------- templates/docs/attaching_logs.html | 6 +-- templates/docs/bash.html | 8 ++-- templates/docs/cloning_checks.html | 2 +- templates/docs/configuring_prometheus.html | 2 +- templates/docs/csharp.html | 2 +- templates/docs/http_api.html | 18 ++++---- templates/docs/javascript.html | 4 +- templates/docs/measuring_script_run_time.html | 2 +- templates/docs/monitoring_cron_jobs.html | 6 +-- templates/docs/php.html | 12 ++--- templates/docs/powershell.html | 10 ++--- templates/docs/powershell.md | 6 +-- templates/docs/python.html | 6 +-- templates/docs/reliability_tips.html | 4 +- templates/docs/ruby.html | 2 +- templates/docs/signalling_failures.html | 4 +- templates/front/snippets/php.html | 2 +- 20 files changed, 72 insertions(+), 72 deletions(-) diff --git a/hc/front/management/commands/pygmentize.py b/hc/front/management/commands/pygmentize.py index 73c25083..b0501b2c 100644 --- a/hc/front/management/commands/pygmentize.py +++ b/hc/front/management/commands/pygmentize.py @@ -40,7 +40,7 @@ class Command(BaseCommand): _process("python_requests_fail", lexers.PythonLexer()) _process("python_requests_start", lexers.PythonLexer()) _process("python_requests_payload", lexers.PythonLexer()) - _process("php", lexers.PhpLexer()) + _process("php", lexers.PhpLexer(startinline=True)) _process("powershell", lexers.shell.PowerShellLexer()) _process("powershell_inline", lexers.shell.BashLexer()) _process("ruby", lexers.RubyLexer()) diff --git a/hc/front/management/commands/render_docs.py b/hc/front/management/commands/render_docs.py index c50a5f81..3559cb3e 100644 --- a/hc/front/management/commands/render_docs.py +++ b/hc/front/management/commands/render_docs.py @@ -20,7 +20,7 @@ class Command(BaseCommand): return extensions = ["fenced_code", "codehilite", "tables", "def_list", "attr_list"] - ec = {"codehilite": {"css_class": "highlight"}} + ec = {"codehilite": {"css_class": "highlight", "startinline": True}} docs_path = os.path.join(settings.BASE_DIR, "templates/docs") for doc in os.listdir(docs_path): diff --git a/templates/docs/api.html b/templates/docs/api.html index 648b7b71..47ee9bd0 100644 --- a/templates/docs/api.html +++ b/templates/docs/api.html @@ -103,12 +103,12 @@ specified value.

The API key is either missing or invalid.

Example Request

-
curl --header "X-Api-Key: your-api-key" SITE_ROOT/api/v1/checks/
+
curl --header "X-Api-Key: your-api-key" SITE_ROOT/api/v1/checks/
 

Example Response

-
{
+
{
   "checks": [
     {
       "name": "Filesystem Backup",
@@ -151,7 +151,7 @@ specified value.

When using the read-only API key, the following fields are omitted: ping_url, update_url, pause_url, channels. An extra unique_key field is added which can be used to GET a check in place of the UUID. The unique_key identifier is stable across API calls. Example:

-
{
+
{
   "checks": [
     {
       "name": "Filesystem Backup",
@@ -203,12 +203,12 @@ using the read-only API key) as an identifier.

The specified check does not exist.

Example Request

-
curl --header "X-Api-Key: your-api-key" SITE_ROOT/api/v1/checks/<uuid>
+
curl --header "X-Api-Key: your-api-key" SITE_ROOT/api/v1/checks/<uuid>
 

Example Response

-
{
+
{
   "name": "Database Backup",
   "tags": "production db",
   "desc": "Runs ~/db-backup.sh",
@@ -235,7 +235,7 @@ added. This identifier is stable across API calls.

Note: the ping_url, update_url and pause_url fields, although omitted, are not really secret. The client already knows the check's unique UUID and so can easily construct these URLs by itself.

-
{
+
{
   "name": "Database Backup",
   "tags": "production db",
   "desc": "Runs ~/db-backup.sh",
@@ -361,20 +361,20 @@ field values.
 the limit is 20 checks per account.
 
 

Example Request

-
curl SITE_ROOT/api/v1/checks/ \
+
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/ \
+
curl SITE_ROOT/api/v1/checks/ \
     --data '{"api_key": "your-api-key", "name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'
 

Example Response

-
{
+
{
   "channels": "",
   "desc": "",
   "grace": 60,
@@ -485,20 +485,20 @@ field values.
 
The specified check does not exist.

Example Request

-
curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc \
+
curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc \
     --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/f618072a-7bde-4eee-af63-71a77c5723bc \
+
curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc \
     --data '{"api_key": "your-api-key", "name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'
 

Example Response

-
{
+
{
   "channels": "",
   "desc": "",
   "grace": 60,
@@ -534,7 +534,7 @@ state. You can resume monitoring of the check by pinging it.

The specified check does not exist.

Example Request

-
curl SITE_ROOT/api/v1/checks/0c8983c9-9d73-446f-adb5-0641fdacc9d4/pause \
+
curl SITE_ROOT/api/v1/checks/0c8983c9-9d73-446f-adb5-0641fdacc9d4/pause \
     --request POST --header "X-Api-Key: your-api-key" --data ""
 
@@ -543,7 +543,7 @@ state. You can resume monitoring of the check by pinging it.

even though the request body is empty. For HTTP POST requests, the Content-Length header is sometimes required by some network proxies and web servers.

Example Response

-
{
+
{
   "channels": "",
   "desc": "",
   "grace": 60,
@@ -579,13 +579,13 @@ check that was just deleted.

The specified check does not exist.

Example Request

-
curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc \
+
curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc \
     --request DELETE --header "X-Api-Key: your-api-key"
 

Example Response

-
{
+
{
   "channels": "",
   "desc": "",
   "grace": 60,
@@ -622,13 +622,13 @@ number of returned pings depends on account's billing plan: 100 for free account
 
The specified check does not exist.

Example Request

-
curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pings/ \
+
curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pings/ \
     --header "X-Api-Key: your-api-key"
 

Example Response

-
{
+
{
   "pings": [
     {
       "type": "success",
@@ -713,13 +713,13 @@ number of returned pings depends on account's billing plan: 100 for free account
 
The specified check does not exist.

Example Request

-
curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/flips/ \
+
curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/flips/ \
     --header "X-Api-Key: your-api-key"
 

Example Response

-
[
+
[
     {
       "timestamp": "2020-03-23T10:18:23+00:00",
       "up": 1
@@ -747,12 +747,12 @@ number of returned pings depends on account's billing plan: 100 for free account
 
The API key is either missing or invalid.

Example Request

-
curl --header "X-Api-Key: your-api-key" SITE_ROOT/api/v1/channels/
+
curl --header "X-Api-Key: your-api-key" SITE_ROOT/api/v1/channels/
 

Example Response

-
{
+
{
   "channels": [
     {
       "id": "4ec5a071-2d08-4baa-898a-eb4eb3cd6941",
diff --git a/templates/docs/attaching_logs.html b/templates/docs/attaching_logs.html
index 75e8876b..3ed16b33 100644
--- a/templates/docs/attaching_logs.html
+++ b/templates/docs/attaching_logs.html
@@ -6,7 +6,7 @@ the request body, so you can inspect it later.

Logging Command Output

In this example, we run certbot renew, capture its output, and submit the captured output to SITE_NAME:

-
#!/bin/sh
+
#!/bin/sh
 
 m=$(/usr/bin/certbot renew 2>&1)
 curl -fsS --retry 3 --data-raw "$m" PING_URL
@@ -16,7 +16,7 @@ curl -fsS --retry 3 --data-raw "In Combination with the /fail Endpoint
 

We can extend the previous example and signal either success or failure depending on the exit code:

-
#!/bin/sh
+
#!/bin/sh
 
 url=PING_URL
 
@@ -30,5 +30,5 @@ curl -fsS --retry 3 --data-raw "All in One Line
 

Finally, all of the above can be packaged in a single line. The one-line version can be put directly in crontab, without using a wrapper script.

-
m=$(/usr/bin/certbot renew 2>&1); curl -fsS --data-raw "$m" "PING_URL$([ $? -ne 0 ] && echo -n /fail)"
+
m=$(/usr/bin/certbot renew 2>&1); curl -fsS --data-raw "$m" "PING_URL$([ $? -ne 0 ] && echo -n /fail)"
 
\ No newline at end of file diff --git a/templates/docs/bash.html b/templates/docs/bash.html index aceecc5d..73664b37 100644 --- a/templates/docs/bash.html +++ b/templates/docs/bash.html @@ -4,7 +4,7 @@ have to do is make a HTTP request at an appropriate place in the script. curl and wget are two common command line HTTP clients you can use.

-
# Sends a HTTP GET request with curl:
+
# Sends a HTTP GET request with curl:
 curl -m 10 --retry 5 PING_URL
 
 # Silent version (no stdout/stderr output unless curl hits an error):
@@ -38,7 +38,7 @@ signal a failure. The following example:

  • if the certbot command is successful (exit code 0), sends HTTP GET to PING_URL
  • otherwise, sends HTTP GET to PING_URL/fail
  • -
    #!/bin/sh
    +
    #!/bin/sh
     
     # Payload here:
     /usr/bin/certbot renew
    @@ -52,7 +52,7 @@ curl -m 10 --retry 5