diff --git a/.gitignore b/.gitignore index 2a18fcf..a78b9ae 100644 --- a/.gitignore +++ b/.gitignore @@ -160,3 +160,6 @@ cython_debug/ #.idea/ # dump/ + +#herreweb_site +repositories/ diff --git a/2023-12-24-old/Readme.md b/2023-12-24-old/Readme.md new file mode 100644 index 0000000..621b53c --- /dev/null +++ b/2023-12-24-old/Readme.md @@ -0,0 +1,36 @@ +# Herreweb Site +Internally build website for [Herreweb](https://www.herreweb.nl). + +## Getting Started +To help contribute to the website, install dependencies in a ``Virtual Environment``: + +``` +python3 -m venv venv +source venv/bin/activate +pip3 install -r requirements.txt +``` + +## Project documentation +As with all Herreweb projects, the docs are provided in their stand-alone ``ReadTheDocs`` environment. + +When contributing to the project, make sure you write your documentation. + +To view the documentation, navigate to **documentation/readthedocs** and run the following commands: + +``` +make html +cd build/html +python3 -m http.server +``` +The website can be accessed at **localhost:8000** + +## Development +To run the backend server navigate to ``herreweb_backend/`` and run: + +> python3 manage.py runserver + +And for the frontend, navigate to ``herreweb_frontend`` and run: + +> npm start + +The file servers are accessible on ports 8000 and 3000. diff --git a/herreweb_backend/.vscode/launch.json b/2023-12-24-old/herreweb_backend/.vscode/launch.json similarity index 100% rename from herreweb_backend/.vscode/launch.json rename to 2023-12-24-old/herreweb_backend/.vscode/launch.json diff --git a/herreweb_backend/herreweb_backend/__init__.py b/2023-12-24-old/herreweb_backend/herreweb_backend/__init__.py similarity index 100% rename from herreweb_backend/herreweb_backend/__init__.py rename to 2023-12-24-old/herreweb_backend/herreweb_backend/__init__.py diff --git a/herreweb_backend/herreweb_backend/asgi.py b/2023-12-24-old/herreweb_backend/herreweb_backend/asgi.py similarity index 100% rename from herreweb_backend/herreweb_backend/asgi.py rename to 2023-12-24-old/herreweb_backend/herreweb_backend/asgi.py diff --git a/herreweb_backend/herreweb_backend/settings.py b/2023-12-24-old/herreweb_backend/herreweb_backend/settings.py similarity index 100% rename from herreweb_backend/herreweb_backend/settings.py rename to 2023-12-24-old/herreweb_backend/herreweb_backend/settings.py diff --git a/herreweb_backend/herreweb_backend/urls.py b/2023-12-24-old/herreweb_backend/herreweb_backend/urls.py similarity index 100% rename from herreweb_backend/herreweb_backend/urls.py rename to 2023-12-24-old/herreweb_backend/herreweb_backend/urls.py diff --git a/herreweb_backend/herreweb_backend/utils.py b/2023-12-24-old/herreweb_backend/herreweb_backend/utils.py similarity index 100% rename from herreweb_backend/herreweb_backend/utils.py rename to 2023-12-24-old/herreweb_backend/herreweb_backend/utils.py diff --git a/herreweb_backend/herreweb_backend/wsgi.py b/2023-12-24-old/herreweb_backend/herreweb_backend/wsgi.py similarity index 100% rename from herreweb_backend/herreweb_backend/wsgi.py rename to 2023-12-24-old/herreweb_backend/herreweb_backend/wsgi.py diff --git a/herreweb_backend/manage.py b/2023-12-24-old/herreweb_backend/manage.py similarity index 100% rename from herreweb_backend/manage.py rename to 2023-12-24-old/herreweb_backend/manage.py diff --git a/herreweb_backend/project/admin.py b/2023-12-24-old/herreweb_backend/project/admin.py similarity index 100% rename from herreweb_backend/project/admin.py rename to 2023-12-24-old/herreweb_backend/project/admin.py diff --git a/herreweb_backend/project/migrations/0001_initial.py b/2023-12-24-old/herreweb_backend/project/migrations/0001_initial.py similarity index 100% rename from herreweb_backend/project/migrations/0001_initial.py rename to 2023-12-24-old/herreweb_backend/project/migrations/0001_initial.py diff --git a/herreweb_backend/project/migrations/0002_alter_project_image_alter_project_rtd_url_and_more.py b/2023-12-24-old/herreweb_backend/project/migrations/0002_alter_project_image_alter_project_rtd_url_and_more.py similarity index 100% rename from herreweb_backend/project/migrations/0002_alter_project_image_alter_project_rtd_url_and_more.py rename to 2023-12-24-old/herreweb_backend/project/migrations/0002_alter_project_image_alter_project_rtd_url_and_more.py diff --git a/herreweb_backend/project/migrations/__init__.py b/2023-12-24-old/herreweb_backend/project/migrations/__init__.py similarity index 100% rename from herreweb_backend/project/migrations/__init__.py rename to 2023-12-24-old/herreweb_backend/project/migrations/__init__.py diff --git a/herreweb_backend/project/models.py b/2023-12-24-old/herreweb_backend/project/models.py similarity index 100% rename from herreweb_backend/project/models.py rename to 2023-12-24-old/herreweb_backend/project/models.py diff --git a/herreweb_backend/project/serializers.py b/2023-12-24-old/herreweb_backend/project/serializers.py similarity index 100% rename from herreweb_backend/project/serializers.py rename to 2023-12-24-old/herreweb_backend/project/serializers.py diff --git a/herreweb_backend/project/views.py b/2023-12-24-old/herreweb_backend/project/views.py similarity index 100% rename from herreweb_backend/project/views.py rename to 2023-12-24-old/herreweb_backend/project/views.py diff --git a/herreweb_backend/static/GHIDRA_1.png b/2023-12-24-old/herreweb_backend/static/GHIDRA_1.png similarity index 100% rename from herreweb_backend/static/GHIDRA_1.png rename to 2023-12-24-old/herreweb_backend/static/GHIDRA_1.png diff --git a/herreweb_backend/static/project_images/1.png b/2023-12-24-old/herreweb_backend/static/project_images/1.png similarity index 100% rename from herreweb_backend/static/project_images/1.png rename to 2023-12-24-old/herreweb_backend/static/project_images/1.png diff --git a/herreweb_backend/static/project_images/.blob/GHIDRA_1.png b/2023-12-24-old/herreweb_backend/static/project_images/.blob/GHIDRA_1.png similarity index 100% rename from herreweb_backend/static/project_images/.blob/GHIDRA_1.png rename to 2023-12-24-old/herreweb_backend/static/project_images/.blob/GHIDRA_1.png diff --git a/herreweb_backend/static/project_images/GHIDRA_1.png b/2023-12-24-old/herreweb_backend/static/project_images/GHIDRA_1.png similarity index 100% rename from herreweb_backend/static/project_images/GHIDRA_1.png rename to 2023-12-24-old/herreweb_backend/static/project_images/GHIDRA_1.png diff --git a/herreweb_backend/static/project_images/GHIDRA_1_nL03hOP.png b/2023-12-24-old/herreweb_backend/static/project_images/GHIDRA_1_nL03hOP.png similarity index 100% rename from herreweb_backend/static/project_images/GHIDRA_1_nL03hOP.png rename to 2023-12-24-old/herreweb_backend/static/project_images/GHIDRA_1_nL03hOP.png diff --git a/herreweb_backend/static/project_images/logo-600w.png b/2023-12-24-old/herreweb_backend/static/project_images/logo-600w.png similarity index 100% rename from herreweb_backend/static/project_images/logo-600w.png rename to 2023-12-24-old/herreweb_backend/static/project_images/logo-600w.png diff --git a/herreweb_backend/static/project_images/tallies.jpeg b/2023-12-24-old/herreweb_backend/static/project_images/tallies.jpeg similarity index 100% rename from herreweb_backend/static/project_images/tallies.jpeg rename to 2023-12-24-old/herreweb_backend/static/project_images/tallies.jpeg diff --git a/herreweb_backend/static/project_images/title/GHIDRA_1.png b/2023-12-24-old/herreweb_backend/static/project_images/title/GHIDRA_1.png similarity index 100% rename from herreweb_backend/static/project_images/title/GHIDRA_1.png rename to 2023-12-24-old/herreweb_backend/static/project_images/title/GHIDRA_1.png diff --git a/herreweb_frontend/.gitignore b/2023-12-24-old/herreweb_frontend/.gitignore similarity index 100% rename from herreweb_frontend/.gitignore rename to 2023-12-24-old/herreweb_frontend/.gitignore diff --git a/herreweb_frontend/.vscode/launch.json b/2023-12-24-old/herreweb_frontend/.vscode/launch.json similarity index 100% rename from herreweb_frontend/.vscode/launch.json rename to 2023-12-24-old/herreweb_frontend/.vscode/launch.json diff --git a/herreweb_frontend/README.md b/2023-12-24-old/herreweb_frontend/README.md similarity index 100% rename from herreweb_frontend/README.md rename to 2023-12-24-old/herreweb_frontend/README.md diff --git a/herreweb_frontend/package-lock.json b/2023-12-24-old/herreweb_frontend/package-lock.json similarity index 100% rename from herreweb_frontend/package-lock.json rename to 2023-12-24-old/herreweb_frontend/package-lock.json diff --git a/herreweb_frontend/package.json b/2023-12-24-old/herreweb_frontend/package.json similarity index 100% rename from herreweb_frontend/package.json rename to 2023-12-24-old/herreweb_frontend/package.json diff --git a/herreweb_frontend/public/favicon.ico b/2023-12-24-old/herreweb_frontend/public/favicon.ico similarity index 100% rename from herreweb_frontend/public/favicon.ico rename to 2023-12-24-old/herreweb_frontend/public/favicon.ico diff --git a/herreweb_frontend/public/index.html b/2023-12-24-old/herreweb_frontend/public/index.html similarity index 100% rename from herreweb_frontend/public/index.html rename to 2023-12-24-old/herreweb_frontend/public/index.html diff --git a/herreweb_frontend/public/logo192.png b/2023-12-24-old/herreweb_frontend/public/logo192.png similarity index 100% rename from herreweb_frontend/public/logo192.png rename to 2023-12-24-old/herreweb_frontend/public/logo192.png diff --git a/herreweb_frontend/public/logo512.png b/2023-12-24-old/herreweb_frontend/public/logo512.png similarity index 100% rename from herreweb_frontend/public/logo512.png rename to 2023-12-24-old/herreweb_frontend/public/logo512.png diff --git a/herreweb_frontend/public/manifest.json b/2023-12-24-old/herreweb_frontend/public/manifest.json similarity index 100% rename from herreweb_frontend/public/manifest.json rename to 2023-12-24-old/herreweb_frontend/public/manifest.json diff --git a/herreweb_frontend/public/robots.txt b/2023-12-24-old/herreweb_frontend/public/robots.txt similarity index 100% rename from herreweb_frontend/public/robots.txt rename to 2023-12-24-old/herreweb_frontend/public/robots.txt diff --git a/herreweb_frontend/src/components/App.js b/2023-12-24-old/herreweb_frontend/src/components/App.js similarity index 100% rename from herreweb_frontend/src/components/App.js rename to 2023-12-24-old/herreweb_frontend/src/components/App.js diff --git a/herreweb_frontend/src/components/AppFooter.js b/2023-12-24-old/herreweb_frontend/src/components/AppFooter.js similarity index 100% rename from herreweb_frontend/src/components/AppFooter.js rename to 2023-12-24-old/herreweb_frontend/src/components/AppFooter.js diff --git a/herreweb_frontend/src/components/AppHeader.js b/2023-12-24-old/herreweb_frontend/src/components/AppHeader.js similarity index 100% rename from herreweb_frontend/src/components/AppHeader.js rename to 2023-12-24-old/herreweb_frontend/src/components/AppHeader.js diff --git a/herreweb_frontend/src/components/Projects.js b/2023-12-24-old/herreweb_frontend/src/components/Projects.js similarity index 100% rename from herreweb_frontend/src/components/Projects.js rename to 2023-12-24-old/herreweb_frontend/src/components/Projects.js diff --git a/herreweb_frontend/src/index.js b/2023-12-24-old/herreweb_frontend/src/index.js similarity index 100% rename from herreweb_frontend/src/index.js rename to 2023-12-24-old/herreweb_frontend/src/index.js diff --git a/herreweb_frontend/src/reportWebVitals.js b/2023-12-24-old/herreweb_frontend/src/reportWebVitals.js similarity index 100% rename from herreweb_frontend/src/reportWebVitals.js rename to 2023-12-24-old/herreweb_frontend/src/reportWebVitals.js diff --git a/herreweb_frontend/src/setupTests.js b/2023-12-24-old/herreweb_frontend/src/setupTests.js similarity index 100% rename from herreweb_frontend/src/setupTests.js rename to 2023-12-24-old/herreweb_frontend/src/setupTests.js diff --git a/herreweb_frontend/src/static/App.css b/2023-12-24-old/herreweb_frontend/src/static/App.css similarity index 100% rename from herreweb_frontend/src/static/App.css rename to 2023-12-24-old/herreweb_frontend/src/static/App.css diff --git a/herreweb_frontend/src/static/AppFooter.css b/2023-12-24-old/herreweb_frontend/src/static/AppFooter.css similarity index 100% rename from herreweb_frontend/src/static/AppFooter.css rename to 2023-12-24-old/herreweb_frontend/src/static/AppFooter.css diff --git a/herreweb_frontend/src/static/AppHeader.css b/2023-12-24-old/herreweb_frontend/src/static/AppHeader.css similarity index 100% rename from herreweb_frontend/src/static/AppHeader.css rename to 2023-12-24-old/herreweb_frontend/src/static/AppHeader.css diff --git a/herreweb_frontend/src/static/Projects.css b/2023-12-24-old/herreweb_frontend/src/static/Projects.css similarity index 100% rename from herreweb_frontend/src/static/Projects.css rename to 2023-12-24-old/herreweb_frontend/src/static/Projects.css diff --git a/herreweb_frontend/src/static/index.css b/2023-12-24-old/herreweb_frontend/src/static/index.css similarity index 100% rename from herreweb_frontend/src/static/index.css rename to 2023-12-24-old/herreweb_frontend/src/static/index.css diff --git a/herreweb_frontend/src/static/logo.svg b/2023-12-24-old/herreweb_frontend/src/static/logo.svg similarity index 100% rename from herreweb_frontend/src/static/logo.svg rename to 2023-12-24-old/herreweb_frontend/src/static/logo.svg diff --git a/2023-12-24-old/requirements.txt b/2023-12-24-old/requirements.txt new file mode 100644 index 0000000..3b14feb --- /dev/null +++ b/2023-12-24-old/requirements.txt @@ -0,0 +1,5 @@ +django +sphinx +djangorestframework +django-cors-headers +Pillow diff --git a/snowstorm-min.js b/2023-12-24-old/snowstorm-min.js similarity index 100% rename from snowstorm-min.js rename to 2023-12-24-old/snowstorm-min.js diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0a7d3a0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +# Use an official Python runtime as a parent image +FROM python:3.9-slim AS base + +# Set the working directory in the container +WORKDIR /app + +# Copy the current directory contents into the container at /app +COPY . /app + +# Install any needed packages specified in requirements.txt +RUN --mount=type=cache,target=/root/.cache/pip pip install --no-cache-dir -r requirements.txt + +# Intermediate build stage (named 'dev' for example) +FROM base AS dev + +# Make port 5000 available to the world outside this container +EXPOSE 5000 + +# Define environment variable +ENV NAME World + +# Run app.py when the container launches +CMD ["flask", "run", "--host=0.0.0.0"] diff --git a/Readme.md b/Readme.md index 621b53c..863e047 100644 --- a/Readme.md +++ b/Readme.md @@ -1,36 +1,9 @@ -# Herreweb Site -Internally build website for [Herreweb](https://www.herreweb.nl). +This website aims to bring the -## Getting Started -To help contribute to the website, install dependencies in a ``Virtual Environment``: +Enable buildkit for docker: -``` -python3 -m venv venv -source venv/bin/activate -pip3 install -r requirements.txt -``` +```sudo DOCKER_BUILDKIT=1 docker build .``` +```sudo docker-compose build``` -## Project documentation -As with all Herreweb projects, the docs are provided in their stand-alone ``ReadTheDocs`` environment. - -When contributing to the project, make sure you write your documentation. - -To view the documentation, navigate to **documentation/readthedocs** and run the following commands: - -``` -make html -cd build/html -python3 -m http.server -``` -The website can be accessed at **localhost:8000** - -## Development -To run the backend server navigate to ``herreweb_backend/`` and run: - -> python3 manage.py runserver - -And for the frontend, navigate to ``herreweb_frontend`` and run: - -> npm start - -The file servers are accessible on ports 8000 and 3000. +Then run with: +```sudo docker-compose up``` \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000..3c6d422 --- /dev/null +++ b/app.py @@ -0,0 +1,91 @@ +from flask import Flask, render_template, redirect +import subprocess, logging, os, shutil + +app = Flask(__name__, static_folder='static/') +os.chdir(os.path.dirname(os.path.abspath(__file__))) + + +def _git_clone(repository_url, destination_folder): + """ + Clone a repository. + """ + try: + subprocess.run(['git', 'clone', repository_url, destination_folder], check=True) + logging.info(f"Git clone successful for {repository_url}") + except subprocess.CalledProcessError as e: + logging.error(f"Git clone unsuccessful for {repository_url}. Error: {e}") + + +def _clone_repositories(): + """ + Loop over all repositories in config/repositories.txt and clone them one by one. + """ + with open('config/repositories.txt', 'r') as f: + repositories = f.readlines() + for repository in repositories: + repository_name = repository.split('/')[-1][:-4].rstrip('.') + _git_clone(repository.strip(), f'repositories/{repository_name}') + + +def _buid_docs(): + """ + Run Makefile (currently not working). + Move documentation to static to be served. + """ + for folder in os.listdir('repositories'): + logging.debug(f'Found {folder}.') + try: + subprocess.run('documentation/Makefile', shell=True, check=True) + except Exception as e: + logging.error(f'Failed on {folder}. {e}') + + try: + if not os.path.exists(f'static/{folder}'): + os.makedirs(f'static/{folder}') + shutil.move(f'repositories/{folder}/documentation', f'static/{folder}') + except Exception as e: + logging.error(f'Failed to move {folder} to static folder. {e}') + + +def _get_repository_folders(): + repository_path = 'repositories' + if os.path.exists(repository_path) and os.path.isdir(repository_path): + return [folder for folder in os.listdir(repository_path) if os.path.isdir(os.path.join(repository_path, folder))] + else: + return [] + + +@app.route('/') +def hello(): + """ + Render homepage. + """ + repository_folders = _get_repository_folders() + return render_template('index.html', repository_folders=repository_folders) + + +@app.route('/') +def serve_sphinx_docs(path='index.html'): + """ + Serve static path to each repository included in config/repositories.txt + """ + return app.send_static_file(path) + + +@app.route('/') +def repository_page(folder): + """ + Create a button for each project and reroute to readthedocs of said project. + """ + documentation_path = os.path.join('static', folder, 'documentation', 'build') + if os.path.exists(documentation_path): + html_file_path = os.path.join(documentation_path, 'index.html') + return redirect(html_file_path) + else: + return f"Documentation not found for repository folder: {folder}" + + +if __name__ == "__main__": + _clone_repositories() + _buid_docs() + app.run(debug=True, host='0.0.0.0', port=5002) diff --git a/config/repositories.txt b/config/repositories.txt new file mode 100644 index 0000000..71879e9 --- /dev/null +++ b/config/repositories.txt @@ -0,0 +1,2 @@ +https://git.herreweb.nl/JonathanHerrewijnen/HerrewebPy.git +https://git.herreweb.nl/EljakimHerrewijnen/wifi-tally_Oostendam.git \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3b0f3ea --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +version: '3.8' +services: + web: + build: + context: . + target: dev # specify the build target if needed + ports: + - "5000:5000" diff --git a/requirements.txt b/requirements.txt index 3b14feb..575d634 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,2 @@ -django -sphinx -djangorestframework -django-cors-headers -Pillow +Flask==2.1.0 # or a later version +Werkzeug==2.0.0 diff --git a/static/wifi-tally_Oostendam/documentation/.vscode/settings.json b/static/wifi-tally_Oostendam/documentation/.vscode/settings.json new file mode 100644 index 0000000..a7d0fc7 --- /dev/null +++ b/static/wifi-tally_Oostendam/documentation/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "esbonio.sphinx.confDir": "" +} \ No newline at end of file diff --git a/static/wifi-tally_Oostendam/documentation/Makefile b/static/wifi-tally_Oostendam/documentation/Makefile new file mode 100644 index 0000000..837d189 --- /dev/null +++ b/static/wifi-tally_Oostendam/documentation/Makefile @@ -0,0 +1,24 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SPHINXAUTOBUILD = sphinx-autobuild +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +livehtml: + @$(SPHINXAUTOBUILD) -b html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/static/wifi-tally_Oostendam/documentation/make.bat b/static/wifi-tally_Oostendam/documentation/make.bat new file mode 100644 index 0000000..747ffb7 --- /dev/null +++ b/static/wifi-tally_Oostendam/documentation/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/static/wifi-tally_Oostendam/documentation/source/conf.py b/static/wifi-tally_Oostendam/documentation/source/conf.py new file mode 100644 index 0000000..a94a64d --- /dev/null +++ b/static/wifi-tally_Oostendam/documentation/source/conf.py @@ -0,0 +1,31 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +project = 'Oostendam Tallies' +copyright = '2023, Eljakim' +author = 'Eljakim' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = [ + 'sphinx_rtd_theme', + 'sphinx.ext.todo', + "sphinxcontrib.drawio", +] + +templates_path = ['_templates'] +exclude_patterns = [] + + + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = 'sphinx_rtd_theme' +html_static_path = ['_static'] diff --git a/static/wifi-tally_Oostendam/documentation/source/dependencies.rst b/static/wifi-tally_Oostendam/documentation/source/dependencies.rst new file mode 100644 index 0000000..2acab77 --- /dev/null +++ b/static/wifi-tally_Oostendam/documentation/source/dependencies.rst @@ -0,0 +1,16 @@ +============ +Dependencies +============ + +Install the following Dependencies: + + * luarocks : ``sudo apt install luarocks`` + * busted : ``sudo luarocks install busted`` + * python3 : ``sudo apt install python3`` + * esptool : ``pip3 install esptool`` + * nodemcu-uploader : ``pip3 install nodemcu-uploader`` + +Install on the Server PC: + + * NodeJS : https://nodejs.org/ + * Next : ``npm install next`` \ No newline at end of file diff --git a/static/wifi-tally_Oostendam/documentation/source/hardware/index.rst b/static/wifi-tally_Oostendam/documentation/source/hardware/index.rst new file mode 100644 index 0000000..00ae2cb --- /dev/null +++ b/static/wifi-tally_Oostendam/documentation/source/hardware/index.rst @@ -0,0 +1,91 @@ +============== +Hardware Setup +============== + +This page describes the hardware setup for the tallies. +How to build the tallies and how to build and flash new firmware to the tallies. + +Build a Tally +============= + +For the tallies a classic ``RGB`` ledstrip is used instead of the more modern ``WS2812B`` standard. This ledstrip is connected as follows: + +.. image:: tally-schematics-simple.png + +Build the firmware +================== + +In order to build the firmware a ``Toolchain`` for cross compilation is required. +This toolchain is provided in the repository in ``nodemcu-firmware/``. +To build the code for the tallies, navigate to ``wifi-tally/tally/`` and run ``make``. + +.. code-block:: console + + $ make + # if it compiles it is syntactically valid + ../../nodemcu-firmware/luac.cross -o /dev/null src/init.lua + "busted" + ●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●● + 91 successes / 0 failures / 0 errors / 0 pending : 0.23373 seconds + +The resulting files are in the ``out/`` folder. + +Flash the firmware +================== +To flash the firmware, first put the device in flash mode. +You can do this by pressing and hodling the ``FLASH`` button and presing the ``RST`` button. +After that you can release the ``FLASH`` button. +Next, navigate to ``../wifi-tally/firmware`` and run ``install_firmware.sh``. + +.. code-block:: console + + $ ./install_firmware.sh + esptool.py v4.4 + Serial port /dev/ttyUSB0 + Connecting.... + Detecting chip type... Unsupported detection protocol, switching and trying again... + Connecting.... + Detecting chip type... ESP8266 + Chip is ESP8266EX + Features: WiFi + Crystal is 26MHz + MAC: 50:02:91:fd:ca:0a + Uploading stub... + Running stub... + Stub running... + Configuring flash size... + Flash will be erased from 0x00000000 to 0x00070fff... + Flash params set to 0x0020 + Compressed 462848 bytes to 301339... + Wrote 462848 bytes (301339 compressed) at 0x00000000 in 26.7 seconds (effective 138.9 kbit/s)... + Hash of data verified. + + Leaving... + + +.. note:: + If you receive an error about permissions, run ``sudo -E ./install_firmware.sh`` to mitigate permissions for the USB device. Also look in the ``troubleshooting`` section if you keep having issues. + +Flash the Application +===================== +Navigate to ``wifi-tally/tally`` and run ``install_application.sh``. + +.. note:: + Make sure to edit the ``out/tally-settings.ini`` for the correct wifi SSID and password. + +.. code:: console + + $ ./install_application.sh + opening port /dev/ttyUSB0 with 115200 baud + Preparing esp for transfer. + Transferring out/my-app.lc as out/my-app.lc + Transferring out/my-led.lc as out/my-led.lc + Transferring out/my-log-buffer.lc as out/my-log-buffer.lc + Transferring out/my-log.lc as out/my-log.lc + Transferring out/my-settings.lc as out/my-settings.lc + Transferring out/my-tally.lc as out/my-tally.lc + Transferring out/my-wifi.lc as out/my-wifi.lc + Transferring out/tally-settings.ini as out/tally-settings.ini + All done! + +The tally is ready! \ No newline at end of file diff --git a/static/wifi-tally_Oostendam/documentation/source/hardware/tally-schematics-simple.png b/static/wifi-tally_Oostendam/documentation/source/hardware/tally-schematics-simple.png new file mode 100644 index 0000000..c1db899 Binary files /dev/null and b/static/wifi-tally_Oostendam/documentation/source/hardware/tally-schematics-simple.png differ diff --git a/static/wifi-tally_Oostendam/documentation/source/index.rst b/static/wifi-tally_Oostendam/documentation/source/index.rst new file mode 100644 index 0000000..ee27636 --- /dev/null +++ b/static/wifi-tally_Oostendam/documentation/source/index.rst @@ -0,0 +1,65 @@ +.. Oostendam Tallies documentation master file, created by + sphinx-quickstart on Mon Jan 23 22:14:59 2023. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Tallies in Oostendam +==================== + +.. toctree:: + :maxdepth: 2 + :caption: Build: + + overview.rst + hardware/index.rst + server/index.rst + + +.. toctree:: + :maxdepth: 2 + :caption: Development: + + patches.rst + troubleshooting.rst + + +.. toctree:: + :maxdepth: 2 + :caption: Migrating: + + migration.rst + +Introduction +============ + +This document contains the documentation for the tallies used in the `Immanuelkapel in Oostendam `_. +The goal in this project is to provide *cheap* indicator lights to show which camera is active during the service. +This way the minister knows which of the camera's is active and use it during the service. + +This project relies heavily on an `existing project on github `_. +The main difference between this code and the project on github is the behaviour of the tally lights. + +Contact +******* + +To contact our church you can see our contact details below: + + ++-------------+----------------------------+ +| | Immanuëlkapel (Oostendam) | ++=============+============================+ +| Street | Pruimendijk 99 | ++-------------+----------------------------+ +| Postal code | 2989 AH Ridderkerk | ++-------------+----------------------------+ +| Phone | 078-6819880 | ++-------------+----------------------------+ + + +.. include:: dependencies.rst + +Result +****** +The tally in our Church in Oostendam: + +.. image:: kerk_tally.jpeg \ No newline at end of file diff --git a/static/wifi-tally_Oostendam/documentation/source/kerk_tally.jpeg b/static/wifi-tally_Oostendam/documentation/source/kerk_tally.jpeg new file mode 100644 index 0000000..f5b03e9 Binary files /dev/null and b/static/wifi-tally_Oostendam/documentation/source/kerk_tally.jpeg differ diff --git a/static/wifi-tally_Oostendam/documentation/source/migration.rst b/static/wifi-tally_Oostendam/documentation/source/migration.rst new file mode 100644 index 0000000..bc03266 --- /dev/null +++ b/static/wifi-tally_Oostendam/documentation/source/migration.rst @@ -0,0 +1,26 @@ +===================== +Migrating to a new PC +===================== +When migrating to a new computer, you need to do the following: + + 1. Configure the new computer to use the *same* IP address as the previous computer. + 2. Install `NodeJS and NPM `_ + 3. Copy the config.json from the old PC (homedir + .wifi-tally.json) to the same location on the new PC. + 4. Run the server on the host PC(see below) + +Run server +========== +To run the server, navigate to ``wifi-tally/hub`` and execute ``run_server.sh`` + +.. code-block:: console + + $ ./run_server.sh + + > wifi-tally-hub@0.1.0 start + > node server.js --env=production + + Using mixer configuration "null" + No video mixer connected. + Listening for Tallies on 0.0.0.0:7411 + Web Server available on http://localhost:3000 + (node:117081) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time \ No newline at end of file diff --git a/static/wifi-tally_Oostendam/documentation/source/overview.drawio b/static/wifi-tally_Oostendam/documentation/source/overview.drawio new file mode 100644 index 0000000..0959e13 --- /dev/null +++ b/static/wifi-tally_Oostendam/documentation/source/overview.drawio @@ -0,0 +1 @@ +3Vffb5swEP5reK0IBkofm6TdJrXStExq92jgAK8GR8Zpkv71O+D4NdI22ppWW17i+3y2z9/dZxuLLfLdJ83X2a2KQVqOHe8strQcZ+ayGf5VyL5BPJc1QKpFTE49sBJPQKBN6EbEUI4cjVLSiPUYjFRRQGRGGNdabcduiZLjVdc8hQmwiriconciNlmDBp7d459BpFm78symnpy3zgSUGY/VdgCxK4sttFKmaeW7BciKvJaXZtz1M71dYBoKc8yA82bAI5cb2tudSATFZvbthiHG/ZOptMlUqgour3p0rtWmiKGa1Uar97lRao3gDMGfYMyeksk3RiGUmVxSL+yEuR+0f1RTnXlkLXc0c23sW6Mwen8/NJpRjtfa/bjaageWhmtzWVUCApHkZSmiFr4Wso2p4aHa/LP0ElSqjY7Iy6GK5DoF8nK71KImQOWAwaCLBsmNeBzPzqk4086vzx82KIWH0+lM0mk5vsQg5iE20qrxnUtZrb3gOWiOjW91oZIbLtB5TqpgnONtJgys1rze9haFPs5ngjQulFS6HstiDkHScKzVAwx6/CiAMOnWewRtYPcy31Mm2wGMdEUHS0DmtlfprJVeNlCoa/899/5/KaXzD5US+zgpsT+Q0g0kp1dSkoAfHVRSfH4R2vZplNTdWO8hpeBfV82HisadisZ7J9FcTERzDSbKEPpSJGqSVSxPM06ChlI88bB2qIhaK1GYOiBvbnlLRLgUaVGxhhQAFv68KnOBb7NL6shFHNcVIXkIcs6jh7SujZGEqt9LQqGXI0XSv9eG1AcvCsg+m/nMHWmI5j6adZr7a8XBwEUlSYmJ/T0tXQhHZcp9/XhbgUZmTv8y8CCI3UPnWeCEzPff5jxjvjfOhXvkeea/wXnmvU42Vmv0gD63PMWjwLEvDeSnv0qCCA5fJWHgud4bXSVeYL8b9Wj2H0+NLPpPUHb1Cw== \ No newline at end of file diff --git a/static/wifi-tally_Oostendam/documentation/source/overview.rst b/static/wifi-tally_Oostendam/documentation/source/overview.rst new file mode 100644 index 0000000..e71e156 --- /dev/null +++ b/static/wifi-tally_Oostendam/documentation/source/overview.rst @@ -0,0 +1,47 @@ +================ +Tallies Overview +================ + +This page gives a short overview of how the tallies work in relation to the camera's. A simple overview of the tallies in correlation between the server and the streamer is shown below: + +.. drawio-image:: overview.drawio + + + +Hardware +======== + +The hardware for the tallies is an ``esp8266`` microcontroller, as they can be found `on Amazon `_. +These microcontrollers are very cheap but are capable of using the ``802.11 b/g/n`` wifi standard(``IEEE``). + +A quick overview of the hardware: + + ++-------------------------+--------------------------------------+ +| Type | Value | ++=========================+======================================+ +| CPU | 32Bit RISC based on ``Xtensa lx106`` | ++-------------------------+--------------------------------------+ +| Instruction RAM | 32 KiB | ++-------------------------+--------------------------------------+ +| Instruction Cache | 32 KiB | ++-------------------------+--------------------------------------+ +| User Data RAM | 80 KiB | ++-------------------------+--------------------------------------+ +| System Data RAM | 16 KiB | ++-------------------------+--------------------------------------+ +| Flash Memory (External) | 4 MiB | ++-------------------------+--------------------------------------+ + +Of the 17 GPIO pins available, only 3 are used for the RGB colouring. +Wifi is used for communication between the tallies and a server that will tell the tally to turn on the lights. + +Software +======== +On the Host a ``NodeJS`` server is run that opens a websocket on port ``7411``. +This websockets waits for tallies to connect and sends data to them when connected. +The server also connects to the streamer, in our case a ``Black Magic ATEM`` that controls the camera's. +The streamer gives information about which camera is active which is passed to the tallies. + + + diff --git a/static/wifi-tally_Oostendam/documentation/source/patches.rst b/static/wifi-tally_Oostendam/documentation/source/patches.rst new file mode 100644 index 0000000..2d71f92 --- /dev/null +++ b/static/wifi-tally_Oostendam/documentation/source/patches.rst @@ -0,0 +1,50 @@ +============= +Tally Patches +============= +This section describes the patches made to the software. These patches are provided in the repository so no user interaction is needed when building the firmware. + +LED patches +=========== +The goal of the patches is to: + + * Disable any signal leds on error, like no wifi connected or server not accessble + * Disable green led when on preview + +In order to add these patches the following code was edited in the firmware: + +.. code-block:: c + + _G.MyLed = { + signal that nothing is being done + initial = flashPattern("O", colors.BLUE), + waitForWifiConnection = flashPattern("Oo", colors.GREEN), + invalidSettingsFile = flashPattern("OoOoOooooooo", colors.BLUE, 2), + waitForWifiIp = flashPattern("OoOo", colors.BLUE), + waitForServerConnection = flashPattern("OoOooo", colors.BLUE), + onPreview = flashPattern("O", colors.GREEN), + onAir = flashPattern("O", colors.RED), + onRelease = flashPattern(".", colors.GREEN, nil, false), + onUnknown = flashPattern("Oooooooo", colors.BLUE, 2), + onHighlight = flashPattern("OoOoOoOo", colors.WHITE), + turnOff = flashPattern("O", colors.BLACK), + } + +This code block was replaced with the following: + +.. code-block:: c + + _G.MyLed = { + initial = flashPattern("O", colors.BLACK), + waitForWifiConnection = flashPattern("O", colors.BLACK), + invalidSettingsFile = flashPattern("O", colors.BLACK), + waitForWifiIp = flashPattern("O", colors.BLACK), + waitForServerConnection = flashPattern("O", colors.BLACK), + onPreview = flashPattern("O", colors.BLACK), + onAir = flashPattern("O", colors.RED), + onRelease = flashPattern("O", colors.BLACK), + onUnknown = flashPattern("O", colors.BLACK), + onHighlight = flashPattern("OoOoOoOo", colors.GREEN), + turnOff = flashPattern("O", colors.BLACK), + } + +Upon each signal the leds will change, but into the BLACK color and into RED when the camera is active. \ No newline at end of file diff --git a/static/wifi-tally_Oostendam/documentation/source/server/index.rst b/static/wifi-tally_Oostendam/documentation/source/server/index.rst new file mode 100644 index 0000000..3935ffd --- /dev/null +++ b/static/wifi-tally_Oostendam/documentation/source/server/index.rst @@ -0,0 +1,63 @@ +====== +Server +====== +The tallies require a server that will direct the tallies and figure out the status of the ``BlackMagic ATEM``. + +Build the server +================ +Navigate to ``wifi-tally/hub`` and run the ``build_server.sh``. + +.. code-block:: console + + $ ./build_server.sh + + > wifi-tally-hub@0.1.0 build + > next build + + Browserslist: caniuse-lite is outdated. Please run: + npx browserslist@latest --update-db + info - Creating an optimized production build + info - Compiled successfully + info - Collecting page data + [== ] info - Generating static pages (0/1)info - Finalizing page optimizati + info - Finalizing page optimization + + Page Size First Load JS + ┌ λ / 4.55 kB 94.4 kB + ├ /_app 0 B 59.2 kB + ├ ○ /404 3.01 kB 62.2 kB + ├ λ /config 1.48 kB 91.3 kB + └ λ /tally/[tallyName] 1.48 kB 91.3 kB + + First Load JS shared by all 59.2 kB + ├ chunks/07ed33f3.bca366.js 68 B + ├ chunks/commons.94f2cd.js 11 kB + ├ chunks/framework.9ec1f7.js 39.9 kB + ├ chunks/main.7e5158.js 7.2 kB + ├ chunks/pages/_app.627bfb.js 284 B + ├ chunks/webpack.e06743.js 751 B + └ css/ba2fd543a36dbb3ceef1.css 25.9 kB + + λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps) + ○ (Static) automatically rendered as static HTML (uses no initial props) + ● (SSG) automatically generated as static HTML + JSON (uses getStaticProps) + (ISR) incremental static regeneration (uses revalidate in getStaticProps) + + [ ===] info - Generating static pages (0/1)% + + +To run the server, navigate to ``wifi-tally/hub`` and execute ``run_server.sh`` + +.. code-block:: console + + $ ./run_server.sh + + > wifi-tally-hub@0.1.0 start + > node server.js --env=production + + Using mixer configuration "null" + No video mixer connected. + Listening for Tallies on 0.0.0.0:7411 + Web Server available on http://localhost:3000 + (node:117081) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time + +Depending on the OS of the stream PC you might need to create a new shell script to execute the **npm run start** command to run the server. \ No newline at end of file diff --git a/static/wifi-tally_Oostendam/documentation/source/troubleshooting.rst b/static/wifi-tally_Oostendam/documentation/source/troubleshooting.rst new file mode 100644 index 0000000..b0fa5c8 --- /dev/null +++ b/static/wifi-tally_Oostendam/documentation/source/troubleshooting.rst @@ -0,0 +1,37 @@ +=============== +Troubleshooting +=============== + +If you have issues with the ``esp8266`` not connecting on /dev/ttyUSB, but the device does show up in lsusb: + +.. code:: console + + $ lsusb + [..] + Bus 001 Device 019: ID 1a86:7523 QinHeng Electronics CH340 serial converter + [..] + +Then this might be related to a udev rule in Linux. +Removing this rule will stop udev from hijacking the USB device. + +.. code:: console + + sudo rm /usr/lib/udev/rules.d/*-brltty-*.rules + sudo udevadm control --reload-rules + sudo systemctl mask brltty.path + +ESPlorer +======== +``ESPlorer`` is a tool that allows you to flash firmware to the ESP8266 using a GUI. This is example code on how to build and run it: + +.. code-block:: consoleabap + + git clone https://github.com/4refr0nt/ESPlorer.git + + # Build it + ./mvnw clean package + + # Run it + java -jar target/ESPlorer.jar + +The ``ESPlorer`` can be used to interact with the ``esp8266`` and flash binaries using a GUI. \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..bc9ffb0 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,14 @@ + + + + + + Repository Folders + + +

Repository Folders

+ {% for folder in repository_folders %} + + {% endfor %} + +