Skip to content

Commit bf774fe

Browse files
inshinnoCoelacanthusHexalphagocc
authored
improve: shrink export html with class selector (#153)
* improve: shrink export html with class selector * chore: styled Co-authored-by: Coelacanthus <CoelacanthusHex@gmail.com> Co-authored-by: Alphagocc <alphagocc@163.com> Co-authored-by: Coelacanthus <coelacanthus@outlook.com>
1 parent b780f2a commit bf774fe

13 files changed

Lines changed: 102 additions & 89 deletions

File tree

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
*.txt text eof=lf
2+
*.cpp text eof=lf
3+
*.hpp text eof=lf
4+
*.h text eof=lf
5+
*.qrc text eof=lf
6+
*.cmake text eof=lf
7+
*.in text eof=lf
8+
*.ui text eof=lf
9+
*.md text eof=lf
10+
*.tex text eof=lf
11+
*.ts text eof=lf

.github/workflows/check_format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
run: git diff --exit-code HEAD
1919
- name: Create Pull Request
2020
if: failure()
21-
uses: peter-evans/create-pull-request@v2
21+
uses: peter-evans/create-pull-request@v3
2222
with:
2323
commit-message: "style: format codes"
2424
title: "Format codes for ${{ github.ref }}"

.github/workflows/cpack-deb-debian.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
name: Check if the workflow has been disabled.
2626
runs-on: ubuntu-latest
2727
steps:
28-
- uses: actions/checkout@v1
28+
- uses: actions/checkout@v2
2929
- name: Get commit message
3030
id: get_message
3131
run: |

.github/workflows/cpack-deb-ubuntu.yml.bak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
name: Check if the workflow has been disabled.
2626
runs-on: ubuntu-latest
2727
steps:
28-
- uses: actions/checkout@v1
28+
- uses: actions/checkout@v2
2929
- name: Get commit message
3030
id: get_message
3131
run: |

.github/workflows/linux-static.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
name: Check if the workflow has been disabled.
2626
runs-on: ubuntu-latest
2727
steps:
28-
- uses: actions/checkout@v1
28+
- uses: actions/checkout@v2
2929
- name: Get commit message
3030
id: get_message
3131
run: |

.github/workflows/sourcefile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
name: Check if the workflow has been disabled.
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v1
15+
- uses: actions/checkout@v2
1616
- name: Get commit message
1717
id: get_message
1818
run: |

makespec/BUILDVERSION

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
197
2-
1+
197

manual/llmanual.pdf

-182 KB
Binary file not shown.

resource.qrc

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
<RCC>
2-
<qresource prefix="/logo">
3-
<file alias="splash2.png">assets/pics/splash2.png</file>
4-
</qresource>
5-
<qresource prefix="/asset">
6-
<file>makespec/VERSION</file>
7-
<file>makespec/VERSIONSUFFIX</file>
8-
<file>makespec/BUILDVERSION</file>
9-
<file>assets/lemon-lime.ico</file>
10-
</qresource>
11-
<qresource prefix="/icon">
12-
<file alias="icon.png">assets/icons/lemon-lime.png</file>
13-
<file alias="code-function.svg">assets/pics/code-function.svg</file>
14-
<file alias="configure.svg">assets/pics/configure.svg</file>
15-
<file alias="dialog-cancel.svg">assets/pics/dialog-cancel.svg</file>
16-
<file alias="dialog-ok-apply.svg">assets/pics/dialog-ok-apply.svg</file>
17-
<file alias="document-edit.svg">assets/pics/document-edit.svg</file>
18-
<file alias="edit-clear.svg">assets/pics/edit-clear.svg</file>
19-
<file alias="edit-delete.svg">assets/pics/edit-delete.svg</file>
20-
<file alias="edit-find-replace.svg">assets/pics/edit-find-replace.svg</file>
21-
<file alias="edit-find.svg">assets/pics/edit-find.svg</file>
22-
<file alias="go-down.svg">assets/pics/go-down.svg</file>
23-
<file alias="go-up.svg">assets/pics/go-up.svg</file>
24-
<file alias="list-add.svg">assets/pics/list-add.svg</file>
25-
<file alias="list-remove.svg">assets/pics/list-remove.svg</file>
26-
<file alias="media-playback-stop.svg">assets/pics/media-playback-stop.svg</file>
27-
<file alias="media-skip-forward.svg">assets/pics/media-skip-forward.svg</file>
28-
<file alias="paint-none.svg">assets/pics/paint-none.svg</file>
29-
<file alias="view-refresh.svg">assets/pics/view-refresh.svg</file>
30-
<file alias="view-sort.svg">assets/pics/view-sort.svg</file>
31-
<file alias="application-exit.svg">assets/pics/application-exit.svg</file>
32-
<file alias="deletecell.svg">assets/pics/deletecell.svg</file>
33-
<file alias="document-close.svg">assets/pics/document-close.svg</file>
34-
<file alias="document-export.svg">assets/pics/document-export.svg</file>
35-
<file alias="document-new.svg">assets/pics/document-new.svg</file>
36-
<file alias="document-save.svg">assets/pics/document-save.svg</file>
37-
<file alias="globe.svg">assets/pics/globe.svg</file>
38-
<file alias="go-parent-folder.svg">assets/pics/go-parent-folder.svg</file>
39-
<file alias="help-about.svg">assets/pics/help-about.svg</file>
40-
<file alias="layer-new.svg">assets/pics/layer-new.svg</file>
41-
<file alias="paint-unknown.svg">assets/pics/paint-unknown.svg</file>
42-
<file alias="quickopen-file.svg">assets/pics/quickopen-file.svg</file>
43-
<file alias="system-help.svg">assets/pics/system-help.svg</file>
44-
<file alias="acrobat.svg">assets/pics/acrobat.svg</file>
45-
</qresource>
46-
</RCC>
1+
<RCC>
2+
<qresource prefix="/logo">
3+
<file alias="splash2.png">assets/pics/splash2.png</file>
4+
</qresource>
5+
<qresource prefix="/asset">
6+
<file>makespec/VERSION</file>
7+
<file>makespec/VERSIONSUFFIX</file>
8+
<file>makespec/BUILDVERSION</file>
9+
<file>assets/lemon-lime.ico</file>
10+
</qresource>
11+
<qresource prefix="/icon">
12+
<file alias="icon.png">assets/icons/lemon-lime.png</file>
13+
<file alias="code-function.svg">assets/pics/code-function.svg</file>
14+
<file alias="configure.svg">assets/pics/configure.svg</file>
15+
<file alias="dialog-cancel.svg">assets/pics/dialog-cancel.svg</file>
16+
<file alias="dialog-ok-apply.svg">assets/pics/dialog-ok-apply.svg</file>
17+
<file alias="document-edit.svg">assets/pics/document-edit.svg</file>
18+
<file alias="edit-clear.svg">assets/pics/edit-clear.svg</file>
19+
<file alias="edit-delete.svg">assets/pics/edit-delete.svg</file>
20+
<file alias="edit-find-replace.svg">assets/pics/edit-find-replace.svg</file>
21+
<file alias="edit-find.svg">assets/pics/edit-find.svg</file>
22+
<file alias="go-down.svg">assets/pics/go-down.svg</file>
23+
<file alias="go-up.svg">assets/pics/go-up.svg</file>
24+
<file alias="list-add.svg">assets/pics/list-add.svg</file>
25+
<file alias="list-remove.svg">assets/pics/list-remove.svg</file>
26+
<file alias="media-playback-stop.svg">assets/pics/media-playback-stop.svg</file>
27+
<file alias="media-skip-forward.svg">assets/pics/media-skip-forward.svg</file>
28+
<file alias="paint-none.svg">assets/pics/paint-none.svg</file>
29+
<file alias="view-refresh.svg">assets/pics/view-refresh.svg</file>
30+
<file alias="view-sort.svg">assets/pics/view-sort.svg</file>
31+
<file alias="application-exit.svg">assets/pics/application-exit.svg</file>
32+
<file alias="deletecell.svg">assets/pics/deletecell.svg</file>
33+
<file alias="document-close.svg">assets/pics/document-close.svg</file>
34+
<file alias="document-export.svg">assets/pics/document-export.svg</file>
35+
<file alias="document-new.svg">assets/pics/document-new.svg</file>
36+
<file alias="document-save.svg">assets/pics/document-save.svg</file>
37+
<file alias="globe.svg">assets/pics/globe.svg</file>
38+
<file alias="go-parent-folder.svg">assets/pics/go-parent-folder.svg</file>
39+
<file alias="help-about.svg">assets/pics/help-about.svg</file>
40+
<file alias="layer-new.svg">assets/pics/layer-new.svg</file>
41+
<file alias="paint-unknown.svg">assets/pics/paint-unknown.svg</file>
42+
<file alias="quickopen-file.svg">assets/pics/quickopen-file.svg</file>
43+
<file alias="system-help.svg">assets/pics/system-help.svg</file>
44+
<file alias="acrobat.svg">assets/pics/acrobat.svg</file>
45+
</qresource>
46+
</RCC>

src/component/exportutil/exportutil.cpp

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ auto ExportUtil::getContestantHtmlCode(Contest *contest, Contestant *contestant,
107107
}
108108

109109
htmlCode += "<table style=\"border: solid;\"><tr>";
110-
htmlCode += QString(R"(<th scope="col" class="a">%1</th>)").arg(tr("Test Case"));
111-
htmlCode += QString(R"(<th scope="col" class="a">%1</th>)").arg(tr("Input File"));
112-
htmlCode += QString(R"(<th scope="col" class="a">%1</th>)").arg(tr("Result"));
113-
htmlCode += QString(R"(<th scope="col" class="a">%1</th>)").arg(tr("Time Used"));
114-
htmlCode += QString(R"(<th scope="col" class="a">%1</th>)").arg(tr("Memory Used"));
115-
htmlCode += QString(R"(<th scope="col" class="a">%1</th></tr>)").arg(tr("Score"));
110+
htmlCode += QString(R"(<th scope="col" class="td-0">%1</th>)").arg(tr("Test Case"));
111+
htmlCode += QString(R"(<th scope="col" class="td-0">%1</th>)").arg(tr("Input File"));
112+
htmlCode += QString(R"(<th scope="col" class="td-0">%1</th>)").arg(tr("Result"));
113+
htmlCode += QString(R"(<th scope="col" class="td-0">%1</th>)").arg(tr("Time Used"));
114+
htmlCode += QString(R"(<th scope="col" class="td-0">%1</th>)").arg(tr("Memory Used"));
115+
htmlCode += QString(R"(<th scope="col" class="td-0">%1</th></tr>)").arg(tr("Score"));
116116
QList<TestCase *> testCases = taskList[i]->getTestCaseList();
117117
QList<QStringList> inputFiles = contestant->getInputFiles(i);
118118
QList<QList<ResultState>> result = contestant->getResult(i);
@@ -127,23 +127,23 @@ auto ExportUtil::getContestantHtmlCode(Contest *contest, Contestant *contestant,
127127

128128
if (k == 0) {
129129
if (score[j].size() == inputFiles[j].size())
130-
htmlCode += QString(R"(<td rowspan="%1" class="a">#%2</td>)")
130+
htmlCode += QString(R"(<td rowspan="%1" class="td-0">#%2</td>)")
131131
.arg(inputFiles[j].size())
132132
.arg(j + 1);
133133
else
134-
htmlCode += QString(R"(<td rowspan="%1" class="a">#%2<br>%3:%4</td>)")
134+
htmlCode += QString(R"(<td rowspan="%1" class="td-0">#%2<br>%3:%4</td>)")
135135
.arg(inputFiles[j].size())
136136
.arg(j + 1)
137137
.arg(tr("Subtask Dependence Status"))
138138
.arg(statusRankingText(score[j].back()));
139139
}
140140

141-
htmlCode += QString("<td class=\"a\">%1</td>").arg(inputFiles[j][k]);
141+
htmlCode += QString("<td class=\"td-0\">%1</td>").arg(inputFiles[j][k]);
142142
QString text;
143143
QString bgColor = "rgb(255, 255, 255)";
144144
QString frColor = "rgb(0, 0, 0)";
145145
Settings::setTextAndColor(result[j][k], text, frColor, bgColor);
146-
htmlCode += QString("<td class=\"a\" style=\"background-color: %2; color: %3;\">%1")
146+
htmlCode += QString("<td class=\"td-0\" style=\"background-color: %2; color: %3;\">%1")
147147
.arg(text)
148148
.arg(bgColor)
149149
.arg(frColor);
@@ -156,7 +156,7 @@ auto ExportUtil::getContestantHtmlCode(Contest *contest, Contestant *contestant,
156156
}
157157

158158
htmlCode += "</td>";
159-
htmlCode += "<td class=\"a\">";
159+
htmlCode += "<td class=\"td-0\">";
160160

161161
if (timeUsed[j][k] != -1) {
162162
htmlCode += QString("").asprintf("%.3lf s", double(timeUsed[j][k]) / 1000);
@@ -165,7 +165,7 @@ auto ExportUtil::getContestantHtmlCode(Contest *contest, Contestant *contestant,
165165
}
166166

167167
htmlCode += "</td>";
168-
htmlCode += "<td class=\"a\">";
168+
htmlCode += "<td class=\"td-0\">";
169169

170170
if (memoryUsed[j][k] != -1) {
171171
htmlCode += QString("").asprintf("%.3lf MB", double(memoryUsed[j][k]) / 1024 / 1024);
@@ -192,7 +192,7 @@ auto ExportUtil::getContestantHtmlCode(Contest *contest, Contestant *contestant,
192192

193193
htmlCode +=
194194
QString(
195-
R"(<td rowspan="%1" class="a" style=" background-color: %2;"><a class="c">%3</a> / %4</td>)")
195+
R"(<td rowspan="%1" class="td-0" style="background-color: %2;"><a class="c">%3</a> / %4</td>)")
196196
.arg(inputFiles[j].size())
197197
.arg(bgColor)
198198
.arg(minv)
@@ -234,11 +234,13 @@ void ExportUtil::exportHtml(QWidget *widget, Contest *contest, const QString &fi
234234
out << "<html><head>";
235235
out << R"(<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />)";
236236
out << "<style type=\"text/css\">th, td {padding-left: 1em; padding-right: 1em; white-space: nowrap; "
237-
"text-align: center; verticle-align: middle;} .a {border-style: none solid solid none; "
238-
"border-width: 1px 3px; border-color: #ccc;} .b {border-style: none solid solid none; "
239-
"border-width: 3px 3px; border-color: #000;} .c {font-weight: bold; font-size: large;} "
240-
".d {font-size:x-large; font-weight:bold;} .e {font-size: small;} .f {font-weight: bold;}"
241-
".g {border-style: none solid solid none; border-width: 3px 2px; border-color: #000;}</style>";
237+
"text-align: center; verticle-align: middle;}"
238+
".td-0 {border-style: none solid solid none; border-width: 1px 3px; border-color: #ccc;}"
239+
".th-0 {border-style: none solid solid none; border-width: 3px 3px; border-color: #000;}"
240+
".th-1 {border-style: none solid solid none; border-width: 3px 2px; border-color: #000;}"
241+
".a-0 {color: black; text-decoration: none;} .c {font-weight: bold; font-size: large;}"
242+
".td-2 {border-radius: 5px; font-weight: bold;}"
243+
".td-3 {border-radius: 5px;}</style>";
242244
out << "<title>" << contest->getContestTitle() << " : " << tr("Contest Result") << "</title>";
243245
out << "</head><body>";
244246
QList<std::pair<int, QString>> sortList;
@@ -275,12 +277,12 @@ void ExportUtil::exportHtml(QWidget *widget, Contest *contest, const QString &fi
275277
out << "<p class=\"e\">" << tr("Click names or task scores to jump to details. Judged By LemonLime")
276278
<< "</p>";
277279
out << R"(<p><table cellpadding="1" style="border-style: solid;"><tr>)";
278-
out << QString(R"(<th class="b" scope="col">%1</th>)").arg(tr("Rank"));
279-
out << QString(R"(<th class="b" scope="col">%1</th>)").arg(tr("Name"));
280-
out << QString(R"(<th class="g" scope="col">%1</th>)").arg(tr("Total Score"));
280+
out << QString(R"(<th class="th-0" scope="col">%1</th>)").arg(tr("Rank"));
281+
out << QString(R"(<th class="th-0" scope="col">%1</th>)").arg(tr("Name"));
282+
out << QString(R"(<th class="th-1" scope="col">%1</th>)").arg(tr("Total Score"));
281283

282284
for (auto &i : taskList)
283-
out << QString(R"(<th class="g" scope="col">%1</th>)").arg(i->getProblemTitle());
285+
out << QString(R"(<th class="th-1" scope="col">%1</th>)").arg(i->getProblemTitle());
284286

285287
out << "</tr>";
286288
QList<int> fullScore;
@@ -292,9 +294,8 @@ void ExportUtil::exportHtml(QWidget *widget, Contest *contest, const QString &fi
292294

293295
for (auto &i : sortList) {
294296
Contestant *contestant = contest->getContestant(i.second);
295-
out << QString("<tr><td class=\"a\">%1</td>").arg(rankList[contestant->getContestantName()] + 1);
296-
out << QString(
297-
R"(<td class="a"><a href="#c%1" style="color: black; text-decoration: none;">%2</a></td>)")
297+
out << QString("<tr><td class=\"td-0\">%1</td>").arg(rankList[contestant->getContestantName()] + 1);
298+
out << QString(R"(<td class="td-0"><a href="#c%1" class="a-0">%2</a></td>)")
298299
.arg(loc[contestant])
299300
.arg(i.second);
300301
int allScore = contestant->getTotalScore();
@@ -311,15 +312,15 @@ void ExportUtil::exportHtml(QWidget *widget, Contest *contest, const QString &fi
311312
#endif
312313
colors->getColorGrand(allScore, sfullScore).getHslF(&h, &s, &l);
313314
h *= 360, s *= 100, l *= 100;
314-
out << QString("<td style=\"background-color: hsl(%2,%3%,%4%); border-radius: 5px; font-weight: "
315-
"bold; border: 2px solid hsl(%2,%3%,%5%);\">%1</td>")
315+
out << QString("<td class=\"td-2\" style=\"background-color: hsl(%2,%3%,%4%); border: 2px solid "
316+
"hsl(%2,%3%,%5%);\">%1</td>")
316317
.arg(allScore)
317318
.arg(h)
318319
.arg(s)
319320
.arg(l)
320321
.arg(qMax(l - 20, 0.00));
321322
} else {
322-
out << QString("<td style=\"border-radius: 5px; font-weight: bold;\">%1</td>").arg(tr("Invalid"));
323+
out << QString("<td class=\"td-2\">%1</td>").arg(tr("Invalid"));
323324
}
324325

325326
for (int j = 0; j < taskList.size(); j++) {
@@ -349,16 +350,15 @@ void ExportUtil::exportHtml(QWidget *widget, Contest *contest, const QString &fi
349350

350351
h *= 360, s *= 100, l *= 100;
351352
out << QString(
352-
R"(<td style="background-color: hsl(%2,%3%,%4%); border-radius: 5px;"><a href="#c%5p%6" style="color: black; text-decoration: none;">%1</a></td>)")
353+
R"(<td class="td-3" style="background: hsl(%2,%3%,%4%);"><a href="#c%5p%6" class="a-0">%1</a></td>)")
353354
.arg(score)
354355
.arg(h)
355356
.arg(s)
356357
.arg(l)
357358
.arg(loc[contestant])
358359
.arg(j);
359360
} else {
360-
out << QString(
361-
R"(<td style="border-radius: 5px;"><a href="#c%2p%3" style="color: black; text-decoration: none;">%1</a></td>)")
361+
out << QString(R"(<td class="td-3"><a href="#c%2p%3" class="a-0">%1</a></td>)")
362362
.arg(tr("Invalid"))
363363
.arg(loc[contestant])
364364
.arg(j);

0 commit comments

Comments
 (0)