Publish post 'Test nginx Configuration Directives' #3

Merged
ccm merged 19 commits from ccm-test-nginx into trunk 2025-06-30 22:49:28 +00:00
Showing only changes of commit 0cc8f18302 - Show all commits

View File

@ -387,7 +387,7 @@ Add a spec:
```moonscript
describe "https://git.domain.abc", ->
it "reverse-proxy's request to a gitea unix socket", ->
it "reverse-proxy's a subdomain request to a unix socket", ->
socket = fname: "unixstreamsrvr.moon", dir: "/run/gitea", owner: "nobody"
basepath = debug.getinfo(1).short_src\match"^(.*)/[^/]*$" or "."
seconds = 0.1
@ -433,29 +433,79 @@ $ make test
## Bonus!: Issues We Ran Into Just Trying To Make This Post
1. `$host$request_uri`
### `$host$request_uri`
`renderers/markdown.moon`
::: filename-for-code-block
`renderers/markdown.moon`
:::
```moonscript
dollar_temp = "0000sitegen_markdown00dollar0000"
```
```moonscript
dollar_temp = "0000sitegen_markdown00dollar0000"
```
So, when two cosmo selectors had no space between them, it was ambiguous
to which selector the numbers belonged.
So, when two cosmo selectors had no space between them, it was ambiguous
to which selector the numbers belonged.
```
0000sitegen_markdown00dollar0000.10000sitegen_markdown00dollar0000.2
```
```
0000sitegen_markdown00dollar0000.10000sitegen_markdown00dollar0000.2
```
Solution was to change the first `0` to a letter `z`:
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.
```
z000sitegen_markdown00dollar0000.1z000sitegen_markdown00dollar0000.2
```
2. `$$ct`
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
```