punkweb-bb 0.2.2__py3-none-any.whl → 0.3.0__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.
Files changed (110) hide show
  1. punkweb_bb/__pycache__/admin.cpython-311.pyc +0 -0
  2. punkweb_bb/__pycache__/admin_forms.cpython-311.pyc +0 -0
  3. punkweb_bb/__pycache__/forms.cpython-311.pyc +0 -0
  4. punkweb_bb/__pycache__/models.cpython-311.pyc +0 -0
  5. punkweb_bb/__pycache__/settings.cpython-311.pyc +0 -0
  6. punkweb_bb/__pycache__/sitemap.cpython-311.pyc +0 -0
  7. punkweb_bb/__pycache__/tests.cpython-311.pyc +0 -0
  8. punkweb_bb/__pycache__/urls.cpython-311.pyc +0 -0
  9. punkweb_bb/__pycache__/utils.cpython-311.pyc +0 -0
  10. punkweb_bb/__pycache__/views.cpython-311.pyc +0 -0
  11. punkweb_bb/__pycache__/widgets.cpython-311.pyc +0 -0
  12. punkweb_bb/admin.py +0 -4
  13. punkweb_bb/admin_forms.py +6 -5
  14. punkweb_bb/forms.py +13 -5
  15. punkweb_bb/migrations/0005_alter_thread_options.py +24 -0
  16. punkweb_bb/migrations/0006_remove_boardprofile__signature_rendered_and_more.py +60 -0
  17. punkweb_bb/migrations/__pycache__/0005_alter_thread_options.cpython-311.pyc +0 -0
  18. punkweb_bb/migrations/__pycache__/0006_remove_boardprofile__signature_rendered_and_more.cpython-311.pyc +0 -0
  19. punkweb_bb/models.py +12 -9
  20. punkweb_bb/settings.py +1 -0
  21. punkweb_bb/static/punkweb_bb/css/thread.css +45 -28
  22. punkweb_bb/static/punkweb_bb/editor/markdown-editor.js +23 -0
  23. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/.eslintrc.json +15 -0
  24. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/.gitignore +108 -0
  25. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/.prettierrc.json +1 -0
  26. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/LICENSE +21 -0
  27. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/README.md +240 -0
  28. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/babel.config.json +14 -0
  29. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/blank.html +18 -0
  30. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/demo.html +126 -0
  31. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/tiny-mde.css +231 -0
  32. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/tiny-mde.js +3086 -0
  33. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/tiny-mde.min.css +1 -0
  34. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/tiny-mde.min.js +1 -0
  35. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/tiny-mde.tiny.js +1 -0
  36. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/docs/_config.yml +1 -0
  37. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/docs/_layouts/default.html +50 -0
  38. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/docs/index.md +174 -0
  39. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/globals.d.ts +172 -0
  40. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/gulpfile.mjs +226 -0
  41. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/block.test.js +696 -0
  42. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/commandbar.test.js +84 -0
  43. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/inline.test.js +486 -0
  44. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/interaction.test.js +31 -0
  45. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/setup.test.js +164 -0
  46. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/util/config.js +2 -0
  47. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/util/server.js +9 -0
  48. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/util/setup.js +1 -0
  49. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/util/test-helpers.js +98 -0
  50. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest-puppeteer.config.js +8 -0
  51. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest.config.js +13 -0
  52. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/package-lock.json +16295 -0
  53. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/package.json +72 -0
  54. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/TinyMDE.js +1926 -0
  55. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/TinyMDECommandBar.js +256 -0
  56. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/css/commandbar.css +72 -0
  57. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/css/editor.css +157 -0
  58. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/css/index.css +3 -0
  59. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/grammar.js +300 -0
  60. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/html/blank.html +18 -0
  61. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/html/demo.html +126 -0
  62. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/index.js +4 -0
  63. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/blockquote.svg +1 -0
  64. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/bold.svg +1 -0
  65. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/clear_formatting.svg +1 -0
  66. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/code.svg +1 -0
  67. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/h1.svg +1 -0
  68. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/h2.svg +1 -0
  69. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/hr.svg +1 -0
  70. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/image.svg +1 -0
  71. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/italic.svg +1 -0
  72. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/link.svg +1 -0
  73. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/ol.svg +1 -0
  74. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/strikethrough.svg +1 -0
  75. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/svg.js +17 -0
  76. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/ul.svg +1 -0
  77. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/tiny.js +3 -0
  78. punkweb_bb/templates/punkweb_bb/base_delete_modal.html +13 -0
  79. punkweb_bb/templates/punkweb_bb/index.html +2 -2
  80. punkweb_bb/templates/punkweb_bb/members.html +3 -1
  81. punkweb_bb/templates/punkweb_bb/partials/category_delete.html +4 -8
  82. punkweb_bb/templates/punkweb_bb/partials/post_delete.html +4 -8
  83. punkweb_bb/templates/punkweb_bb/partials/shout_delete.html +4 -8
  84. punkweb_bb/templates/punkweb_bb/partials/subcategory_delete.html +4 -8
  85. punkweb_bb/templates/punkweb_bb/partials/thread_delete.html +4 -8
  86. punkweb_bb/templates/punkweb_bb/partials/thread_move.html +24 -0
  87. punkweb_bb/templates/punkweb_bb/profile.html +8 -4
  88. punkweb_bb/templates/punkweb_bb/shoutbox/shout_list.html +3 -3
  89. punkweb_bb/templates/punkweb_bb/subcategory.html +1 -1
  90. punkweb_bb/templates/punkweb_bb/thread.html +89 -71
  91. punkweb_bb/templates/punkweb_bb/widgets/markdown-editor.html +3 -0
  92. punkweb_bb/templatetags/__pycache__/markdown.cpython-311.pyc +0 -0
  93. punkweb_bb/templatetags/__pycache__/render.cpython-311.pyc +0 -0
  94. punkweb_bb/templatetags/__pycache__/shoutbox_bbcode.cpython-311.pyc +0 -0
  95. punkweb_bb/templatetags/__pycache__/shoutbox_render.cpython-311.pyc +0 -0
  96. punkweb_bb/templatetags/__pycache__/styled_group_name.cpython-311.pyc +0 -0
  97. punkweb_bb/templatetags/render.py +48 -0
  98. punkweb_bb/templatetags/shoutbox_render.py +22 -0
  99. punkweb_bb/templatetags/styled_group_name.py +2 -2
  100. punkweb_bb/tests.py +3 -3
  101. punkweb_bb/urls.py +1 -0
  102. punkweb_bb/utils.py +23 -7
  103. punkweb_bb/views.py +36 -7
  104. punkweb_bb/widgets.py +20 -0
  105. {punkweb_bb-0.2.2.dist-info → punkweb_bb-0.3.0.dist-info}/METADATA +56 -41
  106. {punkweb_bb-0.2.2.dist-info → punkweb_bb-0.3.0.dist-info}/RECORD +109 -41
  107. punkweb_bb/templatetags/shoutbox_bbcode.py +0 -14
  108. {punkweb_bb-0.2.2.dist-info → punkweb_bb-0.3.0.dist-info}/LICENSE +0 -0
  109. {punkweb_bb-0.2.2.dist-info → punkweb_bb-0.3.0.dist-info}/WHEEL +0 -0
  110. {punkweb_bb-0.2.2.dist-info → punkweb_bb-0.3.0.dist-info}/top_level.txt +0 -0
