Skip to content

Commit

Permalink
Added basic console site generator and web server
Browse files Browse the repository at this point in the history
  • Loading branch information
markqvist committed Jan 7, 2023
1 parent f932c43 commit 0d59b6b
Show file tree
Hide file tree
Showing 20 changed files with 248 additions and 79 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ TODO
Release/*.hex
Release/*.zip
Release/*.json
Console/build
build/*
13 changes: 5 additions & 8 deletions Console.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
#error Target CONFIG_IDF_TARGET is not supported
#endif

// Replace with your network credentials
const char* ssid = "RNode Test";
const char* password = "somepass";

WebServer server(80);

void console_dbg(String msg) {
Expand Down Expand Up @@ -63,6 +59,8 @@ String console_get_content_type(String filename) {
return "application/x-zip";
} else if (filename.endsWith(".gz")) {
return "application/x-gzip";
} else if (filename.endsWith(".whl")) {
return "application/octet-stream";
}
return "text/plain";
}
Expand All @@ -83,6 +81,7 @@ bool console_serve_file(String path) {
File file = SPIFFS.open(path, "r");
console_dbg("Serving file to client");
server.streamFile(file, content_type);
console_dbg("Closing file");
file.close();

console_dbg("File serving done");
Expand All @@ -104,8 +103,7 @@ void console_register_pages() {
void console_start() {
Serial.println("");
console_dbg("Starting Access Point...");
// WiFi.softAP(ssid, password);
WiFi.softAP(bt_devname, password);
WiFi.softAP(bt_devname);
delay(150);
IPAddress ip(10, 0, 0, 1);
IPAddress nm(255, 255, 255, 0);
Expand All @@ -125,10 +123,9 @@ void console_start() {

void console_loop(){
server.handleClient();

// Internally, this yields the thread and allows
// other tasks to run.
delay(5);
delay(2);
}

// void listDir(fs::FS &fs, const char * dirname, uint8_t levels){
Expand Down
27 changes: 14 additions & 13 deletions Console/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
clean:
@echo Cleaning...
@-rm -rf ./build
@echo Cleaning...
@-rm -rf ./build

site:
@mkdir -p ./build
@mkdir -p ./build/css
@mkdir -p ./build/gfx
@mkdir -p ./build/images
python ./build.py
cp assets/css/* build/css/
cp assets/gfx/* build/gfx/
cp assets/images/* build/images/
cp assets/scripts/* build/scripts/
# @cp -r ../../Reticulum/docs/manual/* build/reticulum_manual/
# @cp -r ../../Reticulum/docs/Reticulum\ Manual.pdf build/reticulum_manual/
@mkdir -p ./build
@mkdir -p ./build/css
@mkdir -p ./build/gfx
@mkdir -p ./build/images
# @mkdir -p ./build/pkgs
python ./build.py
@cp assets/css/* build/css/
@cp assets/gfx/* build/gfx/
# @cp assets/images/* build/images/
# @cp assets/scripts/* build/scripts/
# @cp -r ../../Reticulum/docs/manual/* build/reticulum_manual/
# @cp -r ../../Reticulum/docs/Reticulum\ Manual.pdf build/reticulum_manual/
File renamed without changes.
File renamed without changes.
Binary file added Console/assets/gfx/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Console/assets/gfx/nn.webp
Binary file not shown.
File renamed without changes
Binary file added Console/assets/gfx/sideband.webp
Binary file not shown.
52 changes: 50 additions & 2 deletions Console/build.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import markdown
import os
import shutil

packages = {
"rns": "rns-0.4.6-py3-none-any.whl",
"nomadnet": "nomadnet-0.3.1-py3-none-any.whl",
"lxmf": "lxmf-0.2.8-py3-none-any.whl",
}

DEFAULT_TITLE = "RNode Bootstrap Console"
SOURCES_PATH="./source"
BUILD_PATH="./build"
PACKAGES_PATH = "../../dist_archive"
INPUT_ENCODING="utf-8"
OUTPUT_ENCODING="utf-8"

Expand All @@ -13,7 +21,7 @@
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="water.css?v=5">
<link rel="stylesheet" href="{ASSET_PATH}css/water.css">
<link rel="shortcut icon" type="image/x-icon" href="{ASSET_PATH}gfx/icon.png">
<meta charset="utf-8"/>
<title>{PAGE_TITLE}</title>
Expand All @@ -26,7 +34,7 @@

document_end = """</body></html>"""

menu_md = """<center><span class="menu">[Start]({CONTENT_PATH}index.html) | [Replicate]({CONTENT_PATH}replicate.html) | [Guides]({CONTENT_PATH}guides.html) | [Software]({CONTENT_PATH}software/index.html)| [Help](help.html) | [Contribute]({CONTENT_PATH}contribute.html)</span></center>"""
menu_md = """<center><span class="menu">[Start]({CONTENT_PATH}index.html) | [Replicate]({CONTENT_PATH}replicate.html) | [Guides]({CONTENT_PATH}guides.html) | [Software]({CONTENT_PATH}software.html) | [Help](help.html) | [Contribute]({CONTENT_PATH}contribute.html)</span></center>"""

url_maps = [
# { "path": "", "target": "/.md"},
Expand Down Expand Up @@ -125,6 +133,10 @@ def generate_html(f, root_path):
menu_html = markdown.markdown(menu_md.replace("{CONTENT_PATH}", root_path), extensions=["markdown.extensions.fenced_code"]).replace("<p></p>", "")
page_html = markdown.markdown(md, extensions=["markdown.extensions.fenced_code"]).replace("{ASSET_PATH}", root_path)
page_html = page_html.replace("{LXMF_ADDRESS}", LXMF_ADDRESS)
for pkg_name in packages:
page_html = page_html.replace("{PKG_"+pkg_name+"}", pkg_name+".zip")
page_html = page_html.replace("{PKG_NAME_"+pkg_name+"}", packages[pkg_name])

page_date = get_prop(md, "date")
if page_date != None:
page_html = page_html.replace("{DATE}", page_date)
Expand All @@ -133,6 +145,39 @@ def generate_html(f, root_path):

source_files = scan_pages(SOURCES_PATH)

def fetch_reticulum_site():
r_site_path = BUILD_PATH+"/r"
shutil.copytree(PACKAGES_PATH+"/reticulum.network", r_site_path)
shutil.rmtree(r_site_path+"/manual")

def gz_all():
import gzip
for root, dirs, files in os.walk(BUILD_PATH):
for file in files:
fpath = root+"/"+file
print("Gzipping "+fpath+"...")
f = open(fpath, "rb")
g = gzip.open(fpath+".gz", "wb")
g.writelines(f)
g.close()
f.close()
os.unlink(fpath)

from zipfile import ZipFile
for pkg_name in packages:
pkg_file = packages[pkg_name]
pkg_full_path = PACKAGES_PATH+"/"+pkg_file
if os.path.isfile(pkg_full_path):
print("Including "+pkg_file)
z = ZipFile(BUILD_PATH+"/"+pkg_name+".zip", "w")
z.write(pkg_full_path, pkg_full_path[len(PACKAGES_PATH+"/"):])
z.close()
# shutil.copy(pkg_full_path, BUILD_PATH+"/"+pkg_name)

else:
print("Could not find "+pkg_full_path)
exit(1)

for um in url_maps:
with open(SOURCES_PATH+"/"+um["target"], "rb") as f:
of = BUILD_PATH+um["target"].replace(SOURCES_PATH, "").replace(".md", ".html")
Expand Down Expand Up @@ -160,3 +205,6 @@ def generate_html(f, root_path):

with open(of, "wb") as wf:
wf.write(html.encode(OUTPUT_ENCODING))

fetch_reticulum_site()
gz_all()
18 changes: 0 additions & 18 deletions Console/donate.html

This file was deleted.

36 changes: 0 additions & 36 deletions Console/index.html

This file was deleted.

37 changes: 37 additions & 0 deletions Console/source/contribute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[title]: <> (Donate)
## Keep Communications Free and Open
Please take part in keeping the continued development, maintenance and distribution of the RNode ecosystem possible by donating via one of the following channels:

Donating to the project directly helps improve the entire system.

- Monero<br/>
```
84FpY1QbxHcgdseePYNmhTHcrgMX4nFfBYtz2GKYToqHVVhJp8Eaw1Z1EedRnKD19b3B8NiLCGVxzKV17UMmmeEsCrPyA5w
```
<br/><br/>
- Ethereum<br/>
```
0x81F7B979fEa6134bA9FD5c701b3501A2e61E897a
```
<br/><br/>
- Bitcoin<br/>
```
3CPmacGm34qYvR6XWLVEJmi2aNe3PZqUuq
```
<br/><br/>
- Ko-Fi<br/>
<a href="https://ko-fi.com/markqvist">`https://ko-fi.com/markqvist`</a>

## Spread Knowledge and Awareness
Another great way to contribute, is to spread awareness about the RNode project. Here's some ideas:

- Introduce the concepts of Free & Open Communications Systems to your community
- Teach others to build and use RNodes, and how to set up resilient and private communications systems
- Learn about using Reticulum to set up resilient communications networks, and teach these skills to people in your area that need them

## Contribute Code & Ideas
If you like to build and design, there is plenty of oppertunities to take part in the community around RNode, and the wider Reticulum community as well. There's always plenty of work to do, from writing code, to translating guides and information, to designing parts, devices and integrations. You can find us the following places:

- The [Reticulum Matrix Channel](element://room/!TRaVWNnQhAbvuiSnEK%3Amatrix.org?via=matrix.org) at `#reticulum:matrix.org`
- The [discussion forum](https://github.com/markqvist/Reticulum/discussions) on GitHub
- The [Reticulum subreddit](https://reddit.com/r/reticulum)
14 changes: 14 additions & 0 deletions Console/source/help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[title]: <> (Get Help)
## Get Help
If you are having trouble, or if something is not working, these resources may be useful:

- The [Questions & Answers](qa.html) section
- The [No-Grid Communications Handbook](nghb.html)
- The [Reticulum Manual](manual/index.html)

## Community & Support
If things still aren't working as expected here are some great places to ask for help:

- The [discussion forum](https://github.com/markqvist/Reticulum/discussions) on GitHub
- The [Reticulum Matrix Channel](element://room/!TRaVWNnQhAbvuiSnEK%3Amatrix.org?via=matrix.org) at `#reticulum:matrix.org`
- The [Reticulum subreddit](https://reddit.com/r/reticulum)
21 changes: 21 additions & 0 deletions Console/source/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
**Hello!** You have connected to the **RNode Bootstrap Console**.

This repository contains all the tools, software and information necessary to bootstrap networks and communications systems based on Reticulum. The tools and information contained in this RNode will also allow you to replicate the design, build more RNodes and grow your communications ecosystems.

<br/>
<center><img src="{ASSET_PATH}gfx/rnode_iso.png" width="50%"/></center>
<br/>
<center>

### What would you like to do?
This repository contains resources for a variety of different tasks. You can browse this repository freely, or jump straight into a task-oriented workflow by selecting one of the starting points below.
<br/>
<br/>
<button type="button" id="task-rns">Install Reticulum</button>
<button type="button" id="task-rns">Download Programs</button>
<button type="button" id="task-rns">Create RNodes</button>
<button type="button" id="task-rns">Build A Network</button>
<button type="button" id="task-rns">Learn More</button>
<button type="button" id="task-rns">Get Help</button>
<button type="button" id="task-rns">Contribute</button>
</center>
3 changes: 3 additions & 0 deletions Console/source/qa.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[title]: <> (Get Help)
## Questions & Answers
This section contains a list of common questions, and associated answers.
3 changes: 3 additions & 0 deletions Console/source/replicate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[title]: <> (Replicate)
# Create RNodes
This section contains the tools and guides necessary to create more RNodes.
Loading

0 comments on commit 0d59b6b

Please sign in to comment.