Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
504d8048
Commit
504d8048
authored
Mar 21, 2014
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove no longer used avatar support from utils module
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
1dde3554
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
65 deletions
+0
-65
weblate/trans/util.py
weblate/trans/util.py
+0
-65
No files found.
weblate/trans/util.py
View file @
504d8048
...
...
@@ -18,81 +18,16 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import
hashlib
from
django.core.exceptions
import
ImproperlyConfigured
from
django.contrib.sites.models
import
Site
from
django.core.cache
import
cache
from
django.utils.html
import
escape
from
django.conf
import
settings
from
importlib
import
import_module
import
urllib
import
time
import
random
import
os.path
try
:
import
libravatar
HAS_LIBRAVATAR
=
True
except
ImportError
:
HAS_LIBRAVATAR
=
False
AVATAR_URL_PREFIX
=
getattr
(
settings
,
'AVATAR_URL_PREFIX'
,
'https://seccdn.libravatar.org/'
)
# See http://wiki.libravatar.org/api/
# for available choices
AVATAR_DEFAULT_IMAGE
=
getattr
(
settings
,
'AVATAR_DEFAULT_IMAGE'
,
'identicon'
)
PLURAL_SEPARATOR
=
'
\
x1e
\
x1e
'
def
avatar_for_email
(
email
,
size
=
80
):
'''
Generates url for avatar.
'''
# Safely handle blank email
if
email
==
''
:
email
=
'noreply@weblate.org'
# Retrieve from cache
cache_key
=
'avatar-%s-%s'
%
(
email
,
size
)
url
=
cache
.
get
(
cache_key
)
if
url
is
not
None
:
return
url
if
HAS_LIBRAVATAR
:
# Use libravatar library if available
url
=
libravatar
.
libravatar_url
(
email
=
email
,
https
=
True
,
default
=
AVATAR_DEFAULT_IMAGE
,
size
=
size
)
else
:
# Fallback to standard method
mail_hash
=
hashlib
.
md5
(
email
.
lower
()).
hexdigest
()
url
=
"%savatar/%s?"
%
(
AVATAR_URL_PREFIX
,
mail_hash
)
url
+=
urllib
.
urlencode
({
's'
:
str
(
size
),
'd'
:
AVATAR_DEFAULT_IMAGE
})
# Store result in cache
cache
.
set
(
cache_key
,
url
,
3600
*
24
)
return
escape
(
url
)
def
is_plural
(
text
):
'''
Checks whether string is plural form.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment