diff --git a/assets/less/mio/main.less b/assets/less/mio/main.less index 480159ed..25751773 100644 --- a/assets/less/mio/main.less +++ b/assets/less/mio/main.less @@ -11,7 +11,7 @@ :root { --site-max-width: @site-max-width; - --site-background-meta: initial; + --site-background-meta: no-repeat center / cover; --site-background-image: initial; --accent-colour: @default-accent-colour; diff --git a/build.php b/build.php index 43cc4fbd..6633e277 100644 --- a/build.php +++ b/build.php @@ -71,7 +71,7 @@ function deleteAllFilesInDir(string $dir, string $pattern): void $files = globDir($dir, $pattern); foreach ($files as $file) { - safe_delete($file); + unlink($file); misuzu_log("Deleted '{$file}'"); } } diff --git a/public/profile.php b/public/profile.php index d4eb96b5..81af2466 100644 --- a/public/profile.php +++ b/public/profile.php @@ -39,6 +39,21 @@ switch ($mode) { echo file_get_contents($avatar_filename); break; + case 'background': + $user_background = build_path( + create_directory(build_path($app->getStoragePath(), 'backgrounds/original')), + "{$user_id}.msz" + ); + + if (!is_file($user_background)) { + echo render_error(404); + break; + } + + header('Content-Type: ' . mime_content_type($user_background)); + echo file_get_contents($user_background); + break; + case 'view': default: $getProfile = Database::prepare(' @@ -80,7 +95,10 @@ switch ($mode) { break; } - tpl_vars(compact('profile')); + tpl_vars([ + 'profile' => $profile, + 'has_background' => is_file(build_path($app->getStoragePath(), 'backgrounds/original', "{$profile['user_id']}.msz")), + ]); echo tpl_render('user.view'); break; } diff --git a/public/settings.php b/public/settings.php index d4d0246e..1dffaf61 100644 --- a/public/settings.php +++ b/public/settings.php @@ -11,6 +11,7 @@ $userPerms = perms_get_user(MSZ_PERMS_USER, $app->getUserId()); $perms = [ 'edit_profile' => perms_check($userPerms, MSZ_PERM_USER_EDIT_PROFILE), 'edit_avatar' => perms_check($userPerms, MSZ_PERM_USER_CHANGE_AVATAR), + 'edit_background' => perms_check($userPerms, MSZ_PERM_USER_CHANGE_BACKGROUND), ]; if (!$app->hasActiveSession()) { diff --git a/src/Users/user.php b/src/Users/user.php index 129ed31c..d16fa106 100644 --- a/src/Users/user.php +++ b/src/Users/user.php @@ -5,6 +5,7 @@ use Misuzu\IO\File; define('MSZ_PERM_USER_EDIT_PROFILE', 1); define('MSZ_PERM_USER_CHANGE_AVATAR', 1 << 1); +define('MSZ_PERM_USER_CHANGE_BACKGROUND', 1 << 2); define('MSZ_PERM_USER_MANAGE_USERS', 1 << 20); define('MSZ_PERM_USER_MANAGE_ROLES', 1 << 21); diff --git a/templates/master.twig b/templates/master.twig index 061dd9c1..b33c7691 100644 --- a/templates/master.twig +++ b/templates/master.twig @@ -17,6 +17,13 @@ } {% endif %} + {% if site_background_url is defined %} + + {% endif %} {% include '_layout/header.twig' %} diff --git a/templates/settings/account.twig b/templates/settings/account.twig index 28e81094..79a3939e 100644 --- a/templates/settings/account.twig +++ b/templates/settings/account.twig @@ -134,7 +134,6 @@
  • Guidelines
  • Keep things sane and suitable for all ages.
  • Image may not exceed the {{ avatar_max_filesize|byte_symbol(true) }} filesize limit.
  • -
  • Avatar
  • May not be larger than {{ avatar_max_width }}x{{ avatar_max_height }}.
  • Will be centre cropped to be 200x200.
  • Animated gif images are allowed.
  • @@ -192,4 +191,70 @@ }); {% endif %} + + {% if settings_perms.edit_background %} +
    +
    Background
    +
    + + + +
    +
    +
      +
    • Guidelines
    • +
    • Keep things sane and suitable for all ages.
    • +
    • Image may not exceed the {{ avatar_max_filesize|byte_symbol(true) }} filesize limit.
    • +
    • May not be larger than {{ avatar_max_width }}x{{ avatar_max_height }}.
    • +
    • Animated gif images are not allowed.
    • +
    +
    +
    + +
    + + +
    + + +
    +
    +
    +
    + + + {% endif %} {% endblock %} diff --git a/templates/user/view.twig b/templates/user/view.twig index e4c7fcc0..ac4eee88 100644 --- a/templates/user/view.twig +++ b/templates/user/view.twig @@ -8,6 +8,10 @@ {% set youtube_is_channel_id = profile.user_youtube|slice(0, 2) == 'UC' and profile.user_youtube|length == 24 %} +{% if has_background %} + {% set site_background_url = '/profile.php?m=background&u=' ~ profile.user_id %} +{% endif %} + {% set profile_fields = { 'twitter': { 'title': 'Twitter',