mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
修复discussion模块
This commit is contained in:
1 parent
2554cf660a
commit
33e277f28f
30 files changed
+2460
-187
No files matched your search
+4
-1
@@ -1,8 +1,9 @@
|
||||
const md5 = require('./md5');
|
||||
|
||||
exports.gravatar_url = function gravatarUrl(email, size) {
|
||||
exports.gravatar_url = function gravatarUrl(email, size = 32) {
|
||||
return `//gravatar.loli.net/avatar/${md5((email || '').toString().trim().toLowerCase())}?d=mm&s=${size}`;
|
||||
};
|
||||
|
||||
exports.datetime_span = function datetimeSpan(dt, relative = true, format = '%Y-%m-%d %H:%M:%S') {
|
||||
if (!dt) return 'DATETIME_SPAN_ERROR';
|
||||
if (dt.generationTime) dt = new Date(dt.generationTime * 1000);
|
||||
@@ -13,6 +14,7 @@ exports.datetime_span = function datetimeSpan(dt, relative = true, format = '%Y-
|
||||
dt.format(format),
|
||||
);
|
||||
};
|
||||
|
||||
exports.paginate = function* paginate(page, numPages) {
|
||||
const radius = 2; let first; let
|
||||
last;
|
||||
@@ -33,6 +35,7 @@ exports.paginate = function* paginate(page, numPages) {
|
||||
if (page < numPages) yield ['next', page + 1];
|
||||
yield ['last', numPages];
|
||||
};
|
||||
|
||||
exports.format_size = function formatSize(size, base = 1) {
|
||||
size *= base;
|
||||
const unit = 1024;
|
||||
|
||||
Reference in new issue
Block a user