mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
Merge pull request #52 from gordonbanderson/ISSUE8
Addition of Gravatars
This commit is contained in:
commit
ee3da5b38e
@ -26,6 +26,8 @@ class Commenting {
|
|||||||
'require_login' => false, // boolean, whether a user needs to login
|
'require_login' => false, // boolean, whether a user needs to login
|
||||||
'required_permission' => false, // required permission to comment (or array of permissions)
|
'required_permission' => false, // required permission to comment (or array of permissions)
|
||||||
'use_ajax_commenting' => true, // use ajax to post comments.
|
'use_ajax_commenting' => true, // use ajax to post comments.
|
||||||
|
'use_gravatar' => false, // set to true to show gravatar icons,
|
||||||
|
'gravatar_size' => 80, // size of gravatar in pixels. This is the same as the standard default
|
||||||
'show_comments_when_disabled' => false, // when comments are disabled should we show older comments (if available)
|
'show_comments_when_disabled' => false, // when comments are disabled should we show older comments (if available)
|
||||||
'order_comments_by' => "\"Created\" DESC",
|
'order_comments_by' => "\"Created\" DESC",
|
||||||
'comments_per_page' => 10,
|
'comments_per_page' => 10,
|
||||||
|
@ -394,4 +394,19 @@ class Comment extends DataObject {
|
|||||||
$config->set('URI.DisableExternalResources', true);
|
$config->set('URI.DisableExternalResources', true);
|
||||||
return new HTMLPurifier($config);
|
return new HTMLPurifier($config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Calcualate the gravatar link from the email address
|
||||||
|
*/
|
||||||
|
public function Gravatar() {
|
||||||
|
$gravatar = '';
|
||||||
|
$use_gravatar = Commenting::get_config_value($this->BaseClass, 'use_gravatar');
|
||||||
|
if ($use_gravatar) {
|
||||||
|
$gravatar = "http://www.gravatar.com/avatar/" . md5( strtolower(trim($this->Email)));
|
||||||
|
$gravatarsize = Commenting::get_config_value($this->BaseClass, 'gravatar_size');
|
||||||
|
$gravatar.= "?s=".$gravatarsize."&d=mm";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $gravatar;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,9 @@ The module provides a number of built in configuration settings below are the de
|
|||||||
'require_moderation' => false,
|
'require_moderation' => false,
|
||||||
'html_allowed' => false, // allow for sanitized HTML in comments
|
'html_allowed' => false, // allow for sanitized HTML in comments
|
||||||
'html_allowed_elements' => array('a', 'img', 'i', 'b'),
|
'html_allowed_elements' => array('a', 'img', 'i', 'b'),
|
||||||
'use_preview' => false, // preview formatted comment (when allowing HTML)
|
'use_preview' => false, // preview formatted comment (when allowing HTML),
|
||||||
|
'use_gravatar' => false,
|
||||||
|
'gravatar_size' => 80
|
||||||
);
|
);
|
||||||
|
|
||||||
If you want to customize any of the configuration options after you have added the extension (or
|
If you want to customize any of the configuration options after you have added the extension (or
|
||||||
@ -48,3 +50,13 @@ The easiest way to do this is through [Composer](http://getcomposer.org).
|
|||||||
**Important**: Rendering user-provided HTML on your website always risks
|
**Important**: Rendering user-provided HTML on your website always risks
|
||||||
exposing your users to cross-site scripting (XSS) attacks, if the HTML
|
exposing your users to cross-site scripting (XSS) attacks, if the HTML
|
||||||
isn't properly sanitized. Don't allow tags like `<script>` or arbitrary attributes.
|
isn't properly sanitized. Don't allow tags like `<script>` or arbitrary attributes.
|
||||||
|
|
||||||
|
## Gravatars
|
||||||
|
|
||||||
|
Gravatars can be turned on by adding this to your mysite/_config.php file
|
||||||
|
|
||||||
|
Commenting::set_config_value('SiteTree', 'use_gravatar', true);
|
||||||
|
|
||||||
|
The default size is 80 pixels, as per the gravatar site if the 's' parameter is omitted. To change this add the following (again to mysite/_config.php):
|
||||||
|
|
||||||
|
Commenting::set_config_value('SiteTree', 'gravatar_size', 40);
|
@ -1,4 +1,5 @@
|
|||||||
<div class="comment" id="<% if isPreview %>comment-preview<% else %>$Permalink<% end_if %>">
|
<div class="comment" id="<% if isPreview %>comment-preview<% else %>$Permalink<% end_if %>">
|
||||||
|
<% if $Gravatar %><img class="gravatar" src="$Gravatar" alt="Gravatar for $Name" title="Gravatar for $Name" /><% end_if %>
|
||||||
$EscapedComment
|
$EscapedComment
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user