Coder Social home page Coder Social logo

jsolly / awesome-django-blog Goto Github PK

View Code? Open in Web Editor NEW
26.0 26.0 9.0 32.99 MB

Everything you expect in a blogging platform, and more!

Home Page: https://blogthedata.com

License: MIT License

Python 59.62% HTML 16.99% CSS 19.67% JavaScript 2.13% Shell 1.06% Dockerfile 0.42% Smarty 0.10%
blog django htmx python

awesome-django-blog's Introduction

awesome-django-blog's People

Contributors

dependabot[bot] avatar freedompraise avatar jsolly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

awesome-django-blog's Issues

Add robots file for crawlers

Context

A robots.txt file instructs crawlers on whether they are or are not allowed to crawl your site. It is also useful for giving sitemaps to the crawlers so they can better understand how the site is structured.

Things to consider

I should review some of these resources to learn about best practices and how others have implemented it.
https://developers.google.com/search/docs/advanced/robots/create-robots-txt
https://www.youtube.com/watch?v=abgxvrNqNkw
https://www.youtube.com/watch?v=xAXMqiPSY34

Add social media share buttons to post-detail route

Context

I'd like to have the social media share buttons within the post-detail page. This would let viewers easily share posts to their chosen social media platform (LinkedIN, Facebook, etc)

Current Behavior/Workaround

Users must copy/paste the url into a social media post.

Ideal behavior

User clicks a share button corresponding to the social media platform they wish to share to.

Things to consider

This django library looks very promising. It includes:
'Tweet This'
'Share this on Facebook'
'Share on Google+'
'Share on LinkedIn'
'Share on Telegram'
'Share on WhatsApp'
'mailto://'.
'Save to Pinterest'

Investigate whether you can 'scroll' images in ckeditor on mobile devices

Context

Currently, users have to pan their phone screen sideways when they want to see larger images. This looks weird and makes the layout inconsistent.

Ideal behavior

I like the way code snippets work. If the line is too long, a horizontal scrollbar appears and the user can scroll sideways without shifting the page around

Things to consider

I am not sure this is the same experience I'd want on devices with larger screens.

Add blogthedata.com to a CDN

Context

Currently, blogthedata.com gets pretty bad latency when accessed from other countries. I hosted the server in Dallas, Texas because I figured most of my traffic would be from the US and Texas is a pretty good midpoint in the country.

My understanding is that a CDN would distribute my site across many regions, moving the content closer to potential users. Here is a breakdown of the country IP addresses of people who have visited blogthedata.com

[show pie chart]

According to this Geekflare tool, users from countries such as Singapore can expect a time to first byte of about 1.5 seconds!
image

Current Behavior/Workaround

Server in Dallas, Texas serves all content to all users

Ideal behavior

Content can be served in at least a few continents (Maybe one for each major region?) NA, EMEA, LATAM, APAC

Things to consider

Since content is being distributed geographically, we can't guarantee each region will be synced up with the rest (unless we enforce that as a constraint). Seeing this is a blog site, I am personally OK, if there is lag time for all the servers to get the latest and greatest.

Not sure if it makes more sense to implement cache control BEFORE implementing this issue.

According to this Geekflare article, there are several CDNs to choose from, with Cloudfare being the most popular. Might want to do a little research to see what best works for me. Exciting to see that Cloudfare has a free tier!

I think this could have security implications, so adding the security label.

I also think this could have SEO impacts as it would definitley improve load time which is a metric for Google Lighthouse.

Transfer LinkedIN posts to blogthedata.com

I've written articles on LinkedIN that I would like to include on blogthedata.com. The only issue is that I haven't get included the ability to upload images that are hosted on my server.

I really don't want to rely on external servers for images, so once that is implemented, transferring the articles shouldn't be too difficult.

Run unittests before code is committed

Context

A proper CI-CD workflow would be to run all unittests before code is committed. I've done something similar using Git Hooks.

This ensures that code is not merged without unit testing.

Current Behavior/Workaround

Tests are run manually via the VScode UI or running unittest via terminal.

Unittest coverage is assessed manually using Python's coverage module. It outputs this:
image

Ideal behavior

At a most basic level, unittests should be run whenever code is committed.

A second requirement could be to mandate that there is a certain code coverage before code is allowed to be committed.

Things to consider

Since I am using TDD now, enforcing code coverage shouldn't be a problem.
Might be able to leverage this approach:
https://www.codingforentrepreneurs.com/blog/django-github-actions

