feeds: properly use html template

master
pictuga 2020-04-09 20:00:51 +02:00
parent 987a719c4e
commit 9e7b9d95ee
3 changed files with 15 additions and 25 deletions

View File

@ -99,7 +99,7 @@ item_link = ./a/@href
item_desc = ./div[class=desc] item_desc = ./div[class=desc]
item_content = ./div[class=content] item_content = ./div[class=content]
base = <!DOCTYPE html> <html> <head> <title>Feed reader by morss</title> <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;" /> </head> <body> <div id="header"> <h1>@feed.title</h1> <h2>@feed.desc</h2> <p>- via morss</p> </div> <div id="content"> <div class="item"> <a class="title link" href="@item.link" target="_blank">@item.title</a> <div class="desc">@item.desc</div> <div class="content">@item.content</div> </div> </div> <script> var items = document.getElementsByClassName('item') for (var i in items) items[i].onclick = function() { this.classList.toggle('active') document.body.classList.toggle('noscroll') } </script> </body> </html> base = file:reader.html.template
[twitter] [twitter]
mode = html mode = html

View File

@ -47,7 +47,11 @@ def parse_rules(filename=None):
for section in rules.keys(): for section in rules.keys():
for arg in rules[section].keys(): for arg in rules[section].keys():
if '\n' in rules[section][arg]: if rules[section][arg].startswith('file:'):
import_file = os.path.join(os.path.dirname(__file__), rules[section][arg][5:])
rules[section][arg] = open(import_file).read()
elif '\n' in rules[section][arg]:
rules[section][arg] = rules[section][arg].split('\n')[1:] rules[section][arg] = rules[section][arg].split('\n')[1:]
return rules return rules

View File

@ -1,11 +1,9 @@
@require(feed)
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>@feed.title &#8211; via morss</title> <title>Feed reader by morss</title>
<meta charset="UTF-8" />
<meta name="description" content="@feed.desc (via morss)" />
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;" /> <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;" />
<meta name="robots" content="noindex" />
<style type="text/css"> <style type="text/css">
/* columns - from https://thisisdallas.github.io/Simple-Grid/simpleGrid.css */ /* columns - from https://thisisdallas.github.io/Simple-Grid/simpleGrid.css */
@ -32,7 +30,7 @@
padding-right: 20px; /* column-space */ padding-right: 20px; /* column-space */
} }
@@media handheld, only screen and (max-width: 767px) { /* @@ to escape from the template engine */ @media handheld, only screen and (max-width: 767px) {
#content { #content {
width: 100%; width: 100%;
min-width: 0; min-width: 0;
@ -82,6 +80,7 @@
#content { #content {
text-align: justify; text-align: justify;
line-height: 1.5em;
} }
.item .title { .item .title {
@ -171,30 +170,17 @@
<body> <body>
<div id="header"> <div id="header">
<h1>@feed.title</h1> <h1>RSS feed</h1>
@if feed.desc: <h2>with full text articles</h2>
<h2>@feed.desc</h2>
@end
<p>- via morss</p> <p>- via morss</p>
</div> </div>
<div id="content"> <div id="content">
@for item in feed.items:
<div class="item"> <div class="item">
@if item.link: <a class="title link" href="@item.link" target="_blank"></a>
<a class="title link" href="@item.link" target="_blank">@item.title</a> <div class="desc"></div>
@else: <div class="content"></div>
<span class="title">@item.title</span>
@end
<div class="article">
@if item.content:
@item.content
@else:
@item.desc
@end
</div>
</div> </div>
@end
</div> </div>
<script> <script>