Skip to content

Commit d2d8a82

Browse files
committed
feat(web): Replace highlight by prism
1 parent 16c3143 commit d2d8a82

File tree

24 files changed

+289
-1030
lines changed

24 files changed

+289
-1030
lines changed

web/app/controllers/faq.php

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
2-
requireLib('hljs');
2+
requireLib('prism');
33
requireLib('mathjax');
4-
echoUOJPageHeader(UOJLocale::get('help'))
4+
echoUOJPageHeader(UOJLocale::get('help'))
55
?>
66
<article>
77
<header>
@@ -125,37 +125,35 @@
125125
<hr /><p><code>数学公式萌萌哒 $(a + b)^2$ 萌萌哒</code> = 数学公式萌萌哒 $(a + b)^2$ 萌萌哒</p>
126126
<hr /><p><code>&lt;!-- readmore --&gt;</code> = 在外面看这篇博客时会到此为止然后显示一个“阅读更多”字样</p>
127127
<hr /><p>来个更大的例子:</p>
128-
<pre>
129-
```c++
130-
#include &lt;iostream&gt;
131-
```
128+
<pre>```cpp
129+
#include &lt;iostream&gt;
130+
```
132131

133-
```c
134-
#include &lt;stdio.h&gt;
135-
```
132+
```c
133+
#include &lt;stdio.h&gt;
134+
```
136135

137-
```pascal
138-
begin
139-
```
136+
```pascal
137+
begin
138+
```
140139

141-
```python
142-
print '<?= UOJConfig::$data['profile']['oj-name-short'] ?>'
143-
```
140+
```python
141+
print('<?= UOJConfig::$data['profile']['oj-name-short'] ?>')
142+
```
144143

145-
\begin{equation}
146-
\frac{-b + \sqrt{b^2 - 4ac}}{2a}
147-
\end{equation}
144+
\begin{equation}
145+
\frac{-b + \sqrt{b^2 - 4ac}}{2a}
146+
\end{equation}
148147

149-
# 一级标题
150-
## 二级标题
151-
### 三级标题
152-
#### 四级标题
153-
</pre>
148+
# 一级标题
149+
## 二级标题
150+
### 三级标题
151+
#### 四级标题</pre>
154152
<p>会转换为:</p>
155-
<pre><code class="sh_cpp">#include &lt;iostream&gt;</code></pre>
156-
<pre><code class="sh_c">#include &lt;stdio.h&gt;</code></pre>
157-
<pre><code class="sh_pascal">begin</code></pre>
158-
<pre><code class="sh_python">print '<?= UOJConfig::$data['profile']['oj-name-short'] ?>'</code></pre>
153+
<pre><code class="language-cpp">#include &lt;iostream&gt;</code></pre>
154+
<pre><code class="language-c">#include &lt;stdio.h&gt;</code></pre>
155+
<pre><code class="language-pascal">begin</code></pre>
156+
<pre><code class="language-python">print('<?= UOJConfig::$data['profile']['oj-name-short'] ?>')</code></pre>
159157
<p>\begin{equation}
160158
\frac{-b + \sqrt{b^2 - 4ac}}{2a}
161159
\end{equation}</p>

web/app/controllers/hack.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22
requirePHPLib('form');
3-
3+
44
if (!validateUInt($_GET['id']) || !($hack = queryHack($_GET['id']))) {
55
become404Page();
66
}
7-
$submission = querySubmission($hack['submission_id']);
7+
$submission = querySubmission($hack['submission_id']);
88
$problem = queryProblemBrief($submission['problem_id']);
99
$problem_extra_config = getProblemExtraConfig($problem);
1010

@@ -18,7 +18,7 @@
1818
if (!isHackVisibleToUser($hack, $problem, $myUser)) {
1919
become403Page();
2020
}
21-
21+
2222
if (isSuperUser($myUser)) {
2323
$delete_form = new UOJForm('delete');
2424
$delete_form->handle = function() {
@@ -32,7 +32,7 @@
3232
$delete_form->succ_href = "/hacks";
3333
$delete_form->runAtServer();
3434
}
35-
35+
3636
$should_show_content = hasViewPermission($problem_extra_config['view_content_type'], $myUser, $problem, $submission);
3737
$should_show_all_details = hasViewPermission($problem_extra_config['view_all_details_type'], $myUser, $problem, $submission);
3838
$should_show_details = hasViewPermission($problem_extra_config['view_details_type'], $myUser, $problem, $submission);
@@ -44,7 +44,7 @@
4444
|| !isHackFullVisibleToUser($hack, $contest, $problem, $myUser)) {
4545
$should_show_content = $should_show_all_details = false;
4646
}
47-
47+
4848
if ($should_show_all_details) {
4949
$styler = new HackDetailsStyler();
5050
if (!$should_show_details) {
@@ -54,7 +54,7 @@
5454
}
5555
?>
5656
<?php
57-
$REQUIRE_LIB['hljs'] = "";
57+
$REQUIRE_LIB['prism'] = "";
5858
?>
5959
<?php echoUOJPageHeader(UOJLocale::get('problems::hack').' #'.$hack['id']) ?>
6060

web/app/controllers/map_visualizer.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
$REQUIRE_LIB['shjs'] = "";
43
$REQUIRE_LIB['dracula'] = "";
54
$REQUIRE_LIB['base64'] = "";
65
$REQUIRE_LIB['raphael'] = "";
@@ -129,4 +128,4 @@
129128
</script>
130129

131130
<?php
132-
echoUOJPageFooter();
131+
echoUOJPageFooter();

web/app/controllers/paste_view.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
if (!$paste) {
77
become404Page();
88
}
9-
$REQUIRE_LIB['shjs'] = "";
9+
$REQUIRE_LIB['prism'] = "";
1010
echoUOJPageHeader("Paste!");
1111
echoPasteContent($paste);
12-
echoUOJPageFooter();
12+
echoUOJPageFooter();

web/app/controllers/problem.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
requirePHPLib('form');
33
requirePHPLib('judger');
4-
4+
55
if (!validateUInt($_GET['id']) || !($problem = queryProblemBrief($_GET['id']))) {
66
become404Page();
77
}
8-
8+
99
$problem_content = queryProblemContent($problem['id']);
10-
10+
1111
$contest = validateUInt($_GET['contest_id']) ? queryContest($_GET['contest_id']) : null;
1212
if ($contest != null) {
1313
genMoreContestInfo($contest);
@@ -18,7 +18,7 @@
1818
$problem_letter = chr(ord('A') + $problem_rank - 1);
1919
}
2020
}
21-
21+
2222
$is_in_contest = false;
2323
$ban_in_contest = false;
2424
if ($contest != null) {
@@ -75,17 +75,17 @@
7575
}
7676
die();
7777
}
78-
78+
7979
$can_use_zip_upload = true;
8080
foreach ($submission_requirement as $req) {
8181
if ($req['type'] == 'source code') {
8282
$can_use_zip_upload = false;
8383
}
8484
}
85-
85+
8686
function handleUpload($zip_file_name, $content, $tot_size) {
8787
global $problem, $contest, $myUser, $is_in_contest;
88-
88+
8989
$content['config'][] = array('problem_id', $problem['id']);
9090
if ($is_in_contest && $contest['extra_config']["contest_type"]!='IOI' && !isset($contest['extra_config']["problem_{$problem['id']}"])) {
9191
$content['final_test_config'] = $content['config'];
@@ -104,11 +104,11 @@ function handleUpload($zip_file_name, $content, $tot_size) {
104104
Cookie::set('uoj_preferred_language', $language, time() + 60 * 60 * 24 * 365, '/');
105105
}
106106
$esc_language = DB::escape($language);
107-
107+
108108
$result = array();
109109
$result['status'] = "Waiting";
110110
$result_json = json_encode($result);
111-
111+
112112
if ($is_in_contest) {
113113
DB::query("insert into submissions (problem_id, contest_id, submit_time, submitter, content, language, tot_size, status, result, is_hidden) values (${problem['id']}, ${contest['id']}, now(), '${myUser['username']}', '$esc_content', '$esc_language', $tot_size, '${result['status']}', '$result_json', 0)");
114114
} else {
@@ -117,7 +117,7 @@ function handleUpload($zip_file_name, $content, $tot_size) {
117117
}
118118
function handleCustomTestUpload($zip_file_name, $content, $tot_size) {
119119
global $problem, $contest, $myUser;
120-
120+
121121
$content['config'][] = array('problem_id', $problem['id']);
122122
$content['config'][] = array('custom_test', 'on');
123123
$esc_content = DB::escape(json_encode($content));
@@ -133,14 +133,14 @@ function handleCustomTestUpload($zip_file_name, $content, $tot_size) {
133133
Cookie::set('uoj_preferred_language', $language, time() + 60 * 60 * 24 * 365, '/');
134134
}
135135
$esc_language = DB::escape($language);
136-
136+
137137
$result = array();
138138
$result['status'] = "Waiting";
139139
$result_json = json_encode($result);
140-
140+
141141
DB::insert("insert into custom_test_submissions (problem_id, submit_time, submitter, content, status, result) values ({$problem['id']}, now(), '{$myUser['username']}', '$esc_content', '{$result['status']}', '$result_json')");
142142
}
143-
143+
144144
if ($can_use_zip_upload) {
145145
$zip_answer_form = newZipSubmissionForm('zip_answer',
146146
$submission_requirement,
@@ -156,7 +156,7 @@ function handleCustomTestUpload($zip_file_name, $content, $tot_size) {
156156
$zip_answer_form->succ_href = $is_in_contest ? "/contest/{$contest['id']}/submissions" : '/submissions';
157157
$zip_answer_form->runAtServer();
158158
}
159-
159+
160160
$answer_form = newSubmissionForm('answer',
161161
$submission_requirement,
162162
'uojRandAvailableSubmissionFileName',
@@ -204,7 +204,7 @@ function(response_text) {custom_test_onsubmit(response_text, $('#div-custom_test
204204
?>
205205
<?php
206206
$REQUIRE_LIB['mathjax'] = '';
207-
$REQUIRE_LIB['hljs'] = '';
207+
$REQUIRE_LIB['prism'] = '';
208208
?>
209209
<?php echoUOJPageHeader(HTML::stripTags($problem['title']) . ' - ' . UOJLocale::get('problems::problem')) ?>
210210
<?php

web/app/controllers/subdomain/blog/archive.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
<?php
22
requirePHPLib('form');
3-
3+
44
$blogs_cond = "poster = '".UOJContext::userid()."' and is_draft = false";
55
if (!UOJContext::hasBlogPermission()) {
66
$blogs_cond .= " and is_hidden = false";
77
}
8-
8+
99
$display_blogs_cond = $blogs_cond;
10-
10+
1111
if (isset($_GET['tag'])) {
1212
$blog_tag_required = $_GET['tag'];
1313
$display_blogs_cond .= " and '".DB::escape($blog_tag_required)."' in (select tag from blogs_tags where blogs_tags.blog_id = blogs.id)";
1414
} else {
1515
$blog_tag_required = null;
1616
}
17-
17+
1818
$blogs_pag = new Paginator(array(
1919
'col_names' => array('*'),
2020
'table_name' => 'blogs',
2121
'cond' => $display_blogs_cond,
2222
'tail' => 'order by post_time desc',
2323
'page_len' => 10
2424
));
25-
25+
2626
$all_tags = DB::selectAll("select distinct tag from blogs_tags where blog_id in (select id from blogs where $blogs_cond)");
27-
27+
2828
requireLib('mathjax');
29-
requireLib('hljs');
29+
requireLib('prism');
3030
?>
3131
<?php echoUOJPageHeader('日志') ?>
3232

@@ -75,7 +75,7 @@
7575
<?php endforeach ?>
7676
<?php endif ?>
7777
<?php endif ?>
78-
78+
7979
<?= $blogs_pag->pagination() ?>
8080
</div>
8181
</div>

0 commit comments

Comments
 (0)