mirror of
https://github.com/gitbucket/gitbucket.git
synced 2026-05-09 16:46:33 +02:00
Add query parameter by updatedDate for _avatar image for cache control.
This commit is contained in:
@@ -20,7 +20,7 @@ trait AvatarImageProvider { self: RequestCache =>
|
||||
if(account.image.isEmpty && context.settings.gravatar){
|
||||
s"""https://www.gravatar.com/avatar/${StringUtil.md5(account.mailAddress.toLowerCase)}?s=${size}&d=retro&r=g"""
|
||||
} else {
|
||||
s"""${context.path}/${account.userName}/_avatar"""
|
||||
s"""${context.path}/${account.userName}/_avatar?${helpers.hashDate(account.updatedDate)}"""
|
||||
}
|
||||
} getOrElse {
|
||||
s"""${context.path}/_unknown/_avatar"""
|
||||
@@ -31,7 +31,7 @@ trait AvatarImageProvider { self: RequestCache =>
|
||||
if(account.image.isEmpty && context.settings.gravatar){
|
||||
s"""https://www.gravatar.com/avatar/${StringUtil.md5(account.mailAddress.toLowerCase)}?s=${size}&d=retro&r=g"""
|
||||
} else {
|
||||
s"""${context.path}/${account.userName}/_avatar"""
|
||||
s"""${context.path}/${account.userName}/_avatar?${helpers.hashDate(account.updatedDate)}"""
|
||||
}
|
||||
} getOrElse {
|
||||
if(context.settings.gravatar){
|
||||
@@ -49,4 +49,4 @@ trait AvatarImageProvider { self: RequestCache =>
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,11 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
|
||||
*/
|
||||
def date(date: Date): String = new SimpleDateFormat("yyyy-MM-dd").format(date)
|
||||
|
||||
/**
|
||||
* Format java.util.Date to "yyyyMMDDHHmmss" (for url hash ex. /some/path.css?19800101010203
|
||||
*/
|
||||
def hashDate(date: Date): String = new SimpleDateFormat("yyyyMMddHHmmss").format(date)
|
||||
|
||||
/**
|
||||
* Returns singular if count is 1, otherwise plural.
|
||||
* If plural is not specified, returns singular + "s" as plural.
|
||||
|
||||
Reference in New Issue
Block a user