Other resources
https://www.youtube.com/watch?v=odUAJws0sPU
https://www.youtube.com/watch?v=qJPLFDtEi1I&t=4s

Add Light/Dark Mode to site

Users often want sites to display on Light/Dark mode based on their preferences. Not totally sure how this could be advertised, but this could be through:

  • Current MacOS/iOS/Windows/Android theme.
  • Toggle Button on site

It might make sense to keep the theme stored in a cookie if the user wants to get the theme regardless of their system setting. The initial implementation should just match the user's system's theme.

Things to consider

icons, favicons

Add donation button

Context

Peoples of the internet sometimes like to donate to projects. I would like to give them that option!

Ideal behavior

I imagine a component in the sidebar that lets a user quickly donate.

Things to consider

Would also like to add this to the readme.

Use Git Hooks to collect static files before commiting code

Context

Whenever code is committed to source control that adds dependencies or other static conect (images, fonts, etc), automatically handle all the CI-CD stuff without manual intervention.

Current Behavior/Workaround

We must run:
python3 manage.py collectstatic to move assets into the right folders.

Ideal behavior

1 - Commit code
2 - Static files automatically move to correct folders (collectstatic command is run)

Add cache control for static assets

Context

One of the performance opportunities put forth by Google Lighthouse was to implement Cache-Control for static assets.

Once implemented, I can get a performance score of 100 (And hopefully better performance).

Current Behavior/Workaround

No cache control

Ideal behavior

Static assets all have a cache control policy.

Things to consider

My understanding is that cache control will allow clients to hold on to static assets (images, fonts, etc) instead of having to keep fetching them. One danger is that they might not get up-to-date static content after an update...but it looks like this can be mitigated by using hashing on all the assets.

If the hashes don't match, the client will ask for the resource again!

Resources:
https://www.youtube.com/watch?v=TgZnpp5wJWU
https://jakearchibald.com/2016/caching-best-practices/
https://www.youtube.com/watch?v=ZDftZcgEEZo
https://www.youtube.com/watch?v=usN-tbrQynA&list=PLrFzFX2lgkuy79RYoQHekuqnHDRrkUgXx&index=13

This is blocked by #63

Improve Social Media sharing (previews, etc)

Context

Blog posts are often shared to places like LinkedIN via 'posts.' Whenever I have done them, the post either has:
1 - No image
2 - My profile picture as the image
3 - The first picture embedded in a post

It would be great if authors could choose the photo that is featured in places like LinkedIN posts.

Current Behavior/Workaround

If you place an image very close to the top of your post, it appears to be used as the preview. For example, this post shares pretty well on LinkedIN.
image

Ideal behavior

I imagine an image field where you can choose what you want the preview to be. Once this is implemented, we can check the result using the LinkedIN post inspector which will show a preview of what your post will look like when it is published. There is also a facebook post inspector

Things to consider

I know little about social media sharing. WIll need to research this before attempting to implement. Check on this site on how they suggest doing it. This SO post agrees with the site.

It appears that I need to plug into the OpenGraph protocol.

In order to get the mimetype for the uploaded image, looks like I need to do some more work...like adding a validator
https://djangomango.com/blog/detail/checking-mime-types-for-uploaded-files-05a0d53e-4d5f-440f-a454-a5f5891adf01/

Also need to make sure GZIP compression is turned on
https://www.giftofspeed.com/gzip-test/

Investigate how Google displays page content on Search

Context

I am noticing some pages don't look great in google. The home page, for example, is using meta description text that is from a blog post, not what I added to the metadesc for the home page.
image

I think this is because the text I put in was too short.

Things to consider

https://search.google.com/test/rich-results
https://developers.google.com/search/docs/advanced/sitemaps/overview

Could we also take a second look at sitemaps in this issue? I think we need to add category pages to the sitemap (/life_advice, /site_updates)

Add a footer with Copyright, Sitemap, Privacy Policy, Terms of use, Contact, Site navigation, etc

Context

Most websites have a footer. This is an area at the bottom of the page that contains a bunch of information and links.

One reason I want a footer is that I need a place to reference some of the free resources and tools I've used to build the site. These open source contributors deserve recognition!

Current Behavior/Workaround

