[improve] mobile css, [fix] sorting issue
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
d06914aaf1
commit
1930dfc099
@ -25,20 +25,13 @@ def main_entry():
|
|||||||
# Get Files
|
# Get Files
|
||||||
directory = str(Config.DATA_PATH)
|
directory = str(Config.DATA_PATH)
|
||||||
all_files = os.listdir(directory)
|
all_files = os.listdir(directory)
|
||||||
|
|
||||||
|
# Sort Files
|
||||||
markdown_files = [file for file in all_files if file.endswith(".md")]
|
markdown_files = [file for file in all_files if file.endswith(".md")]
|
||||||
|
markdown_files = sorted(markdown_files, reverse=True)
|
||||||
|
|
||||||
# Get Create Time
|
# Get Article Metadata
|
||||||
file_info_list = []
|
articles = [get_article_metadata(filename, directory) for filename in markdown_files]
|
||||||
for filename in markdown_files:
|
|
||||||
file_path = os.path.join(directory, filename)
|
|
||||||
creation_time = os.path.getctime(file_path)
|
|
||||||
file_info_list.append((filename, creation_time))
|
|
||||||
|
|
||||||
# Sort Create Time (Recent First)
|
|
||||||
file_info_list.sort(key=lambda x: x[1], reverse=True)
|
|
||||||
|
|
||||||
# Get Articles
|
|
||||||
articles = [parse_filename(item[0]) for item in file_info_list]
|
|
||||||
|
|
||||||
return make_response(render_template("index.html", articles=articles))
|
return make_response(render_template("index.html", articles=articles))
|
||||||
|
|
||||||
@ -51,7 +44,7 @@ def article_item(id):
|
|||||||
render_template("error.html", status=404, message="Invalid Article")
|
render_template("error.html", status=404, message="Invalid Article")
|
||||||
), 404
|
), 404
|
||||||
|
|
||||||
metadata = get_article_metadata(id)
|
metadata = find_article(id)
|
||||||
if not metadata:
|
if not metadata:
|
||||||
return make_response(
|
return make_response(
|
||||||
render_template("error.html", status=404, message="Invalid Article")
|
render_template("error.html", status=404, message="Invalid Article")
|
||||||
@ -72,23 +65,23 @@ def article_item(id):
|
|||||||
), 404
|
), 404
|
||||||
|
|
||||||
|
|
||||||
def get_article_metadata(id):
|
def find_article(id):
|
||||||
directory = str(Config.DATA_PATH)
|
directory = str(Config.DATA_PATH)
|
||||||
files = os.listdir(directory)
|
files = os.listdir(directory)
|
||||||
for file_name in files:
|
|
||||||
if file_name.startswith(id) and file_name.endswith(".md"):
|
# Find Filename
|
||||||
file_path = os.path.join(directory, file_name)
|
filename = next((x for x in files if x[15:26] == id and x.endswith(".md")), None)
|
||||||
metadata = parse_filename(file_name)
|
if filename is None:
|
||||||
metadata["filepath"] = file_path
|
return None
|
||||||
return metadata
|
|
||||||
return None
|
# Normalize File Info
|
||||||
|
return get_article_metadata(filename, directory)
|
||||||
|
|
||||||
|
|
||||||
def parse_filename(filename):
|
def get_article_metadata(filename, directory):
|
||||||
video_id = filename[:11]
|
|
||||||
title = filename[12:][:-3]
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"video_id": video_id,
|
"date": filename[:14],
|
||||||
"title": title
|
"video_id": filename[15:26],
|
||||||
|
"title": filename[27:][:-3],
|
||||||
|
"filepath": os.path.join(directory, filename)
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
from datetime import datetime
|
||||||
from os import path
|
from os import path
|
||||||
from flask import Blueprint, request
|
from flask import Blueprint, request
|
||||||
from vreader.config import Config
|
from vreader.config import Config
|
||||||
@ -21,7 +22,7 @@ def generate():
|
|||||||
if len(video) != 11:
|
if len(video) != 11:
|
||||||
return {"error": "Invalid VideoID"}
|
return {"error": "Invalid VideoID"}
|
||||||
|
|
||||||
metadata = get_article_metadata(video)
|
metadata = find_article(video)
|
||||||
if metadata is not None:
|
if metadata is not None:
|
||||||
return {"video": video}
|
return {"video": video}
|
||||||
|
|
||||||
@ -35,36 +36,37 @@ def generate():
|
|||||||
directory = str(Config.DATA_PATH)
|
directory = str(Config.DATA_PATH)
|
||||||
title = resp.get("title")
|
title = resp.get("title")
|
||||||
content = resp.get("content")
|
content = resp.get("content")
|
||||||
|
date = datetime.strftime(datetime.utcnow(), "%Y%m%d%H%M%S")
|
||||||
|
|
||||||
# Derive Filename
|
# Derive Filename
|
||||||
new_title = f"{video}_{title}"
|
new_title = f"{date}_{video}_{title}"
|
||||||
file_path = path.join(directory, f"{new_title}.md")
|
filepath = path.join(directory, f"{new_title}.md")
|
||||||
|
|
||||||
# Write File
|
# Write File
|
||||||
file = open(file_path, 'w', encoding='utf-8')
|
file = open(filepath, 'w', encoding='utf-8')
|
||||||
file.write(content)
|
file.write(content)
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
return { "title": resp["title"] }
|
return { "title": resp["title"] }
|
||||||
|
|
||||||
|
|
||||||
def get_article_metadata(id):
|
def find_article(id):
|
||||||
directory = str(Config.DATA_PATH)
|
directory = str(Config.DATA_PATH)
|
||||||
files = os.listdir(directory)
|
files = os.listdir(directory)
|
||||||
for file_name in files:
|
|
||||||
if file_name.startswith(id) and file_name.endswith(".md"):
|
# Find Filename
|
||||||
file_path = os.path.join(directory, file_name)
|
filename = next((x for x in files if x[15:26] == id and x.endswith(".md")), None)
|
||||||
metadata = parse_filename(file_name)
|
if filename is None:
|
||||||
metadata["filepath"] = file_path
|
return None
|
||||||
return metadata
|
|
||||||
return None
|
# Normalize File Info
|
||||||
|
return get_article_metadata(filename, directory)
|
||||||
|
|
||||||
|
|
||||||
def parse_filename(filename):
|
def get_article_metadata(filename, directory):
|
||||||
video_id = filename[:11]
|
|
||||||
title = filename[12:][:-3]
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"video_id": video_id,
|
"date": filename[:14],
|
||||||
"title": title
|
"video_id": filename[15:26],
|
||||||
|
"title": filename[27:][:-3],
|
||||||
|
"filepath": os.path.join(directory, filename)
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import json
|
|||||||
import openai
|
import openai
|
||||||
|
|
||||||
PROMPT_TEMPLATE = """
|
PROMPT_TEMPLATE = """
|
||||||
The following is a video transcription. Write a fully comprehensive article in markdown appropriately utilizing subsections. Be sure to only use the following transcription to write the article:
|
The following is a video transcription. Write a fully comprehensive article in markdown appropriately utilizing subsections. Do not reference the video. Be sure to only use the following transcription to write the article:
|
||||||
|
|
||||||
{context}
|
{context}
|
||||||
"""
|
"""
|
||||||
|
@ -15,10 +15,11 @@ html {
|
|||||||
|
|
||||||
main {
|
main {
|
||||||
height: calc(100dvh - 4rem - env(safe-area-inset-top));
|
height: calc(100dvh - 4rem - env(safe-area-inset-top));
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
#container {
|
#container {
|
||||||
padding-bottom: calc(5em + env(safe-area-inset-bottom) * 2);
|
padding-bottom: calc(5.5em + env(safe-area-inset-bottom) * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No Scrollbar - IE, Edge, Firefox */
|
/* No Scrollbar - IE, Edge, Firefox */
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en" class="bg-secondary">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=0.9, user-scalable=no, viewport-fit=cover">
|
<meta name="viewport" content="width=device-width, initial-scale=0.9, user-scalable=no, viewport-fit=cover">
|
||||||
@ -32,7 +32,7 @@
|
|||||||
<link rel="stylesheet" href="/static/style.css">
|
<link rel="stylesheet" href="/static/style.css">
|
||||||
<link rel="stylesheet" href="/static/tailwind.css">
|
<link rel="stylesheet" href="/static/tailwind.css">
|
||||||
</head>
|
</head>
|
||||||
<body class="text-ptext bg-secondary">
|
<body class="text-ptext bg-primary">
|
||||||
<header class="w-screen h-16 bg-secondary">
|
<header class="w-screen h-16 bg-secondary">
|
||||||
<div
|
<div
|
||||||
class="flex justify-between md:px-6 h-16 w-11/12 md:w-5/6 mx-auto"
|
class="flex justify-between md:px-6 h-16 w-11/12 md:w-5/6 mx-auto"
|
||||||
@ -82,15 +82,21 @@
|
|||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<main class="relative overflow-hidden bg-primary">
|
<main class="relative overflow-hidden bg-primary">
|
||||||
<div id="container" class="h-[100dvh] overflow-auto md:px-6 w-11/12 md:w-5/6 mx-auto mt-3">
|
<div id="container" class="h-[100dvh] md:px-6 w-11/12 md:w-5/6 mx-auto">
|
||||||
<div id="content" class="rounded bg-secondary p-6 mb-3">
|
<div id="content" class="h-full flex flex-col overflow-auto rounded bg-secondary px-6 pt-6 gap-4 my-3">
|
||||||
<div class="flex justify-center w-full mb-6">
|
<div class="flex justify-center w-full">
|
||||||
<a target="_blank" href="https://www.youtube.com/watch?v={{ metadata.video_id }}">
|
<a target="_blank" href="https://www.youtube.com/watch?v={{ metadata.video_id }}">
|
||||||
<img class="h-32 rounded" src="https://i.ytimg.com/vi_webp/{{ metadata.video_id }}/maxresdefault.webp"></img>
|
<img class="h-32 rounded" src="https://i.ytimg.com/vi_webp/{{ metadata.video_id }}/maxresdefault.webp"></img>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<hr class="border-primary pb-5" />
|
<div class="mx-auto flex justify-center gap-4 italic">
|
||||||
{{ markdown_html|safe }}
|
<span class="font-extrabold">NOTE:</span>
|
||||||
|
<span>The following is automatically generated and has not been proofread. It is possible that the generated article contains inaccuracies.</span>
|
||||||
|
</div>
|
||||||
|
<hr class="border-2 border-primary rounded" />
|
||||||
|
<div>
|
||||||
|
{{ markdown_html|safe }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en" class="bg-secondary">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=0.9, user-scalable=no, viewport-fit=cover">
|
<meta name="viewport" content="width=device-width, initial-scale=0.9, user-scalable=no, viewport-fit=cover">
|
||||||
@ -14,7 +14,7 @@
|
|||||||
<link rel="stylesheet" href="/static/style.css">
|
<link rel="stylesheet" href="/static/style.css">
|
||||||
<link rel="stylesheet" href="/static/tailwind.css">
|
<link rel="stylesheet" href="/static/tailwind.css">
|
||||||
</head>
|
</head>
|
||||||
<body class="text-ptext bg-secondary">
|
<body class="text-ptext bg-primary">
|
||||||
<header class="w-screen h-16 bg-secondary">
|
<header class="w-screen h-16 bg-secondary">
|
||||||
<div
|
<div
|
||||||
class="flex justify-between md:px-6 h-16 w-11/12 md:w-5/6 mx-auto"
|
class="flex justify-between md:px-6 h-16 w-11/12 md:w-5/6 mx-auto"
|
||||||
@ -82,7 +82,7 @@
|
|||||||
<span>{{ article.title }}</span>
|
<span>{{ article.title }}</span>
|
||||||
</a>
|
</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<div class="mb-0.5"></div>
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<script>
|
<script>
|
||||||
|
Loading…
Reference in New Issue
Block a user