1
0
mirror of https://github.com/tiyn/beaker-blog.git synced 2025-10-26 16:41:15 +01:00

Compare commits

...

6 Commits

Author SHA1 Message Date
dependabot[bot]
9fa7c9339c Bump flask from 1.1.2 to 2.3.2 in /src
Bumps [flask](https://github.com/pallets/flask) from 1.1.2 to 2.3.2.
- [Release notes](https://github.com/pallets/flask/releases)
- [Changelog](https://github.com/pallets/flask/blob/main/CHANGES.rst)
- [Commits](https://github.com/pallets/flask/compare/1.1.2...2.3.2)

---
updated-dependencies:
- dependency-name: flask
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-01 21:40:50 +00:00
93767e6c8b removing empty logo 2022-07-29 23:21:41 +02:00
6f5c5a98af src: fixed quote-signs 2022-07-29 23:03:37 +02:00
b2676f6bd9 src: changed " and \' 2022-07-29 17:07:28 +02:00
8e2badcea7 src: changed " and \' 2022-07-29 16:59:44 +02:00
8f7ae7a075 src/readme: fixed typos 2022-07-29 16:23:12 +02:00
9 changed files with 96 additions and 98 deletions

View File

@@ -43,7 +43,7 @@ You have to specify the filetype by extension.
### PIP/Python
- `git clone https://github.com/tiyn/beaker-blog`
- `cd tiyny-blog/src`
- `cd beaker-blog/src`
- edit the `config.py` file according to your needs
- `pip3install -r requirements.txt` - install depenencies
- run `python app.py`

View File

@@ -1,4 +1,4 @@
from flask import Flask, flash, make_response, render_template, request, redirect, abort
from flask import Flask, make_response, render_template, abort
import content as con_gen
import config
@@ -13,41 +13,41 @@ WEBSITE = config.WEBSITE
@app.errorhandler(404)
def page_not_found(e):
return render_template('error.html', title=TITLE, errorcode='404', style=STYLE), 404
return render_template("error.html", title=TITLE, errorcode="404", style=STYLE), 404
@app.route('/')
@app.route('/index.html')
@app.route("/")
@app.route("/index.html")
def index():
content = con_gen.gen_index_string()
return render_template('index.html', title=TITLE, content_string=content, style=STYLE)
return render_template("index.html", title=TITLE, content_string=content, style=STYLE)
@app.route('/archive')
@app.route('/archive.html')
def blog_archive():
@app.route("/archive")
@app.route("/archive.html")
def archive():
content = con_gen.gen_arch_string()
return render_template('archive.html', title=TITLE, content_string=content, style=STYLE)
return render_template("archive.html", title=TITLE, content_string=content, style=STYLE)
@app.route('/entry/<path>')
@app.route("/entry/<path>")
def entry(path):
content = con_gen.gen_stand_string(path)
if content != '':
return render_template('standalone.html', title=TITLE, content_string=content, style=STYLE)
if content != "":
return render_template("standalone.html", title=TITLE, content_string=content, style=STYLE)
abort(404)
@app.route('/feed.xml')
@app.route('/rss.xml')
@app.route("/feed.xml")
@app.route("/rss.xml")
def feed():
content = con_gen.get_rss_string()
rss_xml = render_template('rss.xml', content_string=content, title=TITLE,
rss_xml = render_template("rss.xml", content_string=content, title=TITLE,
description=DESCRIPTION, website=WEBSITE)
response = make_response(rss_xml)
response.headers['Content-Type'] = 'application/rss+xml'
response.headers["Content-Type"] = "application/rss+xml"
return response
if __name__ == '__main__':
app.run(host='0.0.0.0')
if __name__ == "__main__":
app.run(host="0.0.0.0")

View File

@@ -1,11 +1,11 @@
# Name/title of your blog
TITLE = 'Beaker Blog'
TITLE = "Beaker Blog"
# Description for RSS of your blog
DESCRIPTION = 'This is your personal Beaker Blog.'
DESCRIPTION = "This is your personal Beaker Blog."
# URL for your website: e.g. https://domain.tld
WEBSITE = 'localhost:5000'
WEBSITE = "localhost:5000"
# Theme for the blog: dark, light
STYLE = 'dark'
STYLE = "dark"

View File

@@ -1,4 +1,3 @@
import datetime
from datetime import datetime
import markdown
import os
@@ -7,8 +6,7 @@ import pathlib
import config
ENTRY_DIR = 'templates/entry'
ENTRY_DIR = "templates/entry"
def gen_arch_string():
"""
@@ -22,34 +20,34 @@ def gen_arch_string():
name_list = os.listdir(path_ex)
full_list = [os.path.join(path_ex, i) for i in name_list]
contents = sorted(full_list, key=os.path.getctime)
content_string = ''
last_month = ''
content_string = ""
last_month = ""
for file in reversed(contents):
curr_date = datetime.fromtimestamp(
os.path.getctime(file)).strftime('%Y-%m-%d')
os.path.getctime(file)).strftime("%Y-%m-%d")
curr_month = datetime.fromtimestamp(
os.path.getctime(file)).strftime('%b %Y')
os.path.getctime(file)).strftime("%b %Y")
if curr_month != last_month:
if last_month != '':
content_string += '</ul>\n'
content_string += '<h2>' + curr_month + '</h2>\n'
content_string += '<ul>\n'
if last_month != "":
content_string += "</ul>\n"
content_string += "<h2>" + curr_month + "</h2>\n"
content_string += "<ul>\n"
last_month = curr_month
filename = pathlib.PurePath(file)
title = open(filename).readline().rstrip('\n')
title = open(filename).readline().rstrip("\n")
filename = filename.name
if filename[0] != '.':
filename = filename.split('.', 1)[0]
content_string += '<li>'
content_string += curr_date + ' - '
content_string += title + ' ['
content_string += '<a href="' + '/index.html#' + \
filename + '">' + 'link' + '</a> - '
content_string += '<a href="' + '/entry/' + \
pathlib.PurePath(file).name + '">' + 'standalone' + '</a>'
content_string += '] <br>'
content_string += '</li>\n'
content_string += '</ul>\n'
if filename[0] != ".":
filename = filename.split(".", 1)[0]
content_string += "<li>"
content_string += curr_date + " - "
content_string += title + " ["
content_string += "<a href=\"" + "/index.html#" + \
filename + "\">" + "link" + "</a> - "
content_string += "<a href=\"" + "/entry/" + \
pathlib.PurePath(file).name + "\">" + "standalone" + "</a>"
content_string += "] <br>"
content_string += "</li>\n"
content_string += "</ul>\n"
return content_string
@@ -61,7 +59,7 @@ def gen_index_string():
string: html-formatted index string
"""
path_ex = ENTRY_DIR
content_string = ''
content_string = ""
if path.exists(path_ex):
name_list = os.listdir(path_ex)
full_list = [os.path.join(path_ex, i) for i in name_list]
@@ -69,26 +67,26 @@ def gen_index_string():
for file in reversed(contents):
filename = pathlib.PurePath(file)
purefile = filename
title = open(filename).readline().rstrip('\n')
title = open(filename).readline().rstrip("\n")
text = open(filename).readlines()[1:]
filename = filename.name
if filename[0] != '.':
filename = filename.split('.', 1)[0]
content_string += '<div class=\'entry\'>\n'
content_string += '<h2 id=\'' + filename + '\'>' + title + '</h2>\n'
content_string += '[<a href="' + '/entry/' + \
pathlib.PurePath(file).name + '">' + \
'standalone' + '</a>]<br>\n'
if file.endswith('.html'):
if filename[0] != ".":
filename = filename.split(".", 1)[0]
content_string += "<div class=\"entry\">\n"
content_string += "<h2 id=\"" + filename + "\">" + title + "</h2>\n"
content_string += "[<a href=\"" + "/entry/" + \
pathlib.PurePath(file).name + "\">" + \
"standalone" + "</a>]<br>\n"
if file.endswith(".html"):
for line in text:
content_string += line
content_string += '<br>'
if file.endswith('.md'):
content_string += "<br>"
if file.endswith(".md"):
content_string += gen_md_content(file, 2)
content_string += '<small>' + \
content_string += "<small>" + \
datetime.fromtimestamp(os.path.getctime(
file)).strftime('%Y-%m-%d') + '</small>'
content_string += '</div>'
file)).strftime("%Y-%m-%d") + "</small>"
content_string += "</div>"
return content_string
@@ -105,21 +103,21 @@ def gen_stand_string(path_ex):
string: html-formatted string string equivalent to the file
"""
filename = os.path.join(ENTRY_DIR, path_ex)
content_string = ''
content_string = ""
if path.exists(filename):
title = open(filename).readline().rstrip('\n')
title = open(filename).readline().rstrip("\n")
text = open(filename).readlines()[1:]
filename_no_end = filename.split('.', 1)[0]
content_string += '<h1>' + title + '</h1>\n'
content_string += '['
content_string += '<a href="' + '/index.html#' + \
filename_no_end + '">' + 'link' + '</a>'
content_string += ']<br>\n'
if filename.endswith('.html'):
filename_no_end = filename.split(".", 1)[0]
content_string += "<h1>" + title + "</h1>\n"
content_string += "["
content_string += "<a href=\"" + "/index.html#" + \
filename_no_end + "\">" + "link" + "</a>"
content_string += "]<br>\n"
if filename.endswith(".html"):
for line in text:
content_string += line
content_string += '<br>'
if filename.endswith('.md'):
content_string += "<br>"
if filename.endswith(".md"):
content_string += gen_md_content(filename, 1)
return content_string
@@ -135,18 +133,18 @@ def gen_md_content(path_ex, depth):
Returns:
string: html-formatted string string equivalent to the markdown file
"""
content_string = ''
content_string = ""
if path.exists(path_ex):
filename = path_ex.split('.', 1)
filename = path_ex.split(".", 1)
fileend = filename[len(filename) - 1]
header = '#'
header = "#"
for i in range(depth):
header += '#'
header += ' '
header += "#"
header += " "
markdown_lines = open(path_ex, "r").readlines()[1:]
markdown_text = ''
markdown_text = ""
for line in markdown_lines:
markdown_text += line.replace('# ', header)
markdown_text += line.replace("# ", header)
content_string = markdown.markdown(
markdown_text, extensions=["fenced_code", "tables"]
)
@@ -165,24 +163,24 @@ def get_rss_string():
name_list = os.listdir(path_ex)
full_list = [os.path.join(path_ex, i) for i in name_list]
contents = sorted(full_list, key=os.path.getctime)
content_string = ''
content_string = ""
for file in reversed(contents):
filename = pathlib.PurePath(file)
title = open(filename).readline().rstrip('\n')
title = open(filename).readline().rstrip("\n")
text = open(filename).readlines()[1:]
filename = filename.name
if filename[0] != '.':
filename = filename.split('.', 1)[0]
content_string += '<item>\n'
content_string += '<title>' + title + '</title>\n'
content_string += '<guid>' + config.WEBSITE + \
'/index.html#' + filename + '</guid>\n'
content_string += '<pubDate>' + \
if filename[0] != ".":
filename = filename.split(".", 1)[0]
content_string += "<item>\n"
content_string += "<title>" + title + "</title>\n"
content_string += "<guid>" + config.WEBSITE + \
"/index.html#" + filename + "</guid>\n"
content_string += "<pubDate>" + \
datetime.fromtimestamp(os.path.getctime(file)).strftime(
'%Y-%m-%d') + '</pubDate>\n'
content_string += '<description>'
"%Y-%m-%d") + "</pubDate>\n"
content_string += "<description>"
for line in text:
content_string += line
content_string += '</description>\n'
content_string += '</item>\n'
content_string += "</description>\n"
content_string += "</item>\n"
return content_string

View File

@@ -1,2 +1,2 @@
Flask==1.1.2
Flask==2.3.2
Markdown==3.1.1

View File

@@ -1,4 +1,4 @@
{% extends 'template.html' %}
{% extends "template.html" %}
{% block content %}
<div class="container">
<div class="blogarchive">

View File

@@ -1,4 +1,4 @@
{% extends 'template.html' %}
{% extends "template.html" %}
{% block content %}
<div class="container">
<div class="standalone">

View File

@@ -13,8 +13,8 @@
<input type="checkbox" id="main-menu-check">
<label for="main-menu-check" class="show-menu">&#9776;</label>
<div class="main-menu">
<a href="/">Blog</a>
<a href="/archive">Archive</a>
<a href="{{ url_for('index') }}">Blog</a>
<a href="{{ url_for('archive') }}">Archive</a>
<label for="main-menu-check" class="hide-menu">X</label>
</div>
</div>