Repository navigation
Expand file tree
/
Copy pathdirectory.html
More file actions
295 lines (252 loc) Β· 8.46 KB
/
Copy pathdirectory.html
File metadata and controls
295 lines (252 loc) Β· 8.46 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
295
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Directory Listing</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.container {
background: white;
border-radius: 8px;
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
max-width: 700px;
width: 100%;
overflow: hidden;
}
.header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 30px;
text-align: center;
}
.header h1 {
font-size: 28px;
margin-bottom: 8px;
}
.header p {
opacity: 0.9;
font-size: 14px;
}
.content {
padding: 30px;
}
.file-list {
list-style: none;
}
.file-item {
padding: 12px 16px;
border-bottom: 1px solid #e5e7eb;
border-radius: 4px;
margin-bottom: 8px;
background: #f9fafb;
transition: all 0.3s ease;
display: flex;
align-items: center;
gap: 12px;
}
.file-item:hover {
background: #f3f4f6;
transform: translateX(4px);
}
.file-item:last-child {
border-bottom: none;
}
.file-item a {
color: #667eea;
text-decoration: none;
font-weight: 500;
flex-grow: 1;
word-break: break-all;
}
.file-item a:hover {
color: #764ba2;
text-decoration: underline;
}
.file-icon {
font-size: 20px;
min-width: 24px;
}
.file-type {
font-size: 12px;
color: #6b7280;
background: white;
padding: 2px 8px;
border-radius: 3px;
white-space: nowrap;
margin-left: auto;
}
.back-link {
display: inline-block;
margin-bottom: 20px;
color: #667eea;
text-decoration: none;
font-size: 14px;
font-weight: 500;
}
.back-link:hover {
text-decoration: underline;
}
.empty-state {
text-align: center;
color: #6b7280;
padding: 40px 20px;
}
/* Dark mode */
@media (prefers-color-scheme: dark) {
body {
background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
}
.container {
background: #2d3748;
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.header {
background: linear-gradient(135deg, #4c51bf 0%, #6b46c1 100%);
color: #f7fafc;
}
.content {
color: #e2e8f0;
}
.file-item {
background: #374151;
border-bottom: 1px solid #4b5563;
color: #e2e8f0;
}
.file-item:hover {
background: #424f63;
}
.file-item a {
color: #a5b4fc;
}
.file-item a:hover {
color: #c4b5fd;
}
.file-type {
background: #2d3748;
color: #cbd5e0;
}
.back-link {
color: #a5b4fc;
}
.back-link:hover {
color: #c4b5fd;
}
.empty-state {
color: #a0aec0;
}
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>π Directory Listing</h1>
<p>Browse available files and resources</p>
</div>
<div class="content">
<a href="/" class="back-link">β Back to Home</a>
<ul class="file-list" id="fileList">
<li class="empty-state">Loading directory contents...</li>
</ul>
</div>
</div>
<script>
const REPO_OWNER = 'Aravindan22';
const REPO_NAME = 'aravindan22.github.io';
const API_URL = `https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/contents/`;
// File type detection
function getFileType(filename) {
const ext = filename.split('.').pop().toLowerCase();
const types = {
'html': 'HTML',
'pdf': 'PDF',
'md': 'Markdown',
'txt': 'Text',
'js': 'JavaScript',
'css': 'CSS',
'json': 'JSON',
'jpg': 'Image',
'jpeg': 'Image',
'png': 'Image',
'gif': 'Image',
'svg': 'SVG',
'zip': 'Archive',
'tar': 'Archive'
};
return types[ext] || ext.toUpperCase();
}
// Get appropriate icon
function getIcon(filename) {
const ext = filename.split('.').pop().toLowerCase();
const icons = {
'html': 'π',
'pdf': 'π',
'md': 'π',
'txt': 'π',
'js': 'βοΈ',
'css': 'π¨',
'json': 'βοΈ',
'jpg': 'πΌοΈ',
'jpeg': 'πΌοΈ',
'png': 'πΌοΈ',
'gif': 'πΌοΈ',
'svg': 'πΌοΈ',
'zip': 'π¦',
'tar': 'π¦'
};
return icons[ext] || 'π';
}
// Fetch and display directory contents
async function loadDirectory() {
const fileList = document.getElementById('fileList');
try {
const response = await fetch(API_URL);
if (!response.ok) throw new Error('Failed to fetch directory');
const files = await response.json();
// Filter out hidden files and directories
const visibleFiles = files.filter(file =>
!file.name.startsWith('.') &&
file.type === 'file'
).sort((a, b) => a.name.localeCompare(b.name));
if (visibleFiles.length === 0) {
fileList.innerHTML = '<li class="empty-state">No files found</li>';
return;
}
fileList.innerHTML = visibleFiles.map(file => {
const isHtml = file.name.toLowerCase().endsWith('.html');
const downloadAttr = isHtml ? '' : 'download';
const targetAttr = isHtml ? 'target="_blank"' : '';
return `
<li class="file-item">
<span class="file-icon">${getIcon(file.name)}</span>
<a href="${file.name}" ${targetAttr} ${downloadAttr}>${file.name}</a>
<span class="file-type">${getFileType(file.name)}</span>
</li>
`;
}).join('');
} catch (error) {
fileList.innerHTML = `<li class="empty-state">Error loading directory: ${error.message}</li>`;
console.error('Error:', error);
}
}
// Load directory on page load
document.addEventListener('DOMContentLoaded', loadDirectory);
// Refresh every 30 seconds to auto-update
setInterval(loadDirectory, 30000);
</script>
</body>
</html>