No footer = (

Ideal behavior

A footer that looks good in Desktop and Mobile

Things to consider

Not really sure how a footer is supposed to look on Mobile.
https://www.orbitmedia.com/blog/website-footer-design-best-practices/

Make sure to add these to the works cited page
https://favicon.io/emoji-favicons/bar-chart/
https://creazilla.com/nodes/55015-bar-chart-emoji-clipart
Django, bootstrap
Thank Corey Schafer and Code Academy

Implement Subresource Integrity (SRI) for static assets

Context

The Mozilla Observatory audit revealed that we have not implemented SRI.

Subresource integrity is a recent W3C standard that protects against attackers modifying the contents of JavaScript libraries hosted on content delivery networks (CDNs) in order to create vulnerabilities in all websites that make use of that hosted library.
Source: Mozilla infosec

The crux of SRI is generating a unique cryptographic hash for each file which locks the resource into a specific point in time.

Things to consider

There appears to be a python module, django-sri, that accomplishes this. Should look into it and see how easy it is to implement.

Add Health and Fitness Category

I often want to write posts about Health and Fitness, but I don't have a category for it! This should be pretty easy to add!

Clean up images when Users and Posts are deleted

Context

Whenever images are uploaded when creating a post or uploading a profile picture, they are not cleaned up when a post is deleted or a user is deleted.

Current Behavior/Workaround

Image resources are uploaded in the following ways

  • User uploads a new profile picture
  • User changes their profile picture
  • Author uploads an image to be used inside the content of a post
  • Author uploads and image to be used as the metaimg for a post

These all stick around forever

Ideal behavior

Image resources should be deleted when

  • A user changes their profile photo (delete the previous one)
  • A user is deleted
  • A post is deleted

Things to consider

I'll have to come up with a strategy for deleting existing resources that are no longer tied to a user or post. Might be able to use this approach.

Add more sorting options for posts

Context

When people visit a category (or view all posts)...they might want to sort the posts based on views/likes so they can see the most popular content first. They also might want to see oldest/newest posts.

Current Behavior/Workaround

There's no way to do this now. Posts are automatically sorted by timestamp (latest first). There is no way to change this.

Ideal behavior

Sort functionality toward the top of the page. Should include:
1 - Sort by time (Descending/ Ascending)
2 - Sort by Likes (High/Low)
3 - Sort by Views (High/Low)
4 - Sort by Tag? ...there is a discussion about this in #2

Things to consider

Should be pretty straightforward. I imagine this would be done by leveraging the get_queryset( ) function to fetch sorted/filtered posts. This is how I did it for the CategoryVIew

    def get_queryset(self):
        cat = self.kwargs.get("cat").replace("-", " ")
        posts = Post.objects.active()
        if self.request.user.is_staff or self.request.user.is_superuser:
            posts = Post.objects.all()
        return posts.filter(category=cat)

Implement Content Security Policy (CSP)

Context

One of the biggest hits I am taking with Mozilla's Observatory tool is that blogthedata.com does not have a CSP.

Things to consider

The Mozilla Foundation has created a Django plugin called django-csp. After installing it, I can use these guides to create a CSP.
https://www.geeksforgeeks.org/adding-csp-headers-in-django-project/
https://dev.to/thepylot/django-web-security-checklist-before-deployment-secure-your-django-app-4jb8

I've done some initial testing and have found that adding some of the reccomendations (like removing inline styles) completely breaks the app's UI.
image

Will need to create a branch for this one and work on it incrementally.

Minify Mailchimp's mc-validate.js

Context

Google Lighthosue is reporting that Mailchimp's js file is not compressed. This negatively affects performance.

Things to consider

I found this guide which involves hosting the JavaScript locally and compressing it myself. I am a bit wary of this because it means I have to make sure it gets updated whenever mailchimp updates their JS.

Would be great if Mailchimp could provide a minified version of their JS CDN link!

Ensure publish date conforms to OpenGraph protocol

Context

I seem to have made a mistake furnishing the publish date to using the OpenGraph protocol. Need to investigate to find out why it's not being picked up.

Steps to Reproduce

When using the LinkedIN post inspector with this link:
https://blogthedata.com/post/integration-tests-are-a-scam-i-wrote-them-anyway/

It says that it cannot be found.

image

This is how I am encoding the publish date:
<meta property="article:published_time" content="{{ post.date_posted|date:'c' }}">

Make site GDPR compliant

Context

We all know about those 'accept cookies' banners that show up on sites these days. I believe this is due to the EU's GDPR laws. It would be great if blogthedata.com conformed to these rules.

Things to consider

I'm not really tracking anyone aside from logging uniue IP addresses to do view/like counts on posts. Will need to research what is needed for a basic site like mine.

Remove '_' from my name on posts

Context

My username is displayed on posts. It would be nice if the underscore could be removed cause it looks weird.

Current behavior

image

Ideal behavior

A space should replace the underscore
image

Things to consider

I don't want to change the username because I don't think it's allowed to have spaces, but there's probably a way to do this in the template. If not, we can do something like we do to slugify/unslugify urls and categories
context["cat"] = Category.objects.get(name=self.kwargs["cat"].replace("-", " "))

Prevent reload when liking a post

Context

Whenever a user likes a post, a page reload happens. Essentially, this line of code is fetching the post-detail page again so the user can see that the post either went up 1 or down 1.

return HttpResponseRedirect(reverse("post-detail", args=[str(slug)]))

Would be great if the page didn't re-load.

Current Behavior/Workaround

1 - User Likes/Unlikes a Post
2 - Page re-loads
3 - Like count is correct, Like button state is correct

This isn't so noticeable on Desktop, but it's really wonky for mobile users. After liking a post, it refreshes the screen and you're scrolled back up to the top of the post-detail page.

Ideal behavior

The only thing that needs to be refreshed is the Like button and the number of likes.
1 - User Likes/Unlikes a post
2 - Like count updates and Like button state changes WITHOUT reload

Things to consider

I believe there's two ways I could solve it. The first is to use a library called django-htmx which I understand to allow me to make AJAX calls without actually writing any Javascript.

The second approach would be to write async JS to pull this off.

I will need to research these two approaches to figure out what is the best choice.

Create Application Diagram

Context

It would be nice if there was some kind of UML application diagram for how blogthedata.com is structured in terms of classes/functions/etc

Current Behavior/Workaround

None

Ideal behavior

An editable diagram that can be easily shared.

Things to consider

Might want to use Draw.io ?

Reactify blogthedata.com

Context

One goal of this site is to teach me web development frameworks. Now it's entirely possible to write the whole app without a single line of JavaScript, but that's silly if I want to get into the Web Dev world.

Thus, a big step for blogthedata.com is to separate the front and backend. There are plenty of tutorials online about 'reactifying' a Django app.

Ideal behavior

I imagine a React.js app that controls what we show to the user. When the app needs to interact with a Database, it should make REST calls to Django which handles the request, makes any needed db changes, and then responds with what React needs.

Things to consider

There will need to be a lot of architecture changes. We should finish the architecture diagram before taking on this issue.
Might want to pick up this book.

Add a Continuous Deployment Workflow

Context

A CI workflow was created in this issue. Now it's time we moved toward CD (Continuous Deployment) where production is updated without manual intervention.

Current Behavior/Workaround

  1. SSH into the production server
  2. Perform a git pull to get the latest code
  3. Restart Apache2 web server

Ideal behavior

I think the best way to do this would be to create a release branch and use a methodology such as Git Flow. to manage the SDLC.

Once code is pushed into the release branch, production should be updated within a reasonable ammount of time (a few minutes?)

Things to consider

We are already collecting static files using Git Hooks which was implemented in this issue. We will probably want to wrap that work into this workflow.

Might want to do more research on modern ways to manage branches.

I think we are going to have to move off of Linode node and move to something that has a starter workflow for GitActions if I am still using GitActions at the time this is implemented. My options today are Alibabacloud, AWS, Azure, Google, IBM, Openshift, Tencent, and Terraform.

Adding Security and performance labels because a whole new infrastructure requires new consideration of these factors.

Might want to check out a tool called Dokku

Migrate to Google Gmail API using Oauth for password reset emails

Context

In this issue, I temporarily fixed password reset emails. Unfortunately, this fix will stop working May 2022.

Google changed the rules on the 'less secure' method of authenticating via username and password.

The setting 'allow less secure apps' automatically turns itself off if it's not actively being used. So if no one tries to reset their password, I assume the password reset with break again.

Google is planning to shut down my 'less secure' way of authenticating with the Gmail API in May 2022, so we need to switch to a more secure way of authenticating.

Current Behavior/Workaround

Uses 'less secure' API call using username/passsword

Ideal behavior

Oauth

Things to consider

Ideally, the password reset emails should be using my blogthedata.com domain, but I am not sure how to pull that off yet. I think it makes sense to implement using Google and then switch over to the blogthedata domain when the time is right.

I think I can use this approach.
https://www.youtube.com/watch?v=7X3fBlMw_1k
https://www.youtube.com/watch?v=44ERDGa9Dr4

Add character count to text fields in post/new route

Context

We need a way for authors to know when they are over the character limit for a field.

Each field has a character limit.
title = models.CharField(max_length=60)
snippet = RichTextField(max_length=300, blank=True, null=True)
metadesc = models.CharField(max_length=140, blank=True, null=True)
category = models.CharField(max_length=100, default='uncategorized')

These are all based on SEO best practices.

Unfortunately, there's no way for authors to know how many characters they have typed until attempting to save the post.

Current Behavior/Workaround

When attempting to save a post where one of the field character limits has been exceeded, you get an error.
image

This error shows if you click 'Post'

Ideal behavior

Would be great to have a running counter that keeps track of every character (spaces, linebreaks, html, etc). That way, the author knows when they are approaching or have exceeded the limit without needing to attempt a save.

Things to consider

One solution would be to just stop the text area from adding characters above the limit. I don't like this option because I often want to finish my sentence or copy/paste text in and then reduce it down with edits.

Automatically add '...' to post snippets

Current Behavior/Workaround

I am currently manually adding '...' to snippets.

Ideal behavior

'...' is added without any manual intervention
image

Things to consider

I've already added them manually, so I probably need to manually take them out, too, so I don't have six periods. I could script it, but there's only like 30 posts, so it shouldn't be a huge pain.

Resolve duplicate static files

Context

Currently, there are two folders with static files /static and /staticfiles. Both appear to have the same files in them. My understanding is that my local dev environment leverages /staticfiles whereas production is using /static.

When I've tried to remove one or the other, it will break Dev or Prod.

# Settings.py
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
STATIC_URL = "/static/"

# Extra places for collectstatic to find static files.
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static"),
]

