link to inserted game
parent
7f1d52e86a
commit
1863dceb44
|
@ -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(
|
||||
|
|
|
@ -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 =>
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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] ? `<span class="by">${commentAuthorText(comment.by)}</span>` : '',
|
||||
truncated = truncateComment(comment.text, 400, ctx);
|
||||
return h(sel, {
|
||||
hook: innerHTML(truncated, text => by + enrichText(text, true))
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}, [
|
||||
|
|
|
@ -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] ? `<span class="by">${commentAuthorText(comment.by)}</span>` : '',
|
||||
truncated = truncateComment(comment.text, 300, ctx);
|
||||
return h('comment', {
|
||||
hook: innerHTML(truncated, text => by + enrichText(text, true))
|
||||
});
|
||||
}).filter(nonEmpty);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue