Remove bonus content

This commit is contained in:
Catalin Constantin Mititiuc 2025-06-30 15:38:56 -07:00
parent 3f494b037d
commit c800c8e775

View File

@ -128,7 +128,7 @@ $ curl -v localhost
## Test an HTTP request ## Test an HTTP request
If we want to write a test for that request, we need some packages from If we want to write a test for that request, we need some packages from
LuaRocks. Let's add a Dockerfile to build an image with those packages LuaRocks. Let's add a `Dockerfile` to build an image with those packages
installed. installed.
### Add a `Dockerfile` ### Add a `Dockerfile`
@ -210,7 +210,7 @@ $ docker exec $ct openresty -s stop
## Create a `Makefile` ## Create a `Makefile`
Ok, we now have a number of long `docker` commands, let's create a `Makefile` We now have a number of long `docker` commands, let's create a `Makefile`
to make running them easier. to make running them easier.
::: filename-for-code-block ::: filename-for-code-block
@ -383,7 +383,7 @@ domain and the directives for the SSL certificates we will generate.
### Generate self-signed SSL/TLS certs for testing ### Generate self-signed SSL/TLS certs for testing
Add a command to our Dockerfile to generate self-signed certificates: Add a command to our `Dockerfile` to generate self-signed certificates:
```Dockerfile ```Dockerfile
RUN openssl req -x509 -newkey rsa:4096 -nodes \ RUN openssl req -x509 -newkey rsa:4096 -nodes \
@ -421,9 +421,9 @@ $ make test
3 successes / 0 failures / 0 errors / 0 pending : 0.017065 seconds 3 successes / 0 failures / 0 errors / 0 pending : 0.017065 seconds
``` ```
## Test reverse proxy a subdomain request to a unix socket ## Test reverse proxy a subdomain request to a Unix socket
Let's say we have a running service that connects to a unix socket. We want to Let's say we have a running service that connects to a Unix socket. We want to
proxy the requests through `nginx` so that our service can respond to `https` proxy the requests through `nginx` so that our service can respond to `https`
requests but can leave handling SSL/TLS to `nginx`. requests but can leave handling SSL/TLS to `nginx`.
@ -564,81 +564,3 @@ These are just a few examples of how to test `nginx` directives. Using these
tools, we can verify that changes to our server configuration are working the tools, we can verify that changes to our server configuration are working the
way we intended. way we intended.
## Bonus!: Issues Ran Into Just Making This Post
### `$host$request_uri`
::: filename-for-code-block
`renderers/markdown.moon`
:::
```moonscript
dollar_temp = "0000sitegen_markdown00dollar0000"
```
So, when two cosmo selectors had no space between them, it was ambiguous
to which selector the numbers belonged.
```
0000sitegen_markdown00dollar0000.10000sitegen_markdown00dollar0000.2
```
Solution was to change the first `0` to a letter `z`:
```
z000sitegen_markdown00dollar0000.1z000sitegen_markdown00dollar0000.2
```
Because `dollar_temp` is a private attribute, I had to copy every function
from the sitegen markdown renderer. Which makes my renderer a copy with
some additions.
::: filename-for-code-block
`spec/renderers_spec.moon`
:::
```moonscript
import escape_cosmo, unescape_cosmo from require "renderers.markdown"
it "escapes and unescapes adjacent cosmo selectors", ->
str = "$one$two"
escaped = escape_cosmo str
assert.same escaped,
"z000sitegen_markdown00dollar0000.1z000sitegen_markdown00dollar0000.2"
assert.same str, (unescape_cosmo escape_cosmo str)
```
### `$$ct`
```
z000sitegen_markdown00dollar0000.1
```
Because `.` is not a valid character for a variable name, when this string
is syntax-highlighted, it gets split, like this:
```
<span>z000sitegen_markdown00dollar0000</span>.1
```
The string is then 'unescaped', but because the string got split by the
closing `</span>` tag, it will no longer match the pattern and the
'unescape' fails.
The solution was to change the `.` in the dollar temp pattern to `_`, which is
a valid character in a variable name. Update the `$one$two` spec escaped
string.
::: filename-for-code-block
`spec/renderers_spec.moon`
:::
```moonscript
it "escapes and unescapes double dollar signs", ->
out = flatten_html render [[
```Makefile
$$name
```]]
assert.same [[<div class="highlight"><pre><span></span><code><span class="py-w"></span><span class="py-nv">$$name</span></code></pre></div>]], out
```