@@ -1,11 +1,7 @@
1
- {% extends 'punkweb_bb/base_modal.html' %}
1
+ {% extends 'punkweb_bb/base_delete_modal.html' %}
2
2
 
3
3
  {% block title %}Delete Subcategory{% endblock %}
4
4
 
5
- {% block content %}
6
- <p>Are you sure you want to delete this subcategory? This action cannot be undone!</p>
7
- <div class="modal__actions">
8
- <button class="modal__cancel pw-button default">Cancel</button>
9
- <button class="pw-button raised danger" hx-delete="{% url 'punkweb_bb:subcategory_delete' subcategory.slug %}">Delete</button>
10
- </div>
11
- {% endblock %}
5
+ {% block object_type %}subcategory{% endblock %}
6
+
7
+ {% block delete_url %}{% url 'punkweb_bb:subcategory_delete' subcategory.slug %}{% endblock %}
@@ -1,11 +1,7 @@
1
- {% extends 'punkweb_bb/base_modal.html' %}
1
+ {% extends 'punkweb_bb/base_delete_modal.html' %}
2
2
 
3
3
  {% block title %}Delete Thread{% endblock %}
4
4
 
5
- {% block content %}
6
- <p>Are you sure you want to delete this thread? This action cannot be undone!</p>
7
- <div class="modal__actions">
8
- <button class="modal__cancel pw-button default">Cancel</button>
9
- <button class="pw-button raised danger" hx-delete="{% url 'punkweb_bb:thread_delete' thread.id %}">Delete</button>
10
- </div>
11
- {% endblock %}
5
+ {% block object_type %}thread{% endblock %}
6
+
7
+ {% block delete_url %}{% url 'punkweb_bb:thread_delete' thread.id %}{% endblock %}
@@ -0,0 +1,24 @@
1
+ {% extends 'punkweb_bb/base_modal.html' %}
2
+
3
+ {% block title %}Move Thread{% endblock %}
4
+
5
+ {% block content %}
6
+ <form class="threadMoveForm" action="{% url 'punkweb_bb:thread_move' thread.id %}" method="post">
7
+ {% csrf_token %}
8
+ {% for field in form %}
9
+ <div class="threadMoveForm__field">
10
+ <label class="pw-input-label" for="{{ field.id_for_label }}">{{ field.label }}</label>
11
+ {{ field }}
12
+ </div>
13
+ {% endfor %}
14
+ {% if form.non_field_errors %}
15
+ {{ form.non_field_errors }}
16
+ {% endif %}
17
+ <div class="threadMoveForm__actions">
18
+ <button class="modal__cancel pw-button default">Cancel</button>
19
+ <button class="pw-button raised primary" type="submit">Move</button>
20
+ </div>
21
+ </form>
22
+ {{form.media.css}}
23
+ {{form.media.js}}
24
+ {% endblock %}
@@ -1,5 +1,5 @@
1
1
  {% extends 'punkweb_bb/base.html' %}
