forked from abikesa/wikipedia
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_wiki.py
More file actions
166 lines (141 loc) · 3.47 KB
/
setup_wiki.py
File metadata and controls
166 lines (141 loc) · 3.47 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
import os
# --- Define structure ---
folders = [
"style",
"js",
"images"
]
files = {
"index.html": """<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Main Page - MyWiki</title>
<link rel="stylesheet" href="style/main.css">
<link rel="stylesheet" href="style/darkmode.css">
<script src="js/toggle-darkmode.js" defer></script>
</head>
<body>
<header id="top-header">
<h1>MyWiki</h1>
<nav>
<a href="index.html">Main Page</a> |
<a href="first-article.html">First Article</a> |
<a href="#" onclick="toggleDarkMode()">Toggle Dark Mode</a>
</nav>
</header>
<main id="content">
<h2>Welcome to MyWiki</h2>
<p>This is a placeholder for your landing page content.</p>
</main>
<footer id="bottom-footer">
<hr>
<p>Last updated: April 2025 | Powered by MyWiki</p>
</footer>
</body>
</html>
""",
"first-article.html": """<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>First Article - MyWiki</title>
<link rel="stylesheet" href="style/main.css">
<link rel="stylesheet" href="style/darkmode.css">
<script src="js/toggle-darkmode.js" defer></script>
</head>
<body>
<header id="top-header">
<h1>First Article</h1>
<nav>
<a href="index.html">Main Page</a> |
<a href="#" onclick="toggleDarkMode()">Toggle Dark Mode</a>
</nav>
</header>
<main id="content">
<h2>Introduction</h2>
<p>This is a placeholder for your first article content.</p>
</main>
<footer id="bottom-footer">
<hr>
<p>Last updated: April 2025 | Powered by MyWiki</p>
</footer>
</body>
</html>
""",
"style/main.css": """/* Main CSS for MyWiki */
body {
font-family: "Linux Libertine", "Georgia", serif;
background-color: #f8f9fa;
color: #202122;
margin: 0;
padding: 0;
}
#top-header, #bottom-footer {
background-color: #ffffff;
padding: 1rem;
text-align: center;
}
#content {
max-width: 960px;
margin: 2rem auto;
padding: 1rem;
background-color: #ffffff;
box-shadow: 0 0 8px rgba(0,0,0,0.1);
}
header nav a {
color: #0645ad;
text-decoration: none;
margin: 0 10px;
}
header nav a:hover {
text-decoration: underline;
}
h1, h2, h3 {
font-weight: normal;
color: #000;
}
a {
color: #0645ad;
}
""",
"style/darkmode.css": """/* Dark Mode CSS for MyWiki */
body.darkmode {
background-color: #121212;
color: #e0e0e0;
}
#content.darkmode {
background-color: #1e1e1e;
}
#top-header.darkmode, #bottom-footer.darkmode {
background-color: #1e1e1e;
}
a.darkmode {
color: #8ab4f8;
}
""",
"js/toggle-darkmode.js": """// JavaScript to toggle dark mode
function toggleDarkMode() {
document.body.classList.toggle("darkmode");
document.getElementById('content').classList.toggle("darkmode");
document.getElementById('top-header').classList.toggle("darkmode");
document.getElementById('bottom-footer').classList.toggle("darkmode");
}
""",
"README.md": """# MyWiki
A private, minimalist encyclopedia inspired by Wikipedia.
Built for personal use and 100% fidelity to the Wikipedia aesthetic.
""",
"favicon.ico": "" # Empty file for now
}
# --- Create folders ---
for folder in folders:
os.makedirs(folder, exist_ok=True)
# --- Create files ---
for filepath, content in files.items():
with open(filepath, "w", encoding="utf-8") as f:
f.write(content)
# --- Create placeholder image ---
with open("images/placeholder.png", "wb") as f:
f.write(b"")
print("✅ Wiki repo structure and starter content generated successfully!")