refactor(remote_judger): reduce storage size with custom elements
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2023-02-06 14:38:07 +08:00
parent e2fc360279
commit 4905ecd6f6
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
4 changed files with 52 additions and 41 deletions

View File

@ -419,24 +419,21 @@ export default class CodeforcesProvider implements IBasicProvider {
const remote_handle = stripHtml(body.partyName).result; const remote_handle = stripHtml(body.partyName).result;
const details = const details =
'<div>' + '<div>' +
'<div class="border-bottom p-3">' + '<remote-result-container>' +
'<table class="table w-auto mb-0 caption-top">' + '<remote-result-table>' +
'<caption class="fw-bold text-body mb-1 pt-0">远端信息</caption>' +
'<tbody class="border-top">' +
Object.entries({ Object.entries({
比赛: stripHtml(body.contestName).result, 比赛: stripHtml(body.contestName).result,
题目: stripHtml(body.problemName).result, 题目: stripHtml(body.problemName).result,
: `<a href="https://codeforces.com${body.href}" target="_blank">${id}</a>`, : `<a href="https://codeforces.com${body.href}">${id}</a>`,
: `<a href="https://codeforces.com/profile/${remote_handle}" target="_blank">${remote_handle}</a>`, : `<a href="https://codeforces.com/profile/${remote_handle}">${remote_handle}</a>`,
状态: stripHtml(body.verdict).result, 状态: stripHtml(body.verdict).result,
}) })
.map( .map(
o => `<tr><td class="fw-bold">${o[0]}</td><td>${o[1]}</td></tr>` o => `<remote-result-tr name="${o[0]}">${o[1]}</remote-result-tr>`
) )
.join('') + .join('') +
'</tbody>' + '</remote-result-table>' +
'</table>' + '</remote-result-container>' +
'</div>' +
`<tests>${tests.join('\n')}</tests>` + `<tests>${tests.join('\n')}</tests>` +
'</div>'; '</div>';

View File

@ -461,37 +461,29 @@ export default class LibreojProvider implements IBasicProvider {
let details = ''; let details = '';
details += details +=
'<div class="border-bottom p-3">' + '<remote-result-container>' +
'<table class="table w-auto mb-0 caption-top">' + '<remote-result-table>' +
'<caption class="fw-bold text-body mb-1 pt-0">远端信息</caption>' +
'<tbody class="border-top">' +
Object.entries({ Object.entries({
: `<a href="https://loj.ac/p/${ : `<a href="https://loj.ac/p/${body.meta.problem.displayId}">#${
body.meta.problem.displayId
}" target="_blank">#${
body.meta.problem.displayId body.meta.problem.displayId
}. ${htmlspecialchars(body.meta.problemTitle)}</a>`, }. ${htmlspecialchars(body.meta.problemTitle)}</a>`,
: `<a href="https://loj.ac/s/${id}" target="_blank">${id}</a>`, : `<a href="https://loj.ac/s/${id}">${id}</a>`,
提交时间: new Date(body.meta.submitTime).toLocaleString('zh-CN'), 提交时间: new Date(body.meta.submitTime).toLocaleString('zh-CN'),
: `<a href="https://loj.ac/user/${body.meta.submitter.id}" target="_blank">${body.meta.submitter.username}</a>`, : `<a href="https://loj.ac/user/${body.meta.submitter.id}">${body.meta.submitter.username}</a>`,
状态: status, 状态: status,
}) })
.map( .map(
o => `<tr><td class="fw-bold">${o[0]}</td><td>${o[1]}</td></tr>` o => `<remote-result-tr name="${o[0]}">${o[1]}</remote-result-tr>`
) )
.join('') + .join('') +
'</tbody>' + '</remote-result-table>' +
'</table>' + '</remote-result-container>';
'</div>';
if (result_show_source) { if (result_show_source) {
details += details +=
'<div class="border-bottom p-3">' + `<remote-source-code language="${body.content.language}">` +
'<div class="fw-bold mb-2">源代码</div>' +
`<pre><code class="language-${body.content.language} bg-light rounded p-3">` +
htmlspecialchars(parse(body.content.code)) + htmlspecialchars(parse(body.content.code)) +
'</code></pre>' + '</remote-source-code>';
'</div>';
} }
// Samples // Samples

View File

@ -295,28 +295,23 @@ export default class LuoguProvider implements IBasicProvider {
let details = ''; let details = '';
details += details +=
'<div class="border-bottom p-3">' + '<remote-result-container>' +
'<table class="table w-auto mb-0 caption-top">' + '<remote-result-table>' +
'<caption class="fw-bold text-body mb-1 pt-0">远端信息</caption>' +
'<tbody class="border-top">' +
Object.entries({ Object.entries({
: `<a href="https://www.luogu.com.cn/problem/${ : `<a href="https://www.luogu.com.cn/problem/${
data.problem.pid data.problem.pid
}" target="_blank">${data.problem.pid} ${htmlspecialchars( }">${data.problem.pid} ${htmlspecialchars(data.problem.title)}</a>`,
data.problem.title : `<a href="https://www.luogu.com.cn/record/${id}">R${id}</a>`,
)}</a>`,
: `<a href="https://www.luogu.com.cn/record/${id}" target="_blank">R${id}</a>`,
提交时间: new Date(data.submitTime * 1000).toLocaleString('zh-CN'), 提交时间: new Date(data.submitTime * 1000).toLocaleString('zh-CN'),
: `<a href="https://www.luogu.com.cn/user/${data.user.uid}" target="_blank">${data.user.name}</a>`, : `<a href="https://www.luogu.com.cn/user/${data.user.uid}">${data.user.name}</a>`,
状态: status, 状态: status,
}) })
.map( .map(
o => `<tr><td class="fw-bold">${o[0]}</td><td>${o[1]}</td></tr>` o => `<remote-result-tr name="${o[0]}">${o[1]}</remote-result-tr>`
) )
.join('') + .join('') +
'</tbody>' + '</remote-result-table>' +
'</table>' + '</remote-result-container>';
'</div>';
if (data.detail.judgeResult.subtasks.length === 1) { if (data.detail.judgeResult.subtasks.length === 1) {
details += Object.entries( details += Object.entries(

View File

@ -410,6 +410,33 @@ class JudgmentDetailsPrinter {
echo '<pre class="bg-light rounded p-3">', "\n"; echo '<pre class="bg-light rounded p-3">', "\n";
$this->_print_c($node); $this->_print_c($node);
echo "\n</pre>"; echo "\n</pre>";
} elseif ($node->nodeName == 'remote-result-container') {
echo '<div class="border-bottom p-3">';
$this->_print_c($node);
echo '</div>';
} elseif ($node->nodeName == 'remote-result-table') {
echo '<table class="table w-auto mb-0 caption-top">';
echo '<caption class="fw-bold text-body mb-1 pt-0">远端信息</caption>';
echo '<tbody class="border-top">';
$this->_print_c($node);
echo '</tbody>';
echo '</table>';
} elseif ($node->nodeName == 'remote-result-tr') {
$name = $node->getAttribute("name");
echo '<tr>';
echo '<td class="fw-bold">', $name, '</td>';
echo '<td>';
$this->_print_c($node);
echo '</td>';
echo '</tr>';
} elseif ($node->nodeName == 'remote-source-code') {
$language = $node->getAttribute("language");
echo '<div class="border-bottom p-3">';
echo '<div class="fw-bold mb-2">源代码</div>';
echo '<pre><code class="language-', $language, ' bg-light mb-0 rounded">';
$this->_print_c($node);
echo "</code></pre>";
echo '</div>';
} elseif ($node->nodeName == 'tests') { } elseif ($node->nodeName == 'tests') {
if ($node->hasAttribute("errcode")) { if ($node->hasAttribute("errcode")) {
echo "<pre>", "Judgment Failed. Error Code: ", $node->getAttribute("errcode"), ".</pre>"; echo "<pre>", "Judgment Failed. Error Code: ", $node->getAttribute("errcode"), ".</pre>";