Skip to content

Commit

Permalink
Finish markdown / landing page things
Browse files Browse the repository at this point in the history
  • Loading branch information
vkottler committed Oct 20, 2024
1 parent 685c342 commit f9984f4
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 15 deletions.
16 changes: 13 additions & 3 deletions runtimepy/data/js/markdown_page.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* should check uri */
/* Dark is hard-coded initial state (in HTML). */
let lightMode = false;

function lightDarkClick(event) {
Expand All @@ -7,10 +7,20 @@ function lightDarkClick(event) {
document.getElementById("runtimepy")
.setAttribute("data-bs-theme", lightMode ? "light" : "dark");

/* update uri */
window.location.hash = lightMode ? "#light-mode" : "";
}

let lightDarkButton = document.getElementById("theme-button");
if (lightDarkButton) {
lightDarkButton.addEventListener("click", lightDarkClick.bind(this));
lightDarkButton.addEventListener("click", lightDarkClick);
}

if (window.location.hash) {
let parts = window.location.hash.slice(1).split(",");

console.log(parts);

if (parts.includes("light-mode")) {
lightDarkButton.click();
}
}
10 changes: 6 additions & 4 deletions runtimepy/net/server/app/landing_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ def landing_page(
"""Create a landing page application"""

# Not currently used.
del app
del request
del response
del request_data

# where do we source this..
markdown = "# What is up y'all"
full_markdown_page(document, markdown)
full_markdown_page(
document,
app.config_param("landing_page", {}, strict=True).get( # type: ignore
"markdown", "no data"
),
)

return document
5 changes: 1 addition & 4 deletions tasks/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ includes:
- package://runtimepy/server.yaml
- dev_no_wait.yaml
- ../tests/data/valid/connection_arbiter/test_ssl.yaml
- ../tests/data/valid/connection_arbiter/landing_page.yaml

port_overrides:
runtimepy_https_server: 8443
Expand All @@ -11,10 +12,6 @@ port_overrides:
# websocket_hostname: nuc2

config:
# Additional web applications.
landing_page:
paths: [/landing_page.html]

http_redirects:
secret.html: http://vaughnkottler.com
secret2.html: https://libre-embedded.com
Expand Down
10 changes: 10 additions & 0 deletions tests/data/valid/connection_arbiter/landing_page.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
config:

# Additional web applications.
landing_page:
paths: [/landing_page.html]
markdown: |
# Sample Markdown
Sample content.
5 changes: 1 addition & 4 deletions tests/data/valid/connection_arbiter/runtimepy_http.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ includes_left:
- package://runtimepy/server.yaml
includes:
- test_ssl.yaml
- landing_page.yaml

app:
- tests.net.stream.runtimepy_http_test
Expand All @@ -18,10 +19,6 @@ config:
foo: bar
xdg_fragment: "wave1,hide-tabs,hide-channels/wave1:sin,cos"

# Additional web applications.
landing_page:
paths: [/landing_page.html]

ports:
- {name: tftp_server, type: udp}

Expand Down

0 comments on commit f9984f4

Please sign in to comment.