-
Notifications
You must be signed in to change notification settings - Fork 0
/
404.html
290 lines (265 loc) · 11.4 KB
/
404.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="description" content="这是个Blog,Ctrl+D收藏不迷路">
<meta name="keywords" content="Sheng,Blog">
<meta name="author" content="Sheng">
<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:site" content="@example.com"/>
<meta name="twitter:title" content="Sheng's Blog"/>
<meta name="twitter:image" content="https://sheng.pages.dev/plugins/seo/twitterbanner.png"/>
<meta property="og:image" content="https://sheng.pages.dev/plugins/seo/facebookbanner.png"/>
<title>Sheng's Blog</title>
<link rel="icon" href="/favicon.ico" sizes="23x23" type="image/x-icon" >
<noscript><p><font size="5" face="arial" color="red">You should enable Javascript to work with this page.</font></p></noscript>
<script src="/showdown.min.js"></script>
<script type="text/javascript" charset="UTF-8" src="/config.js"></script>
<style>
body{
background-color: #a2e1d4;
/*border:1px solid black;width:100%;overflow-y:scroll;overflow-x:scroll;*/
}
img{ width:auto; height:auto; max-width:60%; max-height:60%;}
code {
display: block;
font-family: Consolas, "Courier New", monospace;
font-size: 14px;
line-height: 1.5;
padding: 10px;
background-color: #1a1f16;
color: #ff9f43;
border-radius: 5px;
white-space: pre-wrap;
word-wrap: break-word;
}
code::before {
content: attr(data-lang) " ";
color: #999;
font-weight: bold;
}
code:hover {
cursor: pointer;
}
code::selection {
background-color: #ddd;
color: #000;
}
.myButton {
box-shadow: 0px 10px 14px -7px #276873;
background:linear-gradient(to bottom, #599bb3 5%, #408c99 100%);
background-color:#599bb3;
border-radius:8px;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-family:Arial;
font-size:20px;
font-weight:bold;
padding:13px 32px;
text-decoration:none;
text-shadow:0px 1px 0px #3d768a;
}
.myButton:hover {
background:linear-gradient(to bottom, #408c99 5%, #599bb3 100%);
background-color:#408c99;
}
.myButton:active {
position:relative;
top:1px;
}
.read_pro {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 3px;
background-color: #DDD;
}
.read_pro_inner {
content: '';
position: absolute;
left: 0;
height: 100%;
background-color: #0089f2;
}
</style>
</head>
<body>
<div class="read_pro">
<div class="read_pro_inner" id="read_pro_inner"></div>
</div>
<div id="google_translate_element" style="position:absolute;top:10px;right:10px;z-index:2000;opacity:0.8"></div><br>
<center>
<h1 id="body_blog_title"><strong>Blog_Title</strong></h1>
<a class="myButton" id="button_1" href="/">Button_1</a> <a class="myButton" id="button_2"href="/List">Button_2</a> <a class="myButton" id="button_3" href="/About">Button_3</a>
</center>
<div id="container">
<div id="header" style="background-color:#acf6ef;border-radius:25px;">
<h1 id="article_title" style="margin-bottom:0;border-radius:25px;text-align:center;">Loading...</h1>
</div>
<div id="article_content" style="background-color:#cbf5fb;width:100%;word-break:break-all;word-wrap:break-word;border-radius:5px;">
<center>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32px" height="32px" viewBox="0 0 128 128">
<g>
<circle cx="16" cy="64" r="16" fill="#ff3300" fill-opacity="1"/>
<circle cx="16" cy="64" r="16" fill="#ff7755" fill-opacity="0.67" transform="rotate(45,64,64)"/>
<circle cx="16" cy="64" r="16" fill="#ffa994" fill-opacity="0.42" transform="rotate(90,64,64)"/>
<circle cx="16" cy="64" r="16" fill="#ffd6cc" fill-opacity="0.2" transform="rotate(135,64,64)"/>
<circle cx="16" cy="64" r="16" fill="#ffe7e1" fill-opacity="0.12" transform="rotate(180,64,64)"/>
<circle cx="16" cy="64" r="16" fill="#ffe7e1" fill-opacity="0.12" transform="rotate(225,64,64)"/>
<circle cx="16" cy="64" r="16" fill="#ffe7e1" fill-opacity="0.12" transform="rotate(270,64,64)"/>
<circle cx="16" cy="64" r="16" fill="#ffe7e1" fill-opacity="0.12" transform="rotate(315,64,64)"/>
<animateTransform attributeName="transform" type="rotate" values="0 64 64;315 64 64;270 64 64;225 64 64;180 64 64;135 64 64;90 64 64;45 64 64" calcMode="discrete" dur="720ms" repeatCount="indefinite"></animateTransform>
</g>
</svg>
<br>You should enable Javascript to work with this page.</div>
</center>
<div id="disqus_thread"></div>
<div style="background-color:#acf6ef;clear:both;text-align:center;border-radius:25px;"><h2 id="footer">Copyright © example.com</h2></div>
</div>
</body>
<script type="text/javascript" charset="UTF-8" src="/language.js"></script>
<script>
function getDomain(){
var url = document.location.toString();
var HttpOrHttps = url.split("//")[0];
var domain = url.split("//")[1].split("/")[0];
return(HttpOrHttps+"//"+domain+"/")
}
function getPath(){
var url = document.location.toString();
var arrUrl = url.split("//");
var start = arrUrl[1].indexOf("/")+1;
var relUrl = arrUrl[1].substring(start);
if(relUrl.indexOf("?") != -1){
relUrl = relUrl.split("?")[0];
}
return relUrl;
}
function getTitle(){
var url = document.location.toString();
var path = url.split("//")[1].split("/")[-1];
return(path)
}
function getQueryVariable(variable)
{
/*
url 实例:
https://www.example.com/index.php?id=1&image=awesome.jpg
调用 getQueryVariable("id") 返回 1。
调用 getQueryVariable("image") 返回 "awesome.jpg"。
*/
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
}
return(false);
}
function LoadHTML(markdown_text){
var htmlpage = new showdown.Converter(),
//text = '# hello, markdown!',
text = markdown_text,
html = htmlpage.makeHtml(text);
//加载body中的文章
document.getElementById('article_content').innerHTML= html;
//document.querySelector('body').innerHTML = html;
//document.getElementById('article').innerHTML= htmlpage;
//var name = 'leo';
//var htmlStr = `<div><span>${name}</span></div>`
}
function DomainCheck(){
// 如果当前域名不在允许列表中,将跳转到指定的域名
if (allowedDomains.includes(document.domain)) {
console.log("Domain Allowed")
}
else{
console.log("Domain Disallowed")
const newUrl = ForceJumpBack + getPath();
window.location.href = newUrl;
}
}
function googleTranslateElementInit() {
new google.translate.TranslateElement(
{
includedLanguages: 'en,zh-CN,zh-HK,zh-TW,hr,cs,da,nl,fr,de,el,iw,hu,ga,it,ja,ko,pt,ro,ru,sr,es,th,vi',
layout: google.translate.TranslateElement.InlineLayout.SIMPLE,
autoDisplay: true,
},
'google_translate_element'
);
}
function PathRewrite(){
//自动改写超链接到/?p=xxx以避免404错误码
const LinksInPage = document.querySelectorAll('a');
LinksInPage.forEach(link => {
const url = link.href;
console.log(url)
const parsedUrl = new URL(url);
const hostname = parsedUrl.hostname;
let path = parsedUrl.pathname;
if (PathRewriteDomains.includes(hostname) && !path.startsWith('/?p=')) {
path = path.replace('/', '');
const newPath = '?p=' + path;
link.href = parsedUrl.origin + newPath + parsedUrl.hash;
}
});
}
function ButtonRewrite(){
document.getElementById("button_1").href = getDomain();
document.getElementById("button_2").href = "/?p=List";
document.getElementById("button_3").href = "/?p=About";
}
DomainCheck();
document.getElementById('body_blog_title').innerHTML = blog_name;
document.getElementById('footer').innerHTML= "Copyright © "+blog_name;//底部版权
//document.getElementById('footer').innerHTML= "Copyright © "+startYear+"-"+new Date().getFullYear()+" "+blog_name;//底部版权
let xhr = new XMLHttpRequest();
var md_url = getDomain()+"articles/"+getPath()+".md";
xhr.open("get", md_url, true);
xhr.onload = function () {
if (this.status == 200) {
// if (callback) {
// callback();
//console.log(this.response)
LoadHTML(this.response)
//const reader = new FileReader()
//reader.onload = function () {
// console.log('reader.result', reader.result)
//}
//reader.readAsText(this.response);
//加载标题
document.getElementsByTagName("title")[0].innerText = decodeURI(getPath().split("/").pop())+"_"+blog_name;//是路径中最后一个斜杠后面的文字
//加载body中的标题
document.getElementById('article_title').innerHTML = decodeURI(getPath().split("/").pop());
}
else{
//如果文章不存在
document.getElementsByTagName("title")[0].innerText = "404_"+blog_name;//加载标题
document.getElementById('article_title').innerHTML = "404 "+blog_language_404;//加载body中的标题
//加载body中的文章
document.getElementById('article_content').innerHTML= "";
}
if (PathRewriteDomains.includes(document.domain)){
if (getPath()=="List"){
PathRewrite();
}
ButtonRewrite();
}
};
xhr.send();
document.addEventListener('scroll', function(e) {
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop; // 已经读过被卷起来的文档部分
var scrollHeight = document.documentElement.scrollHeight // 文档总高度
var clientHeight = document.documentElement.clientHeight // 窗口可视高度
document.getElementById('read_pro_inner').style.width = +(scrollTop/(scrollHeight-clientHeight)).toFixed(2)*100 + '%'
})
</script>
<script type="text/javascript" charset="UTF-8" src="/plugins.js"></script>
<!--Google Translate
<script src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
-->
</html>