From 559db657d463cb32a93dd11907e5dcd84c140101 Mon Sep 17 00:00:00 2001 From: Jordan Robinson Date: Sun, 14 Sep 2025 22:10:04 +0100 Subject: [PATCH] change images to be assets and allow for more file types per #25 --- main/forms.py | 2 +- main/templates/main/dashboard.html | 4 ++-- main/templates/main/guides_images.html | 20 +++++++++---------- main/templates/main/image_confirm_delete.html | 2 +- main/templates/main/image_detail.html | 6 +++--- main/templates/main/image_form.html | 4 ++-- main/templates/main/image_list.html | 6 +++--- main/templates/main/landing.html | 2 +- main/templates/main/moderation_images.html | 6 +++--- main/urls.py | 16 +++++++-------- main/views/general.py | 6 +++--- 11 files changed, 37 insertions(+), 37 deletions(-) diff --git a/main/forms.py b/main/forms.py index 0ac4533bef247ea5f65af4db8dbe4f7302a4a426..8cd5fbf06a20b360e32434cbd7be85a1992b7c37 100644 --- a/main/forms.py +++ b/main/forms.py @@ -52,7 +52,7 @@ class UploadImagesForm(forms.Form): file = MultipleFileField( validators=[ dj_validators.FileExtensionValidator( - ["jpeg", "jpg", "png", "svg", "gif", "webp", "tiff", "tif", "bmp"] + ["jpeg", "jpg", "png", "svg", "gif", "webp", "tiff", "tif", "bmp", "txt", "md", "rtf", "pdf", "epub", "doc", "docx", "odt", "ppt", "pptx", "odp", "xls", "xlsx", "ods", "csv", "tsv", "ics", "vcf", "log", "json", "xml", "yml", "yaml", "ini", "toml", "cfg", "conf", "mdown", "markdown"] ) ], ) diff --git a/main/templates/main/dashboard.html b/main/templates/main/dashboard.html index 1608e897a60d3f6dbc4c9da0d5bd4f25e97db1d3..f540145496784cf2960fe42f6021110debb6a709 100644 --- a/main/templates/main/dashboard.html +++ b/main/templates/main/dashboard.html @@ -18,9 +18,9 @@
{% endif %} - + Homepage -
Images +
Assets
Posts
Pages diff --git a/main/templates/main/guides_images.html b/main/templates/main/guides_images.html index be6cc543fb6d7b4f971bb62a43fb9bf041d0e2a0..903fb7213115136c2181cad04d97cfceecd75aba 100644 --- a/main/templates/main/guides_images.html +++ b/main/templates/main/guides_images.html @@ -2,36 +2,36 @@ {% load static %} -{% block title %}Images Guide{% endblock %} +{% block title %}Assets Guide{% endblock %} {% block content %}
-

Images Guide

+

Assets Guide

- Even though we are very text focused, we do support image uploading and hosting. + Even though we are very text focused, we do support asset uploading and hosting. The limits are:

Upload

- There are two ways to upload an image. Either via the - image dashboard, or via any post or page editing page. + There are two ways to upload an asset. Either via the + assets dashboard, or via any post or page editing page.

-

Image dashboard: To upload, use the file selector at the top.

+

Assets dashboard: To upload, use the file selector at the top.

Post/page edit: To upload, just drag and drop onto the text area of the new post or page.

-

Show images

+

Show assets