2
- {% load static styled_username %}
2
+ {% load static render styled_username %}
3
3
 
4
4
  {% block title_prefix %}{{ user.username }} | {% endblock%}
5
5
  {% block og_title_prefix %}{{ user.username }} | {% endblock %}
@@ -39,11 +39,15 @@
39
39
  <div class="profile__info__stats">
40
40
  <div class="profile__info__stat">
41
41
  Date Joined:
42
- <span class="profile__info__stat__value">{{user.date_joined | date:'m/d/Y'}}</span>
42
+ <span class="profile__info__stat__value">
43
+ <time datetime="{{user.date_joined|date:'c'}}">{{user.date_joined | date:'m/d/Y'}}</time>
44
+ </span>
43
45
  </div>
44
46
  <div class="profile__info__stat">
45
47
  Last Login:
46
- <span class="profile__info__stat__value">{{user.last_login | date:'m/d/Y'}}</span>
48
+ <span class="profile__info__stat__value">
49
+ <time datetime="{{user.last_login|date:'c'}}">{{user.last_login | date:'m/d/Y'}}</time>
50
+ </span>
47
51
  </div>
48
52
  <div class="profile__info__stat">
49
53
  Posts:
@@ -72,7 +76,7 @@
72
76
  <a href="{% url 'punkweb_bb:thread' thread.id %}">{{ thread.title }}</a>
73
77
  </div>
74
78
  <p class="profile__thread__preview">
75
- {{ thread.content.rendered|striptags|truncatechars:120 }}
79
+ {{ thread.content|render|striptags|truncatechars:120 }}
76
80
  </p>
77
81
  <div class="profile__thread__date">
78
82
  <time datetime="{{thread.created_at|date:'c'}}">
@@ -1,11 +1,11 @@
1
- {% load shoutbox_bbcode can_delete styled_username %}
1
+ {% load shoutbox_render styled_username can_delete %}
2
2
 
3
3
  {% for shout in shouts %}
4
4
  <div class="shoutbox__shout">
5
5
  <div class="shoutbox__shout__content">
6
- <span>{{shout.created_at|date:'g:i A'}}</span>
6
+ <time datetime="{{shout.created_at|date:'c'}}">{{shout.created_at | date:'g:i A'}}</time>
7
7
  <span><a href="{% url 'punkweb_bb:profile' shout.user.id %}">{{shout.user|styled_username}}</a>: </span>
8
- <span>{{ shout.content | safe | shoutbox_bbcode }}</span>
8
+ <span>{{ shout.content|shoutbox_render }}</span>
9
9
  </div>
10
10
  {% if shout|can_delete:request.user %}
11
11
  <div class="shoutbox__shout__actions">
@@ -101,7 +101,7 @@
101
101
  {{thread.user|styled_username}}
102
102
  </a>
103
103
 
104
- {{thread.created_at|date:'M j, Y'}}</div>
104
+ <time datetime="{{thread.created_at|date:'c'}}">{{thread.created_at | date:'M j, Y'}}</time>
105
105
  </td>
106
106
  <td>{{thread.post_count}}</td>
107
107
  <td>{{thread.view_count | humanize_int}}</td>
@@ -1,12 +1,12 @@
1
1
  {% extends 'punkweb_bb/base.html' %}
2
- {% load static can_delete can_edit can_post styled_username styled_group_name %}
2
+ {% load static render styled_username can_delete can_edit can_post %}
3
3
 
4
4
  {% block title_prefix %}{{thread.title}} | {% endblock %}
