summary refs log tree commit diff stats
diff options
context:
space:
mode:
authormounderfod <mounderfod@gmail.com>2023-07-19 18:35:59 +0200
committermounderfod <mounderfod@gmail.com>2023-07-19 18:35:59 +0200
commit6638acdc0423d4e385bbb6c6eb2022913628c2a9 (patch)
tree0fc01cbdbe9eff136566c4269f8435b1dbc402e5
parenta85989cc62004489e790c64d8af25c4e02fbc20c (diff)
downloadgopherhole-master.tar.gz
Various fixes, add sports page HEAD master
-rw-r--r--app.py22
-rw-r--r--personal/gophermap13
-rw-r--r--personal/phlog/23-06-23-welcome.txt15
-rw-r--r--personal/phlog/23-07-11-fediverse.txt94
-rw-r--r--personal/phlog/23-07-18-emacs.txt60
-rw-r--r--personal/phlog/gophermap7
-rw-r--r--requirements.txtbin140 -> 254 bytes
-rw-r--r--sports.py92
-rw-r--r--static/ascii/cat.txt2
9 files changed, 106 insertions, 199 deletions
diff --git a/app.py b/app.py
index 873c99b..7262e63 100644
--- a/app.py
+++ b/app.py
@@ -1,10 +1,11 @@
 import os
-from os import listdir
-from os.path import isfile, join
+
 from dotenv import load_dotenv
 from pituophis import Item, serve
 from pyfiglet import Figlet
+
 import news
+import sports
 import weather
 
 load_dotenv()
@@ -20,16 +21,13 @@ def handle(request):
         menu.append(Item(itype="1", text="......NEWS", path="/news", host=os.getenv("HOSTNAME")))
         menu.append(
             Item(itype="7", text="......WEATHER (type in city name)", path="/weather", host=os.getenv("HOSTNAME")))
-        menu.append(Item(itype="1", text="......OWNER'S SITE", path="/personal", host=os.getenv("HOSTNAME")))
+        menu.append(Item(itype="1", text="......SPORTS", path="/sports", host=os.getenv("HOSTNAME")))
         return menu
     elif request.path.startswith("/newstxt"):
         return news.get_newstxt(request.path.split("?article=")[1])
     elif request.path.startswith("/weathertxt"):
         return weather.get_weather(request.path)
-    elif request.path == "/personal":
-        with open("personal/gophermap", "r") as f:
-            return [i for i in f.readlines()]
-    elif request.path == "/news" or request.path == "/weather":
+    elif request.path == "/news" or request.path == "/weather" or request.path == "/sports":
         menu = []
         text = figlet.renderText(request.path[1:]).split("\n")
         menu += [Item(text=i) for i in text]
@@ -39,9 +37,17 @@ def handle(request):
                 menu += news.get_news()
             case "/weather":
                 menu += weather.get_cities(request.query)
+            case "/sports":
+                menu += [
+                    menu.append(Item(itype="0", text="FORMULA 1", path="/sports/f1", host=os.getenv("HOSTNAME")))
+                ]
         return menu
+    elif request.path.startswith("/sports/"):
+        match request.path:
+            case "/sports/f1":
+                return sports.get_f1()
     else:
         return [Item(itype="3", text="Page not found")]
 
 