Expected Behavior

There shouldn't be duplicate files in source control...nor should there be local copies that could get out of sync.

Things to consider

We will want to take care of this issue before implementing #19

Add automatic draft saving to posts

Context

A user might want his post to be automatically saved (at some interval) without any manual intervention. This prevents any content from being lost should the page accidentally be closed, hard drive failure, nuclear explosion.

Current Behavior/Workaround

I can save drafts by ticking the draft checkbox and submitting the post. You then need to re-edit the post to continue where you left off.

This isn't a great experience because I've lost progress from forgetting to periodically do this. Plus it's annoying as hell.

Ideal behavior

I think it makes sense to save a draft or check for changes every 15 seconds.

Things to consider

I might want to look into other things that could improve this experience (like preventing the page from being navigated away from)

I am also unsure of what happens if someone leaves their browser open for years and years on end. Should there be some kind of timeout? Maybe I need to implement a sessiontimeout and automatic logout so my server doesn't get pinged every 15 seconds until the end of time.

If the author wants to discard their changes, they should be able to do that.

Add OCSP stapling

Context

According to the Godaddy cert checker, my site doesn't implement this. According to digicert

OCSP stapling can be used to enhance the OCSP protocol by letting the webhosting site be more proactive in improving the client (browsing) experience. OCSP stapling allows the certificate presenter (i.e. web server) to query the OCSP responder directly and then cache the response. This securely cached response is then delivered with the TLS/SSL handshake via the Certificate Status Request extension response, ensuring that the browser gets the same response performance for the certificate status as it does for the website content.

