Skip to content

Commit aea900e

Browse files
committed
Finish markdown / landing page things
1 parent 685c342 commit aea900e

File tree

7 files changed

+32
-17
lines changed

7 files changed

+32
-17
lines changed

runtimepy/data/js/markdown_page.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* should check uri */
1+
/* Dark is hard-coded initial state (in HTML). */
22
let lightMode = false;
33

44
function lightDarkClick(event) {
@@ -7,10 +7,18 @@ function lightDarkClick(event) {
77
document.getElementById("runtimepy")
88
.setAttribute("data-bs-theme", lightMode ? "light" : "dark");
99

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

1313
let lightDarkButton = document.getElementById("theme-button");
1414
if (lightDarkButton) {
15-
lightDarkButton.addEventListener("click", lightDarkClick.bind(this));
15+
lightDarkButton.addEventListener("click", lightDarkClick);
16+
}
17+
18+
if (window.location.hash) {
19+
let parts = window.location.hash.slice(1).split(",");
20+
21+
if (parts.includes("light-mode")) {
22+
lightDarkButton.click();
23+
}
1624
}

runtimepy/net/server/app/landing_page.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ def landing_page(
2525
"""Create a landing page application"""
2626

2727
# Not currently used.
28-
del app
2928
del request
3029
del response
3130
del request_data
3231

33-
# where do we source this..
34-
markdown = "# What is up y'all"
35-
full_markdown_page(document, markdown)
32+
full_markdown_page(
33+
document,
34+
app.config_param("landing_page", {}, strict=True).get( # type: ignore
35+
"markdown", "no data"
36+
),
37+
)
3638

3739
return document

runtimepy/net/server/app/tab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
# internal
1515
from runtimepy.net.arbiter.info import AppInfo
16+
from runtimepy.net.html import kind_url, write_found_file
1617
from runtimepy.net.html.bootstrap import icon_str
1718
from runtimepy.net.html.bootstrap.tabs import TabbedContent
18-
from runtimepy.net.server.app.files import kind_url, write_found_file
1919

2020

2121
class Tab:

tasks/dev.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ includes:
33
- package://runtimepy/server.yaml
44
- dev_no_wait.yaml
55
- ../tests/data/valid/connection_arbiter/test_ssl.yaml
6+
- ../tests/data/valid/connection_arbiter/landing_page.yaml
67

78
port_overrides:
89
runtimepy_https_server: 8443
@@ -11,10 +12,6 @@ port_overrides:
1112
# websocket_hostname: nuc2
1213

1314
config:
14-
# Additional web applications.
15-
landing_page:
16-
paths: [/landing_page.html]
17-
1815
http_redirects:
1916
secret.html: http://vaughnkottler.com
2017
secret2.html: https://libre-embedded.com
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
config:
3+
4+
# Additional web applications.
5+
landing_page:
6+
paths: [/landing_page.html]
7+
markdown: |
8+
# Sample Markdown
9+
10+
Sample content.

tests/data/valid/connection_arbiter/runtimepy_http.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ includes_left:
33
- package://runtimepy/server.yaml
44
includes:
55
- test_ssl.yaml
6+
- landing_page.yaml
67

78
app:
89
- tests.net.stream.runtimepy_http_test
@@ -18,10 +19,6 @@ config:
1819
foo: bar
1920
xdg_fragment: "wave1,hide-tabs,hide-channels/wave1:sin,cos"
2021

21-
# Additional web applications.
22-
landing_page:
23-
paths: [/landing_page.html]
24-
2522
ports:
2623
- {name: tftp_server, type: udp}
2724

tests/net/server/app/test_files.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
# module under test
99
from runtimepy import PKG_NAME
10-
from runtimepy.net.server.app.files import kind_url, set_text_to_file
10+
from runtimepy.net.html import kind_url
11+
from runtimepy.net.server.app.files import set_text_to_file
1112

1213

1314
def test_set_text_to_file_basic():

0 commit comments

Comments
 (0)