punkweb-bb 0.2.3__py3-none-any.whl → 0.4.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 (123) 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__/bbcode.cpython-311.pyc +0 -0
  4. punkweb_bb/__pycache__/forms.cpython-311.pyc +0 -0
  5. punkweb_bb/__pycache__/middleware.cpython-311.pyc +0 -0
  6. punkweb_bb/__pycache__/mixins.cpython-311.pyc +0 -0
  7. punkweb_bb/__pycache__/models.cpython-311.pyc +0 -0
  8. punkweb_bb/__pycache__/pagination.cpython-311.pyc +0 -0
  9. punkweb_bb/__pycache__/parsers.cpython-311.pyc +0 -0
  10. punkweb_bb/__pycache__/response.cpython-311.pyc +0 -0
  11. punkweb_bb/__pycache__/settings.cpython-311.pyc +0 -0
  12. punkweb_bb/__pycache__/signals.cpython-311.pyc +0 -0
  13. punkweb_bb/__pycache__/tags.cpython-311.pyc +0 -0
  14. punkweb_bb/__pycache__/tests.cpython-311.pyc +0 -0
  15. punkweb_bb/__pycache__/urls.cpython-311.pyc +0 -0
  16. punkweb_bb/__pycache__/utils.cpython-311.pyc +0 -0
  17. punkweb_bb/__pycache__/views.cpython-311.pyc +0 -0
  18. punkweb_bb/__pycache__/widgets.cpython-311.pyc +0 -0
  19. punkweb_bb/admin.py +0 -5
  20. punkweb_bb/admin_forms.py +6 -5
  21. punkweb_bb/bbcode.py +155 -0
  22. punkweb_bb/forms.py +13 -5
  23. punkweb_bb/migrations/0005_alter_thread_options.py +24 -0
  24. punkweb_bb/migrations/0006_remove_boardprofile__signature_rendered_and_more.py +60 -0
  25. punkweb_bb/migrations/__pycache__/0005_alter_thread_options.cpython-311.pyc +0 -0
  26. punkweb_bb/migrations/__pycache__/0006_remove_boardprofile__signature_rendered_and_more.cpython-311.pyc +0 -0
  27. punkweb_bb/models.py +6 -6
  28. punkweb_bb/settings.py +1 -0
  29. punkweb_bb/static/punkweb_bb/css/defaults.css +2 -2
  30. punkweb_bb/static/punkweb_bb/css/punkweb-modal.css +2 -0
  31. punkweb_bb/static/punkweb_bb/css/punkweb.css +2 -2
  32. punkweb_bb/static/punkweb_bb/css/subcategory.css +4 -0
  33. punkweb_bb/static/punkweb_bb/css/thread.css +24 -0
  34. punkweb_bb/static/punkweb_bb/editor/bbcode-editor-content.css +4 -5
  35. punkweb_bb/static/punkweb_bb/editor/bbcode-editor.js +0 -5
  36. punkweb_bb/static/punkweb_bb/editor/markdown-editor.js +49 -0
  37. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/.eslintrc.json +15 -0
  38. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/.gitignore +108 -0
  39. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/.prettierrc.json +1 -0
  40. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/LICENSE +21 -0
  41. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/README.md +240 -0
  42. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/babel.config.json +14 -0
  43. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/blank.html +18 -0
  44. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/demo.html +126 -0
  45. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/tiny-mde.css +231 -0
  46. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/tiny-mde.js +3086 -0
  47. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/tiny-mde.min.css +1 -0
  48. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/tiny-mde.min.js +1 -0
  49. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/dist/tiny-mde.tiny.js +1 -0
  50. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/docs/_config.yml +1 -0
  51. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/docs/_layouts/default.html +50 -0
  52. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/docs/index.md +174 -0
  53. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/globals.d.ts +172 -0
  54. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/gulpfile.mjs +226 -0
  55. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/block.test.js +696 -0
  56. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/commandbar.test.js +84 -0
  57. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/inline.test.js +486 -0
  58. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/interaction.test.js +31 -0
  59. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/setup.test.js +164 -0
  60. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/util/config.js +2 -0
  61. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/util/server.js +9 -0
  62. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/util/setup.js +1 -0
  63. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest/util/test-helpers.js +98 -0
  64. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest-puppeteer.config.js +8 -0
  65. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/jest.config.js +13 -0
  66. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/package-lock.json +16295 -0
  67. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/package.json +72 -0
  68. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/TinyMDE.js +1926 -0
  69. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/TinyMDECommandBar.js +256 -0
  70. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/css/commandbar.css +72 -0
  71. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/css/editor.css +157 -0
  72. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/css/index.css +3 -0
  73. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/grammar.js +300 -0
  74. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/html/blank.html +18 -0
  75. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/html/demo.html +126 -0
  76. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/index.js +4 -0
  77. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/blockquote.svg +1 -0
  78. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/bold.svg +1 -0
  79. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/clear_formatting.svg +1 -0
  80. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/code.svg +1 -0
  81. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/h1.svg +1 -0
  82. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/h2.svg +1 -0
  83. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/hr.svg +1 -0
  84. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/image.svg +1 -0
  85. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/italic.svg +1 -0
  86. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/link.svg +1 -0
  87. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/ol.svg +1 -0
  88. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/strikethrough.svg +1 -0
  89. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/svg.js +17 -0
  90. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/svg/ul.svg +1 -0
  91. punkweb_bb/static/punkweb_bb/vendor/tiny-markdown-editor/src/tiny.js +3 -0
  92. punkweb_bb/templates/punkweb_bb/base_delete_modal.html +13 -0
  93. punkweb_bb/templates/punkweb_bb/bbcode.html +2 -3
  94. punkweb_bb/templates/punkweb_bb/index.html +2 -2
  95. punkweb_bb/templates/punkweb_bb/partials/category_delete.html +4 -8
  96. punkweb_bb/templates/punkweb_bb/partials/post_delete.html +4 -8
  97. punkweb_bb/templates/punkweb_bb/partials/shout_delete.html +4 -8
  98. punkweb_bb/templates/punkweb_bb/partials/subcategory_delete.html +4 -8
  99. punkweb_bb/templates/punkweb_bb/partials/thread_delete.html +4 -8
  100. punkweb_bb/templates/punkweb_bb/partials/thread_move.html +24 -0
  101. punkweb_bb/templates/punkweb_bb/profile.html +2 -2
  102. punkweb_bb/templates/punkweb_bb/shoutbox/shout_list.html +2 -2
  103. punkweb_bb/templates/punkweb_bb/subcategory.html +1 -1
  104. punkweb_bb/templates/punkweb_bb/thread.html +24 -14
  105. punkweb_bb/templates/punkweb_bb/widgets/markdown-editor.html +4 -0
  106. punkweb_bb/templatetags/__pycache__/markdown.cpython-311.pyc +0 -0
  107. punkweb_bb/templatetags/__pycache__/render.cpython-311.pyc +0 -0
  108. punkweb_bb/templatetags/__pycache__/shoutbox_bbcode.cpython-311.pyc +0 -0
  109. punkweb_bb/templatetags/__pycache__/shoutbox_render.cpython-311.pyc +0 -0
  110. punkweb_bb/templatetags/render.py +35 -0
  111. punkweb_bb/tests.py +3 -3
  112. punkweb_bb/urls.py +1 -0
  113. punkweb_bb/utils.py +24 -10
  114. punkweb_bb/views.py +45 -23
  115. punkweb_bb/widgets.py +20 -0
  116. {punkweb_bb-0.2.3.dist-info → punkweb_bb-0.4.0.dist-info}/METADATA +58 -51
  117. {punkweb_bb-0.2.3.dist-info → punkweb_bb-0.4.0.dist-info}/RECORD +120 -53
  118. punkweb_bb/bbcode_tags.py +0 -167
  119. punkweb_bb/parsers.py +0 -70
  120. punkweb_bb/templatetags/shoutbox_bbcode.py +0 -14
  121. {punkweb_bb-0.2.3.dist-info → punkweb_bb-0.4.0.dist-info}/LICENSE +0 -0
  122. {punkweb_bb-0.2.3.dist-info → punkweb_bb-0.4.0.dist-info}/WHEEL +0 -0
  123. {punkweb_bb-0.2.3.dist-info → punkweb_bb-0.4.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 %}
