1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-22 04:23:01 +00:00

avatar: fix typo in uploaded avatar name & add new avatars_gravatar_enable setting

This commit is contained in:
Starbeamrainbowlabs 2020-07-10 19:46:06 +01:00
parent f078302c82
commit 41009bb810
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
4 changed files with 23 additions and 9 deletions

View file

@ -21,9 +21,10 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
- Added similar page suggestions between the bottom of the page content and the comments - control it with the new `similarpages_enabled` and `similarpages_count` settings. - Added similar page suggestions between the bottom of the page content and the comments - control it with the new `similarpages_enabled` and `similarpages_count` settings.
- Added absolute redirect support - use it like this: `# REDIRECT [display text](INSERT_REDIRECT_URL_HERE)` - Added absolute redirect support - use it like this: `# REDIRECT [display text](INSERT_REDIRECT_URL_HERE)`
- It's disabled by default due to potential security issues with untrusted editors - enable it with the new `redirect_absolute_enable` setting (default: : `false`) - It's disabled by default due to potential security issues with untrusted editors - enable it with the new `redirect_absolute_enable` setting (default: : `false`)
- Added new settings to control the commenting system - Added new settings to control various features more precisely
- `comment_enabled` controls whether _anyone_ is allowed to comment at all or not - `comment_enabled` controls whether _anyone_ is allowed to comment at all or not
- `comment_hide_all` determines whether the commenting system displays anything at all (if disabled, it's (almost) like the `feature-comments` doesn't exist - consider using the downloader to exclude the commenting system instead of enabling this setting) - `comment_hide_all` determines whether the commenting system displays anything at all (if disabled, it's (almost) like the `feature-comments` doesn't exist - consider using the downloader to exclude the commenting system instead of enabling this setting)
- `avatars_gravatar_enable` determines whether redirects to [gravatar.com](https://gravatar.com/) should be performed if a user hasn't yet uploaded an avatar (if disabled then a blank image is returned instead of a redirect).
### Changed ### Changed
- Fiddled with Parsedown & ParsedownExtra versions - Fiddled with Parsedown & ParsedownExtra versions
@ -40,6 +41,7 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
- Limited sidebar size to 20% of the screen width at most - Limited sidebar size to 20% of the screen width at most
- Fix the [large blank space problem](https://github.com/sbrl/Pepperminty-Wiki/blob/master/Changelog.md#fixed-3) in all themes - Fix the [large blank space problem](https://github.com/sbrl/Pepperminty-Wiki/blob/master/Changelog.md#fixed-3) in all themes
- Squashed the text `\A` appearing before tags at the bottom of pages for some users ([ref](https://gitter.im/Pepperminty-Wiki/Lobby?at=5f0632068342f4627401f145)) - Squashed the text `\A` appearing before tags at the bottom of pages for some users ([ref](https://gitter.im/Pepperminty-Wiki/Lobby?at=5f0632068342f4627401f145))
- Fixed an issue causing uploaded avatars not to render
## v0.21.1-hotfix1 ## v0.21.1-hotfix1

View file

@ -253,7 +253,7 @@ register_module([
* @apiParam {string} size The preferred size of the avatar * @apiParam {string} size The preferred size of the avatar
*/ */
add_action("avatar", function() { add_action("avatar", function() {
global $settings; global $settings, $pageindex;
$size = intval($_GET["size"] ?? 32); $size = intval($_GET["size"] ?? 32);
@ -261,15 +261,26 @@ register_module([
// No user specified // No user specified
if(empty($_GET["user"])) { if(empty($_GET["user"])) {
http_response_code(307); http_response_code(200);
header("x-reason: no-user-specified"); header("x-reason: no-user-specified");
header("location: https://gravatar.com/avatar/?default=blank"); header("content-type: image/png");
header("content-length: 101");
exit(base64_decode("iVBORw0KGgoAAAANSUhEUgAAAFAAAABQAQMAAAC032DuAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAABBJREFUGBljGAWjYBTQDQAAA3AAATXTgHYAAAAASUVORK5CYII="));
} }
$requested_username = $_GET["user"]; $requested_username = $_GET["user"];
$has_avatar = !empty($pageindex->{"Users/$requested_username/Avatar"}) && $pageindex->{"Users/$requested_username/Avatar"}->uploadedfile === true;
if(!$settings->avatars_gravatar_enabled && !$has_avatar) {
http_response_code(404);
header("x-reason: no-avatar-found-gravatar-disabled");
header("content-type: image/png");
header("content-length: 101");
exit(base64_decode("iVBORw0KGgoAAAANSUhEUgAAAFAAAABQAQMAAAC032DuAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAABBJREFUGBljGAWjYBTQDQAAA3AAATXTgHYAAAAASUVORK5CYII=")); // TODO: Refactor out into a separate function
}
// The user hasn't uploaded an avatar // The user hasn't uploaded an avatar
if(empty($pageindex->{"User/$requested_username/Avatar"}) || !$pageindex->{"User/$requested_username/Avatar"}->uploadedfile) { if(!$has_avatar) {
$user_fragment = !empty($settings->users->$requested_username->emailAddress) ? $settings->users->$requested_username->emailAddress : $requested_username; $user_fragment = !empty($settings->users->$requested_username->emailAddress) ? $settings->users->$requested_username->emailAddress : $requested_username;
http_response_code(307); http_response_code(307);

View file

@ -8,7 +8,7 @@ register_module([
"code" => function() { "code" => function() {
global $settings; global $settings;
/** /**
* @api {get} ?action=user-list[format=json] List all users * @api {get} ?action=user-list[&format=json] List all users
* @apiName UserList * @apiName UserList
* @apiGroup Utility * @apiGroup Utility
* @apiPermission Anonymous * @apiPermission Anonymous

View file

@ -228,9 +228,10 @@
"text/plain": "txt", "text/plain": "txt",
"audio/mpeg": "mp3" "audio/mpeg": "mp3"
}}, }},
"min_preview_size": { "type": "number", "description": "The minimum allowed size of generated preview images in pixels.", "default": 1}, "min_preview_size": { "type": "number", "description": "The minimum allowed size of generated preview images in pixels.", "default": 1 },
"max_preview_size": { "type": "number", "description": "The maximum allowed size of generated preview images in pixels.", "default": 2048}, "max_preview_size": { "type": "number", "description": "The maximum allowed size of generated preview images in pixels.", "default": 2048 },
"avatars_show": { "type": "checkbox", "description": "Whether or not to show avatars requires the 'user-preferences' and 'upload' modules, though uploads themselvess can be turned off so long as all avatars have already been uploaded - it's only the 'preview' action that's actually used.", "default": true}, "avatars_show": { "type": "checkbox", "description": "Whether or not to show avatars requires the 'user-preferences' and 'upload' modules, though uploads themselves can be turned off so long as all avatars have already been uploaded - it's only the 'preview' action that's actually used.", "default": true },
"avatars_gravatar_enable": { "type": "checkbox", "description": "Whether gravatars should be displayed if an uploaded avatar is not found. If disabled, users without avatars will show a blank image instead.", "default": true },
"avatars_size": { "type": "number", "description": "The image size to render avatars at. Does not affect the size they're stored at - only the inline rendered size (e.g. on the recent changes page etc.)", "default": 32}, "avatars_size": { "type": "number", "description": "The image size to render avatars at. Does not affect the size they're stored at - only the inline rendered size (e.g. on the recent changes page etc.)", "default": 32},
"search_characters_context": { "type": "number", "description": "The number of characters that should be displayed either side of a matching term in the context below each search result.", "default": 75}, "search_characters_context": { "type": "number", "description": "The number of characters that should be displayed either side of a matching term in the context below each search result.", "default": 75},
"search_characters_context_total": { "type": "number", "description": "The total number of characters that a search result context should display at most.", "default": 250 }, "search_characters_context_total": { "type": "number", "description": "The total number of characters that a search result context should display at most.", "default": 250 },