aboutsummaryrefslogtreecommitdiffstats
path: root/edaweb
diff options
context:
space:
mode:
Diffstat (limited to 'edaweb')
-rw-r--r--edaweb/app.py40
-rw-r--r--edaweb/database.py9
-rw-r--r--edaweb/services.py50
-rwxr-xr-xedaweb/static/images/1583581996540.jpgbin0 -> 89996 bytes
-rwxr-xr-xedaweb/static/images/20251111_102045.jpgbin0 -> 130991 bytes
-rwxr-xr-xedaweb/static/images/20251111_102045.pngbin0 -> 43364 bytes
-rwxr-xr-xedaweb/static/images/2209509307.jpgbin0 -> 46907 bytes
-rwxr-xr-xedaweb/static/images/2684330373.jpgbin0 -> 10428 bytes
-rwxr-xr-xedaweb/static/images/GZhgzaK.pngbin0 -> 124272 bytes
-rwxr-xr-xedaweb/static/images/GegzRla.pngbin0 -> 44635 bytes
-rwxr-xr-xedaweb/static/images/JwL2S2V.pngbin0 -> 120751 bytes
-rwxr-xr-xedaweb/static/images/PXL_20251108_063442686.MP.jpgbin0 -> 6945886 bytes
-rwxr-xr-xedaweb/static/images/aLvcFjj.pngbin0 -> 23224 bytes
-rwxr-xr-xedaweb/static/images/bdd_fuel.pngbin0 -> 153407 bytes
-rwxr-xr-xedaweb/static/images/iKVCEoy.pngbin0 -> 97879 bytes
-rwxr-xr-xedaweb/static/images/photo_2025-12-04_22-34-24.jpgbin0 -> 102750 bytes
-rwxr-xr-xedaweb/static/images/rOJXmjG.pngbin0 -> 101799 bytes
-rwxr-xr-xedaweb/static/images/v2Yfoou.jpgbin0 -> 165128 bytes
-rwxr-xr-xedaweb/static/images/wxbKYVv.pngbin0 -> 123728 bytes
-rw-r--r--edaweb/static/index.md6
-rw-r--r--edaweb/static/robots.txt7
21 files changed, 72 insertions, 40 deletions
diff --git a/edaweb/app.py b/edaweb/app.py
index 436df7a..36fe8bb 100644
--- a/edaweb/app.py
+++ b/edaweb/app.py
@@ -214,26 +214,26 @@ def get_iso_cd():
id_ = id_
)
-@app.route("/random")
-def serve_random():
- try:
- tags = flask.request.args['tags'].split(" ")
- except KeyError:
- flask.abort(400)
-
- sbi = services.get_random_image(tags)
- req = urllib.request.Request(sbi.imurl)
- mediaContent = urllib.request.urlopen(req).read()
- with open(os.path.join(os.path.dirname(__file__), "static", "images", "random.jpg"), "wb") as f:
- f.write(mediaContent)
-
- with database.Database() as db:
- return flask.render_template(
- "random.html.j2",
- **get_template_items("random image", db),
- sbi = sbi,
- localimg = "/img/random.jpg?seed=%i" % random.randint(0, 9999)
- )
+#@app.route("/random")
+#def serve_random():
+# try:
+# tags = flask.request.args['tags'].split(" ")
+# except KeyError:
+# flask.abort(400)
+#
+# sbi = services.get_random_image(tags)
+# req = urllib.request.Request(sbi.imurl)
+# mediaContent = urllib.request.urlopen(req).read()
+# with open(os.path.join(os.path.dirname(__file__), "static", "images", "random.jpg"), "wb") as f:
+# f.write(mediaContent)
+#
+# with database.Database() as db:
+# return flask.render_template(
+# "random.html.j2",
+# **get_template_items("random image", db),
+# sbi = sbi,
+# localimg = "/img/random.jpg?seed=%i" % random.randint(0, 9999)
+# )
@app.route("/questions")
def serve_questions():
diff --git a/edaweb/database.py b/edaweb/database.py
index dab56e7..c6553a6 100644
--- a/edaweb/database.py
+++ b/edaweb/database.py
@@ -20,8 +20,11 @@ class Database:
passwd:str = None
def __enter__(self):
+ config_path = os.path.join(os.path.dirname(__file__), "..", "edaweb.conf")
+ if not os.path.exists(config_path):
+ raise FileNotFoundError("Could not find edaweb.conf config file")
self.config = configparser.ConfigParser(interpolation = None)
- self.config.read(os.path.join(os.path.dirname(__file__), "edaweb.conf"))
+ self.config.read(config_path)
if self.safeLogin:
self.__connection = pymysql.connect(
@@ -44,7 +47,7 @@ class Database:
def get_header_links(self):
with self.__connection.cursor() as cursor:
- cursor.execute("SELECT name, link FROM headerLinks ORDER BY name;")
+ cursor.execute("SELECT name, link FROM headerLinks WHERE display = true ORDER BY name;")
return cursor.fetchall()
def get_image(self, imageName):
@@ -64,7 +67,7 @@ class Database:
def get_header_articles(self):
with self.__connection.cursor() as cursor:
- cursor.execute("SELECT articleName, link FROM headerArticles;")
+ cursor.execute("SELECT articleName, link FROM headerArticles WHERE display = true;")
return cursor.fetchall()
def get_all_categories(self):
diff --git a/edaweb/services.py b/edaweb/services.py
index eca2bde..bb70d2a 100644
--- a/edaweb/services.py
+++ b/edaweb/services.py
@@ -22,8 +22,11 @@ import time
import os
theLastId = 0
+config_path = os.path.join(os.path.dirname(__file__), "..", "edaweb.conf")
+if not os.path.exists(config_path):
+ raise FileNotFoundError("Could not find edaweb.conf config file")
CONFIG = configparser.ConfigParser(interpolation = None)
-CONFIG.read(os.path.join(os.path.dirname(__file__), "edaweb.conf"))
+CONFIG.read(config_path)
def humanbytes(B):
'Return the given bytes as a human friendly KB, MB, GB, or TB string'
@@ -248,7 +251,18 @@ def parse_tweet(tweet_url):
return dt, replying_to, text, images
def scrape_whispa(whispa_url, since = None):
- tree = html.fromstring(requests.get(whispa_url).content.decode())
+ # add a bit of wiggle room in case i don't answer the questions in order (i often do this)
+ if since is None:
+ stop_at = datetime.datetime(year = 2001, month = 8, day = 12)
+ else:
+ stop_at = since - datetime.timedelta(days = 14)
+ print("The newest Q&A timestamp in the database was %s, we will stop looking at %s." % (since.astimezone().isoformat(), stop_at.astimezone().isoformat()))
+
+ html_ = requests.get(whispa_url).content.decode()
+ # with open("temp.html", "w") as f:
+ # f.write(html_)
+
+ tree = html.fromstring(html_)
qnas = []
# we're not doing proper HTML scraping here really... since the site uses client side rendering
# we rather parse the JS scripts to get the JSON payload of useful information... sadly this looks horrible
@@ -256,21 +270,33 @@ def scrape_whispa(whispa_url, since = None):
js = str(script.text)
if "receivedFeedback" in js:
# my god this is horrible...
- for j in json.loads(json.loads(js[19:-1])[1][2:])[0][3]["loadedUser"]["receivedFeedback"]:
- if j["childFeedback"] == []:
+ parsed_json = json.loads(json.loads(js[19:-1])[1][2:])[0][3]["loadedUser"]["receivedFeedback"]
+ # print(json.dumps(parsed_json, indent = 4))
+ # with open("whispas_%i.json" % i, "w") as f:
+ # json.dump(parsed_json, f, indent = 4)
+ for j in parsed_json:
+ if j["_count"]["childFeedback"] < 0:
continue
- dt = datetime.datetime.fromisoformat(j["childFeedback"][0]["createdAt"][:-1])
-
- qnas.append({
- # "id": int(str(maths.modf(maths.log(int(j["id"], 16)))[0])[2:]),
+ answer_url = "https://apiv4.whispa.sh/feedbacks/%s/children/public" % j["id"]
+ req = requests.get(answer_url)
+ firstanswer = req.json()["data"][0]
+ dt = datetime.datetime.fromisoformat(firstanswer["createdAt"][:-1])
+
+ qna = {
+ # "id": int(j["id"], base = 16),
"id": int(dt.timestamp()),
- "link": None,
+ "link": answer_url,
"datetime": dt,
"question": j["content"],
- "answer": j["childFeedback"][0]["content"],
+ "answer": firstanswer["content"],
"host": "whispa.sh"
- })
+ }
+ print(qna)
+ qnas.append(qna)
+ if dt <= stop_at:
+ print("Met the threshold for oldest Q&A, so stopped looking.")
+ break
return qnas
def get_docker_containers(host, ssh_key_path):
@@ -339,7 +365,7 @@ def get_torrent_stats():
"Uploaded:": humanbytes(s["cumulative-stats"]["uploadedBytes"]),
"Active time:": str(datetime.timedelta(seconds = s["cumulative-stats"]["secondsActive"])),
"Files added:": s["cumulative-stats"]["filesAdded"],
- "Current upload speed": humanbytes(s["uploadSpeed"]) + "s/S",
+ "Current upload speed:": humanbytes(s["uploadSpeed"]) + "s/S",
"Current download speed:": humanbytes(s["downloadSpeed"]) + "s/S"
}
diff --git a/edaweb/static/images/1583581996540.jpg b/edaweb/static/images/1583581996540.jpg
new file mode 100755
index 0000000..53ceaae
--- /dev/null
+++ b/edaweb/static/images/1583581996540.jpg
Binary files differ
diff --git a/edaweb/static/images/20251111_102045.jpg b/edaweb/static/images/20251111_102045.jpg
new file mode 100755
index 0000000..9f4c94b
--- /dev/null
+++ b/edaweb/static/images/20251111_102045.jpg
Binary files differ
diff --git a/edaweb/static/images/20251111_102045.png b/edaweb/static/images/20251111_102045.png
new file mode 100755
index 0000000..e7d7700
--- /dev/null
+++ b/edaweb/static/images/20251111_102045.png
Binary files differ
diff --git a/edaweb/static/images/2209509307.jpg b/edaweb/static/images/2209509307.jpg
new file mode 100755
index 0000000..1b5d515
--- /dev/null
+++ b/edaweb/static/images/2209509307.jpg
Binary files differ
diff --git a/edaweb/static/images/2684330373.jpg b/edaweb/static/images/2684330373.jpg
new file mode 100755
index 0000000..b050888
--- /dev/null
+++ b/edaweb/static/images/2684330373.jpg
Binary files differ
diff --git a/edaweb/static/images/GZhgzaK.png b/edaweb/static/images/GZhgzaK.png
new file mode 100755
index 0000000..c73e8b4
--- /dev/null
+++ b/edaweb/static/images/GZhgzaK.png
Binary files differ
diff --git a/edaweb/static/images/GegzRla.png b/edaweb/static/images/GegzRla.png
new file mode 100755
index 0000000..cf12555
--- /dev/null
+++ b/edaweb/static/images/GegzRla.png
Binary files differ
diff --git a/edaweb/static/images/JwL2S2V.png b/edaweb/static/images/JwL2S2V.png
new file mode 100755
index 0000000..9394c56
--- /dev/null
+++ b/edaweb/static/images/JwL2S2V.png
Binary files differ
diff --git a/edaweb/static/images/PXL_20251108_063442686.MP.jpg b/edaweb/static/images/PXL_20251108_063442686.MP.jpg
new file mode 100755
index 0000000..86171bb
--- /dev/null
+++ b/edaweb/static/images/PXL_20251108_063442686.MP.jpg
Binary files differ
diff --git a/edaweb/static/images/aLvcFjj.png b/edaweb/static/images/aLvcFjj.png
new file mode 100755
index 0000000..c928ba7
--- /dev/null
+++ b/edaweb/static/images/aLvcFjj.png
Binary files differ
diff --git a/edaweb/static/images/bdd_fuel.png b/edaweb/static/images/bdd_fuel.png
new file mode 100755
index 0000000..e79522e
--- /dev/null
+++ b/edaweb/static/images/bdd_fuel.png
Binary files differ
diff --git a/edaweb/static/images/iKVCEoy.png b/edaweb/static/images/iKVCEoy.png
new file mode 100755
index 0000000..05d6d70
--- /dev/null
+++ b/edaweb/static/images/iKVCEoy.png
Binary files differ
diff --git a/edaweb/static/images/photo_2025-12-04_22-34-24.jpg b/edaweb/static/images/photo_2025-12-04_22-34-24.jpg
new file mode 100755
index 0000000..51ced37
--- /dev/null
+++ b/edaweb/static/images/photo_2025-12-04_22-34-24.jpg
Binary files differ
diff --git a/edaweb/static/images/rOJXmjG.png b/edaweb/static/images/rOJXmjG.png
new file mode 100755
index 0000000..58a4ae4
--- /dev/null
+++ b/edaweb/static/images/rOJXmjG.png
Binary files differ
diff --git a/edaweb/static/images/v2Yfoou.jpg b/edaweb/static/images/v2Yfoou.jpg
new file mode 100755
index 0000000..f3a3249
--- /dev/null
+++ b/edaweb/static/images/v2Yfoou.jpg
Binary files differ
diff --git a/edaweb/static/images/wxbKYVv.png b/edaweb/static/images/wxbKYVv.png
new file mode 100755
index 0000000..75feb10
--- /dev/null
+++ b/edaweb/static/images/wxbKYVv.png
Binary files differ
diff --git a/edaweb/static/index.md b/edaweb/static/index.md
index a676d59..0d45f12 100644
--- a/edaweb/static/index.md
+++ b/edaweb/static/index.md
@@ -6,10 +6,6 @@ site now also avaliable under the domain [boymoder.blog](https://boymoder.blog)!
my name is eden and im a 23yo (boymoder/[fujoshi](https://www.urbandictionary.com/define.php?term=fujoshi)) computer science/robotics PhD student. i made my own website to encourage others to do so too.
i'll post my thoughts on here sometimes, and use this site to link to other stuff i host [more about me](/thought?id=2).
-[click here for a random image of lio fotia](/random?tags=lio_fotia)
-
-[click here for a random KawoShin image](/random?tags=nagisa_kaworu+ikari_shinji+yaoi)
-
## FOSS alternative services
- [nextcloud - dropbox (+ much more!) alternative](https://nc.eda.gay)
@@ -26,6 +22,8 @@ these sites are hosted on my [homelab system](https://wiki.eda.gay)
## nice websites
- [wiby.me](http://wiby.me/) - search engine for old style websites with limited javascript (my site used to be on here but it got blacklisted for some reason?)
- [dysmorph.nekoweb.org](https://dysmorph.nekoweb.org/) - a site that is very based because it looks similar
+- [transsexual.org](https://web.archive.org/web/20010802032136/http://transsexual.org/Toon.html) - awesome and relatable transsexual comics from a website that's slightly older than me
+- [norfolkchurches.co.uk](http://www.norfolkchurches.co.uk/norwichintro.htm) - site about all the churches in norwich (and norfolk!), the city that has far too many medieval churches than it knows what to do with. this site is preciesly what the internet should be, the muted ramblings of someone with an expert knowledge on his preferred niche interest. without any javascript. nice if, like me, you have a middling interest in theology
- [boymoder.network](https://boymoder.network/) - website for boymoder awareness
- [4chan.org/lgbt/](https://boards.4channel.org/lgbt/) - but dont blame me if u catch brainworms
- [https://www.math.uni-bielefeld.de/~sillke/Twister/fun/elevator-fun90.html](https://www.math.uni-bielefeld.de/~sillke/Twister/fun/elevator-fun90.html) any website with a URL like this is gonna be good
diff --git a/edaweb/static/robots.txt b/edaweb/static/robots.txt
index c2aab7e..04154e9 100644
--- a/edaweb/static/robots.txt
+++ b/edaweb/static/robots.txt
@@ -1,2 +1,7 @@
User-agent: *
-Disallow: / \ No newline at end of file
+Allow: /
+User-agent: Googlebot-Image
+Disallow: *
+User-agent: *
+Disallow: /random*
+