diff options
Diffstat (limited to 'edaweb')
-rw-r--r-- | edaweb/app.py | 4 | ||||
-rw-r--r-- | edaweb/database.py | 4 | ||||
-rw-r--r-- | edaweb/services.py | 12 | ||||
-rw-r--r-- | edaweb/static/index.md | 1 | ||||
-rw-r--r-- | edaweb/static/robots.txt | 4 |
5 files changed, 16 insertions, 9 deletions
diff --git a/edaweb/app.py b/edaweb/app.py index 6902fe4..436df7a 100644 --- a/edaweb/app.py +++ b/edaweb/app.py @@ -17,7 +17,7 @@ import io app = flask.Flask(__name__) CONFIG = configparser.ConfigParser(interpolation = None) -CONFIG.read("edaweb.conf") +CONFIG.read(os.path.join(os.path.dirname(__file__), "edaweb.conf")) shown_images = set() shown_sidebar_images = set() @@ -224,7 +224,7 @@ def serve_random(): sbi = services.get_random_image(tags) req = urllib.request.Request(sbi.imurl) mediaContent = urllib.request.urlopen(req).read() - with open(os.path.join("static", "images", "random.jpg"), "wb") as f: + with open(os.path.join(os.path.dirname(__file__), "static", "images", "random.jpg"), "wb") as f: f.write(mediaContent) with database.Database() as db: diff --git a/edaweb/database.py b/edaweb/database.py index dab56e7..49ec33c 100644 --- a/edaweb/database.py +++ b/edaweb/database.py @@ -44,7 +44,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 +64,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 87af050..eca2bde 100644 --- a/edaweb/services.py +++ b/edaweb/services.py @@ -247,7 +247,7 @@ def parse_tweet(tweet_url): return dt, replying_to, text, images -def scrape_whispa(whispa_url, since): +def scrape_whispa(whispa_url, since = None): tree = html.fromstring(requests.get(whispa_url).content.decode()) qnas = [] # we're not doing proper HTML scraping here really... since the site uses client side rendering @@ -257,6 +257,9 @@ def scrape_whispa(whispa_url, since): 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"] == []: + continue + dt = datetime.datetime.fromisoformat(j["childFeedback"][0]["createdAt"][:-1]) qnas.append({ @@ -359,7 +362,8 @@ def get_recent_commits(db, max_per_repo = 3): return sorted(out, key = lambda a: a["datetime"], reverse = True) if __name__ == "__main__": - import database + print(scrape_whispa(CONFIG.get("qnas", "url"))) + # import database - with database.Database() as db: - print(json.dumps(get_recent_commits(db), indent=4)) + # with database.Database() as db: + # print(json.dumps(get_recent_commits(db), indent=4)) diff --git a/edaweb/static/index.md b/edaweb/static/index.md index a676d59..dacc9ac 100644 --- a/edaweb/static/index.md +++ b/edaweb/static/index.md @@ -26,6 +26,7 @@ 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 - [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..7aa9c7e 100644 --- a/edaweb/static/robots.txt +++ b/edaweb/static/robots.txt @@ -1,2 +1,4 @@ User-agent: *
-Disallow: /
\ No newline at end of file +Allow: /
+User-agent: Googlebot-Image
+Disallow: *
|