mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-04-09 05:16:49 +00:00
created letter-avatars.ts
added @types/randomcolor Signed-off-by: Philip Molares <philip.molares@udo.edu> Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
parent
7cdcf627db
commit
f9193822a7
3 changed files with 15 additions and 10 deletions
|
@ -1,12 +1,11 @@
|
|||
'use strict'
|
||||
// external modules
|
||||
const crypto = require('crypto')
|
||||
const randomcolor = require('randomcolor')
|
||||
const config = require('./config')
|
||||
import { createHash } from 'crypto'
|
||||
import randomColor from 'randomcolor'
|
||||
import config from './config'
|
||||
|
||||
// core
|
||||
exports.generateAvatar = function (name) {
|
||||
const color = randomcolor({
|
||||
export function generateAvatar (name: string): string {
|
||||
const color = randomColor({
|
||||
seed: name,
|
||||
luminosity: 'dark'
|
||||
})
|
||||
|
@ -25,16 +24,16 @@ exports.generateAvatar = function (name) {
|
|||
return svg
|
||||
}
|
||||
|
||||
exports.generateAvatarURL = function (name, email = '', big = true) {
|
||||
export function generateAvatarURL (name: string, email = '', big = true): string {
|
||||
let photo
|
||||
if (typeof email !== 'string') {
|
||||
if (email.length === 0) {
|
||||
email = '' + name + '@example.com'
|
||||
}
|
||||
name = encodeURIComponent(name)
|
||||
|
||||
let hash = crypto.createHash('md5')
|
||||
const hash = createHash('md5')
|
||||
hash.update(email.toLowerCase())
|
||||
let hexDigest = hash.digest('hex')
|
||||
const hexDigest = hash.digest('hex')
|
||||
|
||||
if (email !== '' && config.allowGravatar) {
|
||||
photo = 'https://cdn.libravatar.org/avatar/' + hexDigest
|
|
@ -17,6 +17,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@passport-next/passport-openid": "^1.0.0",
|
||||
"@types/randomcolor": "^0.5.4",
|
||||
"Idle.Js": "git+https://github.com/shawnmclean/Idle.js",
|
||||
"archiver": "^2.1.1",
|
||||
"async": "^2.1.4",
|
||||
|
|
|
@ -202,6 +202,11 @@
|
|||
resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.1.tgz#937fab3194766256ee09fcd40b781740758617e7"
|
||||
integrity sha512-lhbQXx9HKZAPgBkISrBcmAcMpZsmpe/Cd/hY7LGZS5OfkySUBItnPZHgQPssWYUET8elF+yCFBbP1Q0RZPTdaw==
|
||||
|
||||
"@types/randomcolor@^0.5.4":
|
||||
version "0.5.4"
|
||||
resolved "https://registry.yarnpkg.com/@types/randomcolor/-/randomcolor-0.5.4.tgz#75230e780326bf372c13015c361dddca1087eb0f"
|
||||
integrity sha512-7pIw2aYtWXEiqfP01L1+b+Xk3mGGKA14yW492CfaR0lliSM4W6PGB/uhjQX08kFMEK8sAOrT3ufiKUnLlG0ulw==
|
||||
|
||||
"@types/range-parser@*":
|
||||
version "1.2.3"
|
||||
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.3.tgz#7ee330ba7caafb98090bece86a5ee44115904c2c"
|
||||
|
|
Loading…
Add table
Reference in a new issue