crunk-columns is a PESOS style website maker
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

50 lines
1.4 KiB

import json
import os
import flask_apscheduler
import tomli
from flask import Flask
from column import Column
from simplejsonstorage import SimpleJsonStorage
def create_app():
APP = Flask(__name__)
scheduler = flask_apscheduler.APScheduler()
scheduler.api_enabled = False
scheduler.init_app(APP)
scheduler.start()
json_file = SimpleJsonStorage(
os.path.join("data", "feeds.json"), os.path.join("data", "feeds.log")
)
update_feeds(json_file)
@scheduler.task("interval", id="update", minutes=10)
def update():
update_feeds(json_file)
return APP
def update_feeds(json_file):
print("updating feeds from columns.toml file")
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:
title = column_from_file["title"]
column = Column(title, column_from_file["urls"])
if "limit" in column_from_file:
column.set_limit(column_from_file["limit"])
if "sort_order" in column_from_file:
column.set_sort_order(column_from_file["sort_order"])
if "tag_filter" in column_from_file:
column.set_tag_filter(column_from_file["tag_filter"])
column.load_content_from_feeds()
columns[title] = column.__dict__
json_file.update(columns)