photo-objects 0.9.5__tar.gz → 0.9.6__tar.gz

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 (72) hide show
  1. {photo_objects-0.9.5 → photo_objects-0.9.6}/PKG-INFO +1 -1
  2. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/tests/test_utils.py +3 -2
  3. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/views/ui/album.py +18 -8
  4. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/views/ui/configuration.py +16 -6
  5. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/views/ui/photo.py +16 -7
  6. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/views/ui/photo_change_request.py +1 -1
  7. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/views/ui/users.py +4 -6
  8. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/views/ui/utils.py +7 -0
  9. photo_objects-0.9.6/photo_objects/django/views/utils.py +86 -0
  10. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects.egg-info/PKG-INFO +1 -1
  11. {photo_objects-0.9.5 → photo_objects-0.9.6}/pyproject.toml +1 -1
  12. photo_objects-0.9.5/photo_objects/django/views/utils.py +0 -42
  13. {photo_objects-0.9.5 → photo_objects-0.9.6}/LICENSE +0 -0
  14. {photo_objects-0.9.5 → photo_objects-0.9.6}/README.md +0 -0
  15. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/__init__.py +0 -0
  16. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/config.py +0 -0
  17. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/__init__.py +0 -0
  18. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/admin.py +0 -0
  19. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/api/__init__.py +0 -0
  20. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/api/album.py +0 -0
  21. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/api/auth.py +0 -0
  22. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/api/backup.py +0 -0
  23. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/api/photo.py +0 -0
  24. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/api/photo_change_request.py +0 -0
  25. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/api/utils.py +0 -0
  26. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/apps.py +0 -0
  27. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/conf.py +0 -0
  28. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/context_processors.py +0 -0
  29. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/forms.py +0 -0
  30. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/management/__init__.py +0 -0
  31. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/management/commands/__init__.py +0 -0
  32. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/management/commands/clean-scaled-photos.py +0 -0
  33. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/management/commands/create-initial-admin-account.py +0 -0
  34. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/management/commands/restore-backup.py +0 -0
  35. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/migrations/0001_initial.py +0 -0
  36. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/migrations/0002_created_at_updated_at.py +0 -0
  37. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/migrations/0003_admin_visibility.py +0 -0
  38. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/migrations/0004_camera_setup_and_settings.py +0 -0
  39. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/migrations/0005_sitesettings.py +0 -0
  40. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/migrations/0006_photo_alt_text.py +0 -0
  41. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/migrations/0007_backup.py +0 -0
  42. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/migrations/__init__.py +0 -0
  43. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/models.py +0 -0
  44. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/objsto.py +0 -0
  45. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/signals.py +0 -0
  46. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/templatetags/__init__.py +0 -0
  47. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/templatetags/photo_objects_extras.py +0 -0
  48. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/tests/__init__.py +0 -0
  49. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/tests/test_album.py +0 -0
  50. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/tests/test_auth.py +0 -0
  51. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/tests/test_commands.py +0 -0
  52. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/tests/test_img.py +0 -0
  53. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/tests/test_og_meta.py +0 -0
  54. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/tests/test_photo.py +0 -0
  55. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/tests/test_photo_change_requests.py +0 -0
  56. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/tests/utils.py +0 -0
  57. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/urls.py +0 -0
  58. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/views/__init__.py +0 -0
  59. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/views/api/__init__.py +0 -0
  60. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/views/api/album.py +0 -0
  61. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/views/api/auth.py +0 -0
  62. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/views/api/photo.py +0 -0
  63. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/views/api/utils.py +0 -0
  64. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/django/views/ui/__init__.py +0 -0
  65. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/error.py +0 -0
  66. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/img.py +0 -0
  67. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects/utils.py +0 -0
  68. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects.egg-info/SOURCES.txt +0 -0
  69. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects.egg-info/dependency_links.txt +0 -0
  70. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects.egg-info/requires.txt +0 -0
  71. {photo_objects-0.9.5 → photo_objects-0.9.6}/photo_objects.egg-info/top_level.txt +0 -0
  72. {photo_objects-0.9.5 → photo_objects-0.9.6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: photo-objects
3
- Version: 0.9.5
3
+ Version: 0.9.6
4
4
  Summary: Application for storing photos in S3 compatible object-storage.
5
5
  Author: Toni Kangas
6
6
  License: MIT License
@@ -56,8 +56,9 @@ class TestUtils(TestCase):
56
56
  "Plain text description"),
57
57
  (md_multi_p,
58
58
  "Description with bold and italics..."),
59
- (None,
60
- "A simple self-hosted photo server."),
59
+ # TODO: Test default description and description from site-settings
60
+ # (None,
61
+ # "A simple self-hosted photo server."),
61
62
  ]
62
63
 
63
64
  for description, expected in testdata:
@@ -9,11 +9,12 @@ from photo_objects.django.forms import CreateAlbumForm, ModifyAlbumForm
9
9
  from photo_objects.django.models import Album
10
10
  from photo_objects.django.views.utils import (
11
11
  BackLink,
12
+ Preview,
12
13
  meta_description,
13
14
  )
14
15
  from photo_objects.utils import render_markdown
15
16
 
16
- from .utils import json_problem_as_html
17
+ from .utils import json_problem_as_html, preview_helptext
17
18
 
18
19
 
19
20
  @json_problem_as_html
@@ -46,6 +47,7 @@ def new_album(request: HttpRequest):
46
47
  "form": form,
47
48
  "title": "Create album",
48
49
  "back": back,
50
+ "width": "narrow",
49
51
  })
50
52
 
51
53
 
@@ -107,13 +109,19 @@ def edit_album(request: HttpRequest, album_key: str):
107
109
  'photo_objects:show_album',
108
110
  kwargs={"album_key": album_key}))
109
111
 
110
- return render(request, 'photo_objects/form.html', {
111
- "form": form,
112
- "title": "Edit album",
113
- "back": back,
114
- "photo": album.cover_photo,
115
- "info": get_info(request, album_key),
116
- })
112
+ return render(
113
+ request,
114
+ 'photo_objects/form.html',
115
+ {
116
+ "form": form,
117
+ "title": "Edit album",
118
+ "back": back,
119
+ "info": get_info(
120
+ request,
121
+ album_key),
122
+ "width": "narrow",
123
+ "preview": Preview(request, album, preview_helptext("album")),
124
+ })
117
125
 
118
126
 
119
127
  @json_problem_as_html
@@ -145,5 +153,7 @@ def delete_album(request: HttpRequest, album_key: str):
145
153
  "back": back,
146
154
  "photo": album.cover_photo,
147
155
  "resource": target,
156
+ "width": "narrow",
157
+ "preview": Preview(request, album, preview_helptext("album")),
148
158
  **error,
149
159
  })
@@ -6,7 +6,7 @@ from django.urls import reverse
6
6
  from django.utils.translation import gettext_lazy as _
7
7
 
8
8
  from photo_objects.django.api.utils import JsonProblem
9
- from photo_objects.django.views.utils import BackLink
9
+ from photo_objects.django.views.utils import BackLink, Preview
10
10
  from photo_objects.utils import render_markdown
11
11
 
12
12
  from .utils import json_problem_as_html
@@ -169,8 +169,18 @@ def configuration(request: HttpRequest):
169
169
 
170
170
  back = BackLink("Albums", reverse('photo_objects:list_albums'))
171
171
 
172
- return render(request, "photo_objects/configuration.html", {
173
- "title": "Configuration",
174
- "validations": validations,
175
- "back": back,
176
- })
172
+ return render(
173
+ request,
174
+ "photo_objects/configuration.html",
175
+ {
176
+ "title": "Configuration",
177
+ "validations": validations,
178
+ "back": back,
179
+ "width": "narrow",
180
+ "preview": Preview(
181
+ request,
182
+ None,
183
+ "This is an example on how the site will appear by default "
184
+ "when sharing in social media. Note that individual albums "
185
+ "and photos override this default preview."),
186
+ })
@@ -12,11 +12,12 @@ from photo_objects.django.forms import ModifyPhotoForm, UploadPhotosForm
12
12
  from photo_objects.django.models import Photo
13
13
  from photo_objects.django.views.utils import (
14
14
  BackLink,
15
+ Preview,
15
16
  meta_description,
16
17
  )
17
18
  from photo_objects.utils import render_markdown
18
19
 
19
- from .utils import json_problem_as_html
20
+ from .utils import json_problem_as_html, preview_helptext
20
21
 
21
22
 
22
23
  @json_problem_as_html
@@ -53,6 +54,8 @@ def upload_photos(request: HttpRequest, album_key: str):
53
54
  "title": "Upload photos",
54
55
  "back": back,
55
56
  "photo": album.cover_photo,
57
+ "width": "narrow",
58
+ "preview": Preview(request, album, preview_helptext("album")),
56
59
  })
57
60
 
58
61
 
@@ -177,12 +180,16 @@ def edit_photo(request: HttpRequest, album_key: str, photo_key: str):
177
180
  "album_key": album_key,
178
181
  "photo_key": photo_key}))
179
182
 
180
- return render(request, 'photo_objects/form.html', {
181
- "form": form,
182
- "title": "Edit photo",
183
- "back": back,
184
- "photo": photo,
185
- })
183
+ return render(
184
+ request,
185
+ 'photo_objects/form.html',
186
+ {
187
+ "form": form,
188
+ "title": "Edit photo",
189
+ "back": back,
190
+ "width": "narrow",
191
+ "preview": Preview(request, photo, preview_helptext("photo")),
192
+ })
186
193
 
187
194
 
188
195
  @json_problem_as_html
@@ -208,4 +215,6 @@ def delete_photo(request: HttpRequest, album_key: str, photo_key: str):
208
215
  "back": back,
209
216
  "photo": photo,
210
217
  "resource": target,
218
+ "width": "narrow",
219
+ "preview": Preview(request, photo, preview_helptext("photo")),
211
220
  })
@@ -53,9 +53,9 @@ def review_photo_change_request(request: HttpRequest, cr_id: str):
53
53
  "form": form,
54
54
  "title": "Review photo change request",
55
55
  "back": back,
56
- "photo": photo,
57
56
  "info": info,
58
57
  "instructions": render_markdown(
59
58
  f'The current alt text for `{photo.key}` is: '
60
59
  f'_"{photo.alt_text}"_.'),
60
+ "width": "narrow",
61
61
  })
@@ -2,22 +2,20 @@ from django.contrib.auth import views as auth_views
2
2
  from django.http import HttpRequest
3
3
  from django.urls import reverse_lazy
4
4
 
5
- from photo_objects.django.models import SiteSettings
6
- from photo_objects.django.views.utils import BackLink
5
+ from photo_objects.django.views.utils import BackLink, Preview
7
6
 
8
7
 
9
8
  def login(request: HttpRequest):
10
- settings = SiteSettings.objects.get(request.site)
11
-
12
9
  return auth_views.LoginView.as_view(
13
10
  template_name="photo_objects/form.html",
14
11
  extra_context={
15
12
  "title": "Login",
16
- "photo": settings.preview_image,
17
13
  "action": "Login",
18
14
  "back": BackLink(
19
15
  'Albums',
20
16
  reverse_lazy('photo_objects:list_albums')),
21
- "class": "login"
17
+ "class": "login",
18
+ "width": "narrow",
19
+ "preview": Preview(request, None),
22
20
  },
23
21
  )(request)
@@ -8,3 +8,10 @@ def json_problem_as_html(func):
8
8
  except JsonProblem as e:
9
9
  return e.html_response(args[0])
10
10
  return wrapper
