up liens osmose thème détails
This commit is contained in:
parent
38fbc451f5
commit
503e6e9dac
3 changed files with 105 additions and 17 deletions
|
@ -25,6 +25,7 @@ class WikiController extends AbstractController
|
|||
|
||||
$wikiPages = [];
|
||||
$missingTranslations = [];
|
||||
$pageDifferences = [];
|
||||
|
||||
// First pass: collect all staleness scores to find min and max
|
||||
$stalenessScores = [];
|
||||
|
@ -68,6 +69,33 @@ class WikiController extends AbstractController
|
|||
}
|
||||
}
|
||||
|
||||
// Calculate differences between English and French versions
|
||||
foreach ($wikiPages as $key => $languages) {
|
||||
if (isset($languages['en']) && isset($languages['fr'])) {
|
||||
$en = $languages['en'];
|
||||
$fr = $languages['fr'];
|
||||
|
||||
// Calculate differences (French - English)
|
||||
$sectionDiff = (int)$fr['sections'] - (int)$en['sections'];
|
||||
$wordDiff = (int)$fr['word_count'] - (int)$en['word_count'];
|
||||
$linkDiff = (int)$fr['link_count'] - (int)$en['link_count'];
|
||||
$mediaDiff = isset($fr['media_count']) && isset($en['media_count']) ?
|
||||
(int)$fr['media_count'] - (int)$en['media_count'] : 0;
|
||||
|
||||
// Format differences with + or - sign
|
||||
$pageDifferences[$key] = [
|
||||
'section_diff' => $sectionDiff,
|
||||
'section_diff_formatted' => ($sectionDiff >= 0 ? '+' : '') . $sectionDiff,
|
||||
'word_diff' => $wordDiff,
|
||||
'word_diff_formatted' => ($wordDiff >= 0 ? '+' : '') . $wordDiff,
|
||||
'link_diff' => $linkDiff,
|
||||
'link_diff_formatted' => ($linkDiff >= 0 ? '+' : '') . $linkDiff,
|
||||
'media_diff' => $mediaDiff,
|
||||
'media_diff_formatted' => ($mediaDiff >= 0 ? '+' : '') . $mediaDiff,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Sort wiki pages by staleness score (descending)
|
||||
uasort($wikiPages, function($a, $b) {
|
||||
$scoreA = isset($a['en']) && isset($a['fr']) && isset($a['en']['staleness_score']) ? (float)$a['en']['staleness_score'] : 0;
|
||||
|
@ -78,6 +106,7 @@ class WikiController extends AbstractController
|
|||
return $this->render('admin/wiki.html.twig', [
|
||||
'wiki_pages' => $wikiPages,
|
||||
'missing_translations' => $missingTranslations,
|
||||
'page_differences' => $pageDifferences,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
padding: 0.5rem;
|
||||
color: white;
|
||||
}
|
||||
.bg-purple {
|
||||
background-color: #8A2BE2 !important;
|
||||
color: white !important;
|
||||
}
|
||||
#themeMap {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
@ -881,8 +885,32 @@
|
|||
|
||||
const divOsmose = document.querySelector(('#alertes_osmose'))
|
||||
if(divOsmose){
|
||||
|
||||
divOsmose.innerHTML = `<span class="counter">${data.issues.length}</span> objets à ajouter selon Osmose`;
|
||||
if (data.issues.length === 1) {
|
||||
// Si un seul objet, rendre tout le texte cliquable
|
||||
const issueId = data.issues[0].id;
|
||||
divOsmose.innerHTML = `<a href="https://osmose.openstreetmap.fr/fr/error/${issueId}" target="_blank" style="text-decoration: none; color: inherit;">
|
||||
<span class="counter">${data.issues.length}</span> objet à ajouter selon Osmose
|
||||
</a>`;
|
||||
} else {
|
||||
// Si plusieurs objets, lister chaque objet avec son numéro
|
||||
let content = `<span class="counter">${data.issues.length}</span> objets à ajouter selon Osmose : `;
|
||||
|
||||
// Limiter à 5 objets affichés pour éviter de surcharger l'interface
|
||||
const displayLimit = 5;
|
||||
const displayCount = Math.min(data.issues.length, displayLimit);
|
||||
|
||||
for (let i = 0; i < displayCount; i++) {
|
||||
const issueId = data.issues[i].id;
|
||||
content += `<a href="http://localhost:8111/import?url=https://osmose.openstreetmap.fr/api/0.3/issue/${issueId}/fix/0" target="_blank" class="badge bg-purple mx-1">${i}</a>`;
|
||||
}
|
||||
|
||||
// Indiquer s'il y a plus d'objets que ceux affichés
|
||||
if (data.issues.length > displayLimit) {
|
||||
content += `<span class="text-muted">(et ${data.issues.length - displayLimit} autres)</span>`;
|
||||
}
|
||||
|
||||
divOsmose.innerHTML = content;
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`[Osmose] ${data.issues.length} analyses trouvées pour le thème ${theme}`);
|
||||
|
@ -895,7 +923,7 @@
|
|||
.setHTML(
|
||||
(() => {
|
||||
|
||||
return `<div id="osmose-popup-${issue.id}" >Proposition d'ajout <button onclick="loadOsmoseIssueDetails(${issue.id})">${issue.id}</button></div>`
|
||||
return `<div id="osmose-popup-${issue.id}" >Proposition d'ajout <button onclick="()=> window.localtion.href=http://localhost:8111/import?url=https://osmose.openstreetmap.fr/api/0.3/issue/${issue.id}/fix/0)">corriger dans josm</button></div>`
|
||||
})());
|
||||
|
||||
// lapopup.on('open', () => {
|
||||
|
|
|
@ -17,18 +17,15 @@
|
|||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<th rowspan="2">Clé</th>
|
||||
<th colspan="3" class="text-center">Version anglaise</th>
|
||||
<th colspan="3" class="text-center">Version française</th>
|
||||
<th colspan="4" class="text-center">Différences FR vs EN</th>
|
||||
<th rowspan="2" class="text-center">Score de<br>décrépitude</th>
|
||||
<th rowspan="2" class="text-center">Liens</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Sections</th>
|
||||
<th>Mots</th>
|
||||
<th>Liens</th>
|
||||
<th>Sections</th>
|
||||
<th>Mots</th>
|
||||
<th>Liens</th>
|
||||
<th class="text-center">Sections</th>
|
||||
<th class="text-center">Mots</th>
|
||||
<th class="text-center">Liens</th>
|
||||
<th class="text-center">Images</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -39,13 +36,47 @@
|
|||
<strong>{{ key }}</strong>
|
||||
</td>
|
||||
|
||||
<td>{{ languages['en'].sections }}</td>
|
||||
<td>{{ languages['en'].word_count }}</td>
|
||||
<td>{{ languages['en'].link_count }}</td>
|
||||
{% set diff = page_differences[key] %}
|
||||
|
||||
<td>{{ languages['fr'].sections }}</td>
|
||||
<td>{{ languages['fr'].word_count }}</td>
|
||||
<td>{{ languages['fr'].link_count }}</td>
|
||||
<td class="text-center">
|
||||
{% if diff.section_diff > 0 %}
|
||||
<span class="badge bg-success">{{ diff.section_diff_formatted }}</span>
|
||||
{% elseif diff.section_diff < 0 %}
|
||||
<span class="badge bg-danger">{{ diff.section_diff_formatted }}</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary">0</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
{% if diff.word_diff > 0 %}
|
||||
<span class="badge bg-success">{{ diff.word_diff_formatted }}</span>
|
||||
{% elseif diff.word_diff < 0 %}
|
||||
<span class="badge bg-danger">{{ diff.word_diff_formatted }}</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary">0</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
{% if diff.link_diff > 0 %}
|
||||
<span class="badge bg-success">{{ diff.link_diff_formatted }}</span>
|
||||
{% elseif diff.link_diff < 0 %}
|
||||
<span class="badge bg-danger">{{ diff.link_diff_formatted }}</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary">0</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
{% if diff.media_diff > 0 %}
|
||||
<span class="badge bg-success">{{ diff.media_diff_formatted }}</span>
|
||||
{% elseif diff.media_diff < 0 %}
|
||||
<span class="badge bg-danger">{{ diff.media_diff_formatted }}</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary">0</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
{% set score = languages['en'].staleness_score|default(0) %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue