Browse Source

Add CSP, seperate CSS file, sbbs and probably more

master
blank X 5 months ago
parent
commit
27339728cf
Signed by: blankie GPG Key ID: CC15FC822C7F61F5
  1. 1
      .gitignore
  2. 18
      .gitlab-ci.yml
  3. 45
      gensbbsrss.py
  4. 29
      public/blogs.html
  5. 29
      public/index.html
  6. 24
      public/sbbs/index.html
  7. 35
      public/sbbs/slide-switch-account-speedrun.html
  8. 18
      public/style.css
  9. 1
      requirements.txt

1
.gitignore

@ -0,0 +1 @@
index.xml

18
.gitlab-ci.yml

@ -1,11 +1,11 @@
image: alpine:latest
image: ubuntu:20.04
pages:
stage: deploy
script:
- echo 'Nothing to do...'
artifacts:
paths:
- public
only:
- master
stage: deploy
script:
- python3 -m pip install -r requirements.txt && cd public/sbbs && python3 ../../gensbbsrss.py
artifacts:
paths:
- public
only:
- master

45
gensbbsrss.py

@ -0,0 +1,45 @@
import os
from datetime import datetime
from xml.etree import ElementTree
from bs4 import BeautifulSoup
daydict = {1: 'Mon', 2: 'Tue', 3: 'Wed', 4: 'Thu', 5: 'Fri', 6: 'Sat', 7: 'Sun'}
monthdict = {1: 'Jan', 2: 'Feb', 3: 'Mar', 4: 'Apr', 5: 'May', 6: 'Jun', 7: 'Jul', 8: 'Aug', 9: 'Sep', 10: 'Oct', 11: 'Nov', 12: 'Dec'}
with open('index.html') as file:
soup = BeautifulSoup(file.read())
sbbsbase = soup.find('link', rel='canonical')['href']
feed = ElementTree.Element('rss', version='2.0')
channel = ElementTree.SubElement(feed, 'channel')
title = ElementTree.SubElement(channel, 'title')
title.text = 'software being broken showcase'
link = ElementTree.SubElement(channel, 'link')
link.text = sbbsbase
description = ElementTree.SubElement(channel, 'description')
description.text = 'just a showcase of software being broken :)'
language = ElementTree.SubElement(channel, 'language')
language.text = 'en-us'
items = []
for i in os.listdir('.'):
if i in ('index.html', 'index.xml'):
continue
with open(i) as file:
soup = BeautifulSoup(file.read())
item = ElementTree.Element('item')
title = ElementTree.SubElement(item, 'title')
title.text = soup.h1.string
link = ElementTree.SubElement(item, 'link')
link.text = soup.find('link', rel='canonical')['href']
guid = ElementTree.SubElement(item, 'guid')
guid.text = f'sbbs/{os.path.splitext(i)[0]}'
description = ElementTree.SubElement(item, 'description')
description.text = str(soup.find('div', class_='content'))
items.append((datetime.fromisoformat(soup.find('meta', {'name': 'created'})['content']), item))
for date, i in sorted(items, reverse=True, key=lambda i: i[0]):
# http://johnbokma.com/blog/2019/10/09/rfc-822-and-rfc-3339-dates-in-python.html
ctime = date.ctime()
pubdate = ElementTree.SubElement(i, 'pubDate')
pubdate.text = f"{ctime[0:3]}, {date.day:02d} {ctime[4:7]} {date.strftime(' %Y %H:%M:%S %z')}"
channel.append(i)
ElementTree.ElementTree(feed).write('index.xml', 'utf-8')

29
public/blogs.html

@ -3,33 +3,18 @@
<head>
<meta charset="utf-8" />
<meta name="referrer" content="no-referrer" />
<meta http-equiv="content-security-policy" content="default-src 'none'; img-src 'self'; media-src 'self'; style-src 'self'" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="alternate" type="application/rss+xml" href="/sbbs/index.xml" />
<link rel="canonical" href="https://blankx.gitlab.io/blogs.html" />
<meta name="color-scheme" content="dark" />
<title>blankie - blogs that i follow</title>
<style>
body {
background-color: black;
color: white;
font-family: sans-serif;
padding: 2em;
}
h4, .head {
margin-top: -1em;
}
h4 {
color: grey;
}
a {
color: #DD65E1;
}
</style>
<link rel="stylesheet" href="/style.css" crossorigin="anonymous" />
</head>
<body>
<h1>blogs that i follow</h1>
<h4>is this too much</h4>
<div class="head"><a href="index.html">home</a> | <a href="blogs.html">blogs</a></div>
<h4 class="head">is this too much</h4>
<div class="head"><a href="/">home</a> | <a href="/sbbs">sbbs</a> | <a href="/blogs.html">blogs</a></div>
<ul>
<li><b><a href="https://80x24.net">80x24</a> (<a href="https://80x24.net/rss.xml">feed</a>):</b> Thoughts on the bits and bytes of life</li>

29
public/index.html