5
5
  {% block og_title_prefix %}{{thread.title}} | {% endblock %}
6
6
 
7
7
  {% block extra_head %}
8
- <meta name="description" content="{{thread.content.rendered|striptags|truncatechars:120}}" />
9
- <meta property="og:description" content="{{thread.content.rendered|striptags|truncatechars:120}}" />
8
+ <meta name="description" content="{{thread.content|render|striptags|truncatechars:120}}" />
9
+ <meta property="og:description" content="{{thread.content|render|striptags|truncatechars:120}}" />
10
10
  <link rel="stylesheet" href="{% static 'punkweb_bb/css/post-form.css' %}" />
11
11
  <link rel="stylesheet" href="{% static 'punkweb_bb/css/thread.css' %}" />
12
12
  <link rel="stylesheet" href="{% static 'punkweb_bb/css/thread-form.css' %}" />
@@ -41,51 +41,65 @@
41
41
 
42
42
  <div class="pw-card fluid margin">
43
43
  <div class="pw-card-header">
44
- <div class="thread__date">{{thread.created_at|date:'M d, Y'}}</div>
44
+ <div class="thread__date">
45
+ <time datetime="{{thread.created_at|date:'c'}}">{{thread.created_at | date:'M j, Y'}}</time>
46
+ </div>
45
47
  </div>
46
48
  <div class="thread">
47
49
  <div class="thread__user">
48
- {% if thread.user.profile.image %}
49
- <img class="pw-avatar" src="{{thread.user.profile.image.url}}" alt="{{thread.user.username}}" />
50
- {% else %}
51
- <img class="pw-avatar" src="{% static 'punkweb_bb/img/default-profile-image.png' %}" alt="{{thread.user.username}}" />
52
- {% endif %}
53
- <div class="thread__user__usernameContainer">
54
- {% if thread.user.profile.is_online %}
55
- <div class="onlineIndicator"></div>
56
- {% endif %}
57
- <a href="{% url 'punkweb_bb:profile' thread.user.id %}">
58
- {{thread.user|styled_username}}
59
- </a>
60
- </div>
61
50
  <div class="thread__user__info">
62
- <div class="thread__user__info__row">
63
- <div class="thread__user__info__label">Joined:</div>
64
- <div class="thread__user__info__value">
65
- {{thread.user.date_joined|date:"M d, Y"}}
66
- </div>
51
+ <div class="thread__user__image">
52
+ {% if thread.user.profile.image %}
53
+ <img class="pw-avatar" src="{{thread.user.profile.image.url}}" alt="{{thread.user.username}}" />
54
+ {% else %}
55
+ <img class="pw-avatar" src="{% static 'punkweb_bb/img/default-profile-image.png' %}" alt="{{thread.user.username}}" />
56
+ {% endif %}
67
57
  </div>
68
- <div class="thread__user__info__row">
69
- <div class="thread__user__info__label">Posts:</div>
70
- <div class="thread__user__info__value">{{thread.user.profile.post_count}}</div>
58
+ <div class="thread__user__username">
59
+ {% if thread.user.profile.is_online %}
60
+ <div class="onlineIndicator"></div>
61
+ {% endif %}
62
+ <a href="{% url 'punkweb_bb:profile' thread.user.id %}">
63
+ {{thread.user|styled_username}}
64
+ </a>
71
65
  </div>
72
- </div>
73
- {% if thread.user.groups.all|length > 0 %}
74
- <div class="thread__user__groups">
75
- {% for group in thread.user.groups.all %}
76
66
  <div class="thread__user__group">
77
- {{group|styled_group_name}}
67
+ {% if thread.user.profile.priority_group %}
68
+ {{thread.user.profile.priority_group.name}}
69
+ {% else %}
70
+ Member
71
+ {% endif %}
72
+ </div>
73
+ </div>
74
+ <div class="thread__user__details">
75
+ <div class="thread__user__details__row">
76
+ <div class="thread__user__details__label">Joined:</div>
77
+ <div class="thread__user__details__value">
78
+ <time datetime="{{thread.user.date_joined|date:'c'}}">{{thread.user.date_joined | date:'M j, Y'}}</time>
79
+ </div>
80
+ </div>
81
+ <div class="thread__user__details__row">
82
+ <div class="thread__user__details__label">Posts:</div>
83
+ <div class="thread__user__details__value">{{thread.user.profile.post_count}}</div>
78
84
  </div>
79
- {% endfor %}
80
85
  </div>
81
- {% endif %}
82
86
  </div>
83
87
  <div class="thread__main">
84
88
  <div class="thread__content">
85
- {{thread.content.rendered}}
89
+ {{thread.content|render}}
86
90
  </div>