@@ -76,7 +76,7 @@
76
76
  <a href="{% url 'punkweb_bb:thread' thread.id %}">{{ thread.title }}</a>
77
77
  </div>
78
78
  <p class="profile__thread__preview">
79
- {{ thread.content.rendered|striptags|truncatechars:120 }}
79
+ {{ thread.content|render|striptags|truncatechars:120 }}
80
80
  </p>
81
81
  <div class="profile__thread__date">
82
82
  <time datetime="{{thread.created_at|date:'c'}}">
@@ -1,11 +1,11 @@
1
- {% load shoutbox_bbcode can_delete styled_username %}
1
+ {% load 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
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|render_shout }}</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
- <time datetime="{{thread.created_at|date:'c'}}">{{thread.created_at | date:'m j, Y'}}</time>
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 %}
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' %}" />
@@ -42,7 +42,7 @@
42
42
  <div class="pw-card fluid margin">
43
43
  <div class="pw-card-header">
44
44
  <div class="thread__date">
45
- <time datetime="{{thread.created_at|date:'c'}}">{{thread.created_at | date:'M d, Y'}}</time>
45
+ <time datetime="{{thread.created_at|date:'c'}}">{{thread.created_at | date:'M j, Y'}}</time>
46
46
  </div>
47
47
  </div>
