-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
204 lines (167 loc) · 8.13 KB
/
index.html
File metadata and controls
204 lines (167 loc) · 8.13 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GithuBlog | Clean Edition</title>
<meta name="theme-color" content="#ffffff">
<!-- Styles -->
<link href="bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<!-- Scripts -->
<script src="jquery.min.js"></script>
<script src="lodash.min.js"></script>
</head>
<body>
<!-- Particles Background -->
<div id="particles-js"></div>
<!-- Header / Navbar -->
<header id="ownerline">
<div class="brand-area">
<img id="headImg" src="backtohome.png" alt="Avatar"> <!-- Fallback img -->
<a class="ownerName" id="owner" href="/">GithuBlog</a>
</div>
<div class="auth-area">
<a href="javascript:void(0)" class="auth-btn" id="new-issue-btn" style="display:none;">+ New Issue</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">
<svg height="20" viewBox="0 0 16 16" version="1.1" width="20" fill="currentColor">
<path
d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z">
</path>
</svg>
Login
</a>
</div>
</header>
<!-- Main Blog Content -->
<div class="blogContainer" id="blog">
<!-- Content inject by JS -->
<div style="text-align: center; color: #8b949e; margin-top: 50px;">
Loading...
</div>
</div>
<!-- Pagination -->
<div class="pagesContainer" id="pages"></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>
<!-- Inline main logic from previous index.html, adapted -->
<script>
var config;
// Load Particles
particlesJS.load('particles-js', 'app.js', function () {
console.log('particles.js loaded');
});
// 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) {
// Determine config based on domain or fallback to taontech.github.io or localhost behavior
config = data[document.domain] || data['taontech.github.io'] || data['127.0.0.1'];
// If we found a valid config
if (config) {
// Initialize Auth
Auth.init();
// Load Owner Info & Issues
loadRepoInfo();
var pageIndex = Auth.getQueryVariable("p");
loadIssues(pageIndex ? pageIndex : 1); // GitHub API uses 1-based paging, but check old logic
// Update new issue link
var newIssueBtn = document.getElementById("new-issue-btn");
newIssueBtn.setAttribute("href", `https://github.com/${config.owner}/${config.repo}/issues/new`);
newIssueBtn.style.display = "inline-flex";
}
});
function loadRepoInfo() {
var url = `https://api.github.com/repos/${config.owner}/${config.repo}`;
doGetJSON(url, function (repo) {
// Update Header
let img = document.getElementById("headImg");
img.src = repo.owner.avatar_url;
let name = document.getElementById("owner");
name.innerText = repo.owner.login;
name.href = repo.html_url;
// Pagination Calculation
let issuesCount = repo.open_issues;
// Assuming 10 per page
let pageCount = Math.ceil(issuesCount / 10);
var container = document.getElementById("pages");
container.innerHTML = ""; // clear
for (let i = 1; i <= pageCount; i++) {
var page = document.createElement("a");
page.className = "pageLink";
page.href = "/?p=" + i;
page.innerText = i;
// Simple active check
var currentPage = Auth.getQueryVariable("p") || 1;
if (i == currentPage) page.classList.add("active");
container.appendChild(page);
}
});
}
function loadIssues(pageIndex) {
// Check old logic: was pageIndex 0 based or 1 based? Old code: "issues?per_page=10&page="+pageIndex
// GitHub API is 1-based by default. If old code passed 0, it might return page 1 (or error).
// Let's assume 1-based for safety or stick to passed value.
if (pageIndex < 1) pageIndex = 1;
var url = `https://api.github.com/repos/${config.owner}/${config.repo}/issues?per_page=10&page=${pageIndex}`;
doGetJSON(url, function (issues) {
var container = document.getElementById("blog");
container.innerHTML = ""; // Clear loading
issues.forEach(issue => {
// Create Card
var card = document.createElement("div");
card.className = "card-tech";
var titleLink = document.createElement("a");
titleLink.className = "card-title";
// Using existing issue viewer
titleLink.href = "issuse.html#" + issue.number;
titleLink.innerText = issue.title;
var meta = document.createElement("div");
meta.className = "card-meta";
meta.innerHTML = `
<span class="meta-item">📅 ${new Date(issue.created_at).toLocaleDateString()}</span>
<span class="meta-item">💬 ${issue.comments}</span>
`;
var preview = document.createElement("div");
preview.className = "card-preview";
var bodyText = issue.body ? issue.body.substr(0, 200).replace(/[#*`]/g, '') + "..." : "No description.";
preview.innerText = bodyText;
card.appendChild(titleLink);
card.appendChild(meta);
card.appendChild(preview);
// Cache for issue view
localStorage.setItem(issue.number, JSON.stringify(issue));
container.appendChild(card);
});
});
}
</script>
</body>
</html>