-serve(port=70, handler=handle)
+serve(port=70, handler=handle, pub_dir="personal")
diff --git a/personal/gophermap b/personal/gophermap
deleted file mode 100644
index 71ffe3e..0000000
--- a/personal/gophermap
+++ /dev/null
@@ -1,13 +0,0 @@
-i                  \   /\    ----------------		null.host	1
-i                  )  ( ')  <|  mounderfod  |		null.host	1
-i                 (  / )     ----------------		null.host	1
-i                 \(__)|		null.host	1
-i		null.host	1
-iWelcome to my gopher space! My name is Noah, but I go by mounderfod.		null.host	1
-iI am interested in music, programming and video games.		null.host	1
-i		null.host	1
-iLanguages I speak: French, English		null.host	1
-iPronouns: he/him		null.host	1
-i		null.host	1
-hMy WWW site	URL:https://mounderfod.online	gopher.mounderfod.online	70
-1Phlog (mirror of my blog)	/personal/phlog	gopher.mounderfod.online	70
diff --git a/personal/phlog/23-06-23-welcome.txt b/personal/phlog/23-06-23-welcome.txt
deleted file mode 100644
index dd74824..0000000
--- a/personal/phlog/23-06-23-welcome.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-Welcome to my blog!
-===================
-23 June 2023 | https://www.mounderfod.online/2023/06/23/welcome-to-my-blog.html
-
-Hello, I have decided to set up a blog on my website :) 
-Basically, I will use this page to create more long-form posts to express various ideas and other things that 
-I've found cool recently. 
-
-How does the website work? 
---------------------------
-The frontend was all written by me in raw HTML/CSS. 
-The little time marquee at the top of the page was my own idea, 
-but I "borrowed" the time formatting code from Stack Overflow. 
-In terms of backend, the website uses Jekyll and is being hosted on GitHub using Vercel to deploy it. 
-If anything is not working or you just want to contact me, contact me on Discord @mounderfod.
diff --git a/personal/phlog/23-07-11-fediverse.txt b/personal/phlog/23-07-11-fediverse.txt
deleted file mode 100644
index ef30e1b..0000000
--- a/personal/phlog/23-07-11-fediverse.txt
+++ /dev/null
@@ -1,94 +0,0 @@
-Enter The Fediverse
-===================
-11 July 2023 | https://www.mounderfod.online/2023/07/11/enter-the-fediverse.html
-
-If you havent heard, Reddit is in a bit of a pickle. In short, they have changed their API pricing
-in such a way as to effectively make it impossible for 3rd party apps to continue, presumably in
-order to improve that sweet ad revenue (a move probably inspired by Twitter's). In any case, the lack 
-of Reddit for a few days (and my general dissatisfaction with the platform at that time) led me to 
-explore alternatives, which led me to Lemmy, a finding which would cause me to dive much deeper into a much 
-wider thing - the Fediverse. This article will explore this process and how Ive found it so far.
-
-Lemmy
------ 
-As I said, the first thing that I'd found for this was Lemmy. Lemmy is, according to its own website:
-
-"a selfhosted social link aggregation and discussion platform. It is completely free and open, and not 
-controlled by any company. This means that there is no advertising, tracking, or secret algorithms. Content is 
-organized into communities, so it is easy to subscribe to topics that you are interested in, and ignore others. 
-Voting is used to bring the most interesting items to the top."
-
-Sounds cool, and most importantly, very similar to Reddit UX-wise, so I went and made an account.
-
-I should probably explain something out of the gate - there isnt one Lemmy website. Thats the whole point of 
-the Fediverse. Instead, there are many instances of Lemmy, all of which are federated, that is to say, they are 
-all interconnected. From my instance, I can make a post on another instance, which a user from yet another 
-instance can comment on. This way, there is no central authority for the whole site. Its like crypto, but 
-without the enormous range of scams and profiteering.
-
-Anyway, the instance that I decided to start with was lemmy.blahaj.zone. I was told that the instance you start 
-with doesnt really matter, so I chose this one on somewhat silly grounds - I own a Blahaj myself.
-
-It worked pretty well to begin with, as from my perspective it seemed to be working just like Reddit; I could 
-make posts, join communities, and so on. However, I quickly noticed that choosing an instance wasnt going to be 
-as simple for me as I had anticipated, due to my own pickiness and the particulars of federation.
-
-How federation works (a crude explanation)
-------------------------------------------
-Obviously, it would be wildly inefficient if every server shared everything that happened on it with every 
-server. As a result, federation on ActivityPub (the protocol that Lemmy, Mastodon, and more - including the 
-dreaded Meta Threads - use as their base) works like this:
-
-1. a user on server A requests a post/user/community on server B by using the search function 
-2. server B provides what they requested and creates a federated link between it and server A
-3. any future activity on the post/user/community is sent to server A for anyone to see
-
-This is probably an oversimplification, and it doesnt work 100% of the time (particularly when federating 
-between servers running different software), but from my observations this is basically how it works.
-
-This is also where my issue with the instance Id chosen came up. There was nothing inherently wrong with the 
-instance or its admins, and in fact it was a lovely instance, but several of the communities that I was 
-interested in (such as the Modded Minecraft or RetroWeb ones) had not yet federated properly. This is no fault 
-of the instances, and once I had searched for them myself, any new activity would be visible to me. But I am an 
-impatient moron, and I wanted to see what the existing activity was, and besides I began to notice that not all 
-comments on posts were being federated to me (such that going to the home instance of the post showed more 
-comments than I could see or respond to on my own instance), and this bothered me for some reason, so I decided 
-that I would begin to look for another instance.
-
-Side note: This issue is probably fixed now as the instance has grown some since the time of this experience.
-
-Conveniently, it became apparent to me on that same day that the SDF network, a lovely network of Internet 
-services, including a public Unix shell, had recently set up a Lemmy server. I had been a member of SDF for a 
-couple of weeks, and had been using their IRC and bulletin board during that time, so I figured I would set up 
-an account there - and besides, I checked in advance, and the federation seemed to be more to my liking - so 
-now Ive been using lemmy.sdf.org as my home instance and its been great - my username is 
-@mounderfod@lemmy.sdf.org if youre curious.
-
-Mastodon 
--------- 
-Of course, if youre familiar with the Fediverse (or have read the article up to this point), 
-you know that Lemmy is not the only Fediverse service that exists. Next for me was a replacement for Twitter, 
-which Id ditched on the day it was bought by Elon Musk (a fact which turned out to be excellent foresight on my 
-part, but realistically I was going to delete my account anyway, so it wasnt exactly a stroke of genius).
-
-This one was a little easier, since I discovered that SDF also had a Mastodon instance. I have to say that in 
-recent times Ive found myself using Mastodon a lot more than Lemmy; theres more users so theres more content 
-for me to access, and the lack of algorithm is really refreshing because it allows me to build my feed with 
-only the content (and people) that I want to see.
-
-If youd like to follow me on Mastodon my account is @mounderfod@mastodon.sdf.org.
-
-Other services and conclusion
------------------------------
-By this point I was fully immersed in the Fediverse, and quickly set up Pixelfed to replace Instagram and 
-Funkwhale to store my personal music collection. I also intend to set up my website with IndieWeb, which is 
-basically federation for blogs.
-
-At the start of this article, I explained that this all started because of Reddits API changes. But the truth 
-is, I was starting to become disillusioned with the mainstream social media networks long before this, with the 
-constant algorithms, ragebait and promotion of far-right content putting a drain on my own energy. I was 
-perhaps longing for freedom to control what I put my attention on. If this sounds like you, then I would 
-strongly recommend that you at least try the Fediverse networks - in any case, its much easier to delete your 
-account with them than with e.g. Facebook if you dont like it!
-
-I hope this article was of at least some interest to you, and thank you for making it this far :D
diff --git a/personal/phlog/23-07-18-emacs.txt b/personal/phlog/23-07-18-emacs.txt
deleted file mode 100644
index f59db3f..0000000
--- a/personal/phlog/23-07-18-emacs.txt
+++ /dev/null
@@ -1,60 +0,0 @@
-Using Emacs
-===========
-18 July 2023 | https://www.mounderfod.online/2023/07/18/using-emacs.html
-
-This post is being written in Emacs :) 
-
-What? 
------
-Emacs is, according to its own website: 
-
-"An extensible, customizable, free/libre text editor and more." 
-
-Basically, its one of the oldest text editors to exist, is (technically) entirely keyboard-based, and manages to combine simplicity with 
-power. In short, its great and Im going to talk about it now. 
-
-Why? 
-----
-Why am I using Emacs? Well, theres a few reasons: 
-
-- Id heard of it before and it sounded cool 
-- Its complex enough that it would present an interesting learning curve, but not so difficult as to discourage me 
-- Its useful for editing posts and HTML like this 
-- It ships with Tetris built in (need I say more?)
-
-How? 
-----
-I went to the website and downloaded it. My laptop currently uses Windows, and Emacs is made by GNU so as 
-expected I was berated for my choice of OS: 
-
-"To improve the use of proprietary systems is a misguided goal. Our aim, rather, is to eliminate them." 
-
-But I wasnt going to concern myself with GNUs plans for world domination; thats a problem for another day. The install was fairly simple, like any other
-application, and upon running the program I am greeted with a pleasant menu screen. 
-
-Now it was time for me to learn how to use Emacs. Emacs is primarily keyboard-based, as it was developed at a time where not all computers had GUIs at all, 
-let alone mice to interact with them. As such, and also due to its age, it has its own set of keybinding patterns which are overall very different to that 
-of most applications. For example, saving a file in MS Word is Ctrl-S, while in Emacs it is C-x C-s, which means Ctrl-x followed by Ctrl-S. Youll notice that in 
-this example, two keybindings need to be pressed to perform one action. This is common in Emacs, as there are lots of commands and not many keys, 
-and there are even some commands that dont have keybindings and must be invoked by pressing M-x (M meaning Alt) and then typing the command name out. 
-
-This was all a bit complex for me to understand at first, but I quickly got the hang of it (as I had done with the more standard keybinding patterns that existed 
-elsewhere in the computing world). 
-
-Customising Emacs 
------------------
-Now that I had gotten the grips of Emacs' basic usage, I needed to tailor it to my own needs. My plan was to use Emacs for editing Markdown posts (such as this one) 
-or HTML files, and my website is hosted on GitHub, so I needed something to cover both bases. 
-
-For the latter, there was already Emacs VersionControl, but this was a generic version control tool 
-and wasnt tailored to the specifics of Git. Therefore, I did some googling and came across Magit. A few more googles educated me in how to add the package 
-repository it was in and how to then install the package (M-x package-install RET magit RET), and I was quickly able to clone, commit, and push to the website 
-repository. Perfect! Now I needed to improve my Markdown editing experience. .md files are text, and so I could edit them as normal in Emacs, but then I wouldnt 
-be able to enjoy things such as syntax highlighting and easy access to various formatting options without typing them out manually. Again, a quick google found 
-markdown-mode, and within moments it was installed. The package adds a major mode to Emacs - Emacs is mode-based, meaning that there are modes of editing which 
-result in different functionality of the editor for different purposes - in this case, the markdown mode (enabled with M-x markdown-mode) provides syntax 
-highlighting and commands to automatically paste in the syntax for links, etc. 
-
-And that was it! 
-I had installed, learned to use, and configured Emacs and could now use it to edit blog posts for this very website (or Gopher phlog, if youre reading it on that 
-mirror). Next I shall get it set up for developing my Python/Java projects - Ill keep you posted!
diff --git a/personal/phlog/gophermap b/personal/phlog/gophermap
deleted file mode 100644
index 71ea7c9..0000000
--- a/personal/phlog/gophermap
+++ /dev/null
@@ -1,7 +0,0 @@
-1Back to homepage	/	gopher.mounderfod.online	70
-i		null.host	1
-imounderfod's Phlog (Gopher blog)		null.host	1
-i		null.host	1
-018 July 2023 - Using Emacs	/personal/phlog/23-07-18-emacs.txt	gopher.mounderfod.online	70
-011 July 2023 - Enter the Fediverse	/personal/phlog/23-07-11-fediverse.txt	gopher.mounderfod.online	70
-023 June 2023 - Welcome to my blog!	/personal/phlog/23-06-23-welcome.txt	gopher.mounderfod.online    70
diff --git a/requirements.txt b/requirements.txt
index c713bce..ac1283c 100644
--- a/requirements.txt
+++ b/requirements.txt
Binary files differdiff --git a/sports.py b/sports.py
new file mode 100644
index 0000000..3110714
--- /dev/null
+++ b/sports.py
@@ -0,0 +1,92 @@
+import requests
+from prettytable import PrettyTable
+from pyfiglet import Figlet
+from unidecode import unidecode
+
+def get_f1():
+    result = []
+    f = Figlet(font="big")
+    result += f.renderText("formula 1").split("\n")
+
+    result.append("=" * 80)
+    result.append("Last Race".center(80))
+    result.append("=" * 80)
+
+    lastRace = requests.get("http://ergast.com/api/f1/current/last/results.json").json()['MRData']['RaceTable']['Races'][0]
+    result.append(f"Round {lastRace['round']}: {lastRace['raceName']}")
+    result.append(f"Took place @ {lastRace['Circuit']['circuitName']} on {lastRace['date']}")
+
+    result.append("\n\n")
+
+    results = PrettyTable()
+    results.field_names = ['Position', 'Driver', 'Constructor', 'Time']
+
+    for i in lastRace['Results']:
+        if i['status'] != "Finished":
+            results.add_row([
+                i['positionText'],
+                unidecode(i['Driver']['givenName']) + " " + unidecode(i['Driver']['familyName']),
+                i['Constructor']['name'],
+                f"DNF lap {i['laps']} ({i['status']})"
+            ])
+        else:
+            results.add_row([
+                i['positionText'],
+                unidecode(i['Driver']['givenName']) + " " + unidecode(i['Driver']['familyName']),
+                i['Constructor']['name'],
+                i['Time']['time']
+            ])
+
+    result.append(results.get_string())
+    result.append("\n\n")
+
+    result.append("=" * 80)
+    result.append("Next Race".center(80))
+    result.append("=" * 80)
+
+    nextRace = requests.get("http://ergast.com/api/f1/current/next.json").json()['MRData']['RaceTable']['Races'][0]
+    result.append(f"Round {nextRace['round']}: {nextRace['raceName']}")
+    result.append(f"Taking place @ {nextRace['Circuit']['circuitName']}")
+    result.append(f"P1: {nextRace['FirstPractice']['date']} @ {nextRace['FirstPractice']['time'][:5]}")
+    result.append(f"P2: {nextRace['SecondPractice']['date']} @ {nextRace['SecondPractice']['time'][:5]}")
+    result.append(f"P2: {nextRace['ThirdPractice']['date']} @ {nextRace['ThirdPractice']['time'][:5]}")
+    result.append(f"Qualifying: {nextRace['Qualifying']['date']} @ {nextRace['Qualifying']['time'][:5]}")
+    result.append(f"Final Race: {nextRace['date']} @ {nextRace['time'][:4]}")
+
+    result.append("\n\n")
+
+    result.append("=" * 80)
+    result.append("Driver Standings".center(80))
+    result.append("=" * 80)
+
+    driverStandings = requests.get("http://ergast.com/api/f1/current/driverStandings.json").json()['MRData']['StandingsTable']['StandingsLists'][0]['DriverStandings']
+    dsTable = PrettyTable()
+    dsTable.field_names = ["Position", "Driver", "Constructor", "Points", "Wins"]
+    for i in driverStandings:
+        dsTable.add_row([
+            i['positionText'],
+            f"{unidecode(i['Driver']['givenName'])} {unidecode(i['Driver']['familyName'])} ({i['Driver']['nationality']})",
+            i['Constructors'][0]['name'],
+            i['points'],
+            i['wins']
+        ])
+    result.append(dsTable.get_string())
+    result.append("\n\n")
+
+    result.append("=" * 80)
+    result.append("Constructor Standings".center(80))
+    result.append("=" * 80)
+
+    constructorStandings = requests.get("http://ergast.com/api/f1/current/constructorStandings.json").json()['MRData']['StandingsTable']['StandingsLists'][0]['ConstructorStandings']
+    csTable = PrettyTable()
+    csTable.field_names = ["Position", "Constructor", "Points", "Wins"]
+    for i in constructorStandings:
+        csTable.add_row([
+            i['positionText'],
+            i['Constructor']['name'],
+            i['points'],
+            i['wins']
+        ])
+    result.append(csTable.get_string())
+
+    return result
\ No newline at end of file
diff --git a/static/ascii/cat.txt b/static/ascii/cat.txt
index 41fb038..172e0a5 100644
--- a/static/ascii/cat.txt
+++ b/static/ascii/cat.txt
@@ -14,7 +14,5 @@
 (ascii art by Joan Stark)
 
 +------------------------------------------+
-|                                          |
 |               DIRECTORIES                |
-|                                          |
 +------------------------------------------+