- To show the uploaded images on a BōcPress blog post or page, one can write the following: + To show the uploaded assets on a BōcPress blog post or page, one can write the following:
![image description here](https://mataroa.blog/images/896f9b41.png)

diff --git a/main/templates/main/image_confirm_delete.html b/main/templates/main/image_confirm_delete.html index 1ba58ced4b76e13fb0de318bd3443006bde50d3b..b0d0859acb23eb5f4feb5333cff37b9620e6bfe8 100644 --- a/main/templates/main/image_confirm_delete.html +++ b/main/templates/main/image_confirm_delete.html @@ -4,7 +4,7 @@ {% block content %}

-

Delete {{ image.name }} for sure?

+

Are you sure you want to delete {{ image.name }}?

{% csrf_token %} diff --git a/main/templates/main/image_detail.html b/main/templates/main/image_detail.html index c5965ba9296ce1345769a79320ae137340f85d3a..6a4096a366fb2a4e4565153a170fd583d64badaa 100644 --- a/main/templates/main/image_detail.html +++ b/main/templates/main/image_detail.html @@ -7,14 +7,14 @@

{{ image.name }}

- Use markdown syntax to add this image in a post: + Use markdown syntax to add this asset in a post as an image:

![{{ image.name }}]({{ request.scheme }}:{{ image.raw_url_absolute }}) diff --git a/main/templates/main/image_form.html b/main/templates/main/image_form.html index 86e26b35ec0acc65eb1882ae46c1682091d39914..7c751aab463f628872bb6fc4d51fd2c6c32e6bfc 100644 --- a/main/templates/main/image_form.html +++ b/main/templates/main/image_form.html @@ -1,10 +1,10 @@ {% extends 'main/layout.html' %} -{% block title %}Editing {{ form.name.value }} image — {{ request.user.username }}{% endblock %} +{% block title %}Editing {{ form.name.value }} asset — {{ request.user.username }}{% endblock %} {% block content %}
-

Editing image

+

Editing asset

{{ form.as_p }} diff --git a/main/templates/main/image_list.html b/main/templates/main/image_list.html index 991ef26112bb215e5ded08a095f831cb0ac7d538..3b585c3c330df9c10e72a7a84b639f795ef39c96 100644 --- a/main/templates/main/image_list.html +++ b/main/templates/main/image_list.html @@ -1,10 +1,10 @@ {% extends 'main/layout.html' %} -{% block title %}Images — {{ request.user.username }}{% endblock %} +{% block title %}Assets — {{ request.user.username }}{% endblock %} {% block content %}
-

Images

+

Assets

{{ form.non_field_errors }}

@@ -22,7 +22,7 @@

- Using: {{ images|length }} out of 1000 images. + Using: {{ images|length }} out of 1000 assets. {{ total_quota }}MB out of 1000MB.

diff --git a/main/templates/main/landing.html b/main/templates/main/landing.html index c88ad32ed480fa8375b1f8c15e543f0409ac1569..f6f6af16eefc1e6a20142b501d3b67ebe5f822c0 100644 --- a/main/templates/main/landing.html +++ b/main/templates/main/landing.html @@ -41,7 +41,7 @@
  • - Image hosting is included + Assets hosting is included
  • Feed Subscriptions available for readers
    • diff --git a/main/templates/main/moderation_images.html b/main/templates/main/moderation_images.html index 807d0baa931a50fe0bc57a817d7cbaf4183dd6e2..7ca276bad23748fb3e0690f0a234ea808272c03e 100644 --- a/main/templates/main/moderation_images.html +++ b/main/templates/main/moderation_images.html @@ -1,10 +1,10 @@ {% extends 'main/layout.html' %} -{% block title %}Moderation Images{% endblock %} +{% block title %}Moderation Assets{% endblock %} {% block content %}
      -

      Moderation Images

      +

      Moderation Assets

      @@ -25,7 +25,7 @@
      ID
      User
      -
      Images
      +
      Assets
      Size (MB)
      Joined
      diff --git a/main/urls.py b/main/urls.py index 0f6cfaf8d99f61dde625a028867a1e94fb3eeef6..33f0a1aca74e3b7aff04088bba999d237dadc079 100644 --- a/main/urls.py +++ b/main/urls.py @@ -15,7 +15,7 @@ urlpatterns = [ path("about/transparency/", general.transparency, name="transparency"), path("about/comparisons/", general.comparisons, name="comparisons"), path("guides/markdown/", general.guides_markdown, name="guides_markdown"), - path("guides/images/", general.guides_images, name="guides_images"), + path("guides/assets/", general.guides_images, name="guides_images"), path( "guides/custom-domain/", general.guides_customdomain, name="guides_customdomain" ), @@ -46,7 +46,7 @@ urlpatterns += [ path("moderation/index/", moderation.index, name="moderation_index"), path("moderation/cards/", moderation.user_cards, name="moderation_user_cards"), path("moderation/users/", moderation.user_list, name="moderation_user_list"), - path("moderation/images/", moderation.images_leaderboard, name="moderation_images"), + path("moderation/assets/", moderation.images_leaderboard, name="moderation_images"), path("moderation/posts/", moderation.posts_leaderboard, name="moderation_posts"), path("moderation/stats/", moderation.stats, name="moderation_stats"), path( @@ -231,20 +231,20 @@ urlpatterns += [ ), ] -# images +# assets (images and other files) urlpatterns += [ - path("images/.", general.image_raw, name="image_raw"), + path("assets/.", general.image_raw, name="image_raw"), re_path( - r"^images/(?P\?[\w\=]+)?$", # e.g. images/ or images/?raw=true + r"^assets/(?P\?[\w\=]+)?$", # e.g. assets/ or assets/?raw=true general.ImageList.as_view(), name="image_list", ), - path("images//", general.ImageDetail.as_view(), name="image_detail"), + path("assets//", general.ImageDetail.as_view(), name="image_detail"), path( - "images//edit/", general.ImageUpdate.as_view(), name="image_update" + "assets//edit/", general.ImageUpdate.as_view(), name="image_update" ), path( - "images//delete/", + "assets//delete/", general.ImageDelete.as_view(), name="image_delete", ), diff --git a/main/views/general.py b/main/views/general.py index dc78d1f4164851fd8fc36f9ef8ea1be6a540a4dd..5ab03d79e5ad044e7b3b6e6611fc5231e75e7ce5 100644 --- a/main/views/general.py +++ b/main/views/general.py @@ -811,8 +811,8 @@ class ImageList(LoginRequiredMixin, FormView): data = f.read() # check for file limit - if len(data) > 1.1 * 1000 * 1000: - form.add_error("file", "File too big. Limit is 1MB.") + if len(data) > 5 * 1024 * 1024: + form.add_error("file", "File too big. Limit is 5MB.") return self.form_invalid(form) # quota limit 1GB total per user @@ -868,7 +868,7 @@ class ImageDetail(LoginRequiredMixin, DetailView): # find posts that use this image context["used_by_posts"] = [] for post in models.Post.objects.filter(owner=self.request.user): - if "/images/" + self.object.filename in post.body: + if "/assets/" + self.object.filename in post.body: context["used_by_posts"].append(post) return context