48
48
  <div class="thread">
@@ -75,7 +75,7 @@
75
75
  <div class="thread__user__details__row">
76
76
  <div class="thread__user__details__label">Joined:</div>
77
77
  <div class="thread__user__details__value">
78
- <time datetime="{{thread.user.date_joined|date:'c'}}">{{thread.user.date_joined | date:'M d, Y'}}</time>
78
+ <time datetime="{{thread.user.date_joined|date:'c'}}">{{thread.user.date_joined | date:'M j, Y'}}</time>
79
79
  </div>
80
80
  </div>
81
81
  <div class="thread__user__details__row">
@@ -86,10 +86,20 @@
86
86
  </div>
87
87
  <div class="thread__main">
88
88
  <div class="thread__content">
89
- {{thread.content.rendered}}
89
+ {{thread.content|render}}
90
90
  </div>
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 %}
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 %}
92
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 %}
93
103
  {% if perms.punkweb_bb.pin_thread %}
94
104
  <a
95
105
  class="pw-icon-button default rounded"
@@ -139,9 +149,9 @@
139
149
  {% endif %}
140
150
  </div>
141
151
  {% endif %}
142
- {% if thread.user.profile.signature.rendered %}
152
+ {% if thread.user.profile.signature|render %}
143
153
  <div class="thread__signature">
144
- {{thread.user.profile.signature.rendered}}
154
+ {{thread.user.profile.signature|render}}
145
155
  </div>
146
156
  {% endif %}
147
157
  </div>
@@ -153,7 +163,7 @@
153
163
  <div id="post-{{post.id}}" class="pw-card fluid margin">
154
164
  <div class="pw-card-header thread__header">
155
165
  <div class="thread__date">
156
- <time datetime="{{post.created_at|date:'c'}}">{{post.created_at | date:'M d, Y'}}</time>
166
+ <time datetime="{{post.created_at|date:'c'}}">{{post.created_at | date:'M j, Y'}}</time>
157
167
  </div>
158
168
  <a class="thread__index" href="{{post.get_absolute_url}}">#{{post.index}}</a>
159
169
  </div>
@@ -191,7 +201,7 @@
191
201
  <div class="thread__user__details__row">
192
202
  <div class="thread__user__details__label">Joined:</div>
193
203
  <div class="thread__user__details__value">
194
- <time datetime="{{post.user.date_joined|date:'c'}}">{{post.user.date_joined | date:'M d, Y'}}</time>
204
+ <time datetime="{{post.user.date_joined|date:'c'}}">{{post.user.date_joined | date:'M j, Y'}}</time>
195
205
  </div>
196
206
  </div>
197
207
  <div class="thread__user__details__row">
@@ -202,7 +212,7 @@
202
212
  </div>
203
213
  <div class="thread__main">
204
214
  <div class="thread__content">
205
- {{post.content.rendered}}
215
+ {{post.content|render}}
206
216
  </div>
207
217
  {% if post|can_delete:request.user or post|can_edit:request.user %}
