aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobby <[email protected]>2022-08-03 00:02:04 +0530
committerBobby <[email protected]>2022-08-03 00:02:04 +0530
commit5ab9a8355296b28565e8a39d6b8fff0cbb504932 (patch)
treefcbee3237b30731300594b2f20bba7eae63aee3d
parent4b2cb153d4a43d9cd52bb4975af757d6ce193f3d (diff)
downloadthatcomputerscientist-5ab9a8355296b28565e8a39d6b8fff0cbb504932.tar.xz
thatcomputerscientist-5ab9a8355296b28565e8a39d6b8fff0cbb504932.zip
Added views for user home page
-rw-r--r--blog/static/css/main.css161
-rw-r--r--blog/static/images/favicons/android-chrome-192x192.pngbin22940 -> 0 bytes
-rw-r--r--blog/static/images/favicons/android-chrome-512x512.pngbin99299 -> 0 bytes
-rw-r--r--blog/static/images/favicons/apple-touch-icon.pngbin20759 -> 0 bytes
-rw-r--r--blog/static/images/favicons/favicon-16x16.pngbin612 -> 0 bytes
-rw-r--r--blog/static/images/favicons/favicon-32x32.pngbin1514 -> 0 bytes
-rw-r--r--blog/static/images/favicons/favicon.icobin15406 -> 0 bytes
-rw-r--r--blog/static/images/favicons/favicon.pngbin26043 -> 0 bytes
-rw-r--r--blog/static/images/favicons/site.webmanifest1
-rw-r--r--blog/static/images/logo.pngbin14822 -> 0 bytes
-rw-r--r--blog/templates/account.html93
-rw-r--r--blog/templates/home.html28
-rw-r--r--blog/templates/homepage.html7
-rw-r--r--blog/templates/partials/base.html23
-rw-r--r--blog/templates/partials/sidebar.html69
-rw-r--r--blog/views.py6
-rw-r--r--userpages/views.py2
17 files changed, 4 insertions, 386 deletions
diff --git a/blog/static/css/main.css b/blog/static/css/main.css
deleted file mode 100644
index cf534be3..00000000
--- a/blog/static/css/main.css
+++ /dev/null
@@ -1,161 +0,0 @@
-/* making a sidebar layout with 20% sidebar */
-body {
- display: inline-flex;
- flex-direction: row;
- flex-wrap: wrap;
- min-height: calc(100vh);
- background-color: #fafafa;
- padding: 0;
- min-width: calc(100vw - 16px);
- width: 100%;
- font-family: serif;
- margin: 0;
- padding: 0;
-}
-
-.sidebar {
- background-color: #bad9ff;
- padding: 20px;
- overflow-x: hidden;
- overflow-y: auto;
- border: 1px solid #191919;
- min-width: 15rem;
- max-width: 15rem;
-}
-
-.main {
- flex: 1;
- padding: 20px;
- overflow-x: hidden;
- overflow-y: auto;
-}
-
-.title:visited {
- color: #000;
-}
-
-.title > h1 {
- font-size: 1.2rem;
- font-weight: bold;
- margin-top: 0;
-}
-
-.title {
- display: block;
-}
-
-.title > img {
- width: 10rem;
- height: 3.23rem;
- display: block;
- margin: 0px auto 10px auto;
- pointer-events: none;
-}
-
-.alert {
- background-color: #ffd4bd;
- padding: 20px;
- border: 1px solid #191919;
-}
-
-lebel, input, textarea, select {
- display: block;
- margin: 5px 0px;
- font-family: serif;
- font-size: 16px;
-}
-
-input[type = 'submit'] {
- margin-top: 10px;
-}
-
-fieldset {
- border: 1px solid #191919;
- padding: 10px 20px;
-}
-
-nav > ul {
- list-style: none;
- padding: 0;
- margin: 0;
-}
-
-nav > ul > li {
- margin: 5px 0;
-}
-
-.center {
- text-align: center;
-}
-
-.login-box {
- padding: 20px;
- border: 1px solid #191919;
-}
-
-.login-box > p {
- margin-top: 0;
- margin-bottom: 10px;
-}
-
-.error {
- color: red;
-}
-
-.success {
- color: green;
-}
-
-.alert.success {
- background-color: #d4ffbd;
- padding: 10px;
- color: rgb(5, 74, 5);
- font-weight: bold;
-}
-
-.alert.error {
- background-color: #ffbdbd;
- padding: 10px;
- color: rgb(74, 5, 5);
- font-weight: bold;
-}
-
-.account {
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
-}
-
-.ac-sidebar {
- padding: 20px;
- overflow-x: hidden;
- overflow-y: auto;
-}
-
-.ac-main {
- flex: 1;
- padding: 20px;
- overflow-x: hidden;
- overflow-y: auto;
-}
-
-.errorbox {
- background-color: #ffd4bd;
- padding: 20px;
- border: 1px solid #191919;
-}
-
-.errorbox > h1 {
- margin-top: 0;
-}
-
-/* Optimize for phones */
-@media only screen and (max-width: 480px) {
- body {
- flex-direction: column;
- }
-
- .account {
- flex-direction: column;
- }
-}
diff --git a/blog/static/images/favicons/android-chrome-192x192.png b/blog/static/images/favicons/android-chrome-192x192.png
deleted file mode 100644
index e9d9c66c..00000000
--- a/blog/static/images/favicons/android-chrome-192x192.png
+++ /dev/null
Binary files differ
diff --git a/blog/static/images/favicons/android-chrome-512x512.png b/blog/static/images/favicons/android-chrome-512x512.png
deleted file mode 100644
index 7a2d8305..00000000
--- a/blog/static/images/favicons/android-chrome-512x512.png
+++ /dev/null
Binary files differ
diff --git a/blog/static/images/favicons/apple-touch-icon.png b/blog/static/images/favicons/apple-touch-icon.png
deleted file mode 100644
index 4d1c7a33..00000000
--- a/blog/static/images/favicons/apple-touch-icon.png
+++ /dev/null
Binary files differ
diff --git a/blog/static/images/favicons/favicon-16x16.png b/blog/static/images/favicons/favicon-16x16.png
deleted file mode 100644
index ccab5501..00000000
--- a/blog/static/images/favicons/favicon-16x16.png
+++ /dev/null
Binary files differ
diff --git a/blog/static/images/favicons/favicon-32x32.png b/blog/static/images/favicons/favicon-32x32.png
deleted file mode 100644
index 59f8e353..00000000
--- a/blog/static/images/favicons/favicon-32x32.png
+++ /dev/null
Binary files differ
diff --git a/blog/static/images/favicons/favicon.ico b/blog/static/images/favicons/favicon.ico
deleted file mode 100644
index db7a682d..00000000
--- a/blog/static/images/favicons/favicon.ico
+++ /dev/null
Binary files differ
diff --git a/blog/static/images/favicons/favicon.png b/blog/static/images/favicons/favicon.png
deleted file mode 100644
index 67ff62f2..00000000
--- a/blog/static/images/favicons/favicon.png
+++ /dev/null
Binary files differ
diff --git a/blog/static/images/favicons/site.webmanifest b/blog/static/images/favicons/site.webmanifest
deleted file mode 100644
index 58a15c20..00000000
--- a/blog/static/images/favicons/site.webmanifest
+++ /dev/null
@@ -1 +0,0 @@
-{"name":"","short_name":"","icons":[{"src":"/static/images/favicons/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/static/images/favicons/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"} \ No newline at end of file
diff --git a/blog/static/images/logo.png b/blog/static/images/logo.png
deleted file mode 100644
index 56366c3d..00000000
--- a/blog/static/images/logo.png
+++ /dev/null
Binary files differ
diff --git a/blog/templates/account.html b/blog/templates/account.html
deleted file mode 100644
index 50b58996..00000000
--- a/blog/templates/account.html
+++ /dev/null
@@ -1,93 +0,0 @@
-{% extends 'partials/base.html' %} {% block content %}
-<div class="main">
- <h1>My Account</h1>
- <p>You can change account settings for <strong>{{ user.username }}</strong> here. If you wish to have additional support, please contact me at <a href="mailto:[email protected]?subject=[URGENT]%20Support%20Request%20for%20{{ user.username }}">[email protected]</a>. Please take care of the following points before you submit your support request:</p>
- <ul>
- <li>Please do not edit the subject line.</li>
- <li>As an individual monitoring this email, I request you to refrain yourself from spamming.</li>
- <li>Please do not include any sensitive information (like credit card numbers, passwords, etc.) in the email.</li>
- <li>Allow me upto 48 hours to respond to your support request.</li>
- <li>Do not send multiple support requests.</li>
- <li>Please note that this is a support request related to your account. Please do not file any bugs here. If you have noticed a bug, please report it to the <a href="https://github.com/luciferreeves/thatcomputerscientist/issues">GitHub Issues</a> page.</li>
- </ul>
- <p>Your avatar is fetched from gravatar. Update your gravatar email to fetch the avatar. If you don't have an account, you can sign up for one <a href="https://en.gravatar.com/" target="_blank">here</a>. If you haven't set up your gravatar email, we would try to fetch your profile picture from your account email, by default. If your account email and gravatar email are the same, you do not need to set a gravatar email.</p>
- {% if user_subdomain_url %}
- {% load replace %}
- <div class="alert" style="padding: 0 10px">
- <p>Your account is publicly accessible at <a href="{{ user_subdomain_url }}">{{ user_subdomain_url|replace:"https://"|replace:"http://" }}</a>. If you wish to change your account to private, you can do so below.</p>
- </div>
- {% endif %}
- {% for message in messages %}
- <div class="alert {{message.tags}}">
- <p>{{ message }}</p>
- </div>
- {% endfor %}
- <div class="account">
- <div class="ac-sidebar">
- <fieldset>
- <legend>Avatar</legend>
- <img src="https://www.gravatar.com/avatar/{{avatar}}?s=200" alt="{{ user.username }}'s avatar" width="200" height="200"/>
- </fieldset>
- <form method="post" action="{% url 'users:changepassword' %}">
- {% csrf_token %}
- <fieldset>
- <legend>Change Password</legend>
- <label for="oldPassword">Current Password</label>
- <input type="password" name="oldPassword" id="oldPassword" placeholder="Current Password" />
- <label for="newPassword">New Password</label>
- <input type="password" name="newPassword" id="newPassword" placeholder="New Password" />
- <label for="confirmPassword">Confirm New Password</label>
- <input type="password" name="confirmPassword" id="confirmPassword" placeholder="Confirm New Password" />
- <input type="submit" value="Change Password" />
- </fieldset>
- </form>
- <form method="post" onsubmit="event.preventDefault();">
- <fieldset>
- <legend class="error">Delete Account</legend>
- <input type="submit" value="Delete Account" />
- </fieldset>
- </form>
- </div>
- <div class="ac-main">
- <form method="post" action="{% url 'users:update' %} ">
- {% csrf_token %}
- <fieldset>
- <legend>Account Details</legend>
- <label for="firstname">First Name</label>
- <input type="text" name="firstname" id="firstname" value="{{ user.first_name }}" placeholder="First Name" />
- <label for="lastname">Last Name</label>
- <input type="text" name="lastname" id="lastname" value="{{ user.last_name }}" placeholder="Last Name" />
- <label for="gravatarEmail">Gravatar Email</label>
- <input type="text" name="gravatarEmail" id="gravatarEmail" value="{{ user_profile.gravatar_email }}" placeholder="Gravatar Email" />
- <label for="location">Location</label>
- <input type="text" name="location" id="location" value="{{ user_profile.location }}" placeholder="Location" maxlength="50"/>
- <label for="bio">Bio</label>
- <textarea name="bio" id="bio" placeholder="Bio">{{ user_profile.bio }}</textarea>
- <label for="isPublic">Account Visibility</label>
- <select name="isPublic" id="isPublic">
- <option value="1"{% if user_profile.is_public %} selected{% endif %}>Public</option>
- <option value="0"{% if not user_profile.is_public %} selected{% endif %}>Private</option>
- </select>
- {% if user_profile.is_public %}
- <label for="emailPublic">Email Visibility</label>
- <select name="emailPublic" id="emailPublic">
- <option value="1"{% if user_profile.email_public %} selected{% endif %}>Public</option>
- <option value="0"{% if not user_profile.email_public %} selected{% endif %}>Private</option>
- </select>
- {% endif %}
- <input type="submit" value="Update Account" />
- </fieldset>
- </form>
- <form method="post" action = "{% url 'users:sendchangeuseremail' %}">
- {% csrf_token %}
- <fieldset>
- <legend>Change Email</legend>
- <label for="email">Your current registered email is <em><u>{{ user.email }}</u></em>. Please note that a verification email will be sent to the new email address in order to update the current email address. Please provide the new email address in the box below:</label>
- <input type="email" name="email" id="email" placeholder="New Email" />
- <input type="submit" value="Change Email" />
- </fieldset>
- </form>
- </div>
- </div>
-</div>
-{% endblock %}
diff --git a/blog/templates/home.html b/blog/templates/home.html
deleted file mode 100644
index 6b120d0b..00000000
--- a/blog/templates/home.html
+++ /dev/null
@@ -1,28 +0,0 @@
-{% extends 'partials/base.html' %} {% block content %}
-<div class="main">
- <div class="alert">
- <h1 class="center">That Computer Scientist</h1>
- <p>
- Welcome to the home of That Computer Scientist. This is my personal
- website where I share all of my thoughts, ideas, and experiences. To know
- more about me, please visit my <a href="/about">About</a> page. If you
- would like to connect with me, please visit my
- <a href="/contact">Contact</a> page. Please use the sidebar to navigate
- the site.
- </p>
- </div>
- <br />
- <div class="alert" style="background-color: rgb(223, 255, 243)">
- <p>
- This website is a work in progress. I am currently working on adding more
- features to this website. I aim to build a retro looking personal website,
- where I will share my articles and Ideas, which will be built entirely
- around the idea of "collaborative writing" — where anyone can write new
- articles or edit existing ones.
- </p>
- </div>
- <section>
- <h2>Recent Posts</h2>
- </section>
-</div>
-{% endblock %}
diff --git a/blog/templates/homepage.html b/blog/templates/homepage.html
deleted file mode 100644
index 73639601..00000000
--- a/blog/templates/homepage.html
+++ /dev/null
@@ -1,7 +0,0 @@
-{% extends 'partials/base.html' %} {% block content %}
-<div class="main">
- <section>
- <h2>My Homepage</h2>
- </section>
-</div>
-{% endblock %}
diff --git a/blog/templates/partials/base.html b/blog/templates/partials/base.html
deleted file mode 100644
index ba78a931..00000000
--- a/blog/templates/partials/base.html
+++ /dev/null
@@ -1,23 +0,0 @@
-{% load static %}
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="UTF-8" />
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <meta
- name="description"
- content="Welcome to the home of That Computer Scientist. I am Kumar Priyansh. This is my personal website where I share all of my thoughts, ideas, and experiences."
- />
- <title>That Computer Scientist - {{ title }}</title>
- <link preload rel="stylesheet" href="{% static 'css/main.css' %}" />
- <link rel="apple-touch-icon" sizes="180x180" href="{% static 'images/favicons/apple-touch-icon.png' %}">
- <link rel="icon" type="image/png" sizes="32x32" href="{% static 'images/favicons/favicon-32x32.png' %}">
- <link rel="icon" type="image/png" sizes="16x16" href="{% static 'images/favicons/favicon-16x16.png' %}">
- <link rel="manifest" href="{% static 'images/favicons/site.webmanifest' %}">
- </head>
- <body>
- {% include 'partials/sidebar.html' %}
- {% block content %} {% endblock %}
- </body>
-</html>
diff --git a/blog/templates/partials/sidebar.html b/blog/templates/partials/sidebar.html
deleted file mode 100644
index cd46c18a..00000000
--- a/blog/templates/partials/sidebar.html
+++ /dev/null
@@ -1,69 +0,0 @@
-{% load static %}
-<div class="sidebar">
- <a href="/" class="title">
- <img src="{% static 'images/logo.png' %}" alt="That Computer Scientist Logo" width="10rem" height="3.23rem">
- <!-- Login Box -->
- </a>
- {% if user.is_authenticated %}
- <div class="login-box">
- <p>Welcome, {{ user.username }}!</p>
- <button type="submit" onclick="location.href='{% url 'users:logout' %}'">Logout</button>
- </div>
- {% else %}
- <fieldset>
- <legend>Login Area</legend>
- <form method="post" action="{% url 'users:login' %} ">
- {% csrf_token %}
- <label for="username">Username</label>
- <input type="text" id="username" name="username" placeholder="Username" autocomplete="off">
- <label for="password">Password</label>
- <input type="password" id="password" name="password" placeholder="Password">
- <input type="hidden" name="next" value="{{ request.path }}">
- <input type="submit" value="Login">
- </form>
- {% for message in messages %}
- {% if message.message == "EVERR" %}
- <form method="post" action="{% url 'users:sendverificationemail' %}" >
- <p class="{{message.tags}}">
- Your email is unverified. Please check your inbox for a verification email or to request a new verification email by clicking{% csrf_token %}<input type="hidden" name="username"><input style="display: inline; background: none; border: none; color: blue; text-decoration: underline; cursor: pointer; margin: 0;" type="submit" value="here.">
- </p>
- </form>
- {% else %}
- <p class="{{message.tags}}">{{message.message}}</p>
- {% endif %}
- {% endfor %}
- </fieldset>
- {% endif %}
- <br>
- <fieldset>
- <legend>Navigation</legend>
- <nav>
- <ul>
- <li><a href="/">Home</a></li>
- <li><a href="/about">About</a></li>
- <li><a href="/contact">Contact</a></li>
- <li><a href="/blog">Blog</a></li>
- {% if user.is_authenticated %}
- <li><a href="{% url 'account' %}">My Account</a></li>
- <li><a href="{% url 'homepage' %}">My Homepage<a></li>
- {% else %}
- <li><a href="/register">Register</a></li>
- {% endif %}
- {% if user.is_superuser %}
- <li><a href="/admin">Administration</a></li>
- {% endif %}
- </ul>
- </nav>
- </fieldset>
-</div>
-
-<script>
- // get the username parameter from the url
- var username = new URLSearchParams(window.location.search).get('username');
- // if the username parameter is not empty, set the username input to the value of the username parameter
- if (username) {
- document.getElementsByName("username").forEach(function(input) {
- input.value = username;
- });
- }
-</script>
diff --git a/blog/views.py b/blog/views.py
index 8d3dbe44..5fa42889 100644
--- a/blog/views.py
+++ b/blog/views.py
@@ -6,7 +6,7 @@ import hashlib
# Create your views here.
def home(request):
- return render(request, 'home.html', {'title': 'Home'})
+ return render(request, 'blog/home.html', {'title': 'Home'})
def account(request):
user = request.user
@@ -23,10 +23,10 @@ def account(request):
except UserProfile.DoesNotExist:
user_profile = None
avatar = hashlib.md5(str(user.email).lower().encode()).hexdigest()
- return render(request, 'account.html', {'title': 'Account', 'user_profile': user_profile, 'avatar': avatar, 'user_subdomain_url': user_subdomain_url})
+ return render(request, 'blog/account.html', {'title': 'Account', 'user_profile': user_profile, 'avatar': avatar, 'user_subdomain_url': user_subdomain_url})
else:
# Redirect to login page
return redirect('/')
def homepage(request):
- return render(request, 'homepage.html', {'title': 'Homepage'})
+ return render(request, 'blog/homepage.html', {'title': 'Homepage'})
diff --git a/userpages/views.py b/userpages/views.py
index 11b2fce7..46da5eb8 100644
--- a/userpages/views.py
+++ b/userpages/views.py
@@ -12,7 +12,7 @@ def home(request):
user_profile = UserProfile.objects.get(user=user)
is_public = user_profile.is_public
if is_public:
- return HttpResponse('Welcome to {}\'s homepage!'.format(subdomain))
+ return render(request, 'userpages/home.html', {'title': 'Homepage', 'username': str(user.username).capitalize()})
else:
raise Http404('{} is not public.'.format(subdomain))
except UserProfile.DoesNotExist: