diff --git a/constants.py b/constants.py index 897bdf0..e81a5a5 100644 --- a/constants.py +++ b/constants.py @@ -121,7 +121,7 @@ DEFAULT_CONFIGURATION = { 'min_username_length': 2, 'max_username_length': 24, - 'valid_username_chars': string.ascii_letters + string.digits + '~!@#$%^&*()[]{}:;,.<>/\\-_+=', + 'valid_username_chars': string.ascii_letters + string.digits + '~!@#$%^*()[]{}:;,.<>/\\-_+=', 'min_password_length': 6, 'id_length': 12, diff --git a/etiquette.py b/etiquette.py index 19cdf10..9b719ba 100644 --- a/etiquette.py +++ b/etiquette.py @@ -404,8 +404,8 @@ def get_search_core(): limit = 50 # OFFSET - offset = request.args.get('offset', None) - if offset: + offset = request.args.get('offset', '') + if offset.isdigit(): offset = int(offset) else: offset = None @@ -421,6 +421,15 @@ def get_search_core(): tag_mays = [qualname_map.get(tag, tag) for tag in tag_mays if tag != ''] tag_forbids = [qualname_map.get(tag, tag) for tag in tag_forbids if tag != ''] + # AUTHOR + authors = request.args.get('author', None) + if authors: + authors = authors.split(',') + authors = [a.strip() for a in authors] + authors = [P.get_user(username=a) for a in authors] + else: + authors = None + # ORDERBY orderby = request.args.get('orderby', None) if orderby: @@ -430,11 +439,11 @@ def get_search_core(): orderby = None # HAS_TAGS - has_tags = request.args.get('has_tags', '') - if has_tags == '': - has_tags = None - else: + has_tags = request.args.get('has_tags', None) + if has_tags: has_tags = helpers.truthystring(has_tags) + else: + has_tags = None # MINMAXERS area = request.args.get('area', None) @@ -454,6 +463,7 @@ def get_search_core(): 'bytes': bytes, 'duration': duration, + 'authors': authors, 'created': created, 'extension': extension_list, 'extension_not': extension_not_list, diff --git a/jsonify.py b/jsonify.py index 3418a38..779c577 100644 --- a/jsonify.py +++ b/jsonify.py @@ -38,7 +38,7 @@ def photo(p, include_albums=True, include_tags=True): 'has_thumbnail': bool(p.thumbnail), 'created': p.created, 'filename': p.basename, - 'mimetype': p.mimetype(), + 'mimetype': p.mimetype, } if include_albums: j['albums'] = [album(a, minimal=True) for a in p.albums()] diff --git a/objects.py b/objects.py index 73c30a7..ebb509a 100644 --- a/objects.py +++ b/objects.py @@ -300,6 +300,8 @@ class Photo(ObjectBase): self.ratio = row_tuple['ratio'] self.thumbnail = row_tuple['thumbnail'] + self.mimetype = helpers.get_mimetype(self.real_filepath) + def __reinit__(self): ''' Reload the row from the database and do __init__ with them. @@ -392,8 +394,7 @@ class Photo(ObjectBase): hopeful_filepath = self.make_thumbnail_filepath() return_filepath = None - mime = self.mimetype() - if mime == 'image': + if self.mimetype == 'image': self.photodb.log.debug('Thumbnailing %s' % self.real_filepath) try: image = PIL.Image.open(self.real_filepath) @@ -413,7 +414,7 @@ class Photo(ObjectBase): image.save(hopeful_filepath, quality=50) return_filepath = hopeful_filepath - elif mime == 'video' and constants.ffmpeg: + elif self.mimetype == 'video' and constants.ffmpeg: #print('video') probe = constants.ffmpeg.probe(self.real_filepath) try: @@ -495,9 +496,6 @@ class Photo(ObjectBase): hopeful_filepath = os.path.join(folder, basename) + '.jpg' return hopeful_filepath - def mimetype(self): - return helpers.get_mimetype(self.real_filepath) - @decorators.time_me def reload_metadata(self, *, commit=True): ''' @@ -510,8 +508,7 @@ class Photo(ObjectBase): self.ratio = None self.duration = None - mime = self.mimetype() - if mime == 'image': + if self.mimetype == 'image': try: image = PIL.Image.open(self.real_filepath) except (OSError, ValueError): @@ -521,7 +518,7 @@ class Photo(ObjectBase): image.close() self.photodb.log.debug('Loaded image data for {photo:r}'.format(photo=self)) - elif mime == 'video' and constants.ffmpeg: + elif self.mimetype == 'video' and constants.ffmpeg: try: probe = constants.ffmpeg.probe(self.real_filepath) if probe and probe.video: @@ -531,7 +528,7 @@ class Photo(ObjectBase): except: traceback.print_exc() - elif mime == 'audio': + elif self.mimetype == 'audio': try: probe = constants.ffmpeg.probe(self.real_filepath) if probe and probe.audio: diff --git a/phototagger.py b/phototagger.py index 90e8db4..8c0442c 100644 --- a/phototagger.py +++ b/phototagger.py @@ -452,6 +452,8 @@ class PDBPhotoMixin: elif author is not None: # Just to confirm author_id = self.get_user(id=author).id + else: + author_id = None extension = os.path.splitext(filename)[1] extension = extension.replace('.', '') @@ -524,6 +526,7 @@ class PDBPhotoMixin: bytes=None, duration=None, + authors=None, created=None, extension=None, extension_not=None, @@ -541,11 +544,14 @@ class PDBPhotoMixin: orderby=None ): ''' - PHOTO PROPERTISE + PHOTO PROPERTIES area, width, height, ratio, bytes, duration: A hyphen_range string representing min and max. Or just a number for lower bound. TAGS AND FILTERS + authors: + A list of User object or users IDs. + created: A hyphen_range string respresenting min and max. Or just a number for lower bound. @@ -615,6 +621,11 @@ class PDBPhotoMixin: extension_not = helpers._normalize_extensions(extension_not) mimetype = helpers._normalize_extensions(mimetype) + if authors is not None: + if isinstance(authors, str): + authors = {authors, } + authors = set(a.id if isinstance(a, objects.User) else a for a in authors) + if filename is not None: if not isinstance(filename, str): filename = ' '.join(filename) @@ -669,10 +680,13 @@ class PDBPhotoMixin: #print('Failed extension_not') continue - if mimetype and photo.mimetype() not in mimetype: + if mimetype and photo.mimetype not in mimetype: #print('Failed mimetype') continue + if authors and photo.author_id not in authors: + continue + if filename and not _helper_filenamefilter(subject=photo.basename, terms=filename): #print('Failed filename') continue diff --git a/static/Highlander_Normal.ttf b/static/Highlander_Normal.ttf deleted file mode 100644 index 00bf36c..0000000 Binary files a/static/Highlander_Normal.ttf and /dev/null differ diff --git a/static/common.css b/static/common.css index 342239a..2e5de5e 100644 --- a/static/common.css +++ b/static/common.css @@ -154,6 +154,10 @@ li bottom: 0; right: 0; } +.photo_card_grid_filename +{ + word-break:break-word; +} .photo_card_grid_tags { position: absolute; @@ -195,8 +199,3 @@ li { background-color: #faa; } - -@font-face { - font-family: 'Highlander'; - src: url('/static/Highlander_Normal.ttf'); -} \ No newline at end of file diff --git a/templates/album.html b/templates/album.html index 805370a..a3aa873 100644 --- a/templates/album.html +++ b/templates/album.html @@ -47,12 +47,12 @@ p {% endfor %} {% endif %} + {% set photos = album.photos() %} Download: - These files - {% if sub_albums %} | Include children{% endif %} + {% if photos %}These files{% endif %} + {% if sub_albums %}Include children{% endif %} - {% set photos = album.photos() %} {% if photos %}