Commit 4d943b81 authored by njean42's avatar njean42
Browse files

Show different panels when comparing two versions.

parent 163dc105
......@@ -33,7 +33,7 @@ class HTML:
pageId = 0
def side_by_side_panels(img,jsons,v1,v2,images_dir):
def side_by_side_panels(img,jsons,v1,v2,images_dir,known_panels):
html = '<h2>{0}</h2><div class="sidebyside"><div class="version">{1}</div><div class="version">{2}</div></div><div class="sidebyside">'.format(img,v1,v2)
oneside = """
......@@ -42,13 +42,16 @@ class HTML:
var reader = new Reader({{
container: $('#page{id}'),
comicsJson: {json},
images_dir: '{images_dir}'
images_dir: '{images_dir}',
known_panels: {known_panels}
}});
reader.loadPage(0);
</script>
"""
i = -1
for js in jsons:
html += oneside.format(id=HTML.pageId,json=js,images_dir=images_dir)
i += 1
html += oneside.format(id=HTML.pageId,json=js,images_dir=images_dir,known_panels=known_panels[i])
HTML.pageId += 1
html += '</div>'
......
......@@ -25,6 +25,8 @@ class Reader {
}
this.comic = options.comicsJson;
this.known_panels = options.known_panels ? options.known_panels : [];
// init attributes
this.currpage = 0;
this.currpanel = 0;
......@@ -206,13 +208,16 @@ class Reader {
var [imgw,imgh] = imginfo['size'];
var i =1;
var i = 1;
for (var p in imginfo['panels'])
{
var unknown = !this.known_panels.includes(parseInt(p));
p = imginfo['panels'][p];
var [x,y,w,h] = p;
var panel = $('<div class="panel"><!-- --></div>');
if (unknown)
panel.addClass('unknown');
var panelcss = {
top: '' + y/imgh*100 + '%',
left: '' + x/imgw*100 + '%',
......
......@@ -68,10 +68,13 @@ ul {
align-items: center;
}
.kumiko-reader.debug .container:not(.zoomed) .panel {
border: 2px solid red;
border: 2px solid #3498db;
margin-left: -2px;
margin-top: -2px;
}
.kumiko-reader.debug .container:not(.zoomed) .panel.unknown {
border: 4px solid #e74c3c;
}
.kumiko-reader.debug .container:not(.zoomed) .panel:hover,
.kumiko-reader.debug .container:not(.zoomed) .panel:active {
background-color: rgba(52,152,219,0.5);
......@@ -81,13 +84,16 @@ ul {
display: none;
}
.kumiko-reader.debug .container:not(.zoomed) .panel span {
color: red;
color: #3498db;
font-size: 75%;
background-color: white;
opacity: 0.9;
border-radius: 30px;
padding: 2px 6px;
}
.kumiko-reader.debug .container:not(.zoomed) .panel.unknown span {
color: #e74c3c;
}
.kumiko-reader.debug .container:not(.zoomed) .panel span.panelnb { font-size: 150%; }
/* Debug show panel edges */
......
......@@ -12,8 +12,8 @@ class Tester:
files = []
git_repo = 'https://framagit.org/nicooo/kumiko'
git_versions = [
# 'v1.0', 'v1.1',
'v1.11',
# 'v1.0', 'v1.1', 'v1.11',
'v1.2',
'current',
]
......@@ -108,25 +108,30 @@ class Tester:
print('error, image sizes are not the same',json1[p]['size'],json2[p]['size'])
continue
is_diff = False
if len(json1[p]['panels']) != len(json2[p]['panels']):
is_diff = True
else:
gutterThreshold = Kumiko.getGutterThreshold(json1[p]['size'])
for pan in range(len(json1[p]['panels'])):
p1 = Panel(json1[p]['panels'][pan], gutterThreshold/2)
p2 = Panel(json2[p]['panels'][pan], gutterThreshold/2)
if p1 != p2:
is_diff = True
break
gutterThreshold = Kumiko.getGutterThreshold(json1[p]['size'])
panels_v1 = list(map(lambda p: Panel(p, gutterThreshold/2), json1[p]['panels']))
panels_v2 = list(map(lambda p: Panel(p, gutterThreshold/2), json2[p]['panels']))
known_panels = [[],[]]
j = -1
for p1 in panels_v1:
j += 1
if p1 in panels_v2:
known_panels[0].append(j)
j = -1
for p2 in panels_v2:
j += 1
if p2 in panels_v1:
known_panels[1].append(j)
images_dir = f if os.path.isdir(f) else os.path.dirname(f)
images_dir = os.path.relpath(images_dir,'tests/results')+'/'
if is_diff:
if len(known_panels[0]) != len(panels_v1) or len(known_panels[1]) != len(panels_v2):
files_diff[json1[p]['filename']] = {
'jsons': [json.dumps([json1[p]]),json.dumps([json2[p]])],
'images_dir': images_dir
'images_dir': images_dir,
'known_panels': [json.dumps(known_panels[0]),json.dumps(known_panels[1])]
}
print('Found',len(files_diff),'differences')
......@@ -143,7 +148,7 @@ class Tester:
diff_file.write(HTML.nbdiffs(files_diff))
for img in files_diff:
diff_file.write(HTML.side_by_side_panels(img,files_diff[img]['jsons'],v1,v2,images_dir=files_diff[img]['images_dir']))
diff_file.write(HTML.side_by_side_panels(img,files_diff[img]['jsons'],v1,v2,images_dir=files_diff[img]['images_dir'], known_panels=files_diff[img]['known_panels']))
diff_file.write(HTML.footer)
diff_file.close()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment