Move /file/ urls to /photo/id/download.

master
voussoir 2022-11-11 21:35:29 -08:00
parent 25b0f4106f
commit e3a0b3898f
3 changed files with 7 additions and 7 deletions

View File

@ -35,8 +35,8 @@ def get_photo_json(photo_id):
photo = flasktools.json_response(photo) photo = flasktools.json_response(photo)
return photo return photo
@site.route('/file/<photo_id>') @site.route('/photo/<photo_id>/download')
@site.route('/file/<photo_id>/<basename>') @site.route('/photo/<photo_id>/download/<basename>')
def get_file(photo_id, basename=None): def get_file(photo_id, basename=None):
photo_id = photo_id.split('.')[0] photo_id = photo_id.split('.')[0]
photo = common.P.get_photo(photo_id) photo = common.P.get_photo(photo_id)
@ -51,7 +51,7 @@ def get_file(photo_id, basename=None):
if use_original_filename: if use_original_filename:
download_as = photo.basename download_as = photo.basename
else: else:
download_as = photo.id + photo.dot_extension download_as = f'{photo.id}{photo.dot_extension}'
download_as = etiquette.helpers.remove_path_badchars(download_as) download_as = etiquette.helpers.remove_path_badchars(download_as)
download_as = urllib.parse.quote(download_as) download_as = urllib.parse.quote(download_as)

View File

@ -42,9 +42,9 @@ def comma_join(l):
@filter_function @filter_function
def file_link(photo, short=False): def file_link(photo, short=False):
if short: if short:
return f'/file/{photo.id}{photo.dot_extension}' return f'/photo/{photo.id}/download/{photo.id}{photo.dot_extension}'
basename = jinja2.filters.do_urlencode(photo.basename) basename = jinja2.filters.do_urlencode(photo.basename)
return f'/file/{photo.id}/{basename}' return f'/photo/{photo.id}/download/{basename}'
@filter_function @filter_function
def islice(gen, start, stop): def islice(gen, start, stop):

View File

@ -143,10 +143,10 @@ function file_link(photo, short)
{ {
if (short) if (short)
{ {
return `/file/${photo.id}${photo.dot_extension}`; return `/photo/${photo.id}/download/${photo.id}${photo.dot_extension}`;
} }
const basename = escape(photo.filename); const basename = escape(photo.filename);
return `/file/${photo.id}/${basename}`; return `/photo/${photo.id}/download/${basename}`;
} }
cards.photos.create = cards.photos.create =