87
- {% if thread|can_delete:request.user or thread|can_edit:request.user or perms.punkweb_bb.pin_thread or perms.punkweb_bb.close_thread %}
91
+ {% if thread|can_delete:request.user or thread|can_edit:request.user or perms.punkweb_bb.pin_thread or perms.punkweb_bb.close_thread or perms.punkweb_bb.move_thread %}
88
92
  <div class="thread__actions">
93
+ {% if perms.punkweb_bb.move_thread %}
94
+ <a
95
+ class="pw-icon-button default rounded"
96
+ title="Move"
97
+ hx-get="{% url 'punkweb_bb:thread_move' thread.id %}"
98
+ hx-target="#modal-portal"
99
+ >
100
+ <span class="material-symbols-outlined">move_item</span>
101
+ </a>
102
+ {% endif %}
89
103
  {% if perms.punkweb_bb.pin_thread %}
90
104
  <a
91
105
  class="pw-icon-button default rounded"
@@ -135,9 +149,9 @@
135
149
  {% endif %}
136
150
  </div>
137
151
  {% endif %}
138
- {% if thread.user.profile.signature.rendered %}
152
+ {% if thread.user.profile.signature|render %}
139
153
  <div class="thread__signature">
140
- {{thread.user.profile.signature.rendered}}
154
+ {{thread.user.profile.signature|render}}
141
155
  </div>
142
156
  {% endif %}
143
157
  </div>
@@ -148,53 +162,57 @@
148
162
  {% for post in posts %}
149
163
  <div id="post-{{post.id}}" class="pw-card fluid margin">
150
164
  <div class="pw-card-header thread__header">
151
- <div class="thread__date">{{post.created_at|date:'M d, Y'}}</div>
165
+ <div class="thread__date">
166
+ <time datetime="{{post.created_at|date:'c'}}">{{post.created_at | date:'M j, Y'}}</time>
167
+ </div>
152
168
  <a class="thread__index" href="{{post.get_absolute_url}}">#{{post.index}}</a>
153
169
  </div>
154
170
  <div class="thread">
155
171
  <div class="thread__user">
156
- {% if post.user.profile.image %}
157
- <div class="thread__user__image">
158
- <img class="pw-avatar" src="{{post.user.profile.image.url}}" alt="{{post.user.username}}" />
159
- </div>
160
- {% else %}
161
- <div class="thread__user__image">
162
- <img class="pw-avatar" src="{% static 'punkweb_bb/img/default-profile-image.png' %}" alt="{{post.user.username}}" />
163
- </div>
164
- {% endif %}
165
- <div class="thread__user__usernameContainer">
166
- {% if post.user.profile.is_online %}
167
- <div class="onlineIndicator"></div>
168
- {% endif %}
169
- <a href="{% url 'punkweb_bb:profile' post.user.id %}">
170
- {{post.user|styled_username}}
171
- </a>
172
- </div>
173
172
  <div class="thread__user__info">
174
- <div class="thread__user__info__row">
175
- <div class="thread__user__info__label">Joined:</div>
176
- <div class="thread__user__info__value">
177
- {{post.user.date_joined|date:"M d, Y"}}
173
+ <div class="thread__user__image">
174
+ {% if post.user.profile.image %}
175
+ <div class="thread__user__image">
176
+ <img class="pw-avatar" src="{{post.user.profile.image.url}}" alt="{{post.user.username}}" />
177
+ </div>
178
+ {% else %}
179
+ <div class="thread__user__image">
180
+ <img class="pw-avatar" src="{% static 'punkweb_bb/img/default-profile-image.png' %}" alt="{{post.user.username}}" />
178
181
  </div>
182
+ {% endif %}
179
183
  </div>
180
- <div class="thread__user__info__row">
181
- <div class="thread__user__info__label">Posts:</div>
182
- <div class="thread__user__info__value">{{post.user.profile.post_count}}</div>
184
+ <div class="thread__user__username">
185
+ {% if post.user.profile.is_online %}
186
+ <div class="onlineIndicator"></div>
187
+ {% endif %}
188
+ <a href="{% url 'punkweb_bb:profile' post.user.id %}">
189
+ {{post.user|styled_username}}
190
+ </a>
183
191
  </div>
184
- </div>
185
- {% if post.user.groups.all|length > 0 %}
186
- <div class="thread__user__groups">
187
- {% for group in post.user.groups.all %}
188
192
  <div class="thread__user__group">
