Skip to content

Commit 48e7259

Browse files
committed
hover displays submission path
1 parent b9b048a commit 48e7259

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

compare50/_renderer/_renderer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def percentage(self):
6868

6969
@attr.s(slots=True)
7070
class HTMLSubmission:
71+
path = attr.ib(converter=str)
7172
name = attr.ib(converter=str)
7273
files = attr.ib()
7374
num_chars_matched = attr.ib()
@@ -131,7 +132,7 @@ def render(pass_to_results, dest, sub_to_name):
131132

132133
for sub in subs:
133134
graph_info["nodes"].append({"id": sub_to_name[sub]})
134-
graph_info["data"][sub_to_name[sub]] = {"is_archive": sub.is_archive}
135+
graph_info["data"][sub_to_name[sub]] = {"is_archive": sub.is_archive, "path": str(sub.path)}
135136

136137
index_css = common_css + [read_file(STATIC / "index.css")]
137138
index_js = [read_file(STATIC / f) for f in ("d3.v4.min.js", "d3-scale-chromatic.v1.min.js", "d3-simple-slider.js", "index.js")]
@@ -287,7 +288,7 @@ def html_submission(self, submission, file_to_spans, ignored_spans):
287288
html_files = self.html_files(submission, file_to_spans, ignored_spans)
288289
num_chars_matched = sum(f.num_chars_matched for f in html_files)
289290
num_chars = sum(f.num_chars for f in html_files)
290-
return HTMLSubmission(self.sub_to_name[submission], html_files, num_chars_matched, num_chars)
291+
return HTMLSubmission(submission.path, self.sub_to_name[submission], html_files, num_chars_matched, num_chars)
291292

292293
def data(self, result, html_fragments, ignored_spans):
293294
fragment_to_spans = {}

compare50/_renderer/static/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,11 @@ function update_index() {
361361
new_trs.append("td")
362362
.attr("class", "sub_name")
363363
.datum(d => d[field])
364-
.html(d => GRAPH.data[d.id].is_archive ? `${ARCHIVE_IMG} ${d.id}` : d.id);
364+
.html(d => {
365+
const fic_name = GRAPH.data[d.id].is_archive ? `${ARCHIVE_IMG} ${d.id}` : d.id;
366+
const path = GRAPH.data[d.id].path || '';
367+
return `<span title="${path}">${fic_name}</span>`;
368+
});
365369
}
366370

367371
new_trs.append("td")

compare50/_renderer/templates/match.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="row sticky-top bg-dark text-light" id="{{name}}sub_names">
55
{% for sub in sub_a, sub_b %}
66
<div class="col-sm-6 col-2 sub_name">
7-
<h5>{{sub.name}} ({{sub.percentage}}%)</h5>
7+
<h5 title="{{sub.path}}">{{sub.name}} ({{sub.percentage}}%)</h5>
88
</div>
99
{% endfor %}
1010
</div>

0 commit comments

Comments
 (0)