-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathissuse.html
More file actions
294 lines (252 loc) · 10.3 KB
/
issuse.html
File metadata and controls
294 lines (252 loc) · 10.3 KB
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
291
292
293
294
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="cache-control" content="max-age=7200">
<meta name="theme-color" content="#ffffff">
<title>GithuBlog | Issue Detail</title>
<!-- Styles -->
<link href="bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<!-- Third-party Styles -->
<link rel="stylesheet" href="gitalk.css" crossorigin="anonymous">
<link rel="stylesheet" href="obsidian.min.css">
<!-- Scripts -->
<script src="jquery.min.js"></script>
<script src="bootstrap.min.js"></script>
<script src="lodash.min.js"></script>
<script src="showdown.min.js"></script>
<script src="gitalk.min.js" crossorigin="anonymous"></script>
<script src="highlight.min.js"></script>
<script>
// Dynamic mermaid loader
const loadScript = (url, onloadFunction) => {
var newScript = document.createElement("script");
newScript.onerror = (oError) => {
throw new URIError("The script " + oError.target.src + " didn't load correctly.");
};
if (onloadFunction) { newScript.onload = onloadFunction; }
document.head.insertAdjacentElement('beforeend', newScript);
newScript.src = url;
}
const loadMermaidOnNeed = () => {
loadScript('mermaid10.min.js', () => {
document.head.insertAdjacentHTML("beforeend", `<style>.mermaid svg { background-color: #ffffff !important; }</style>`);
console.log("mermaid init done");
mermaid.initialize({ startOnLoad: false, securityLevel: "strict", theme: "default" });
window.mermaid.init(undefined, document.querySelectorAll('.language-mermaid'));
})
}
</script>
<script>
var config;
// XHR Helper
function doGetJSON(url, successHandler, errorHandler) {
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
successHandler(JSON.parse(xhr.responseText));
} else if (errorHandler) {
errorHandler(xhr);
}
}
};
xhr.send(null);
}
// Initialize
doGetJSON('config.json', function (data) {
config = data[document.domain] || data['taontech.github.io'] || data['127.0.0.1'];
if (config) {
// Initialize Auth
Auth.init();
// Load Issue Content
var bd = localStorage.getItem(getiid());
// Always try to fetch fresh if not explicit offline mode, but honoring existing logic
// If local storage has it, render it first then maybe verify?
// Existing logic: if(bd == undefined) showMarkdown() else showLocalMarkdown(bd)
// Let's stick to existing optimization but make it robust
if (bd) {
showLocalMarkdown(bd);
} else {
showMarkdown(); // Fetch from API
}
// Update Edit Link
var edit = document.getElementById("edit_text");
if (edit) edit.href = `https://github.com/${config.owner}/${config.repo}/issues/${getiid()}`;
}
});
// Auth placeholder (assuming Auth is loaded via auth.js or we need access to it)
// Since auth.js is not imported yet, let's allow basic page function without full auth integration for commenting for now,
// OR import auth.js. I will import auth.js in the body.
</script>
<script>
var parseAndRender = function (text) {
var converter = new showdown.Converter();
converter.setFlavor('github');
converter.setOption('tables', true);
document.getElementById("iss-container").innerHTML = converter.makeHtml(text);
};
function getQueryVariable(variable) {
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 getiid() {
var url = location.hash; //#
url = decodeURI(url);
var iid = 0;
if (url.indexOf("#") != -1) {
iid = url.substr(1);
}
return iid;
}
function renderPageElements(data) {
// Header Info
let img = document.getElementById("headImg");
if (data.user) img.src = data.user.avatar_url;
else if (data.owner) img.src = data.owner.avatar_url; // Handle repo vs issue object diffs if any
let name = document.getElementById("owner");
if (data.user) name.innerText = data.user.login;
// Title
var title = document.getElementById("issue-title");
title.innerText = data.title;
// Body
parseAndRender(data.body);
loadMermaidOnNeed();
hljs.highlightAll();
// Gitalk
if (typeof Gitalk !== 'undefined') {
var gitalk = new Gitalk({
id: data.id, // Ensure ID is string/unique. GitHub Issue ID is unique.
number: data.number,
title: data.title,
clientID: config.clientId,
clientSecret: config.clientSecret,
repo: config.repo,
owner: config.owner,
admin: [config.owner],
body: decodeURI(location.href)
});
gitalk.render('gitalk-container');
}
}
function showLocalMarkdown(bdStr) {
var bd = JSON.parse(bdStr);
renderPageElements(bd);
}
function showMarkdown() {
var url = `https://api.github.com/repos/${config.owner}/${config.repo}/issues/${getiid()}`;
doGetJSON(url, function (bb) {
// console.log(bb)
localStorage.setItem(bb.number, JSON.stringify(bb)); // Save complete object, note: previous code saved responseText
renderPageElements(bb);
});
}
</script>
<!-- Additional styles for issue content -->
<style>
.issue-card {
background: #fff;
border-radius: 8px;
box-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
padding: 40px;
margin-bottom: 40px;
}
.issue-title {
font-family: 'Google Sans', sans-serif;
font-size: 2rem;
color: #202124;
margin-bottom: 20px;
border-bottom: 1px solid #dadce0;
padding-bottom: 20px;
}
/* Markdown Content Adjustments */
#iss-container img {
max-width: 100%;
border-radius: 4px;
}
#iss-container pre {
background: #f6f8fa;
padding: 16px;
border-radius: 6px;
}
#iss-container blockquote {
color: #6a737d;
border-left: 0.25em solid #dfe2e5;
padding: 0 1em;
}
.comments-section {
margin-top: 40px;
}
</style>
</head>
<body>
<!-- Particles Background -->
<div id="particles-js"></div>
<!-- Header / Navbar -->
<header id="ownerline">
<div class="brand-area">
<a href="/" style="display:flex; align-items:center; gap:12px; text-decoration:none;">
<img id="headImg" src="backtohome.png" alt="Avatar">
<span class="ownerName" id="owner">GithuBlog</span>
</a>
</div>
<div class="auth-area">
<a href="#" class="auth-btn" id="edit_text" target="_blank"
style="background-color: white; color: var(--text-secondary); border: 1px solid var(--border-color);">
Edit on GitHub
</a>
<div id="user-display" class="user-display" style="display:none;">
<img id="user-avatar-login" class="user-avatar-small" src="" alt="User">
<span id="user-name-login"></span>
<a href="javascript:Auth.logout()" class="auth-btn"
style="border:none; color: #ff6b6b; padding: 0 8px;">Logout</a>
</div>
<a href="javascript:Auth.login()" class="auth-btn" id="login-btn">Login</a>
</div>
</header>
<!-- Main Content -->
<div class="blogContainer article-mode">
<!-- Back Button -->
<div style="margin-bottom: 20px;">
<a href="/" class="pageLink" style="display:inline-flex; align-items:center; gap:5px;">
← Back to Home
</a>
</div>
<!-- Issue Card -->
<div class="issue-card">
<div id="issue-title" class="issue-title">Loading...</div>
<div id="iss-container"></div>
</div>
<!-- Comments -->
<div id="gitalk-container" class="comments-section"></div>
</div>
<!-- Footer Badge -->
<div class="footer-badge">
<a href="https://ipw.cn/ipv6webcheck/?site=ipw.cn" title="IPv6 Ready" target='_blank'>
<img style='display:inline-block;vertical-align:middle; height: 30px;' alt="IPv6 Ready"
src="https://static.ipw.cn/icon/ipv6-s1.svg">
</a>
</div>
<!-- Scripts -->
<script src="particles.min.js"></script>
<script src="auth.js"></script>
<script src="app.js"></script> <!-- loads particles -->
<script>
// Init Auth if config managed to load it, but usually app.js/particles finishes last
// Additional auth init check if needed
window.addEventListener('load', function () {
if (typeof Auth !== 'undefined' && typeof config !== 'undefined') {
Auth.init();
}
});
</script>
</body>
</html>