189
- {{group|styled_group_name}}
193
+ {% if post.user.profile.priority_group %}
194
+ {{post.user.profile.priority_group.name}}
195
+ {% else %}
196
+ Member
197
+ {% endif %}
198
+ </div>
199
+ </div>
200
+ <div class="thread__user__details">
201
+ <div class="thread__user__details__row">
202
+ <div class="thread__user__details__label">Joined:</div>
203
+ <div class="thread__user__details__value">
204
+ <time datetime="{{post.user.date_joined|date:'c'}}">{{post.user.date_joined | date:'M j, Y'}}</time>
205
+ </div>
206
+ </div>
207
+ <div class="thread__user__details__row">
208
+ <div class="thread__user__details__label">Posts:</div>
209
+ <div class="thread__user__details__value">{{post.user.profile.post_count}}</div>
190
210
  </div>
191
- {% endfor %}
192
211
  </div>
193
- {% endif %}
194
212
  </div>
195
213
  <div class="thread__main">
196
214
  <div class="thread__content">
197
- {{post.content.rendered}}
215
+ {{post.content|render}}
198
216
  </div>
199
217
  {% if post|can_delete:request.user or post|can_edit:request.user %}
200
218
  <div class="thread__actions">
@@ -220,9 +238,9 @@
220
238
  {% endif %}
221
239
  </div>
222
240
  {% endif %}
223
- {% if post.user.profile.signature.rendered %}
241
+ {% if post.user.profile.signature|render %}
224
242
  <div class="thread__signature">
225
- {{post.user.profile.signature.rendered}}
243
+ {{post.user.profile.signature|render}}
226
244
  </div>
227
245
  {% endif %}
228
246
  </div>
@@ -0,0 +1,3 @@
1
+ <div class="markdown-editor-container">
2
+ {% include "django/forms/widgets/textarea.html" %}
3
+ </div>
@@ -0,0 +1,48 @@
1
+ import html
2
+ from io import StringIO
3
+
4
+ import markdown as md
5
+ from django import template
6
+ from django.template.defaultfilters import stringfilter
7
+ from django.utils.safestring import mark_safe
8
+ from precise_bbcode.bbcode import get_parser
9
+
10
+ from punkweb_bb.settings import RENDERER
11
+
12
+ register = template.Library()
13
+
14
+
15
+ def unmark_element(element, stream=None):
16
+ if stream is None:
17
+ stream = StringIO()
18
+ if element.text:
19
+ stream.write(element.text)
20
+ for sub in element:
21
+ unmark_element(sub, stream)
22
+ if element.tail:
23
+ stream.write(element.tail)
24
+ return stream.getvalue()
25
+
26
+
27
+ md.Markdown.output_formats["plain"] = unmark_element
28
+ unmark = md.Markdown(output_format="plain")
29
+ unmark.stripTopLevelTags = False
30
+
31
+
32
+ @register.filter(is_safe=True)
33
+ @stringfilter
34
+ def render(value):
35
+ if RENDERER == "bbcode":
36
+ parser = get_parser()
37
+ rendered = parser.render(value)
38
+ elif RENDERER == "markdown":
39
+ escaped = html.escape(value, quote=False)
40
+ rendered = md.markdown(escaped, extensions=["markdown.extensions.fenced_code"])
41
+
42
+ return mark_safe(rendered)
43
+
44
+
45
+ @register.filter()
46
+ @stringfilter
47
+ def unmarkdown(value):
48
+ return unmark.convert(value)
@@ -0,0 +1,22 @@
1
+ import html
2
+ from django import template
3
+ from django.template.defaultfilters import stringfilter
4
+ from django.utils.safestring import mark_safe
5
+
6
+ from punkweb_bb.parsers import get_shoutbox_parser
7
+ from punkweb_bb.settings import RENDERER
8
+
9
+ register = template.Library()
10
+
11
+
12
+ @register.filter(is_safe=True)
13
+ @stringfilter
14
+ def shoutbox_render(value):
15
+ if RENDERER == "bbcode":
16
+ parser = get_shoutbox_parser()
17
+ rendered = parser.render(value)
18
+ elif RENDERER == "markdown":
19
+ escaped = html.escape(value, quote=False)
20
+ rendered = escaped
21
+
22
+ return mark_safe(rendered)
@@ -1,11 +1,11 @@
1
1
  from django import template
2
2
  from django.utils.safestring import mark_safe
3
3
 
4
- from punkweb_bb.utils import get_group_name_styled
4
+ from punkweb_bb.utils import get_styled_group_name
5
5
 
6
6
  register = template.Library()
7
7
 
8
8
 
9
9
  @register.filter
10
10
  def styled_group_name(group):
11
- return mark_safe(get_group_name_styled(group))
11
+ return mark_safe(get_styled_group_name(group))
punkweb_bb/tests.py CHANGED
@@ -422,7 +422,7 @@ class SettingsViewTestCase(TestCase):
422
422
  )