Things to consider

Digicert has a guide on how to do this in Apache
https://www.digicert.com/kb/ssl-support/apache-enable-ocsp-stapling-on-server.htm

There is also this cool tool put out by Mozilla that appears to add OCSP stapling to an apache config boilerplate
https://ssl-config.mozilla.org/#server=apache&version=2.4.41&config=intermediate&openssl=1.1.1k&guideline=5.6

Investigate large cummulative layout shift vlaues

Context

After making some layout changes, we now have a pretty high CLS according to Google Lighthouse
image
The biggest issue is that the body is shifting a lot.

Things to consider

Will need to learn more about how bootstrap renders elements to debug this one

Add security.txt

Context

In addition to a robot.txt, there appears to also be a security.txt file that has something to do with reporting security vulnerabilities. It is documented here:
https://securitytxt.org/

Things to consider

Will need to look into this more to see if it makes sense to implement!

Make unit tests more 'mockist' by adding mocks, stubs

Context

I like the idea of unit tests doing more 'checking' then testing. There's really no need to involve the database and external servers when stubs and mocks will do.

This will also greatly increase the speed of the tests and hopefully improve my software design.

Current Behavior/Workaround

Unit tests are more 'classisit' where they make real connections to servers and databases to get results.

Ideal behavior

unit tests are completely disconnected from databases and servers which will make them more 'unit testy' as opposed to being more 'integraty'

Things to consider

Probably want to wait on this issue #20 to be implemented before taking this on.
https://pypi.org/project/django-webtest/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.