camper/deploy
jordi fita mas da127124a1 Add cover media to campsite types
This is the image that is shown at the home page, and maybe other pages
in the future.  We can not use a static file because this image can be
changed by the customer, not us; just like name and description.

I decided to keep the actual media content in the database, but to copy
this file out to the file system the first time it is accessed. This is
because we are going to replicate the database to a public instance that
must show exactly the same image, but the customer will update the image
from the private instance, behind a firewall.  We could also synchronize
the folder where they upload the images, the same way we will replicate,
but i thought that i would make the whole thing a little more brittle:
this way if it can replicate the update of the media, it is impossible
to not have its contents; dumping it to a file is to improve subsequent
requests to the same media.

I use the hex representation of the media’s hash as the URL to the
resource, because PostgreSQL’s base64 is not URL save (i.e., it uses
RFC2045’s charset that includes the forward slash[0]), and i did not
feel necessary write a new function just to slightly reduce the URLs’
length.

Before checking if the file exists, i make sure that the given hash is
an hex string, like i do for UUID, otherwise any other check is going
to fail for sure.  I moved out hex.Valid function from UUID to check for
valid hex values, but the actual hash check is inside app/media because
i doubt it will be used outside that module.

[0]: https://datatracker.ietf.org/doc/html/rfc2045#section-6.8
2023-09-10 03:04:18 +02:00
..
add_campsite.sql Add the campsite relation, HTTP handlers, and form 2023-08-14 20:18:26 +02:00
add_campsite_type.sql Add cover media to campsite types 2023-09-10 03:04:18 +02:00
add_media.sql Add media relation and add_media function 2023-09-08 20:03:26 +02:00
add_season.sql Add seasons’ relation, functions, and admin section 2023-08-16 20:15:57 +02:00
available_countries.sql Add company and company_user relations, along with their dependencies 2023-07-29 04:25:56 +02:00
available_currencies.sql Add company and company_user relations, along with their dependencies 2023-07-29 04:25:56 +02:00
available_languages.sql Add authentication relations, views, and functions for PostgreSQL 2023-07-22 01:59:12 +02:00
build_cookie.sql Add authentication relations, views, and functions for PostgreSQL 2023-07-22 01:59:12 +02:00
campsite.sql Add the campsite relation, HTTP handlers, and form 2023-08-14 20:18:26 +02:00
campsite_type.sql Add cover media to campsite types 2023-09-10 03:04:18 +02:00
change_password.sql Add authentication relations, views, and functions for PostgreSQL 2023-07-22 01:59:12 +02:00
check_cookie.sql Move the user role down to company_user relation 2023-08-08 02:22:16 +02:00
color.sql Add seasons’ relation, functions, and admin section 2023-08-16 20:15:57 +02:00
company.sql Move the user role down to company_user relation 2023-08-08 02:22:16 +02:00
company_host.sql Use HTTP Host to establish the request’s company 2023-08-03 20:21:21 +02:00
company_user.sql Move the user role down to company_user relation 2023-08-08 02:22:16 +02:00
country.sql Add company and company_user relations, along with their dependencies 2023-07-29 04:25:56 +02:00
country_code.sql Add company and company_user relations, along with their dependencies 2023-07-29 04:25:56 +02:00
country_i18n.sql Add company and company_user relations, along with their dependencies 2023-07-29 04:25:56 +02:00
currency.sql Add company and company_user relations, along with their dependencies 2023-07-29 04:25:56 +02:00
currency_code.sql Add company and company_user relations, along with their dependencies 2023-07-29 04:25:56 +02:00
current_company_id.sql Move the user role down to company_user relation 2023-08-08 02:22:16 +02:00
current_user_cookie.sql Add authentication relations, views, and functions for PostgreSQL 2023-07-22 01:59:12 +02:00
current_user_email.sql Add authentication relations, views, and functions for PostgreSQL 2023-07-22 01:59:12 +02:00
edit_campsite.sql Add the campsite relation, HTTP handlers, and form 2023-08-14 20:18:26 +02:00
edit_campsite_type.sql Add cover media to campsite types 2023-09-10 03:04:18 +02:00
edit_season.sql Add seasons’ relation, functions, and admin section 2023-08-16 20:15:57 +02:00
email.sql Add authentication relations, views, and functions for PostgreSQL 2023-07-22 01:59:12 +02:00
encrypt_password.sql Add authentication relations, views, and functions for PostgreSQL 2023-07-22 01:59:12 +02:00
ensure_role_exists.sql Move the user role down to company_user relation 2023-08-08 02:22:16 +02:00
extension_citext.sql Add authentication relations, views, and functions for PostgreSQL 2023-07-22 01:59:12 +02:00
extension_pg_libphonenumber.sql Add company and company_user relations, along with their dependencies 2023-07-29 04:25:56 +02:00
extension_pgcrypto.sql Add authentication relations, views, and functions for PostgreSQL 2023-07-22 01:59:12 +02:00
extension_uri.sql Add company and company_user relations, along with their dependencies 2023-07-29 04:25:56 +02:00
extension_vat.sql Add company and company_user relations, along with their dependencies 2023-07-29 04:25:56 +02:00
input_is_valid.sql Add the form to update company’s tax details 2023-08-15 22:35:21 +02:00
input_is_valid_phone.sql Add the form to update company’s tax details 2023-08-15 22:35:21 +02:00
language.sql Add authentication relations, views, and functions for PostgreSQL 2023-07-22 01:59:12 +02:00
login.sql Add authentication relations, views, and functions for PostgreSQL 2023-07-22 01:59:12 +02:00
login_attempt.sql Add authentication relations, views, and functions for PostgreSQL 2023-07-22 01:59:12 +02:00
logout.sql Add authentication relations, views, and functions for PostgreSQL 2023-07-22 01:59:12 +02:00
media.sql Add media relation and add_media function 2023-09-08 20:03:26 +02:00
media_type.sql Add media relation and add_media function 2023-09-08 20:03:26 +02:00
policies_company.sql Move the user role down to company_user relation 2023-08-08 02:22:16 +02:00
roles.sql Add authentication relations, views, and functions for PostgreSQL 2023-07-22 01:59:12 +02:00
schema_auth.sql Add authentication relations, views, and functions for PostgreSQL 2023-07-22 01:59:12 +02:00
schema_camper.sql Add authentication relations, views, and functions for PostgreSQL 2023-07-22 01:59:12 +02:00
schema_public.sql Add authentication relations, views, and functions for PostgreSQL 2023-07-22 01:59:12 +02:00
season.sql Add seasons’ relation, functions, and admin section 2023-08-16 20:15:57 +02:00
set_cookie.sql Move the user role down to company_user relation 2023-08-08 02:22:16 +02:00
to_color.sql Add seasons’ relation, functions, and admin section 2023-08-16 20:15:57 +02:00
to_integer.sql Add seasons’ relation, functions, and admin section 2023-08-16 20:15:57 +02:00
user.sql Move the user role down to company_user relation 2023-08-08 02:22:16 +02:00
user_profile.sql Move the user role down to company_user relation 2023-08-08 02:22:16 +02:00