@knowcode/doc-builder 1.1.12 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +63 -0
- package/assets/css/notion-style.css +264 -49
- package/lib/core-builder.js +317 -68
- package/lib/deploy.js +12 -55
- package/package.json +1 -1
- package/temp-test/docs/README.md +69 -0
- package/temp-test/docs/test-file.md +1 -0
- package/temp-test/html/README.html +164 -0
- package/temp-test/html/css/notion-style.css +1758 -0
- package/temp-test/html/css/style.css +1974 -0
- package/temp-test/html/js/auth.js +65 -0
- package/temp-test/html/js/main.js +1333 -0
- package/temp-test/html/test-file.html +101 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple Client-Side Authentication for JUNO Documentation
|
|
3
|
+
* This runs on every page load to check authentication
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
(function() {
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
// Skip auth check on login and logout pages
|
|
10
|
+
const currentPage = window.location.pathname;
|
|
11
|
+
if (currentPage === '/login.html' || currentPage === '/logout.html' || currentPage.includes('login') || currentPage.includes('logout')) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Check if user is authenticated
|
|
16
|
+
function isAuthenticated() {
|
|
17
|
+
const authToken = getCookie('juno-auth');
|
|
18
|
+
if (!authToken) return false;
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
// Decode and validate token
|
|
22
|
+
const decoded = atob(authToken);
|
|
23
|
+
const [username, password] = decoded.split(':');
|
|
24
|
+
|
|
25
|
+
// Check against valid credentials
|
|
26
|
+
return username === 'juno' && password === 'docs2025';
|
|
27
|
+
} catch (error) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Get cookie value
|
|
33
|
+
function getCookie(name) {
|
|
34
|
+
const value = `; ${document.cookie}`;
|
|
35
|
+
const parts = value.split(`; ${name}=`);
|
|
36
|
+
if (parts.length === 2) return parts.pop().split(';').shift();
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Redirect to login if not authenticated
|
|
41
|
+
function redirectToLogin() {
|
|
42
|
+
const currentUrl = window.location.pathname + window.location.search;
|
|
43
|
+
const loginUrl = '/login.html' + (currentUrl !== '/' ? '?redirect=' + encodeURIComponent(currentUrl) : '');
|
|
44
|
+
window.location.href = loginUrl;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Check authentication on page load
|
|
48
|
+
if (!isAuthenticated()) {
|
|
49
|
+
redirectToLogin();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Add logout functionality to logout buttons
|
|
53
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
54
|
+
const logoutLinks = document.querySelectorAll('a[href*="logout"]');
|
|
55
|
+
logoutLinks.forEach(link => {
|
|
56
|
+
link.addEventListener('click', function(e) {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
// Clear auth cookie
|
|
59
|
+
document.cookie = 'juno-auth=; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
|
|
60
|
+
window.location.href = '/logout.html';
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
})();
|