Skip to content

Commit

Permalink
lastmod
Browse files Browse the repository at this point in the history
  • Loading branch information
trinkey committed Oct 25, 2024
1 parent 87b802c commit 4e3fd34
Show file tree
Hide file tree
Showing 14 changed files with 88 additions and 49 deletions.
1 change: 1 addition & 0 deletions smiggins/backend/api/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ def comment_edit(request, data: EditComment):
}

post.edited = True
post.edited_at = round(time.time())
post.content = content
post.content_warning = c_warning
post.private_comment = data.private
Expand Down
1 change: 1 addition & 0 deletions smiggins/backend/api/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ def post_edit(request, data: EditPost):
}

post.edited = True
post.edited_at = round(time.time())
post.content = content
post.content_warning = c_warning
post.private_post = data.private
Expand Down
6 changes: 4 additions & 2 deletions smiggins/backend/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ def get_post_json(post_id: int, current_user_id: int=0, comment: bool=False, cac
"parent_is_comment": post.parent_is_comment if isinstance(post, Comment) else False,
"poll": poll,
"logged_in": user is not None,
"edited": post.edited
"edited": post.edited,
"edited_at": post.edited_at
}

if isinstance(post, Post) and post.quote != 0:
Expand Down Expand Up @@ -422,7 +423,8 @@ def get_post_json(post_id: int, current_user_id: int=0, comment: bool=False, cac
"blocked": False,
"has_quote": isinstance(quote, Post) and quote.quote,
"poll": bool(quote.poll) if isinstance(quote, Post) else False,
"edited": post.edited
"edited": quote.edited,
"edited_at": quote.edited_at
}

except Comment.DoesNotExist:
Expand Down
2 changes: 1 addition & 1 deletion smiggins/backend/sitemaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def sitemap_post(request, index: int) -> HttpResponse:
request, "sitemap/post.xml", user=None,

URL=WEBSITE_URL,
posts=[[i[0], _get_lastmod(i[1])] for i in Post.objects.filter(Q(private_post=False) | Q(private_post=None)).order_by("post_id").values_list("post_id", "timestamp")[index * ITEMS_PER_SITEMAP : (index + 1) * ITEMS_PER_SITEMAP :]]
posts=[[i[0], _get_lastmod(i[2] if i[2] else i[1])] for i in Post.objects.filter(Q(private_post=False) | Q(private_post=None)).order_by("post_id").values_list("post_id", "timestamp", "edited_at")[index * ITEMS_PER_SITEMAP : (index + 1) * ITEMS_PER_SITEMAP :]]
)
r["Content-Type"] = "application/xml"
return r
22 changes: 10 additions & 12 deletions smiggins/backend/templating.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import json

# from cairosvg import svg2png
from cairosvg import svg2png
from django.http import (HttpResponse, HttpResponseRedirect,
HttpResponseServerError)
from posts.models import Comment, Hashtag, Post, PrivateMessageContainer, User
Expand Down Expand Up @@ -418,20 +418,18 @@ def pending(request) -> HttpResponse | HttpResponseRedirect:
return get_HTTP_response(request, "pending.html", user=user)

def generate_favicon(request, a) -> HttpResponse | HttpResponseServerError:
# colors: tuple[str, str, str] = a.split("-")
colors: tuple[str, str, str] = a.split("-")

# png_data: bytes | None = svg2png(
# FAVICON_DATA.replace("@{background}", f"#{colors[0]}").replace("@{background_alt}", f"#{colors[1]}").replace("@{accent}", f"#{colors[2]}"),
# output_width=32,
# output_height=32
# )

# if not isinstance(png_data, bytes):
# return HttpResponseServerError("500 Internal Server Error")
png_data: bytes | None = svg2png(
FAVICON_DATA.replace("@{background}", f"#{colors[0]}").replace("@{background_alt}", f"#{colors[1]}").replace("@{accent}", f"#{colors[2]}"),
output_width=32,
output_height=32
)

# return HttpResponse(png_data, content_type="image/png")
if not isinstance(png_data, bytes):
return HttpResponseServerError("500 Internal Server Error")

return HttpResponseRedirect("/static/img/old_favicon.ico")
return HttpResponse(png_data, content_type="image/png")

# These two functions are referenced in smiggins/urls.py
def _404(request, exception) -> HttpResponse:
Expand Down
29 changes: 16 additions & 13 deletions smiggins/less/home.less
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,22 @@ input.c-warning {
margin-top: 0.75em;
width: 23.5em;
}

.displ-name-container {
width: 23.5em;
}
}

.displ-name-container {
width: calc(26.95em - (3em / 7));
display: flex;
flex-direction: row-reverse;
justify-content: left;
align-items: flex-start;

.spacing {
margin-left: auto;
}
}

.post {
Expand Down Expand Up @@ -243,17 +255,6 @@ input.c-warning {
color: var(--subtext);
}

.displ-name-container {
display: flex;
flex-direction: row-reverse;
justify-content: left;
align-items: flex-start;

.spacing {
margin-left: auto;
}
}

.bottom-content-icon svg,
svg.bottom-content-icon {
width: 1.25em;
Expand Down Expand Up @@ -333,8 +334,10 @@ button.bottom-content-icon {
left: calc(97vw - 17em - 2px);
}

.quote-area .post {
width: calc(94vw - (2em / 7) - 120px) !important;
.quote-area {
.post, .displ-name-container {
width: calc(94vw - (2em / 7) - 120px) !important;
}
}

.bottom-spacing {
Expand Down
23 changes: 23 additions & 0 deletions smiggins/posts/migrations/0050_comment_edited_at_post_edited_at.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.1.1 on 2024-10-25 12:38

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('posts', '0049_comment_edited_post_edited'),
]

operations = [
migrations.AddField(
model_name='comment',
name='edited_at',
field=models.IntegerField(null=True),
),
migrations.AddField(
model_name='post',
name='edited_at',
field=models.IntegerField(null=True),
),
]
2 changes: 2 additions & 0 deletions smiggins/posts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class Post(models.Model):
quote = models.IntegerField(default=0)
quote_is_comment = models.BooleanField(default=False)
edited = models.BooleanField(default=False)
edited_at = models.IntegerField(null=True)

likes = models.JSONField(default=list, blank=True)
comments = models.JSONField(default=list, blank=True)
Expand Down Expand Up @@ -98,6 +99,7 @@ class Comment(models.Model):
timestamp = models.IntegerField()
parent = models.IntegerField(default=0)
edited = models.BooleanField(default=False)
edited_at = models.IntegerField(null=True)

parent_is_comment = models.BooleanField(default=False)
private_comment = models.BooleanField(null=True)
Expand Down
2 changes: 1 addition & 1 deletion smiggins/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
&& Aliases: email, enable_email
## Default: false
*/
"enable_email": true,
"enable_email": false,

/*
** SET TO FALSE for production servers!!! This determines whether or not to
Expand Down
2 changes: 1 addition & 1 deletion smiggins/templates/css/home.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4e3fd34

Please sign in to comment.