base game code; there's no game here (yet)
This commit is contained in:
parent
0cd9cc5fb7
commit
07b56dcd40
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "ext/imsky/wordlists"]
|
||||
path = ext/imsky/wordlists
|
||||
url = https://github.com/imsky/wordlists
|
28
Dockerfile
Normal file
28
Dockerfile
Normal file
@ -0,0 +1,28 @@
|
||||
FROM python:3.11-alpine AS base
|
||||
|
||||
# install rust environment (for rant)
|
||||
ENV RUSTUP_HOME=/usr/local/rustup CARGO_HOME=/usr/local/cargo PATH=/usr/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin RUST_VERSION=1.61.0
|
||||
RUN apk add --no-cache rustup gcc musl-dev
|
||||
RUN rustup-init -y
|
||||
|
||||
# install rant
|
||||
RUN cargo install --color=never rant --version 4.0.0-alpha.33 --root / --features cli
|
||||
|
||||
RUN mkdir -p /lib/wordlist
|
||||
COPY ext/imsky/wordlists /lib/wordlist
|
||||
#RUN python /lib/wordlist/render.py -o rant /app/rant/wordlist.rant
|
||||
|
||||
# prereqs
|
||||
COPY app/requirements.txt /app/requirements.txt
|
||||
RUN pip install -r /app/requirements.txt
|
||||
|
||||
# installing app
|
||||
COPY app /app
|
||||
WORKDIR /app
|
||||
|
||||
|
||||
CMD [ "python", "index.wsgi" ]
|
||||
EXPOSE 80
|
||||
|
||||
FROM base AS dev
|
||||
COPY static /app/static
|
7
LICENSE
7
LICENSE
@ -1,3 +1,5 @@
|
||||
Copyright © 2023 Nicole O'Connor.
|
||||
|
||||
Permission is hereby granted, without written agreement and without
|
||||
license or royalty fees, to use, copy, modify, and distribute this
|
||||
software and its documentation for any purpose, provided that the
|
||||
@ -15,3 +17,8 @@ BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
||||
ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
|
||||
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
|
||||
|
||||
(Images used in this project come from Wikimedia Commons. Individual
|
||||
file sources can be located within each file's metadata, which can be
|
||||
read by tools such as rdjpgcom(1).)
|
22
app/index.wsgi
Normal file
22
app/index.wsgi
Normal file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import gevent.monkey
|
||||
gevent.monkey.patch_all()
|
||||
|
||||
import logging
|
||||
|
||||
import flask
|
||||
from gevent.pywsgi import WSGIServer
|
||||
|
||||
from pylocal import core
|
||||
|
||||
@core.app.route("/")
|
||||
def index():
|
||||
if not core.base_context_live:
|
||||
core.render_base_context()
|
||||
return flask.render_template("main_page.j2", **core.base_context)
|
||||
|
||||
if __name__ == "__main__":
|
||||
#core.app.run("0.0.0.0", 1337)
|
||||
http_server = WSGIServer(('', 80), core.app, log=logging.getLogger(name="gevent"))
|
||||
http_server.serve_forever()
|
29
app/pylocal/core.py
Normal file
29
app/pylocal/core.py
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
|
||||
import flask
|
||||
|
||||
app = flask.Flask("seagull-game", root_path="/app")
|
||||
|
||||
base_context = {}
|
||||
base_context_live = False
|
||||
|
||||
def render_base_context():
|
||||
global base_context
|
||||
global base_context_live
|
||||
|
||||
print(flask.request.host)
|
||||
|
||||
domain_components = flask.request.host.split(".")
|
||||
base_domain = ".".join(domain_components[-2:])
|
||||
|
||||
# all this wind up for...
|
||||
if base_domain == "otl-hga.net": # production, use assets from S3
|
||||
base_context["styles"] = ["https://cdn.otl-hga.net/seagull/css/seagull.css"]
|
||||
base_context["scripts"] = ["https://cdn.otl-hga.net/seagull/js/seagull.js"]
|
||||
base_context["seagull_pic"] = "https://cdn.otl-hga.net/seagull/image/seagull.jpg"
|
||||
else: # dev, serve files from here
|
||||
base_context["styles"] = [flask.url_for("static", filename="css/seagull.css")]
|
||||
base_context["scripts"] = [flask.url_for("static", filename="js/seagull.js")]
|
||||
base_context["seagull_pic"] = flask.url_for("static", filename="image/seagull.jpg")
|
||||
|
||||
base_context_live = True
|
2
app/requirements.txt
Normal file
2
app/requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
Flask==2.2.2
|
||||
gevent==22.10.2
|
39
app/templates/main_page.j2
Normal file
39
app/templates/main_page.j2
Normal file
@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Seagull Game</title>
|
||||
{%- for style in styles -%}
|
||||
<link rel="stylesheet" href="{{ style }}">
|
||||
{%- endfor -%}
|
||||
{%- for script in scripts -%}
|
||||
<script src="{{ script }}"></script>
|
||||
{%- endfor -%}
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
<h1>This doesn't work without JavaScript.</h1><br />
|
||||
<h2>You're probably using a browser extension or privacy tool that disables it.</h2>
|
||||
</noscript>
|
||||
<div id="root">
|
||||
|
||||
<div id="main-sidebar">
|
||||
<div id="side-seagull-image"> <img width="256" src={{ seagull_pic }}> </div>
|
||||
<div id="side-seagull-name"><span id="lbl-seagull-name">Nameless</span> <a href="javascript:change_seagull_name()">✏️</a></div>
|
||||
<div id="side-seagull-name-editor"><input type="text" id="edt-seagull-name"> <a href="javascript:confirm_seagull_name()">✅</a><a href="javascript:cancel_seagull_name()">❌</a></div>
|
||||
<div id="side-seagull-stats">
|
||||
<p id="side-seagull-lvl">Lv 1 LoadError</p>
|
||||
<p id="side-seagull-misc">
|
||||
Colony: 1337<br />
|
||||
Shinies: 420<br />
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content">
|
||||
<div id="main-day-stats">It has been <span id="main-day-counter">a cosmically unknowable number of</span> days.</div>
|
||||
<div id="main-log"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
1
ext/imsky/wordlists
Submodule
1
ext/imsky/wordlists
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit cdda0e81d62151349c3a17679b5a0433eec60327
|
53
static/css/seagull.css
Normal file
53
static/css/seagull.css
Normal file
@ -0,0 +1,53 @@
|
||||
html, body { height: 100% }
|
||||
|
||||
div#root {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
div#main-sidebar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
max-width: 265px;
|
||||
/*padding-left: 5px;*/
|
||||
padding-right: 5px;
|
||||
border-right: 0.125em solid rgb(192, 192, 192);
|
||||
}
|
||||
|
||||
div#side-seagull-name {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
div#side-seagull-name-editor {
|
||||
display: none;
|
||||
}
|
||||
|
||||
div#main-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
div#main-log {
|
||||
display: flex;
|
||||
flex-direction: column-reverse;
|
||||
}
|
||||
|
||||
div.log-line {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
div.log-tick {
|
||||
font-size: 0.75em;
|
||||
margin-right: 0.2em;
|
||||
}
|
||||
|
||||
div.log-msg {
|
||||
margin-left: 0.2em;
|
||||
}
|
BIN
static/image/seagull.jpg
Normal file
BIN
static/image/seagull.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
48
static/js/seagull.js
Normal file
48
static/js/seagull.js
Normal file
@ -0,0 +1,48 @@
|
||||
var page_elements = {};
|
||||
|
||||
function record_log(text) {
|
||||
const div_logrow = document.createElement("div");
|
||||
div_logrow.className = "log-line";
|
||||
|
||||
const div_logtick = document.createElement("div");
|
||||
div_logtick.className = "log-tick"
|
||||
div_logtick.innerHTML = "Day 69";
|
||||
div_logrow.append(div_logtick);
|
||||
|
||||
const div_logmsg = document.createElement("div");
|
||||
div_logmsg.innerHTML = text;
|
||||
div_logmsg.className = "log-msg";
|
||||
div_logrow.append(div_logmsg);
|
||||
|
||||
page_elements["div_log"].append(div_logrow);
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function (ev) {
|
||||
page_elements["div_log"] = document.querySelector("#main-log");
|
||||
page_elements["div_name"] = document.querySelector("#side-seagull-name");
|
||||
page_elements["div_name_editor"] = document.querySelector("#side-seagull-name-editor");
|
||||
page_elements["lbl_name"] = document.querySelector("#lbl-seagull-name");
|
||||
page_elements["edt_name"] = document.querySelector("#edt-seagull-name");
|
||||
|
||||
record_log("It works!");
|
||||
});
|
||||
|
||||
function change_seagull_name() {
|
||||
page_elements["div_name"].style.display = "none";
|
||||
page_elements["div_name_editor"].style.display = "block";
|
||||
}
|
||||
|
||||
function confirm_seagull_name() {
|
||||
const new_name = page_elements["edt_name"].value;
|
||||
page_elements["lbl_name"].innerHTML = new_name;
|
||||
|
||||
page_elements["div_name"].style.display = "block";
|
||||
page_elements["div_name_editor"].style.display = "none";
|
||||
}
|
||||
|
||||
function cancel_seagull_name() {
|
||||
page_elements["edt_name"].value = "";
|
||||
|
||||
page_elements["div_name"].style.display = "block";
|
||||
page_elements["div_name_editor"].style.display = "none";
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user