208
218
  <div class="thread__actions">
@@ -228,9 +238,9 @@
228
238
  {% endif %}
229
239
  </div>
230
240
  {% endif %}
231
- {% if post.user.profile.signature.rendered %}
241
+ {% if post.user.profile.signature|render %}
232
242
  <div class="thread__signature">
233
- {{post.user.profile.signature.rendered}}
243
+ {{post.user.profile.signature|render}}
234
244
  </div>
235
245
  {% endif %}
236
246
  </div>
@@ -0,0 +1,4 @@
1
+ <div class="markdown-editor-container">
2
+ <div id="markdown-editor-toolbar"></div>
3
+ {% include "django/forms/widgets/textarea.html" %}
4
+ </div>
@@ -0,0 +1,35 @@
1
+ import html
2
+
3
+ import markdown as md
4
+ from django import template
5
+ from django.template.defaultfilters import stringfilter
6
+ from django.utils.safestring import mark_safe
7
+
8
+ from punkweb_bb.bbcode import get_parser, get_shoutbox_parser
9
+ from punkweb_bb.settings import PARSER
10
+
11
+ register = template.Library()
12
+
13
+
14
+ @register.filter(is_safe=True)
15
+ @stringfilter
16
+ def render(value):
17
+ if PARSER == "bbcode":
18
+ parser = get_parser()
19
+ rendered = parser.format(value)
20
+ return mark_safe(rendered)
21
+ elif PARSER == "markdown":
22
+ escaped = html.escape(value)
23
+ rendered = md.markdown(escaped, extensions=["markdown.extensions.fenced_code"])
24
+ return mark_safe(rendered)
25
+ return value
26
+
27
+
28
+ @register.filter(is_safe=True)
29
+ @stringfilter
30
+ def render_shout(value):
31
+ if PARSER == "bbcode":
32
+ parser = get_shoutbox_parser()
33
+ rendered = parser.format(value)
34
+ return mark_safe(rendered)
35
+ return value
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,6 +1,18 @@
1
- from django.contrib.auth.models import Group
1
+ from django.forms import Textarea
2
2
  from django.utils.text import slugify
3
3
 
4
+ from punkweb_bb.bbcode import get_parser
5
+ from punkweb_bb.settings import PARSER
6
+ from punkweb_bb.widgets import BBCodeEditorWidget, MarkdownEditorWidget
7
+
8
+
9
+ def get_editor_widget():
10
+ if PARSER == "bbcode":
11
+ return BBCodeEditorWidget()
12
+ elif PARSER == "markdown":
13
+ return MarkdownEditorWidget()
14
+ return Textarea(attrs={"class": "pw-input"})
15
+
4
16
 
5
17
  def get_unique_slug(model, field):
6
18
  base_slug = slugify(field)
@@ -31,17 +43,19 @@ def get_styled_username(user):
31
43
  group = get_highest_priority_group(user)
32
44
 
33
45
  if group:
46
+ parser = get_parser()
34
47
  username_style = group.style.username_style
35
- styled_username = username_style.rendered.replace("{USER}", user.username)
36
- return styled_username
37
- else:
38
- return user.username
48
+ rendered = parser.format(username_style.replace("{USER}", user.username))
49
+ return rendered
50
+
51
+ return user.username
39
52
 
40
53
 
41
54
  def get_styled_group_name(group):
42
- if group.style is None:
43
- return group.name
44
- else:
55
+ if group.style is not None:
56
+ parser = get_parser()
45
57
  username_style = group.style.username_style
46
- styled_group_name = username_style.rendered.replace("{USER}", group.name)
47
- return styled_group_name
58
+ rendered = parser.format(username_style.replace("{USER}", group.name))
59
+ return rendered
60
+
61
+ return group.name
punkweb_bb/views.py CHANGED
@@ -14,6 +14,7 @@ from punkweb_bb.forms import (
14
14
  SignUpForm,
15
15
  SubcategoryModelForm,
16
16
  ThreadModelForm,
17
+ ThreadMoveForm,
17
18
  )
18
19
  from punkweb_bb.guests import guest_list
19
20
  from punkweb_bb.models import Category, Post, Shout, Subcategory, Thread
@@ -406,11 +407,11 @@ def thread_delete_view(request, thread_id):
406
407
 
