Browse Source

big commit fixing parsed dates

main
crunk 1 year ago
parent
commit
938f4fd364
  1. 2
      README.md
  2. 11
      app.py
  3. 9
      column.py
  4. 14
      columns.toml
  5. 2
      parse_rss_feeds.py
  6. 5
      start.py
  7. 8
      static/css/base.css
  8. 1
      static/css/template.css
  9. 1
      templates/base.html

2
README.md

@ -9,7 +9,7 @@ This is a [PESOS](https://indieweb.org/PESOS) style website maker.
## work in progress.
* download and parse rss only on startup not on every index.html download
* <s>make sort_order types</s>
* <s>make sort_order types</s> done
* sort_order options are: default(same order as rss), reverse, random, chronological, reverse-chronological.
* <s>make limits to amount of entries.</s> done
* make category filter.

11
app.py

@ -1,6 +1,6 @@
import os
from flask import Flask
import flask_apscheduler
# from flask_sqlalchemy import SQLAlchemy
# db = SQLAlchemy()
# migrate = Migrate()
@ -8,9 +8,16 @@ from flask import Flask
def create_app():
APP = Flask(__name__)
scheduler = flask_apscheduler.APScheduler()
scheduler.api_enabled = False
scheduler.init_app(APP)
scheduler.start()
# APP.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///data/crunk_data.db"
# APP.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
# db.init_app(APP)
# migrate.init_app(APP, db, render_as_batch=True)
@scheduler.task("interval", id="update", minutes=10)
def update():
print("Updating the RSS feeds!")
return APP

9
column.py

@ -1,5 +1,6 @@
import random
from datetime import datetime
from time import mktime
from parse_rss_feeds import parse_rss_feeds
@ -29,17 +30,13 @@ class Column:
return
if self.sort_order.lower() == "chronological":
entrylist.sort(
key=lambda x: datetime.strptime(
x[1][1], "%a, %d %b %Y %H:%M:%S %z"
)
key=lambda x: datetime.fromtimestamp(mktime(x[1][1]))
)
self.entries = dict(entrylist)
return
if self.sort_order.lower() == "reverse-chronological":
entrylist.sort(
key=lambda x: datetime.strptime(
x[1][1], "%a, %d %b %Y %H:%M:%S %z"
)
key=lambda x: datetime.fromtimestamp(mktime(x[1][1]))
)
entrylist.reverse()
self.entries = dict(entrylist)

14
columns.toml

@ -1,10 +1,20 @@
[[column]]
urls = ["https://varia.zone/logs/x-y/feed.rss.xml","https://varia.zone/logs/x-y-protocols/feed.rss.xml"]
title = "code"
limit = 40
limit = 5
sort_order = "random"
[[column]]
urls = ["https://post.lurk.org/@cmos4040.rss","https://post.lurk.org/tags/radio.rss"]
urls = ["https://post.lurk.org/@cmos4040.rss"]
title = "circulations"
sort_order = "reverse"
[[column]]
urls = ["https://post.lurk.org/tags/radio.rss"]
title = "radio"
sort_order = "reverse-chronological"
[[column]]
urls = ["https://post.lurk.org/tags/forth.rss"]
title = "forth"
sort_order = "chronological"

2
parse_rss_feeds.py

@ -14,7 +14,7 @@ def _parse_single_rss_feed(url, entries):
entries[title] = []
entrylist = entries[title]
entrylist.append(entry.description)
entrylist.append(entry.published)
entrylist.append(entry.published_parsed)
return entries

5
start.py

@ -1,7 +1,5 @@
from flask import (
render_template,
)
import tomli
from flask import render_template
from app import create_app
from column import Column
@ -13,6 +11,7 @@ APP = create_app()
def index():
with open("columns.toml", "rb") as f:
column_dict = tomli.load(f)
columns_file = column_dict["column"]
columns = []
for column_from_file in columns_file:

8
static/css/base.css

@ -1,12 +1,14 @@
body {
text-rendering: optimizelegibility;
-moz-text-size-adjust: none;
margin: 0px;
}
.crunkcolumns {
display: grid;
grid-auto-flow: column;
grid-gap: 10px;
grid-template-columns: repeat(auto-fill, 350px);
grid-gap: 1px;
grid-template-columns: repeat(auto-fill, 336px);
margin-left: 6px;
}
.feed {
@ -15,7 +17,7 @@ body {
.feeditem {
display: flex;
width: 350px;
width: 336px;
position: relative;
flex-direction: column;
box-sizing: border-box;

1
static/css/template.css

@ -0,0 +1 @@
/* copy and adjust from base.css */

1
templates/base.html

@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Title</title>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/base.css')}}">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/template.css')}}">
<link rel="shortcut icon" href="{{ url_for('static', filename='icons/favicon.ico') }}">
</head>
<body>

Loading…
Cancel
Save