Compare commits
No commits in common. "608e85bc931cda759cdfe76548079793304948ee" and "f3031b3ebea5820f5ec6a3488e7e85fdc3f3ef91" have entirely different histories.
608e85bc93
...
f3031b3ebe
8 changed files with 9 additions and 31 deletions
|
@ -1,6 +1,6 @@
|
||||||
# txtdiary
|
# txtdiary
|
||||||
|
|
||||||
[![status-badge](https://git.mylloon.fr/Anri/txtdiary/badges/workflows/publish.yml/badge.svg)](https://git.mylloon.fr/Anri/txtdiary/actions?workflow=publish.yml)
|
![status-badge](https://git.mylloon.fr/Anri/txtdiary/badges/workflows/publish.yml/badge.svg)
|
||||||
|
|
||||||
personal diary with txt style, can be private!
|
personal diary with txt style, can be private!
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ from glob import glob
|
||||||
from os import mkdir, urandom
|
from os import mkdir, urandom
|
||||||
|
|
||||||
from flask import Flask, session
|
from flask import Flask, session
|
||||||
|
|
||||||
from utils.config import Config
|
from utils.config import Config
|
||||||
|
|
||||||
app = Flask(__name__, static_url_path="/")
|
app = Flask(__name__, static_url_path="/")
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
from flask import Blueprint, flash, redirect, render_template, request
|
from flask import Blueprint, flash, redirect, render_template, request
|
||||||
from werkzeug import Response
|
|
||||||
|
|
||||||
from utils.config import Config
|
from utils.config import Config
|
||||||
from utils.misc import create_post, fresh_file_id, get_post_cdate, get_posts
|
from utils.misc import create_post, fresh_file_id, get_posts
|
||||||
|
from werkzeug import Response
|
||||||
|
|
||||||
name = __name__.split(".")[-1]
|
name = __name__.split(".")[-1]
|
||||||
router = Blueprint(name, __name__)
|
router = Blueprint(name, __name__)
|
||||||
|
@ -13,18 +12,7 @@ def index() -> str:
|
||||||
"""index page"""
|
"""index page"""
|
||||||
posts = []
|
posts = []
|
||||||
if not Config.private or (Config.private and Config.is_logged()):
|
if not Config.private or (Config.private and Config.is_logged()):
|
||||||
for p in get_posts():
|
posts = [p.split("/")[-1][:-4] for p in get_posts()]
|
||||||
|
|
||||||
def titleify(s):
|
|
||||||
return s.split("/")[-1]
|
|
||||||
|
|
||||||
def linkify(s):
|
|
||||||
return ".".join(titleify(s).split(".")[:-1])
|
|
||||||
|
|
||||||
def datify(s):
|
|
||||||
return s[:-14] + " " + s[-4:]
|
|
||||||
|
|
||||||
posts.append((linkify(p), titleify(p), datify(get_post_cdate(p))))
|
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"index.html",
|
"index.html",
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
from flask import Blueprint, flash, redirect, render_template, request
|
from flask import Blueprint, flash, redirect, render_template, request
|
||||||
from werkzeug import Response
|
|
||||||
|
|
||||||
from utils.config import Config
|
from utils.config import Config
|
||||||
|
from werkzeug import Response
|
||||||
|
|
||||||
name = __name__.split(".")[-1]
|
name = __name__.split(".")[-1]
|
||||||
router = Blueprint(name, __name__)
|
router = Blueprint(name, __name__)
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
from flask import Blueprint, flash, redirect, render_template
|
from flask import Blueprint, flash, redirect, render_template
|
||||||
from werkzeug import Response
|
|
||||||
|
|
||||||
from utils.config import Config
|
from utils.config import Config
|
||||||
from utils.misc import delete_post, get_post, post_file_id, post_filename
|
from utils.misc import delete_post, get_post, post_file_id, post_filename
|
||||||
|
from werkzeug import Response
|
||||||
|
|
||||||
name = __name__.split(".")[-1]
|
name = __name__.split(".")[-1]
|
||||||
router = Blueprint(name, __name__)
|
router = Blueprint(name, __name__)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
from flask import Blueprint, jsonify, request, session
|
from flask import Blueprint, jsonify, request, session
|
||||||
from werkzeug import Response
|
|
||||||
|
|
||||||
from utils.config import Config
|
from utils.config import Config
|
||||||
|
from werkzeug import Response
|
||||||
|
|
||||||
name = __name__.split(".")[-1]
|
name = __name__.split(".")[-1]
|
||||||
router = Blueprint(name, __name__)
|
router = Blueprint(name, __name__)
|
||||||
|
|
|
@ -19,8 +19,7 @@
|
||||||
<ul>
|
<ul>
|
||||||
{% for p in posts: %}
|
{% for p in posts: %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ config.sanitized_base() }}/read/{{ p[0] }}">{{ p[1] }}</a>
|
<a href="{{ config.sanitized_base() }}/read/{{ p }}">{{ p }}.txt</a>
|
||||||
({{ p[2] }})
|
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -6,7 +6,6 @@ from time import ctime
|
||||||
|
|
||||||
from flask import session
|
from flask import session
|
||||||
from pytz import timezone
|
from pytz import timezone
|
||||||
|
|
||||||
from utils.config import Config
|
from utils.config import Config
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,11 +50,7 @@ def get_post(filename: str) -> File | None:
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
with open(filename, "r") as reader:
|
with open(filename, "r") as reader:
|
||||||
return File(reader.read(), get_post_cdate(filename))
|
return File(reader.read(), ctime(os_path.getmtime(filename)))
|
||||||
|
|
||||||
|
|
||||||
def get_post_cdate(filename: str) -> str:
|
|
||||||
return ctime(os_path.getmtime(filename))
|
|
||||||
|
|
||||||
|
|
||||||
def delete_post(filename: str) -> bool:
|
def delete_post(filename: str) -> bool:
|
||||||
|
|
Loading…
Reference in a new issue