407
408
  @login_required(login_url="/login/")
408
409
  def thread_pin_view(request, thread_id):
409
- thread = get_object_or_404(Thread, pk=thread_id)
410
-
411
410
  if not request.user.has_perm("punkweb_bb.pin_thread"):
412
411
  return HttpResponseForbidden("You do not have permission to pin threads.")
413
412
 
413
+ thread = get_object_or_404(Thread, pk=thread_id)
414
+
414
415
  thread.is_pinned = not thread.is_pinned
415
416
  thread.save()
416
417
 
@@ -419,17 +420,47 @@ def thread_pin_view(request, thread_id):
419
420
 
420
421
  @login_required(login_url="/login/")
421
422
  def thread_close_view(request, thread_id):
422
- thread = get_object_or_404(Thread, pk=thread_id)
423
-
424
423
  if not request.user.has_perm("punkweb_bb.close_thread"):
425
424
  return HttpResponseForbidden("You do not have permission to close threads.")
426
425
 
426
+ thread = get_object_or_404(Thread, pk=thread_id)
427
+
427
428
  thread.is_closed = not thread.is_closed
428
429
  thread.save()
429
430
 
430
431
  return htmx_redirect(thread.get_absolute_url())
431
432
 
432
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
+
433
464
  @login_required(login_url="/login/")
434
465
  def post_create_view(request, thread_id):
435
466
  thread = get_object_or_404(Thread, pk=thread_id)
@@ -557,16 +588,22 @@ def bbcode_view(request):
557
588
  ("Italic", "[i]Italic Text[/i]"),
558
589
  ("Underline", "[u]Underlined Text[/u]"),
559
590
  ("Strikethrough", "[s]Strikethrough Text[/s]"),
560
- ("Quote", "[quote=Example]Quoted Text[/quote]"),
561
- ("Center", "[center]Centered Text[/center]"),
562
591
  ("Color", "[color=red]Red Text[/color]"),
592
+ ("Font", "[font=serif]Serif Text[/font]"),
593
+ ("Shadow", "[shadow=red]Red Shadow Text[/shadow]"),
594
+ ("Size", "[size=7]Size 7 Text[/size]"),
595
+ ("Superscript", "Sup [sup]Superscript Text[/sup]"),
596
+ ("Subscript", "Sub [sub]Subscript Text[/sub]"),
597
+ ("Horizontal Rule", "[hr]"),
598
+ ("Left", "[left]Left Text[/left]"),
599
+ ("Center", "[center]Centered Text[/center]"),
600
+ ("Right", "[right]Right Text[/right]"),
601
+ ("Quote", "[quote=Example]Quoted Text[/quote]"),
563
602
  ("Url", "[url=https://google.com]Link Text[/url]"),
564
603
  (
565
604
  "Image",
566
605
  "[img]https://placehold.co/400[/img]",
567
606
  ),
568
- # Custom
569
- ("Horizontal Rule", "[hr]"),
570
607
  (
571
608
  "Code",
572
609
  """
@@ -585,23 +622,8 @@ class ThreadModelForm(forms.ModelForm):
585
622
  [/code]
586
623
  """,
587
624
  ),
588
- ("Email", "[email=test@example.com]Example[/email]"),
589
- ("Font", "[font=serif]Serif Text[/font]"),
590
625
  ("Ordered List", "[ol][li]Item 1[/li][li]Item 2[/li][/ol]"),
591
626
  ("Unordered List", "[ul][li]Item 1[/li][li]Item 2[/li][/ul]"),
592
- ("Shadow", "[shadow=red]Red Shadow Text[/shadow]"),
593
- ("Size", "[size=7]Size 7 Text[/size]"),
594
- (
595
- "Checkbox",
596
- """
597
- [n]Unchecked
598
- [y]Checked
599
- """,
600
- ),
601
- ("Superscript", "Sup [sup]Superscript Text[/sup]"),
602
- ("Subscript", "Sub [sub]Subscript Text[/sub]"),
603
- ("Left", "[left]Left Text[/left]"),
604
- ("Right", "[right]Right Text[/right]"),
605
627
  ("Escape", "[escape][b]Escaped bbcode[/b][/escape]"),
606
628
  )
607
629
 
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
+ )