@ -3,33 +3,18 @@
<head>
<meta charset="utf-8" />
<meta name="referrer" content="no-referrer" />
<meta http-equiv="content-security-policy" content="default-src 'none'; img-src 'self'; media-src 'self'; style-src 'self'" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="alternate" type="application/rss+xml" href="/sbbs/index.xml" />
<link rel="canonical" href="https://blankx.gitlab.io" />
<meta name="color-scheme" content="dark" />
<title>blankie</title>
<style>
body {
background-color: black;
color: white;
font-family: sans-serif;
padding: 2em;
}
h4, .head {
margin-top: -1em;
}
h4 {
color: grey;
}
a, code {
color: #DD65E1;
}
</style>
<link rel="stylesheet" href="/style.css" crossorigin="anonymous" />
</head>
<body>
<h1>blankie</h1>
<h4>i break everything i touch</h4>
<div class="head"><a href="index.html">home</a> | <a href="blogs.html">blogs</a></div>
<h4 class="head">i break everything i touch</h4>
<div class="head"><a href="/">home</a> | <a href="/sbbs">sbbs</a> | <a href="/blogs.html">blogs</a></div>
<p>I'm a 14 year old programmer that breaks everything I touch, and this site is hand-written HTML and CSS containing no javascript.</p>
<p>My GPG key is <a href="gpgkey.asc">here</a></p>

24
public/sbbs/index.html

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="referrer" content="no-referrer" />
<meta http-equiv="content-security-policy" content="default-src 'none'; img-src 'self'; media-src 'self'; style-src 'self'" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="alternate" type="application/rss+xml" href="/sbbs/index.xml" />
<link rel="canonical" href="https://blankx.gitlab.io/sbbs" />
<meta name="color-scheme" content="dark" />
<title>blankie - sbbs</title>
<link rel="stylesheet" href="/style.css" crossorigin="anonymous" />
</head>
<body>
<h1>sbbs</h1>
<h4 class="head">software being broken showcase</h4>
<div class="head"><a href="/">home</a> | <a href="/sbbs">sbbs</a> | <a href="/blogs.html">blogs</a></div>
<p><a href="index.xml">RSS</a></p>
<ul>
<li><a href="slide-switch-account-speedrun.html">Breaking Slide for Reddit by switching accounts too fast</a></li>
</ul>
</body>
</html>

35
public/sbbs/slide-switch-account-speedrun.html

@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="referrer" content="no-referrer" />
<meta http-equiv="content-security-policy" content="default-src 'none'; img-src 'self'; media-src 'self'; style-src 'self'" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="alternate" type="application/rss+xml" href="/sbbs/index.xml" />
<link rel="canonical" href="https://blankx.gitlab.io/sbbs/slide-switch-account-speedrun.html" />
<meta name="color-scheme" content="dark" />
<meta name="created" content="2021-07-16T16:44:01+07:00" />
<title>Breaking Slide for Reddit by switching accounts too fast</title>
<link rel="stylesheet" href="/style.css" crossorigin="anonymous" />
</head>
<body>
<h1>Breaking Slide for Reddit by switching accounts too fast</h1>
<h4 class="head">black screen any%</h4>
<div class="head"><a href="/">home</a> | <a href="/sbbs">sbbs</a> | <a href="/blogs.html">blogs</a></div>
<h4>Created on: 2021-07-16 16:44:01 +07:00</h4>
<div class="content">
<p>So I decided to check on Reddit, but then there was a bug in Slide for Reddit (the app I'm using) which wouldn't show upvotes I made nor let me upvote anything. Previously I discovered a workaround where when you browse as a guest and go back to your account, the bug will stop for some time.</p>
<p>I decided to switch to a guest and back to my account too fast and, lo-and-behold, black screen.</p>
<p>I went to Settings -> Apps &amp; notifications -> See all apps -> Slide -> Additional settings in the app, and now I see the settings. From here we can tap on About and /r/slideforreddit and we are now on the Slide subreddit.</p>
<p>Here I just used the search to search for the subreddit I wanted to go to and things worked for the most part. For an actual fix I opened <code>/data/data/me.ccrama.redditslide/shared_prefs/appRestart.xml</code>, and found this:</p>
<pre><code>
&lt;boolean name=&quot;loggedin&quot; value=&quot;true&quot; /&gt;
&lt;string name=&quot;name&quot;&gt;LOGGEDOUT&lt;/string&gt;
</code></pre>
<p>Ah yes, being logged in and logged out at the same time. I just changed <code>LOGGEDOUT</code> to my username and now slide works again (but I switched to guest and back to my account SLOWLY to try to eliminate any configuration errors for now)</p>
</div>
</body>
</html>

18
public/style.css

@ -0,0 +1,18 @@
body {
background-color: black;
color: white;
font-family: sans-serif;
padding: 2em;
}
.head, h4.head {
margin-top: -1em;
}
h4 {
color: grey;
}
a, code {
color: #DD65E1;
}

1
requirements.txt

@ -1 +1,2 @@
feedparser
beautifulsoup4

Loading…
Cancel
Save