diff --git a/modules/study/src/main/Env.scala b/modules/study/src/main/Env.scala
index a07024e699..3f50e9464d 100644
--- a/modules/study/src/main/Env.scala
+++ b/modules/study/src/main/Env.scala
@@ -87,7 +87,8 @@ final class Env(
private lazy val explorerGame = new ExplorerGame(
importer = explorerImporter,
- lightUser = lightUserApi.sync
+ lightUser = lightUserApi.sync,
+ baseUrl = NetBaseUrl
)
private lazy val studyMaker = new StudyMaker(
diff --git a/modules/study/src/main/ExplorerGame.scala b/modules/study/src/main/ExplorerGame.scala
index 313f133e40..e43dcba0ef 100644
--- a/modules/study/src/main/ExplorerGame.scala
+++ b/modules/study/src/main/ExplorerGame.scala
@@ -12,7 +12,8 @@ import lila.user.User
private final class ExplorerGame(
importer: lila.explorer.ExplorerImporter,
- lightUser: LightUser.GetterSync
+ lightUser: LightUser.GetterSync,
+ baseUrl: String
) {
def quote(gameId: Game.ID): Fu[Option[Comment]] =
@@ -53,10 +54,12 @@ private final class ExplorerGame(
private def gameComment(game: Game) = Comment(
id = Comment.Id.make,
- text = Comment.Text(gameTitle(game)),
+ text = Comment.Text(s"${gameTitle(game)}, ${gameUrl(game)}"),
by = Comment.Author.Lichess
)
+ private def gameUrl(game: Game) = s"$baseUrl/${game.id}"
+
private def gameYear(pgn: Option[ParsedPgn], g: Game): Int = pgn.flatMap { p =>
p.tag(_.UTCDate) orElse p.tag(_.Date)
}.flatMap { pgnDate =>
diff --git a/public/stylesheets/analyse.css b/public/stylesheets/analyse.css
index 909ec8737a..2bc06c18fb 100644
--- a/public/stylesheets/analyse.css
+++ b/public/stylesheets/analyse.css
@@ -1264,7 +1264,8 @@ body.piece_letter .tview2 move {
white-space: nowrap;
font-weight: bold;
}
-.tview2 move.parent {
+.tview2 move.parent,
+.tview2 comment a {
color: #3893e8!important;
}
.tview2 move.current {
diff --git a/ui/analyse/src/treeView/columnView.ts b/ui/analyse/src/treeView/columnView.ts
index 9217046224..747c601a6f 100644
--- a/ui/analyse/src/treeView/columnView.ts
+++ b/ui/analyse/src/treeView/columnView.ts
@@ -8,6 +8,7 @@ import { authorText as commentAuthorText } from '../study/studyComments';
import AnalyseCtrl from '../ctrl';
import { MaybeVNodes, ConcealOf, Conceal } from '../interfaces';
import { nonEmpty, mainHook, nodeClasses, renderInlineCommentsOf, truncateComment, retroLine } from './treeView';
+import { enrichText, innerHTML } from '../util';
import { Ctx as BaseCtx, Opts as BaseOpts } from './treeView';
interface Ctx extends BaseCtx {
@@ -171,10 +172,11 @@ function renderMainlineCommentsOf(ctx: Ctx, node: Tree.Node, conceal: Conceal, w
else if (comment.text.indexOf('Mistake.') === 0) sel += '.mistake';
else if (comment.text.indexOf('Blunder.') === 0) sel += '.blunder';
if (conceal) sel += '.' + conceal;
- return h(sel, [
- node.comments![1] ? h('span.by', commentAuthorText(comment.by)) : null,
- truncateComment(comment.text, 400, ctx)
- ]);
+ const by = node.comments![1] ? `${commentAuthorText(comment.by)}` : '',
+ truncated = truncateComment(comment.text, 400, ctx);
+ return h(sel, {
+ hook: innerHTML(truncated, text => by + enrichText(text, true))
+ });
});
}
diff --git a/ui/analyse/src/treeView/inlineView.ts b/ui/analyse/src/treeView/inlineView.ts
index 4d6c8b3b17..b5003e1c70 100644
--- a/ui/analyse/src/treeView/inlineView.ts
+++ b/ui/analyse/src/treeView/inlineView.ts
@@ -24,7 +24,7 @@ function renderChildrenOf(ctx: Ctx, node: Tree.Node, opts: Opts): MaybeVNodes |
isMainline: true,
withIndex: opts.withIndex
}),
- ...renderInlineCommentsOf(ctx, main, true),
+ ...renderInlineCommentsOf(ctx, main),
h('interrupt', renderLines(ctx, cs.slice(1), {
parentPath: opts.parentPath,
isMainline: true
@@ -65,7 +65,7 @@ function renderLines(ctx: Ctx, nodes: Tree.Node[], opts: Opts): VNode {
function renderMoveAndChildrenOf(ctx: Ctx, node: Tree.Node, opts: Opts): MaybeVNodes {
const path = opts.parentPath + node.id,
- comments = renderInlineCommentsOf(ctx, node, true);
+ comments = renderInlineCommentsOf(ctx, node);
if (opts.truncate === 0) return [
h('move', { attrs: { p: path } }, '[...]')
];
@@ -110,7 +110,7 @@ export default function(ctrl: AnalyseCtrl): VNode {
showGlyphs: !!ctrl.study || ctrl.showComputer(),
showEval: !!ctrl.study || ctrl.showComputer()
};
- const commentTags = renderInlineCommentsOf(ctx, root, true);
+ const commentTags = renderInlineCommentsOf(ctx, root);
return h('div.tview2.inline', {
hook: mainHook(ctrl)
}, [
diff --git a/ui/analyse/src/treeView/treeView.ts b/ui/analyse/src/treeView/treeView.ts
index 1279010dd9..1132386f02 100644
--- a/ui/analyse/src/treeView/treeView.ts
+++ b/ui/analyse/src/treeView/treeView.ts
@@ -81,17 +81,15 @@ export function nodeClasses(c: AnalyseCtrl, path: Tree.Path): NodeClasses {
};
}
-export function renderInlineCommentsOf(ctx: Ctx, node: Tree.Node, rich?: boolean): MaybeVNodes {
+export function renderInlineCommentsOf(ctx: Ctx, node: Tree.Node): MaybeVNodes {
if (!ctx.ctrl.showComments || empty(node.comments)) return [];
return node.comments!.map(comment => {
if (comment.by === 'lichess' && !ctx.showComputer) return;
- const by = node.comments![1] ? h('span.by', commentAuthorText(comment.by)) : null;
- return rich ? h('comment', {
- hook: innerHTML(comment.text, text => enrichText(text, true))
- }) : h('comment', [
- by,
- truncateComment(comment.text, 300, ctx)
- ]);
+ const by = node.comments![1] ? `${commentAuthorText(comment.by)}` : '',
+ truncated = truncateComment(comment.text, 300, ctx);
+ return h('comment', {
+ hook: innerHTML(truncated, text => by + enrichText(text, true))
+ });
}).filter(nonEmpty);
}