forked from barryclark/jekyll-now
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaper-review-template.html
More file actions
486 lines (432 loc) · 21.7 KB
/
paper-review-template.html
File metadata and controls
486 lines (432 loc) · 21.7 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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Paper Review - [Paper Title]</title>
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<!-- Add highlight.js for code syntax highlighting (with explicit loading of languages) -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@11.7.0/styles/github.css">
<script src="https://cdn.jsdelivr.net/npm/highlight.js@11.7.0/lib/highlight.min.js"></script>
<!-- Add Marked.js for Markdown parsing (pinned version) -->
<script src="https://cdn.jsdelivr.net/npm/marked@4.3.0/marked.min.js"></script>
<!-- Add MathJax for rendering LaTeX equations -->
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<!-- Inline initialization script to ensure highlight.js is properly loaded -->
<script>
// Global flag to track if highlight.js is available
window.highlightJsLoaded = false;
// Function to check if highlight.js is available
function checkHighlightJs() {
if (typeof hljs !== 'undefined') {
console.log('highlight.js detected');
window.highlightJsLoaded = true;
// Configure highlight.js
try {
hljs.configure({
ignoreUnescapedHTML: true
});
console.log('highlight.js configured successfully');
} catch (err) {
console.error('Failed to configure highlight.js:', err);
}
return true;
}
return false;
}
// Try to initialize highlight.js when the script loads
checkHighlightJs();
// Also check when the DOM is fully loaded
document.addEventListener('DOMContentLoaded', function() {
if (!window.highlightJsLoaded) {
if (checkHighlightJs()) {
console.log('highlight.js initialized on DOMContentLoaded');
} else {
console.warn('highlight.js not available on DOMContentLoaded');
// Try to load highlight.js dynamically if not available
const script = document.createElement('script');
script.src = 'https://cdn.jsdelivr.net/npm/highlight.js@11.7.0/lib/highlight.min.js';
script.onload = function() {
console.log('highlight.js loaded dynamically');
checkHighlightJs();
};
document.head.appendChild(script);
}
}
});
</script>
<style>
/* Debug panel styles */
#debug-panel {
position: fixed;
bottom: 0;
right: 0;
width: 400px;
max-height: 300px;
overflow-y: auto;
background-color: rgba(0, 0, 0, 0.8);
color: #fff;
font-family: monospace;
font-size: 12px;
padding: 10px;
z-index: 9999;
display: none;
}
#debug-panel.show {
display: block;
}
#debug-panel .log {
margin-bottom: 5px;
border-bottom: 1px solid #444;
padding-bottom: 5px;
}
#debug-panel .error {
color: #ff6b6b;
}
#debug-panel .warn {
color: #feca57;
}
#debug-panel .info {
color: #54a0ff;
}
#debug-toggle {
position: fixed;
bottom: 10px;
right: 10px;
background-color: #333;
color: white;
border: none;
padding: 5px 10px;
border-radius: 4px;
cursor: pointer;
z-index: 10000;
}
</style>
</head>
<body>
<header>
<div class="container">
<div class="logo">
<a href="index.html">Your Name</a>
</div>
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="index.html#about">About</a></li>
<li><a href="index.html#projects">Projects</a></li>
<li><a href="index.html#papers">Paper Reviews</a></li>
<li><a href="index.html#contact">Contact</a></li>
</ul>
<div class="mobile-menu-btn">
<span></span>
<span></span>
<span></span>
</div>
</nav>
</div>
</header>
<main class="paper-review">
<div class="container">
<article class="review-content">
<!-- Paper Header -->
<header class="paper-header">
<h1 id="paper-title">Paper Title</h1>
<div class="paper-meta">
<p class="authors" id="paper-authors">Authors: Author 1, Author 2, et al.</p>
<p class="conference" id="paper-conference">Conference/Journal: Conference Name Year</p>
<div class="paper-links">
<a href="#" class="btn small" target="_blank" id="paper-pdf">
<i class="fas fa-file-pdf"></i> PDF
</a>
<a href="#" class="btn small" target="_blank" id="paper-code">
<i class="fas fa-code"></i> Code
</a>
</div>
</div>
</header>
<!-- Content will be loaded from Markdown -->
<div id="markdown-content">
<div class="loading">
<p>Loading paper review...</p>
</div>
</div>
</article>
<!-- Sidebar -->
<aside class="review-sidebar">
<div class="paper-info-card">
<h3>Paper Information</h3>
<ul id="paper-metadata">
<li><strong>Category:</strong> <span id="paper-category">[Category]</span></li>
<li><strong>Year:</strong> <span id="paper-year">[Year]</span></li>
<li><strong>Venue:</strong> <span id="paper-venue">[Venue]</span></li>
<li><strong>Citations:</strong> <span id="paper-citations">[Number]</span></li>
</ul>
</div>
<div class="related-papers">
<h3>Related Papers</h3>
<ul id="related-papers-list">
<li><a href="#">Related Paper 1</a></li>
<li><a href="#">Related Paper 2</a></li>
<li><a href="#">Related Paper 3</a></li>
</ul>
</div>
</aside>
</div>
</main>
<footer>
<div class="container">
<p>© <span id="year">2024</span> Your Name. All rights reserved.</p>
</div>
</footer>
<div id="debug-panel"></div>
<button id="debug-toggle">Debug</button>
<script src="js/main.js"></script>
<script>
// Custom logger for debugging
const debugPanel = document.getElementById('debug-panel');
const debugToggle = document.getElementById('debug-toggle');
// Override console methods to also display in debug panel
const originalConsole = {
log: console.log,
error: console.error,
warn: console.warn,
info: console.info
};
function addToDebugPanel(type, ...args) {
const logItem = document.createElement('div');
logItem.className = `log ${type}`;
logItem.textContent = args.map(arg =>
typeof arg === 'object' ? JSON.stringify(arg) : String(arg)
).join(' ');
debugPanel.appendChild(logItem);
debugPanel.scrollTop = debugPanel.scrollHeight;
}
console.log = function(...args) {
originalConsole.log(...args);
addToDebugPanel('log', ...args);
};
console.error = function(...args) {
originalConsole.error(...args);
addToDebugPanel('error', ...args);
};
console.warn = function(...args) {
originalConsole.warn(...args);
addToDebugPanel('warn', ...args);
};
console.info = function(...args) {
originalConsole.info(...args);
addToDebugPanel('info', ...args);
};
debugToggle.addEventListener('click', function() {
debugPanel.classList.toggle('show');
});
document.addEventListener('DOMContentLoaded', async function() {
// Get the paper ID from the URL parameter
const urlParams = new URLSearchParams(window.location.search);
const paperId = urlParams.get('id') || 'example-paper'; // Default to example-paper if no ID provided
console.log(`Loading paper with ID: ${paperId}`);
try {
// Load paper metadata and content
const metadataResponse = await fetch(`papers/${paperId}/metadata.json`);
if (!metadataResponse.ok) {
throw new Error(`Failed to load paper metadata: ${metadataResponse.status} ${metadataResponse.statusText}`);
}
const metadata = await metadataResponse.json();
console.log('Metadata loaded successfully:', metadata);
// Update page title
document.title = `Paper Review - ${metadata.title}`;
// Update header information
document.getElementById('paper-title').textContent = metadata.title;
document.getElementById('paper-authors').textContent = `Authors: ${metadata.authors}`;
document.getElementById('paper-conference').textContent = `Conference/Journal: ${metadata.venue} ${metadata.year}`;
// Update links
if (metadata.pdfUrl) {
document.getElementById('paper-pdf').href = metadata.pdfUrl;
}
if (metadata.codeUrl) {
document.getElementById('paper-code').href = metadata.codeUrl;
} else {
document.getElementById('paper-code').style.display = 'none';
}
// Update sidebar metadata
document.getElementById('paper-category').textContent = metadata.category;
document.getElementById('paper-year').textContent = metadata.year;
document.getElementById('paper-venue').textContent = metadata.venue;
document.getElementById('paper-citations').textContent = metadata.citations || 'N/A';
// Update related papers
const relatedPapersList = document.getElementById('related-papers-list');
relatedPapersList.innerHTML = '';
if (metadata.relatedPapers && metadata.relatedPapers.length > 0) {
metadata.relatedPapers.forEach(paper => {
const li = document.createElement('li');
const a = document.createElement('a');
a.href = `paper-review-template.html?id=${paper.id}`;
a.textContent = paper.title;
li.appendChild(a);
relatedPapersList.appendChild(li);
});
} else {
relatedPapersList.innerHTML = '<li>No related papers</li>';
}
// Load and render the Markdown content
console.log(`Attempting to load Markdown content from papers/${paperId}/review.md`);
try {
let markdownContent = '';
try {
// First try with fetch API
console.log('Trying fetch API first...');
const contentResponse = await fetch(`papers/${paperId}/review.md`);
if (!contentResponse.ok) {
throw new Error(`Failed to load paper content: ${contentResponse.status} ${contentResponse.statusText}`);
}
markdownContent = await contentResponse.text();
console.log('Markdown content loaded via fetch, length:', markdownContent.length);
} catch (fetchError) {
console.warn('Fetch failed, trying XMLHttpRequest as fallback:', fetchError);
// Fallback to XMLHttpRequest (sometimes works better with local files)
markdownContent = await new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.open('GET', `papers/${paperId}/review.md`, true);
xhr.onload = function() {
if (xhr.status === 200) {
console.log('Markdown content loaded via XHR, length:', xhr.responseText.length);
resolve(xhr.responseText);
} else {
reject(new Error(`XHR request failed: ${xhr.status}`));
}
};
xhr.onerror = function() {
reject(new Error('Network error occurred'));
};
xhr.send();
});
}
// Verify content loaded
if (!markdownContent || markdownContent.trim() === '') {
throw new Error('Markdown content is empty');
}
// Check if marked.js is available
if (typeof marked === 'undefined') {
throw new Error('marked.js library is not loaded');
}
// Configure marked.js options
console.log('Configuring marked.js...');
try {
// Using the latest marked.js API
marked.use({
pedantic: false,
gfm: true,
breaks: true,
sanitize: false,
smartLists: true,
smartypants: true,
highlight: function(code, lang) {
// Check if highlight.js is available using our global flag
if (!window.highlightJsLoaded) {
// Try to check again, maybe it loaded in the meantime
checkHighlightJs();
}
if (!window.highlightJsLoaded) {
console.warn('highlight.js not available for syntax highlighting, displaying plain code');
return code;
}
// Apply syntax highlighting if language is specified and available
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(code, { language: lang }).value;
} catch (err) {
console.error('Failed to highlight code block:', err);
}
}
// Fallback to auto-detection or plain code
try {
return hljs.highlightAuto(code).value;
} catch (err) {
console.error('Failed to auto-highlight code block:', err);
return code;
}
}
});
// Convert markdown to HTML and insert into the page
console.log('Parsing Markdown content...');
const parsedHtml = marked.parse(markdownContent);
console.log('Markdown parsed successfully, HTML length:', parsedHtml.length);
// Set the HTML content
document.getElementById('markdown-content').innerHTML = parsedHtml;
console.log('HTML content set to DOM');
// Initialize syntax highlighting for code blocks
console.log('Initializing syntax highlighting for code blocks...');
if (window.highlightJsLoaded) {
document.querySelectorAll('pre code').forEach((block) => {
try {
hljs.highlightElement(block);
} catch (err) {
console.error('Error highlighting code block:', err);
}
});
} else {
console.warn('highlight.js not available for code block highlighting');
// Try one more time to load highlight.js and apply it
setTimeout(function() {
if (checkHighlightJs()) {
console.log('highlight.js loaded on delayed check, applying to code blocks');
document.querySelectorAll('pre code').forEach((block) => {
try {
hljs.highlightElement(block);
} catch (err) {
console.error('Error highlighting code block on delayed check:', err);
}
});
}
}, 1000); // Wait 1 second and try again
}
} catch (markdownError) {
console.error('Error in marked.js:', markdownError);
// Fallback to basic HTML
document.getElementById('markdown-content').innerHTML = `
<div class="error">
<h2>Error Processing Markdown</h2>
<p>${markdownError.message}</p>
<hr>
<pre>${markdownContent}</pre>
</div>
`;
}
// Render MathJax equations
if (typeof MathJax !== 'undefined') {
console.log('Rendering MathJax equations...');
MathJax.typesetPromise().catch((err) => {
console.error('Error rendering MathJax:', err);
});
} else {
console.warn('MathJax is not available');
}
} catch (contentError) {
console.error('Error loading/rendering Markdown:', contentError);
document.getElementById('markdown-content').innerHTML = `
<div class="error">
<h2>Error Loading Paper Content</h2>
<p>${contentError.message}</p>
<p>Please check that the review.md file exists at papers/${paperId}/review.md</p>
</div>
`;
}
} catch (error) {
console.error('Error loading paper review:', error);
document.getElementById('markdown-content').innerHTML = `
<div class="error">
<h2>Error Loading Paper Review</h2>
<p>${error.message}</p>
<p>Please check the paper ID and try again.</p>
</div>
`;
}
});
</script>
</body>
</html>