-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
168 lines (161 loc) · 4.01 KB
/
index.html
File metadata and controls
168 lines (161 loc) · 4.01 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Imposition EPUB Reader</title>
<script src="https://cdn.jsdelivr.net/pyodide/v0.29.1/full/pyodide.js"></script>
<style>
body {
font-family: sans-serif;
margin: 0;
display: flex;
flex-direction: column;
height: 100vh;
background-color: #f0f2f5;
}
header {
background-color: #333;
color: white;
padding: 1rem;
text-align: center;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
header h1 {
margin: 0;
font-size: 1.5rem;
}
main {
display: flex;
flex: 1;
overflow: hidden;
padding: 1rem;
gap: 1rem;
max-width: 1200px;
margin: 0 auto;
width: 100%;
box-sizing: border-box;
}
#toc {
width: 250px;
background: white;
border: 1px solid #ddd;
border-radius: 8px;
overflow-y: auto;
padding: 1rem;
}
#toc h3 {
margin-top: 0;
border-bottom: 1px solid #eee;
padding-bottom: 0.5rem;
}
#toc ul {
list-style: none;
padding: 0;
}
#toc li {
margin-bottom: 0.5rem;
}
#toc a {
text-decoration: none;
color: #007bff;
display: block;
padding: 0.25rem 0.5rem;
border-radius: 4px;
}
#toc a:hover {
background-color: #f8f9fa;
}
#toc a.active {
font-weight: bold;
color: #0056b3;
background-color: #e9ecef;
}
#viewer-container {
flex: 1;
background: white;
border: 1px solid #ddd;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}
#viewer {
width: 100%;
height: 100%;
}
footer {
background-color: white;
padding: 1rem;
display: flex;
justify-content: center;
gap: 1rem;
border-top: 1px solid #ddd;
}
button {
padding: 0.5rem 1.5rem;
font-size: 1rem;
cursor: pointer;
border: 1px solid #007bff;
background-color: white;
color: #007bff;
border-radius: 4px;
transition: all 0.2s;
min-width: 120px;
}
button:hover:not(:disabled) {
background-color: #007bff;
color: white;
}
button:disabled {
border-color: #ccc;
color: #ccc;
cursor: not-allowed;
}
</style>
</head>
<body>
<header>
<h1>Imposition EPUB Reader</h1>
</header>
<main>
<div id="toc">
<h3>Contents</h3>
<!-- TOC will be injected here -->
</div>
<div id="viewer-container">
<div id="viewer"></div>
</div>
</main>
<footer>
<button id="prev">Previous</button>
<button id="next">Next</button>
</footer>
<script type="text/javascript">
// Provide a real pyfetch implementation for the browser
window.pyfetch = async (url) => {
const response = await fetch(url);
const buffer = await response.arrayBuffer();
return {
bytes: () => Promise.resolve(new Uint8Array(buffer)),
};
};
async function main() {
let pyodide = await loadPyodide({
indexURL: "https://cdn.jsdelivr.net/pyodide/v0.29.1/full/",
});
window.pyodide = pyodide;
await pyodide.loadPackage("micropip");
const micropip = pyodide.pyimport("micropip");
await micropip.install("./dist/imposition-0.1.0-py2.py3-none-any.whl");
const response = await fetch("run_imposition.py");
const pythonScript = await response.text();
try {
await pyodide.runPythonAsync(pythonScript);
await pyodide.globals.get("main")();
} catch (e) {
console.error("Error running Python script:", e);
}
}
main();
</script>
</body>
</html>