文档版本显示提交信息
This commit is contained in:
parent
b1ad58a121
commit
95d27a4a0a
@ -33,6 +33,7 @@
|
||||
<div class="revision__header flex flex--column">
|
||||
<user-name :user-id="revision.sub"></user-name>
|
||||
<div class="revision__created">{{revision.created | formatTime}}</div>
|
||||
<div class="revision__msg">{{revision.message}}</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
@ -412,6 +413,14 @@ export default {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.revision__msg {
|
||||
font-size: 0.75em;
|
||||
opacity: 0.6;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.layout--revision {
|
||||
.cledit-section *,
|
||||
.cl-preview-section * {
|
||||
|
@ -70,6 +70,7 @@ export default new Provider({
|
||||
return {
|
||||
sub,
|
||||
id: entry.version,
|
||||
message: entry.commit && entry.commit.message,
|
||||
created: new Date(entry.committed_at).getTime(),
|
||||
};
|
||||
});
|
||||
|
@ -155,6 +155,7 @@ export default new Provider({
|
||||
return {
|
||||
id: sha,
|
||||
sub,
|
||||
message: commit.message,
|
||||
created: date ? new Date(date).getTime() : 1,
|
||||
};
|
||||
});
|
||||
|
@ -278,6 +278,7 @@ export default new Provider({
|
||||
return {
|
||||
id: sha,
|
||||
sub,
|
||||
message: commit.message,
|
||||
created: new Date(date).getTime(),
|
||||
};
|
||||
});
|
||||
|
@ -237,6 +237,7 @@ export default new Provider({
|
||||
return {
|
||||
id: sha,
|
||||
sub,
|
||||
message: commit.message,
|
||||
created: new Date(date).getTime(),
|
||||
};
|
||||
});
|
||||
|
@ -145,6 +145,7 @@ export default new Provider({
|
||||
return {
|
||||
id: sha,
|
||||
sub,
|
||||
message: commit.message,
|
||||
created: date ? new Date(date).getTime() : 1,
|
||||
};
|
||||
});
|
||||
|
@ -266,6 +266,7 @@ export default new Provider({
|
||||
return {
|
||||
id: sha,
|
||||
sub,
|
||||
message: commit.message,
|
||||
created: new Date(date).getTime(),
|
||||
};
|
||||
});
|
||||
|
@ -134,14 +134,17 @@ export default new Provider({
|
||||
user = author;
|
||||
} else if (committer && committer.login) {
|
||||
user = committer;
|
||||
} else if (commit && commit.author) {
|
||||
user = commit.author;
|
||||
}
|
||||
const sub = `${githubHelper.subPrefix}:${user.id}`;
|
||||
userSvc.addUserInfo({ id: sub, name: user.login, imageUrl: user.avatar_url });
|
||||
const sub = `${githubHelper.subPrefix}:${user.id || user.name}`;
|
||||
userSvc.addUserInfo({ id: sub, name: user.login || user.name, imageUrl: user.avatar_url });
|
||||
const date = (commit.author && commit.author.date)
|
||||
|| (commit.committer && commit.committer.date);
|
||||
return {
|
||||
id: sha,
|
||||
sub,
|
||||
message: commit.message,
|
||||
created: date ? new Date(date).getTime() : 1,
|
||||
};
|
||||
});
|
||||
|
@ -254,15 +254,18 @@ export default new Provider({
|
||||
user = author;
|
||||
} else if (committer && committer.login) {
|
||||
user = committer;
|
||||
} else if (commit && commit.author) {
|
||||
user = commit.author;
|
||||
}
|
||||
const sub = `${githubHelper.subPrefix}:${user.id}`;
|
||||
userSvc.addUserInfo({ id: sub, name: user.login, imageUrl: user.avatar_url });
|
||||
const sub = `${githubHelper.subPrefix}:${user.id || user.name}`;
|
||||
userSvc.addUserInfo({ id: sub, name: user.login || user.name, imageUrl: user.avatar_url });
|
||||
const date = (commit.author && commit.author.date)
|
||||
|| (commit.committer && commit.committer.date)
|
||||
|| 1;
|
||||
return {
|
||||
id: sha,
|
||||
sub,
|
||||
message: commit.message,
|
||||
created: new Date(date).getTime(),
|
||||
};
|
||||
});
|
||||
|
@ -148,6 +148,7 @@ export default new Provider({
|
||||
return {
|
||||
id: entry.id,
|
||||
sub,
|
||||
message: entry.commit && entry.commit.message,
|
||||
created: date ? new Date(date).getTime() : 1,
|
||||
};
|
||||
});
|
||||
|
@ -270,6 +270,7 @@ export default new Provider({
|
||||
return {
|
||||
id: entry.id,
|
||||
sub,
|
||||
message: entry.commit && entry.commit.message,
|
||||
created: date ? new Date(date).getTime() : 1,
|
||||
};
|
||||
});
|
||||
|
@ -65,62 +65,6 @@ function strftime(time, formatString) {
|
||||
});
|
||||
}
|
||||
|
||||
let dayFirst = null;
|
||||
let yearSeparator = null;
|
||||
|
||||
// Private: Determine if the day should be formatted before the month name in
|
||||
// the user's current locale. For example, `9 Jun` for en-GB and `Jun 9`
|
||||
// for en-US.
|
||||
//
|
||||
// Returns true if the day appears before the month.
|
||||
function isDayFirst() {
|
||||
if (dayFirst !== null) {
|
||||
return dayFirst;
|
||||
}
|
||||
|
||||
if (!('Intl' in window)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const options = { day: 'numeric', month: 'short' };
|
||||
const formatter = new window.Intl.DateTimeFormat(undefined, options);
|
||||
const output = formatter.format(new Date(0));
|
||||
|
||||
dayFirst = !!output.match(/^\d/);
|
||||
return dayFirst;
|
||||
}
|
||||
|
||||
// Private: Determine if the year should be separated from the month and day
|
||||
// with a comma. For example, `9 Jun 2014` in en-GB and `Jun 9, 2014` in en-US.
|
||||
//
|
||||
// Returns true if the date needs a separator.
|
||||
function isYearSeparator() {
|
||||
if (yearSeparator !== null) {
|
||||
return yearSeparator;
|
||||
}
|
||||
|
||||
if (!('Intl' in window)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const options = { day: 'numeric', month: 'short', year: 'numeric' };
|
||||
const formatter = new window.Intl.DateTimeFormat(undefined, options);
|
||||
const output = formatter.format(new Date(0));
|
||||
|
||||
yearSeparator = !!output.match(/\d,/);
|
||||
return yearSeparator;
|
||||
}
|
||||
|
||||
// Private: Determine if the date occurs in the same year as today's date.
|
||||
//
|
||||
// date - The Date to test.
|
||||
//
|
||||
// Returns true if it's this year.
|
||||
function isThisYear(date) {
|
||||
const now = new Date();
|
||||
return now.getUTCFullYear() === date.getUTCFullYear();
|
||||
}
|
||||
|
||||
class RelativeTime {
|
||||
constructor(date) {
|
||||
this.date = date;
|
||||
@ -128,7 +72,7 @@ class RelativeTime {
|
||||
|
||||
toString() {
|
||||
const ago = this.timeElapsed();
|
||||
return ago || `on ${this.formatDate()}`;
|
||||
return ago || `${this.formatDate()}`;
|
||||
}
|
||||
|
||||
timeElapsed() {
|
||||
@ -158,11 +102,7 @@ class RelativeTime {
|
||||
}
|
||||
|
||||
formatDate() {
|
||||
let format = isDayFirst() ? '%e %b' : '%b %e';
|
||||
if (!isThisYear(this.date)) {
|
||||
format += isYearSeparator() ? ', %Y' : ' %Y';
|
||||
}
|
||||
return strftime(this.date, format);
|
||||
return strftime(this.date, '%Y-%m-%d');
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user