From e74e15353172e0ae1bf3bb6d463e886f359f4030 Mon Sep 17 00:00:00 2001 From: Bobby Date: Wed, 5 Jul 2023 02:03:33 -0400 Subject: Added My Anime List --- blog/urls.py | 2 + blog/views.py | 25 +++++++ static/css/styles.css | 5 ++ static/images/site/icons/loading-fast.gif | Bin 0 -> 466270 bytes templates/blog/anidata.html | 6 ++ templates/blog/anilist.html | 11 ++++ templates/blog/partials/sidebar.html | 104 ++++++++++++++++-------------- 7 files changed, 106 insertions(+), 47 deletions(-) create mode 100644 static/images/site/icons/loading-fast.gif create mode 100644 templates/blog/anidata.html create mode 100644 templates/blog/anilist.html diff --git a/blog/urls.py b/blog/urls.py index d62e7464..57e5d08d 100644 --- a/blog/urls.py +++ b/blog/urls.py @@ -27,4 +27,6 @@ urlpatterns = [ path('policy', views.policy, name='policy'), path('socialify', views.socialify, name='socialify'), path('rss/', RSSFeed(), name='rss_feed'), + path('anidata', views.anidata, name='anidata'), + path('anilist', views.anilist, name='anilist'), ] diff --git a/blog/views.py b/blog/views.py index b253db6e..9b573491 100644 --- a/blog/views.py +++ b/blog/views.py @@ -16,6 +16,7 @@ from django.http import Http404, HttpResponse, HttpResponseRedirect from django.shortcuts import redirect, render, reverse from dotenv import load_dotenv from haystack.query import SearchQuerySet +import requests from user_agents import parse from announcements.models import Announcement @@ -561,3 +562,27 @@ def socialify(request): socialify_options[key] = 0 return render(request, 'blog/socialify.html', {'title': 'Socialify', 'options': socialify_options, 'url': url}) + +def anilist(request): + return render(request, 'blog/anilist.html', {'title': 'My Anime List'}) + +def anidata(request): + malURL = 'https://myanimelist.net/animelist/crvs' + MALContent = requests.get(malURL).content + MALContent = MALContent.decode('utf-8') + MALParsed = BeautifulSoup(MALContent, 'html.parser') + # remove script tags + for tag in MALParsed(['script', 'meta', 'noscript']): + tag.extract() + + # add myanimelist.net to relative links + for link in MALParsed.find_all('a'): + if link.get('href') and link.get('href')[0] == '/': + link['href'] = 'https://myanimelist.net' + link['href'] + + # make all links open in new tab + link['target'] = '_blank' + + MALContent = MALParsed.prettify() + + return render(request, 'blog/anidata.html', {'title': 'My Anime List', 'MALContent': MALContent}) diff --git a/static/css/styles.css b/static/css/styles.css index 6ae81a7e..ceefb21d 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -18,6 +18,11 @@ body { display: none !important; } +.iframe-loader { + background: url('../images/site/icons/loading-fast.gif') no-repeat top center; + background-size: 30%; +} + font:hover, .VIpgJd-yAWNEb-VIpgJd-fmcmS-sn54Q { background: none !important; box-shadow: none !important; diff --git a/static/images/site/icons/loading-fast.gif b/static/images/site/icons/loading-fast.gif new file mode 100644 index 00000000..144d7dbb Binary files /dev/null and b/static/images/site/icons/loading-fast.gif differ diff --git a/templates/blog/anidata.html b/templates/blog/anidata.html new file mode 100644 index 00000000..78e7106c --- /dev/null +++ b/templates/blog/anidata.html @@ -0,0 +1,6 @@ +{{ MALContent|safe }} + diff --git a/templates/blog/anilist.html b/templates/blog/anilist.html new file mode 100644 index 00000000..375f635e --- /dev/null +++ b/templates/blog/anilist.html @@ -0,0 +1,11 @@ +{% extends 'blog/partials/base.html' %} {% block content %} +{% load static %} +
+ +
+{% endblock content %} +{% block scripts %} + +{% endblock scripts %} \ No newline at end of file diff --git a/templates/blog/partials/sidebar.html b/templates/blog/partials/sidebar.html index 57f0e5ca..c0611890 100644 --- a/templates/blog/partials/sidebar.html +++ b/templates/blog/partials/sidebar.html @@ -156,6 +156,63 @@ Advertisement +
+

Fun Stuff

+ +
+

Archives

{% endif %} -
-

Fun Stuff

- -
- {% if anonymous_users or logged_in_users or admin_users %}

Who's Online?

-- cgit v1.2.3