Skip to content

Commit

Permalink
Merge pull request #503 from matchID-project/dev
Browse files Browse the repository at this point in the history
Fix firefox bug & gedcom fixes
  • Loading branch information
rhanka authored Mar 15, 2021
2 parents cc21a18 + bf62f29 commit 1e73b62
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 31 deletions.
13 changes: 7 additions & 6 deletions src/components/views/GedcomPersonCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
class="rf-card rf-card--horizontal rf-card--{expand ? "md": "sm"}"
class:rf-card--left-arrow={expand}
on:click={toggleExpand}
class:rf-inactive={(!active)&&(!focus)}
>
<div class="rf-card__img" style="position:relative">
<img
class="rf-background--{ active ? "bf" : "g400"}"
class="{ focus ? "rf-background--bf" : (active? "rf-callout--scheme-soft-blue-soft" : "rf-background--g400") }"
class:match={match}
alt={ record.sex }
src={ record.sex === 'M' ? '/male.svg' : '/female.svg' }
Expand Down Expand Up @@ -98,8 +99,10 @@
{/if}
{#if record.cons}
<p>
<strong>Conjoint</strong><br>
<a class="rf-link" href="#{record.cons.id}" title={record.cons.surn+' '+(record.cons.givn || '')}>{record.cons.surn} {record.cons.givn || ''}</a>
<strong>Conjoint{record.cons.lengh > 1 ? 's' : ''}</strong><br>
{#each record.cons as cons}
<a class="rf-link" href="#{cons.id}" title={cons.surn+' '+(cons.givn || '')}>{cons.surn} {cons.givn || ''}</a>
{/each}
</p>
{/if}
{#if record.chil}
Expand Down Expand Up @@ -136,14 +139,13 @@
export let mouseenter = () => {};
export let mouseleave = () => {};
export let active = false;
export let focus = false;
let match = false;
let linkCopied = false;
let expand;
$: console.log(record.note, note);
window.addEventListener('hashchange', () => {
expand = (window.location.hash.replace('#','') === id);
}, false)
Expand Down Expand Up @@ -187,7 +189,6 @@
}
return x && !match;
}).forEach(n => {
console.log('la',n);
note += '<br>' + `${n}`.replace(/(http:\S+)/g,'<a target="_blank" class="rf-link" href="$1">$1</a>')
});
}
Expand Down
85 changes: 63 additions & 22 deletions src/components/views/GedcomTree.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,46 @@
<div
class="rf-container-fluid"
on:click={actualizeLines}
on:mouseleave={() => {showFamily = undefined; showId = undefined}}
>
<div class="rf-grid-row rf-text--center">
<div class="rf-col-12 rf-margin-3N">
<strong>Visualisation des individus de l'arbre généalogique: </strong>
</div>
{#each Object.keys(gedcom).filter(x => /\@i.*@/i.test(x)).sort((a,b) => gedcom[a].rank - gedcom[b].rank) as id}
<GedcomPersonCard
id={id}
active={showFamily && ((showFamily === gedcom[id].fams) || (showFamily === gedcom[id].famc))}
record={gedcom[id]}
mouseenter={() => {
actualizeLines();
showFamily = gedcom[id].fams;
}}
/>
{#each Object.keys(gedcom)
.filter(x => /\@i.*@/i.test(x))
.map(i => Math.round(gedcom[i].rank))
.sort()
.filter(function(el,i,a){return i===a.indexOf(el)})
as gen}
<div class="rf-container-fluid">
<div class="rf-grid-row rf-text--center rf-margin-bottom-2N">
{#each Object.keys(gedcom)
.filter(i => /\@i.*@/i.test(i) && (Math.round(gedcom[i].rank) === gen))
as id}
<GedcomPersonCard
id={id}
focus={(showId === id)}
active={(!showId)
|| sameFamily(gedcom[id].fams,showFamily)
|| sameFamily(gedcom[id].famc,showFamily)
|| (gedcom[id].chil && gedcom[id].chil.some(c => c.id === showId))
}
record={gedcom[id]}
mouseenter={() => {
actualizeLines();
showFamily = gedcom[id].fams;
showId = id;
}}
/>
{/each}
</div>
</div>
{/each}
</div>
</div>
{#each Object.keys(gedcom).filter(x => /\@f.*@/i.test(x)) as id}
<div class="line" class:rf-hide={showFamily !== id} id={id}></div>
{#each Object.keys(gedcom).filter(x => /\@f.*@/i.test(x)) as f}
<div class="line" class:rf-hide={!sameFamily(f,showFamily)} id={f}></div>
{/each}
{/if}

Expand All @@ -31,9 +51,13 @@
export let gedcom;
let computed = false;
let fmax = 10000;
let showFamily;
let showFamily, showId;
const getGenerationRank = (i) => {
if (!i) {return -1;}
if (gedcom[i].rank !== undefined) {
return gedcom[i].rank
}
if(gedcom[i] && gedcom[i].pare) {
let fRank = 0;
if (gedcom[i].fams) {
Expand All @@ -43,9 +67,23 @@
fRank = Math.max(...gedcom[i].fams.map(f => parseInt((f.replace(/\@f(.*)\@/i,'$1'))))) / fmax;
}
}
return 1 + fRank + Math.min(...gedcom[i].pare.map(p => getGenerationRank(p.id)));
gedcom[i].rank = 1 + fRank + Math.max(...gedcom[i].pare.map(p => getGenerationRank(p.id)));
} else {
gedcom[i].rank = 0;
}
gedcom[i].rank = Math.max(
gedcom[i].rank || 0,
(gedcom[i].cons && Math.max(...gedcom[i].cons.map(c => getGenerationRank(c.id)))) || 0
);
return gedcom[i].rank;
}
const sameFamily = (f1, f2) => {
if (!f1) {return false}
if (f1 && typeof(f1) === 'string') {
f1 = [f1];
}
return 0;
return f1.some(f => f2 && f2.includes(f));
}
const actualizeLines = () => {
Expand Down Expand Up @@ -79,7 +117,7 @@
f.chil = f.chil.map(c => c)
}
f.chil.forEach(c => {
gedcom[c].pare = parents.map(p => {
gedcom[c].pare = parents.filter(p => gedcom[p]).map(p => {
return {
id: p,
surn: gedcom[p].surn || gedcom[p].name.replace(/^.*\/\s*(.*)\s*\/.*$/,'$1'),
Expand All @@ -88,7 +126,7 @@
})
})
parents.forEach(p => {
gedcom[p].chil = f.chil.map(c => {
gedcom[p].chil = f.chil.filter(c => gedcom[c]).map(c => {
return {
id: c,
surn: gedcom[c].surn || gedcom[c].name.replace(/^.*\/\s*(.*)\s*\/.*$/,'$1'),
Expand All @@ -98,20 +136,22 @@
})
}
if (f.wife && f.husb) {
gedcom[f.wife].cons = {
if (!gedcom[f.wife].cons) { gedcom[f.wife].cons = [] }
gedcom[f.wife].cons.push({
id: f.husb,
surn: gedcom[f.husb].surn || gedcom[f.husb].name.replace(/^.*\/\s*(.*)\s*\/.*$/,'$1'),
givn: gedcom[f.husb].givn || gedcom[f.husb].name.replace(/^(.*)\/\s*(.*)\s*\/.*$/,'$1')
}
gedcom[f.husb].cons = {
});
if (!gedcom[f.husb].cons) { gedcom[f.husb].cons = [] }
gedcom[f.husb].cons.push({
id: f.wife,
surn: gedcom[f.wife].surn || gedcom[f.wife].name.replace(/^.*\/\s*(.*)\s*\/.*$/,'$1'),
givn: gedcom[f.wife].givn || gedcom[f.wife].name.replace(/^(.*)\/\s*(.*)\s*\/.*$/,'$1')
}
});
}
});
Object.keys(gedcom).filter(x => /\@i.*\@/i.test(x)).forEach(i => {
gedcom[i].rank = getGenerationRank(i);
getGenerationRank(i);
});
computed = true;
actualizeLines();
Expand Down Expand Up @@ -165,6 +205,7 @@
</script>

<style>
.line{
position:absolute;
width:2px;
Expand Down
7 changes: 7 additions & 0 deletions src/components/views/LinkCheck.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@
let gedcom = JSON.parse(JSON.stringify($linkOptions.csv.gedcom));
const idCol = $linkResults.header.indexOf('id');
Object.keys(gedcom).filter(i => /\@i.*@/i.test(i)).forEach(i => {
delete gedcom[i].rank;
delete gedcom[i].cons;
delete gedcom[i].pare;
delete gedcom[i].chil;
})
$linkResults.rows.forEach((r,i) => {
const l = $linkValidations[i];
const gedcomId = r[0][0];
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/LinkJob.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
formData.append('encoding', $linkOptions.csv.encoding);
formData.append('skipLines', $linkOptions.csv.skipLines);
formData.append('candidateNumber', $linkOptions.api.candidateNumber);
formData.append('pruneScoe', $linkOptions.api.pruneScore);
formData.append('pruneScore', $linkOptions.api.pruneScore);
formData.append('dateFormat', $linkOptions.csv.dateFormat || 'DD/MM/YYYY');
Object.keys($linkMapping && $linkMapping.reverse).map(k => formData.append(k,$linkMapping.reverse[k]));
if ($linkOptions.csv.type === 'gedcom') {
Expand Down
4 changes: 2 additions & 2 deletions src/components/views/LinkSampleTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
}
}
};
return row.map(col => col.replace(/^\s*/,'') || '<vide>');
return row.map(col => col.replace(/^\s*/,'').replace(/\s*$/,'') || '<vide>');
});
if (quoteCounts[0] > quoteCounts[1]) {
quote = q;
Expand Down Expand Up @@ -244,7 +244,7 @@
[/(\@\S+\@)/mg, (a,b) => {return b.toLowerCase()}],
// simple array
[/^( *)(\w{4}): *([^\n]+)\n(\1(\2): *([^\n]+)\n)+/mg,(a) => {
return a.replace(/:.*$/s,':\n') + a.replace(/( +)\w{4}: +(.*)/mg,' $1- $2');
return a.substring(0,a.indexOf(':')+1) + '\n' + a.replace(/( +)\w{4}: +(.*)/mg,' $1- $2');
}],
//complex arrays
[/^(\s*)(\w{4}):\s*([^\n]*\n(\s+\1[a-zA-Z0-9_\-][^\n]*\n)*)\1(\2):\s*([^\n]*)\n/mg,'$1$2:\n $1- $3 $1- $6\n'],
Expand Down
1 change: 1 addition & 0 deletions stats/src/parseLogs.pl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

@referrerUrlRegexp = (
[qr|^(https?://)?(www\.)?|,'""'],
[qr/^(fr|fr\.m|m)\./,'""'],
[qr|/.*$|,'""'],
[qr|\d+.\d+.\d+.\d+(:\d+)?$|,'"internal"'],
[qr|^(https?://)?[a-z].*matchid.io?$|,'"matchid.io"'],
Expand Down

0 comments on commit 1e73b62

Please sign in to comment.