punkweb-bb 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- punkweb_bb/__pycache__/guests.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/middleware.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/models.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/settings.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/tests.cpython-311.pyc +0 -0
- punkweb_bb/__pycache__/views.cpython-311.pyc +0 -0
- punkweb_bb/guests.py +20 -0
- punkweb_bb/middleware.py +7 -0
- punkweb_bb/migrations/0002_thread_view_count.py +18 -0
- punkweb_bb/migrations/__pycache__/0002_thread_view_count.cpython-311.pyc +0 -0
- punkweb_bb/models.py +4 -0
- punkweb_bb/settings.py +4 -0
- punkweb_bb/static/punkweb_bb/css/profile.css +7 -0
- punkweb_bb/static/punkweb_bb/css/punkweb.css +23 -0
- punkweb_bb/templates/punkweb_bb/base.html +1 -1
- punkweb_bb/templates/punkweb_bb/index.html +19 -6
- punkweb_bb/templates/punkweb_bb/subcategory.html +7 -1
- punkweb_bb/templates/punkweb_bb/thread.html +5 -2
- punkweb_bb/templates/punkweb_bb/thread_create.html +3 -0
- punkweb_bb/templates/punkweb_bb/thread_update.html +3 -0
- punkweb_bb/templatetags/__pycache__/__init__.cpython-311.pyc +0 -0
- punkweb_bb/templatetags/__pycache__/humanize_count.cpython-311.pyc +0 -0
- punkweb_bb/templatetags/__pycache__/humanize_int.cpython-311.pyc +0 -0
- punkweb_bb/templatetags/humanize_int.py +12 -0
- punkweb_bb/tests.py +529 -2
- punkweb_bb/views.py +20 -4
- punkweb_bb-0.1.4.dist-info/METADATA +175 -0
- {punkweb_bb-0.1.2.dist-info → punkweb_bb-0.1.4.dist-info}/RECORD +31 -23
- punkweb_bb-0.1.2.dist-info/METADATA +0 -72
- {punkweb_bb-0.1.2.dist-info → punkweb_bb-0.1.4.dist-info}/LICENSE +0 -0
- {punkweb_bb-0.1.2.dist-info → punkweb_bb-0.1.4.dist-info}/WHEEL +0 -0
- {punkweb_bb-0.1.2.dist-info → punkweb_bb-0.1.4.dist-info}/top_level.txt +0 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
punkweb_bb/guests.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from expiringdict import ExpiringDict
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class GuestList:
|
|
5
|
+
def __init__(self):
|
|
6
|
+
self.__guests = ExpiringDict(max_len=2048, max_age_seconds=60 * 5)
|
|
7
|
+
|
|
8
|
+
def length(self):
|
|
9
|
+
return len(self.__guests)
|
|
10
|
+
|
|
11
|
+
def add(self, ip):
|
|
12
|
+
if not self.__guests.get(ip, None):
|
|
13
|
+
self.__guests[ip] = True
|
|
14
|
+
|
|
15
|
+
def clear_expired(self):
|
|
16
|
+
for key in list(self.__guests.keys()):
|
|
17
|
+
_ = self.__guests.get(key, None)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
guest_list = GuestList()
|
punkweb_bb/middleware.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
from django.core.cache import cache
|
|
2
2
|
from django.utils import timezone
|
|
3
3
|
|
|
4
|
+
from punkweb_bb.guests import guest_list
|
|
5
|
+
|
|
4
6
|
|
|
5
7
|
class ProfileOnlineCacheMiddleware:
|
|
6
8
|
def __init__(self, get_response):
|
|
@@ -11,6 +13,11 @@ class ProfileOnlineCacheMiddleware:
|
|
|
11
13
|
cache.set(
|
|
12
14
|
f"profile_online_{request.user.profile.id}", timezone.now(), 60 * 5
|
|
13
15
|
)
|
|
16
|
+
else:
|
|
17
|
+
ip = request.META.get("REMOTE_ADDR")
|
|
18
|
+
guest_list.add(ip)
|
|
19
|
+
|
|
20
|
+
guest_list.clear_expired()
|
|
14
21
|
|
|
15
22
|
response = self.get_response(request)
|
|
16
23
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Generated by Django 4.2.11 on 2024-05-07 04:24
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
("punkweb_bb", "0001_initial"),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AddField(
|
|
14
|
+
model_name="thread",
|
|
15
|
+
name="view_count",
|
|
16
|
+
field=models.PositiveIntegerField(default=0),
|
|
17
|
+
),
|
|
18
|
+
]
|
|
Binary file
|
punkweb_bb/models.py
CHANGED
|
@@ -5,6 +5,7 @@ import os
|
|
|
5
5
|
from django.contrib.auth import get_user_model
|
|
6
6
|
from django.core.cache import cache
|
|
7
7
|
from django.db import models
|
|
8
|
+
from django.forms import ValidationError
|
|
8
9
|
from django.urls import reverse
|
|
9
10
|
from django.utils import timezone
|
|
10
11
|
from precise_bbcode.fields import BBCodeTextField
|
|
@@ -107,6 +108,7 @@ class Thread(UUIDPrimaryKeyMixin, TimestampMixin):
|
|
|
107
108
|
is_pinned = models.BooleanField(default=False)
|
|
108
109
|
is_closed = models.BooleanField(default=False)
|
|
109
110
|
last_post_created_at = models.DateTimeField(auto_now_add=True)
|
|
111
|
+
view_count = models.PositiveIntegerField(default=0)
|
|
110
112
|
|
|
111
113
|
class Meta:
|
|
112
114
|
ordering = (
|
|
@@ -161,6 +163,8 @@ class Post(UUIDPrimaryKeyMixin, TimestampMixin):
|
|
|
161
163
|
return thread_url
|
|
162
164
|
|
|
163
165
|
def save(self, *args, **kwargs):
|
|
166
|
+
if self.thread.is_closed:
|
|
167
|
+
raise ValidationError("Cannot add posts to a closed thread.")
|
|
164
168
|
if self._state.adding:
|
|
165
169
|
self.thread.last_post_created_at = timezone.now()
|
|
166
170
|
self.thread.save()
|
punkweb_bb/settings.py
CHANGED
|
@@ -4,4 +4,8 @@ PUNKWEB_BB = getattr(settings, "PUNKWEB_BB", {})
|
|
|
4
4
|
|
|
5
5
|
SITE_NAME = PUNKWEB_BB.get("SITE_NAME", "PUNKWEB")
|
|
6
6
|
SITE_TITLE = PUNKWEB_BB.get("SITE_TITLE", "PunkwebBB")
|
|
7
|
+
FAVICON = PUNKWEB_BB.get("FAVICON", "punkweb_bb/favicon.ico")
|
|
7
8
|
SHOUTBOX_ENABLED = PUNKWEB_BB.get("SHOUTBOX_ENABLED", True)
|
|
9
|
+
DISCORD_WIDGET_ENABLED = PUNKWEB_BB.get("DISCORD_WIDGET_ENABLED", False)
|
|
10
|
+
DISCORD_WIDGET_THEME = PUNKWEB_BB.get("DISCORD_WIDGET_THEME", "dark")
|
|
11
|
+
DISCORD_SERVER_ID = PUNKWEB_BB.get("DISCORD_SERVER_ID", None)
|
|
@@ -646,3 +646,26 @@ blockquote cite {
|
|
|
646
646
|
.pw-breadcrumb-item.active {
|
|
647
647
|
color: var(--breadcrumb-active);
|
|
648
648
|
}
|
|
649
|
+
|
|
650
|
+
/* Callout */
|
|
651
|
+
|
|
652
|
+
.pw-callout {
|
|
653
|
+
background-color: var(--oc-gray-1);
|
|
654
|
+
border: 1px solid var(--border);
|
|
655
|
+
border-radius: 0.25rem;
|
|
656
|
+
color: var(--oc-gray-9);
|
|
657
|
+
padding: 0.5rem 1rem;
|
|
658
|
+
width: 100%;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
.pw-callout.primary {
|
|
662
|
+
background-color: var(--primary-0);
|
|
663
|
+
border-color: 1px solid var(--primary-4);
|
|
664
|
+
color: var(--primary-9);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
.pw-callout.danger {
|
|
668
|
+
background-color: var(--oc-red-0);
|
|
669
|
+
border-color: 1px solid var(--oc-red-4);
|
|
670
|
+
color: var(--oc-red-9);
|
|
671
|
+
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<meta charset="UTF-8" />
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
8
8
|
<title>{% block title_prefix %}{% endblock %}{{ punkweb_bb.settings.SITE_TITLE|default:"PunkwebBB" }}</title>
|
|
9
|
-
<link rel="icon" href="{% static
|
|
9
|
+
<link rel="icon" href="{% static punkweb_bb.settings.FAVICON %}" />
|
|
10
10
|
<link rel="stylesheet" href="{% static 'punkweb_bb/vendor/open-color.css' %}" />
|
|
11
11
|
<link rel="stylesheet" href="{% static 'punkweb_bb/vendor/prism.css' %}" />
|
|
12
12
|
<link rel="stylesheet" href="{% static 'punkweb_bb/css/defaults.css' %}" />
|
|
@@ -171,16 +171,29 @@
|
|
|
171
171
|
</div>
|
|
172
172
|
{% endif %}
|
|
173
173
|
<div class="index__statistics__row">
|
|
174
|
-
<div class="index__statistics__label">
|
|
175
|
-
<div class="index__statistics__value">{{
|
|
176
|
-
</div>
|
|
177
|
-
<div class="index__statistics__row">
|
|
178
|
-
<div class="index__statistics__label">Staff online:</div>
|
|
179
|
-
<div class="index__statistics__value">{{staff_online|length}}</div>
|
|
174
|
+
<div class="index__statistics__label">Users online:</div>
|
|
175
|
+
<div class="index__statistics__value">{{total_online}} ({{members_online|length}} members, {{staff_online|length}} staff, {{guests_online}} guests)</div>
|
|
180
176
|
</div>
|
|
181
177
|
</div>
|
|
182
178
|
</div>
|
|
183
179
|
</div>
|
|
180
|
+
{% if punkweb_bb.settings.DISCORD_WIDGET_ENABLED %}
|
|
181
|
+
{% if punkweb_bb.settings.DISCORD_SERVER_ID %}
|
|
182
|
+
<iframe
|
|
183
|
+
src="https://discord.com/widget?id={{ punkweb_bb.settings.DISCORD_SERVER_ID }}&theme={{ punkweb_bb.settings.DISCORD_WIDGET_THEME|default:'dark' }}"
|
|
184
|
+
width="100%"
|
|
185
|
+
height="384"
|
|
186
|
+
allowtransparency="true"
|
|
187
|
+
frameborder="0"
|
|
188
|
+
sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts">
|
|
189
|
+
</iframe>
|
|
190
|
+
{% else %}
|
|
191
|
+
<div class="pw-callout danger">
|
|
192
|
+
<h4>Discord Widget Error</h4>
|
|
193
|
+
<p><code>DISCORD_SERVER_ID</code> not configured in settings module.</p>
|
|
194
|
+
</div>
|
|
195
|
+
{% endif %}
|
|
196
|
+
{% endif %}
|
|
184
197
|
</div>
|
|
185
198
|
</div>
|
|
186
199
|
</div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{% extends 'punkweb_bb/base.html' %}
|
|
2
|
-
{% load static %}
|
|
2
|
+
{% load static humanize_int %}
|
|
3
3
|
|
|
4
4
|
{% block title_prefix %}{{subcategory.name}} | {% endblock%}
|
|
5
5
|
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
<li class="pw-breadcrumb-item">
|
|
15
15
|
<a href="{% url 'punkweb_bb:index' %}">Home</a>
|
|
16
16
|
</li>
|
|
17
|
+
<li class="pw-breadcrumb-item">
|
|
18
|
+
<a href="{{subcategory.category.get_absolute_url}}">{{subcategory.category.name}}</a>
|
|
19
|
+
</li>
|
|
17
20
|
<li class="pw-breadcrumb-item active">
|
|
18
21
|
{{subcategory.name}}
|
|
19
22
|
</li>
|
|
@@ -44,12 +47,14 @@
|
|
|
44
47
|
<colgroup>
|
|
45
48
|
<col span="1">
|
|
46
49
|
<col span="1" width="96px">
|
|
50
|
+
<col span="1" width="96px">
|
|
47
51
|
<col span="1" width="160px">
|
|
48
52
|
</colgroup>
|
|
49
53
|
<thead>
|
|
50
54
|
<tr>
|
|
51
55
|
<th>Title</th>
|
|
52
56
|
<th>Posts</th>
|
|
57
|
+
<th>Views</th>
|
|
53
58
|
<th></th>
|
|
54
59
|
</tr>
|
|
55
60
|
</thead>
|
|
@@ -74,6 +79,7 @@
|
|
|
74
79
|
{{thread.created_at|date:'M j, Y'}}</div>
|
|
75
80
|
</td>
|
|
76
81
|
<td>{{thread.post_count}}</td>
|
|
82
|
+
<td>{{thread.view_count | humanize_int}}</td>
|
|
77
83
|
<td>
|
|
78
84
|
{% if thread.latest_post %}
|
|
79
85
|
<div class="thread__latestPost">
|
|
@@ -21,6 +21,9 @@
|
|
|
21
21
|
<li class="pw-breadcrumb-item">
|
|
22
22
|
<a href="{% url 'punkweb_bb:index' %}">Home</a>
|
|
23
23
|
</li>
|
|
24
|
+
<li class="pw-breadcrumb-item">
|
|
25
|
+
<a href="{{thread.subcategory.category.get_absolute_url}}">{{thread.subcategory.category.name}}</a>
|
|
26
|
+
</li>
|
|
24
27
|
<li class="pw-breadcrumb-item">
|
|
25
28
|
<a href="{{thread.subcategory.get_absolute_url}}">{{thread.subcategory.name}}</a>
|
|
26
29
|
</li>
|
|
@@ -56,7 +59,7 @@
|
|
|
56
59
|
<div class="thread__user__info__row">
|
|
57
60
|
<div class="thread__user__info__label">Joined:</div>
|
|
58
61
|
<div class="thread__user__info__value">
|
|
59
|
-
{{thread.user.
|
|
62
|
+
{{thread.user.date_joined|date:"M d, Y"}}
|
|
60
63
|
</div>
|
|
61
64
|
</div>
|
|
62
65
|
<div class="thread__user__info__row">
|
|
@@ -117,7 +120,7 @@
|
|
|
117
120
|
<div class="thread__user__info__row">
|
|
118
121
|
<div class="thread__user__info__label">Joined:</div>
|
|
119
122
|
<div class="thread__user__info__value">
|
|
120
|
-
{{post.user.
|
|
123
|
+
{{post.user.date_joined|date:"M d, Y"}}
|
|
121
124
|
</div>
|
|
122
125
|
</div>
|
|
123
126
|
<div class="thread__user__info__row">
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
<li class="pw-breadcrumb-item">
|
|
16
16
|
<a href="{% url 'punkweb_bb:index' %}">Home</a>
|
|
17
17
|
</li>
|
|
18
|
+
<li class="pw-breadcrumb-item">
|
|
19
|
+
<a href="{{subcategory.category.get_absolute_url}}">{{subcategory.category.name}}</a>
|
|
20
|
+
</li>
|
|
18
21
|
<li class="pw-breadcrumb-item">
|
|
19
22
|
<a href="{{subcategory.get_absolute_url}}">{{subcategory.name}}</a>
|
|
20
23
|
</li>
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
<li class="pw-breadcrumb-item">
|
|
16
16
|
<a href="{% url 'punkweb_bb:index' %}">Home</a>
|
|
17
17
|
</li>
|
|
18
|
+
<li class="pw-breadcrumb-item">
|
|
19
|
+
<a href="{{thread.subcategory.category.get_absolute_url}}">{{thread.subcategory.category.name}}</a>
|
|
20
|
+
</li>
|
|
18
21
|
<li class="pw-breadcrumb-item">
|
|
19
22
|
<a href="{{thread.subcategory.get_absolute_url}}">{{thread.subcategory.name}}</a>
|
|
20
23
|
</li>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|