11
+
12
+
13
+ def preview_helptext(resource_type: str) -> str:
14
+ return (
15
+ f"This is an example on how the {resource_type} will currently appear "
16
+ "when sharing on social media."
17
+ )
@@ -0,0 +1,86 @@
1
+ from django.http import HttpRequest
2
+ from django.utils.dateformat import format as format_date
3
+
4
+ from photo_objects.django.models import Album, Photo, SiteSettings
5
+ from photo_objects.utils import first_paragraph_textcontent
6
+
7
+
8
+ class BackLink:
9
+ def __init__(self, text: str, url: str):
10
+ self.text = text
11
+ self.url = url
12
+
13
+
14
+ # TODO: Use this also for meta-og tags
15
+ class Preview:
16
+ def __init__(
17
+ self,
18
+ request: HttpRequest,
19
+ resource: Album | Photo = None,
20
+ helptext: str = None):
21
+ self.description = meta_description(request, resource)
22
+ self.photo = meta_photo(request, resource)
23
+ self.title = meta_title(request, resource)
24
+ self.helptext = helptext
25
+
26
+
27
+ def _default_album_description(request: HttpRequest, album: Album) -> str:
28
+ count = album.photo_set.count()
29
+ plural = 's' if count != 1 else ''
30
+ return f"Album with {count} photo{plural} in {request.site.name}."
31
+
32
+
33
+ def _default_photo_description(photo: Photo) -> str:
34
+ date_str = format_date(photo.timestamp, "F Y")
35
+ return f"Photo from {date_str} in {photo.album.title} album."
36
+
37
+
38
+ def meta_description(
39
+ request: HttpRequest,
40
+ resource: Album | Photo | str = None) -> str:
41
+ text = None
42
+ if isinstance(resource, Album):
43
+ return (
44
+ first_paragraph_textcontent(resource.description) or
45
+ _default_album_description(request, resource))
46
+
47
+ if isinstance(resource, Photo):
48
+ return (
49
+ first_paragraph_textcontent(resource.description) or
50
+ _default_photo_description(resource))
51
+
52
+ if isinstance(resource, str):
53
+ return first_paragraph_textcontent(resource)
54
+
55
+ settings = SiteSettings.objects.get(request.site)
56
+ text = first_paragraph_textcontent(settings.description)
57
+ return text or "A simple self-hosted photo server."
58
+
59
+
60
+ def meta_photo(
61
+ request: HttpRequest,
62
+ resource: Album | Photo = None) -> Photo:
63
+ if isinstance(resource, Photo):
64
+ return resource
65
+
66
+ if isinstance(resource, Album):
67
+ return resource.cover_photo
68
+
69
+ settings = SiteSettings.objects.get(request.site)
70
+ return settings.preview_image
71
+
72
+
73
+ def meta_title(
74
+ request: HttpRequest,
75
+ resource: Album | Photo | str = None) -> str:
76
+ text = None
77
+ if isinstance(resource, Album):
78
+ text = resource.title
79
+
80
+ if isinstance(resource, Photo):
81
+ text = resource.title or resource.filename
82
+
83
+ if isinstance(resource, str):
84
+ text = resource
85
+
86
+ return text or request.site.name
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: photo-objects
3
- Version: 0.9.5
3
+ Version: 0.9.6
4
4
  Summary: Application for storing photos in S3 compatible object-storage.
5
5
  Author: Toni Kangas
6
6
  License: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "photo-objects"
7
- version = "0.9.5"
7
+ version = "0.9.6"
8
8
  dependencies = [
9
9
  "markdown~=3.7",
10
10
  "minio>=7.2.0,<7.2.19",
@@ -1,42 +0,0 @@
1
- from django.http import HttpRequest
2
- from django.utils.dateformat import format as format_date
3
-
4
- from photo_objects.django.models import Album, Photo
5
- from photo_objects.utils import first_paragraph_textcontent
6
-
7
-
8
- class BackLink:
9
- def __init__(self, text: str, url: str):
10
- self.text = text
11
- self.url = url
12
-
13
-
14
- def _default_album_description(request: HttpRequest, album: Album) -> str:
15
- count = album.photo_set.count()
16
- plural = 's' if count != 1 else ''
17
- return f"Album with {count} photo{plural} in {request.site.name}."
18
-
19
-
20
- def _default_photo_description(photo: Photo) -> str:
21
- date_str = format_date(photo.timestamp, "F Y")
22
- return f"Photo from {date_str} in {photo.album.title} album."
23
-
24
-
25
- def meta_description(
26
- request: HttpRequest,
27
- resource: Album | Photo | str | None) -> str:
28
- text = None
29
- if isinstance(resource, Album):
30
- text = (
31
- first_paragraph_textcontent(resource.description) or
32
- _default_album_description(request, resource))
33
-
34
- if isinstance(resource, Photo):
35
- text = (
36
- first_paragraph_textcontent(resource.description) or
37
- _default_photo_description(resource))
38
-
39
- if isinstance(resource, str):
40
- text = first_paragraph_textcontent(resource)
41
-
42
- return text or "A simple self-hosted photo server."
File without changes
File without changes
File without changes