423
423
 
424
424
  self.user.profile.refresh_from_db()
425
- self.assertEqual(self.user.profile._signature_rendered, "<strong>test</strong>")
425
+ self.assertEqual(self.user.profile.signature, "[b]test[/b]")
426
426
 
427
427
  self.assertEqual(response.status_code, 200)
428
428
 
@@ -546,7 +546,7 @@ class ThreadUpdateViewTestCase(TestCase):
546
546
  self.assertRedirects(response, self.thread.get_absolute_url())
547
547
  self.thread.refresh_from_db()
548
548
  self.assertEqual(self.thread.title, "edit")
549
- self.assertEqual(self.thread._content_rendered, "edit")
549
+ self.assertEqual(self.thread.content, "edit")
550
550
 
551
551
 
552
552
  class ThreadDeleteViewTestCase(TestCase):
@@ -675,7 +675,7 @@ class PostUpdateViewTestCase(TestCase):
675
675
 
676
676
  self.assertRedirects(response, self.post.get_absolute_url())
677
677
  self.post.refresh_from_db()
678
- self.assertEqual(self.post._content_rendered, "edit")
678
+ self.assertEqual(self.post.content, "edit")
679
679
 
680
680
 
681
681
  class PostDeleteViewTestCase(TestCase):
punkweb_bb/urls.py CHANGED
@@ -61,6 +61,7 @@ urlpatterns = [
61
61
  ),
62
62
  path("thread/<str:thread_id>/pin/", views.thread_pin_view, name="thread_pin"),
63
63
  path("thread/<str:thread_id>/close/", views.thread_close_view, name="thread_close"),
64
+ path("thread/<str:thread_id>/move/", views.thread_move_view, name="thread_move"),
64
65
  path("post/<str:post_id>/delete/", views.post_delete_view, name="post_delete"),
65
66
  path("post/<str:post_id>/update/", views.post_update_view, name="post_update"),
66
67
  path("shout-list/", views.shout_list_view, name="shout_list"),
punkweb_bb/utils.py CHANGED
@@ -1,5 +1,19 @@
1
- from django.contrib.auth.models import Group
2
1
  from django.utils.text import slugify
2
+ from precise_bbcode.bbcode import get_parser
3
+ from punkweb_bb.settings import RENDERER
4
+
5
+
6
+ def get_editor_widget():
7
+ if RENDERER == "bbcode":
8
+ from punkweb_bb.widgets import BBCodeEditorWidget
9
+
10
+ return BBCodeEditorWidget()
11
+ elif RENDERER == "markdown":
12
+ from punkweb_bb.widgets import MarkdownEditorWidget
13
+
14
+ return MarkdownEditorWidget()
15
+ else:
16
+ raise ValueError("Invalid renderer")
3
17
 
4
18
 
5
19
  def get_unique_slug(model, field):
@@ -18,8 +32,8 @@ def get_unique_slug(model, field):
18
32
  return slug
19
33
 
20
34
 
21
- def get_user_highest_priority_group(user):
22
- groups = Group.objects.filter(user=user, style__isnull=False)
35
+ def get_highest_priority_group(user):
36
+ groups = user.groups.filter(style__isnull=False)
23
37
 
24
38
  if groups.exists():
25
39
  return groups.order_by("-style__priority").first()
@@ -28,20 +42,22 @@ def get_user_highest_priority_group(user):
28
42
 
29
43
 
30
44
  def get_styled_username(user):
31
- group = get_user_highest_priority_group(user)
45
+ group = get_highest_priority_group(user)
32
46
 
33
47
  if group:
48
+ parser = get_parser()
34
49
  username_style = group.style.username_style
35
- styled_username = username_style.rendered.replace("{USER}", user.username)
50
+ styled_username = parser.render(username_style.replace("{USER}", user.username))
36
51
  return styled_username
37
52
  else:
38
53
  return user.username
39
54
 
40
55
 
41
- def get_group_name_styled(group):
56
+ def get_styled_group_name(group):
42
57
  if group.style is None:
43
58
  return group.name
44
59
  else:
60
+ parser = get_parser()
45
61
  username_style = group.style.username_style
46
- styled_group_name = username_style.rendered.replace("{USER}", group.name)
62
+ styled_group_name = parser.render(username_style.replace("{USER}", group.name))
47
63
  return styled_group_name
punkweb_bb/views.py CHANGED
@@ -1,5 +1,3 @@
1
- import datetime
2
-
3
1
  from django.contrib.auth import authenticate, get_user_model, login, logout
