theme
This commit is contained in:
@@ -8,7 +8,7 @@ from goose3 import Goose
|
||||
|
||||
cgitb.enable()
|
||||
|
||||
goose = Goose({'enable_image_fetching': True})
|
||||
goose = Goose()
|
||||
|
||||
def fetch_site(url):
|
||||
return goose.extract(url=url)
|
||||
@@ -17,14 +17,11 @@ def format_output(article):
|
||||
with open('template.html', 'r') as f:
|
||||
template = f.read()
|
||||
|
||||
extra = ""
|
||||
if article.top_image:
|
||||
extra += """<img src="{}" />""".format(article.top_image.src)
|
||||
|
||||
return template.format(
|
||||
title=article.title,
|
||||
body=article.cleaned_text,
|
||||
extra=extra)
|
||||
)
|
||||
|
||||
def print_headers():
|
||||
print('Content-Type: text/html; charset=utf8\r\n\r\n')
|
||||
|
||||
38
site.css
38
site.css
@@ -1,7 +1,24 @@
|
||||
.light {
|
||||
--background: #fff;
|
||||
--foreground: #333;
|
||||
}
|
||||
|
||||
.dark {
|
||||
--background: #2e3440;
|
||||
--foreground: #d8dee9;
|
||||
}
|
||||
|
||||
.darker {
|
||||
--background: #000;
|
||||
--foreground: #d8dee9;
|
||||
}
|
||||
|
||||
|
||||
html,
|
||||
body {
|
||||
background-color: #2e3440;
|
||||
color: #d8dee9;
|
||||
background-color: var(--background);
|
||||
color: var(--foreground);
|
||||
font-family: serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
@@ -9,6 +26,7 @@ body {
|
||||
h1 {
|
||||
font-size: 28px;
|
||||
font-weight: 800;
|
||||
hyphens: auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@@ -19,6 +37,11 @@ h1 {
|
||||
padding: 32px;
|
||||
}
|
||||
|
||||
.theme {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.text {
|
||||
font-size: 16px;
|
||||
line-height: 22px;
|
||||
@@ -48,10 +71,10 @@ form {
|
||||
}
|
||||
|
||||
input {
|
||||
border: 1px solid #d8dee9;
|
||||
border: 1px solid var(--foreground);
|
||||
border-radius: 22px;
|
||||
background-color: #2e3440;
|
||||
color: #d8dee9;
|
||||
background-color: var(--background);
|
||||
color: var(--foreground);
|
||||
height: 44px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
@@ -70,6 +93,11 @@ input:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
select {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
@media(min-width: 500px) {
|
||||
form {
|
||||
align-items: baseline;
|
||||
|
||||
@@ -10,10 +10,24 @@
|
||||
<link rel="icon" type="image/png" href="/favicon@2x.png" size="128x128">
|
||||
<link rel="icon" type="image/png" href="/favicon@3x.png" size="192x192">
|
||||
</head>
|
||||
<body>
|
||||
<body class="dark">
|
||||
<h1>{title}</h1>
|
||||
<div class="main">
|
||||
<div class="text">{extra}{body}</div>
|
||||
<div class="theme">
|
||||
<select onchange="setTheme(event)">
|
||||
<option value="darker">Light-on-Black</option>
|
||||
<option value="dark" selected>Light-on-Dark</option>
|
||||
<option value="light">Dark-on-White</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="main">
|
||||
<div class="text">
|
||||
{body}
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
function setTheme(e) {{
|
||||
document.body.className = e.currentTarget.value;
|
||||
}}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user