4
2
  from django.contrib.auth.decorators import login_required
5
3
  from django.http import HttpResponseForbidden
@@ -16,6 +14,7 @@ from punkweb_bb.forms import (
16
14
  SignUpForm,
17
15
  SubcategoryModelForm,
18
16
  ThreadModelForm,
17
+ ThreadMoveForm,
19
18
  )
20
19
  from punkweb_bb.guests import guest_list
21
20
  from punkweb_bb.models import Category, Post, Shout, Subcategory, Thread
@@ -408,11 +407,11 @@ def thread_delete_view(request, thread_id):
408
407
 
409
408
  @login_required(login_url="/login/")
410
409
  def thread_pin_view(request, thread_id):
411
- thread = get_object_or_404(Thread, pk=thread_id)
412
-
413
410
  if not request.user.has_perm("punkweb_bb.pin_thread"):
414
411
  return HttpResponseForbidden("You do not have permission to pin threads.")
415
412
 
413
+ thread = get_object_or_404(Thread, pk=thread_id)
414
+
416
415
  thread.is_pinned = not thread.is_pinned
417
416
  thread.save()
418
417
 
@@ -421,17 +420,47 @@ def thread_pin_view(request, thread_id):
421
420
 
422
421
  @login_required(login_url="/login/")
423
422
  def thread_close_view(request, thread_id):
424
- thread = get_object_or_404(Thread, pk=thread_id)
425
-
426
423
  if not request.user.has_perm("punkweb_bb.close_thread"):
427
424
  return HttpResponseForbidden("You do not have permission to close threads.")
428
425
 
426
+ thread = get_object_or_404(Thread, pk=thread_id)
427
+
429
428
  thread.is_closed = not thread.is_closed
430
429
  thread.save()
431
430
 
432
431
  return htmx_redirect(thread.get_absolute_url())
433
432
 
434
433
 
434
+ @login_required(login_url="/login/")
435
+ def thread_move_view(request, thread_id):
436
+ if not request.user.has_perm("punkweb_bb.move_thread"):
437
+ return HttpResponseForbidden("You do not have permission to move threads.")
438
+
439
+ thread = get_object_or_404(Thread, pk=thread_id)
440
+
441
+ if request.method == "POST":
442
+ form = ThreadMoveForm(request.POST)
443
+
444
+ if form.is_valid():
445
+ thread.subcategory = form.cleaned_data["subcategory"]
446
+ thread.save()
447
+
448
+ return redirect(thread)
449
+
450
+ initial_data = {
451
+ "subcategory": thread.subcategory,
452
+ }
453
+
454
+ form = ThreadMoveForm(data=initial_data)
455
+
456
+ context = {
457
+ "thread": thread,
458
+ "form": form,
459
+ }
460
+
461
+ return render(request, "punkweb_bb/partials/thread_move.html", context=context)
462
+
463
+
435
464
  @login_required(login_url="/login/")
436
465
  def post_create_view(request, thread_id):
437
466
  thread = get_object_or_404(Thread, pk=thread_id)
@@ -498,7 +527,7 @@ def post_delete_view(request, post_id):
498
527
 
499
528
  def current_shouts():
500
529
  return Shout.objects.filter(
501
- created_at__gt=timezone.now() - datetime.timedelta(hours=12)
530
+ created_at__gt=timezone.now() - timezone.timedelta(hours=12)
502
531
  ).order_by("created_at")
503
532
 
504
533
 
punkweb_bb/widgets.py CHANGED
@@ -20,3 +20,23 @@ class BBCodeEditorWidget(forms.Textarea):
20
20
  "/static/punkweb_bb/editor/bbcode-editor-tags.js",
21
21
  "/static/punkweb_bb/editor/bbcode-editor.js",
22
22
  )
23
+
24
+
25
+ class MarkdownEditorWidget(forms.Textarea):
26
+ template_name = "punkweb_bb/widgets/markdown-editor.html"
27
+
28
+ def __init__(self, *args, **kwargs):
29
+ super(MarkdownEditorWidget, self).__init__(*args, **kwargs)
30
+ self.attrs["class"] = "markdown-editor"
31
+
32
+ class Media:
33
+ css = {
34
+ "all": (
35
+ "/static/punkweb_bb/vendor/tiny-markdown-editor/dist/tiny-mde.min.css",
36
+ )
37
+ }
38
+ js = (
39
+ "/static/punkweb_bb/vendor/jquery-3.7.0.min.js",
40
+ "/static/punkweb_bb/vendor/tiny-markdown-editor/dist/tiny-mde.min.js",
41
+ "/static/punkweb_bb/editor/markdown-editor.js",
42
+ )