diff --git a/MANIFEST.in b/MANIFEST.in index 0a726ee..12c7925 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,3 @@ recursive-include vreader/api *.py recursive-include vreader/templates * +recursive-include vreader/static * diff --git a/Makefile b/Makefile index b96e2c1..20230e8 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,18 @@ -docker_build_local: +docker_build_local: build_tailwind docker build -t vreader:latest . -docker_build_release_dev: +docker_build_release_dev: build_tailwind docker buildx build \ --platform linux/amd64,linux/arm64 \ -t gitea.va.reichard.io/evan/vreader:dev \ --push . -docker_build_release_latest: +docker_build_release_latest: build_tailwind docker buildx build \ --platform linux/amd64,linux/arm64 \ -t gitea.va.reichard.io/evan/vreader:latest \ -t gitea.va.reichard.io/evan/vreader:`git describe --tags` \ --push . + +build_tailwind: + tailwind build -o ./vreader/static/tailwind.css --minify diff --git a/README.md b/README.md index da18e24..48e8e9d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,14 @@ -# VReader +

-Turn YouTube videos into articles! I banged this one out in a couple of hours, so it's a bit scrappy. Will slowly improve it. +

+ + + +

+ +--- + +VReader allows you to take videos from YouTube and convert them into articles! ## Running Server diff --git a/banner.png b/banner.png new file mode 100644 index 0000000..3528a85 Binary files /dev/null and b/banner.png differ diff --git a/banner.xcf b/banner.xcf new file mode 100644 index 0000000..5f5362d Binary files /dev/null and b/banner.xcf differ diff --git a/shell.nix b/shell.nix index 8e4c91c..4afd529 100644 --- a/shell.nix +++ b/shell.nix @@ -2,6 +2,7 @@ pkgs.mkShell { packages = with pkgs; [ + nodePackages.tailwindcss python311 ]; } diff --git a/tailwind.config.js b/tailwind.config.js new file mode 100644 index 0000000..3f14a8e --- /dev/null +++ b/tailwind.config.js @@ -0,0 +1,16 @@ +/** @type {import('tailwindcss').Config} */ +module.exports = { + content: ["./vreader/templates/**/*.html", "./vreader/assets/**/*.{html,js}"], + theme: { + extend: { + colors: { + primary: "var(--color-primary)", + secondary: "var(--color-secondary)", + tertiary: "var(--color-tertiary)", + ptext: "var(--color-primary-text)", + stext: "var(--color-secondary-text)", + }, + }, + }, + plugins: [], +}; diff --git a/vreader/api/common.py b/vreader/api/common.py index 29e2fa2..586f021 100644 --- a/vreader/api/common.py +++ b/vreader/api/common.py @@ -1,13 +1,25 @@ from flask import Blueprint -from flask import make_response, render_template +from flask import make_response, render_template, send_from_directory from html_sanitizer import Sanitizer from markdown import markdown from vreader.config import Config import os + bp = Blueprint("common", __name__) sanitizer = Sanitizer() + +@bp.route("/static/") +def static(path): + return send_from_directory("static", path) + + +@bp.route("/manifest.json") +def manifest(): + return send_from_directory("static", "manifest.json") + + @bp.route("/", methods=["GET"]) def main_entry(): # Get Files @@ -30,6 +42,7 @@ def main_entry(): return make_response(render_template("index.html", articles=articles)) + @bp.route("/articles/", methods=["GET"]) def article_item(id): diff --git a/vreader/api/v1.py b/vreader/api/v1.py index cd6b1a1..025341e 100644 --- a/vreader/api/v1.py +++ b/vreader/api/v1.py @@ -4,17 +4,9 @@ from flask import Blueprint, request from vreader.config import Config import vreader + bp = Blueprint("v1", __name__, url_prefix="/api/v1") -@bp.route("/articles", methods=["GET"]) -def articles(): - directory = str(Config.DATA_PATH) - - all_files = os.listdir(directory) - markdown_files = [file for file in all_files if file.endswith(".md")] - articles = [parse_filename(file) for file in markdown_files] - - return articles @bp.route("/generate", methods=["POST"]) def generate(): diff --git a/vreader/oai.py b/vreader/oai.py index 621fc29..9bd86a0 100644 --- a/vreader/oai.py +++ b/vreader/oai.py @@ -4,18 +4,12 @@ from typing import Any, List import json import openai -INITIAL_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: {context} """ -INITIAL_PROMPT_TEMPLATE_OLD = """ -The following is a video transcription. Write a comprehensive article in markdown utilizing the following content: - -{context} -""" - @dataclass class ChatCompletion: id: str @@ -33,13 +27,12 @@ class OpenAIConnector: # self.model = "gpt-3.5-turbo-16k" self.model = "gpt-3.5-turbo-1106" - self.word_cap = 1000 openai.api_key = api_key def query(self, context: str) -> Any: - # Create Initial Prompt - prompt = INITIAL_PROMPT_TEMPLATE.format(context = context) + # Create Prompt + prompt = PROMPT_TEMPLATE.format(context = context) messages = [{"role": "user", "content": prompt}] print("[OpenAIConnector] Running OAI Query") @@ -59,6 +52,7 @@ class OpenAIConnector: # Return Response return { "title": title, "content": content } + def get_title(self, markdown: str): lines = markdown.split('\n') for line in lines: diff --git a/vreader/static/icons/icon512.png b/vreader/static/icons/icon512.png new file mode 100644 index 0000000..7ba9858 Binary files /dev/null and b/vreader/static/icons/icon512.png differ diff --git a/vreader/static/manifest.json b/vreader/static/manifest.json new file mode 100644 index 0000000..d0d694e --- /dev/null +++ b/vreader/static/manifest.json @@ -0,0 +1,17 @@ +{ + "name": "VReader", + "short_name": "VReader", + "lang": "en-US", + "theme_color": "#123636", + "display": "standalone", + "scope": "/", + "start_url": "/", + "icons": [ + { + "purpose": "any", + "sizes": "512x512", + "src": "/static/icons/icon512.png", + "type": "image/png" + } + ] +} diff --git a/vreader/static/style.css b/vreader/static/style.css new file mode 100644 index 0000000..e4204d1 --- /dev/null +++ b/vreader/static/style.css @@ -0,0 +1,68 @@ +/* ----------------------------- */ +/* -------- PWA Styling -------- */ +/* ----------------------------- */ +html, +body { + overscroll-behavior-y: none; + margin: 0px; +} + +html { + height: calc(100% + env(safe-area-inset-bottom)); + padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 + env(safe-area-inset-left); +} + +main { + height: calc(100dvh - 4rem - env(safe-area-inset-top)); +} + +#container { + padding-bottom: calc(5em + env(safe-area-inset-bottom) * 2); +} + +/* No Scrollbar - IE, Edge, Firefox */ +* { + -ms-overflow-style: none; + scrollbar-width: none; +} + +/* No Scrollbar - WebKit */ +*::-webkit-scrollbar { + display: none; +} + +/* ----------------------------- */ +/* ----------- Theme ----------- */ +/* ----------------------------- */ +@media (prefers-color-scheme: light) { + html { + --color-primary: #f3f4f6; + --color-secondary: #e5e7eb; + --color-tertiary: #d1d5db; + --color-primary-text: #1f2937; + --color-secondary-text: #4b5563; + } +} + +@media (prefers-color-scheme: dark) { + html { + --color-primary: #091b1b; + --color-secondary: #123636; + --color-tertiary: #1f5c5c; + --color-primary-text: #ffffff; + --color-secondary-text: #d6f1ed; + } +} + +/* +@media (prefers-color-scheme: dark) { + html { + --color-primary: #091B1B; + --color-secondary: #123636; + --color-tertiary: #1F5C5C; + --color-primary-text: #FFFFFF; + --color-secondary-text: #D6F1ED; + } +} +*/ diff --git a/vreader/static/tailwind.css b/vreader/static/tailwind.css new file mode 100644 index 0000000..c371266 --- /dev/null +++ b/vreader/static/tailwind.css @@ -0,0 +1 @@ +/*! tailwindcss v3.3.2 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border:0 solid #e5e7eb}:after,:before{--tw-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:initial}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:initial;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:initial}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,::backdrop,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#3b82f680;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.relative{position:relative}.mx-auto{margin-left:auto;margin-right:auto}.mb-0{margin-bottom:0}.mb-0\.5{margin-bottom:.125rem}.mb-3{margin-bottom:.75rem}.mb-6{margin-bottom:1.5rem}.mr-6{margin-right:1.5rem}.mt-3{margin-top:.75rem}.flex{display:flex}.h-10{height:2.5rem}.h-14{height:3.5rem}.h-16{height:4rem}.h-32{height:8rem}.h-\[100dvh\]{height:100dvh}.w-11\/12{width:91.666667%}.w-full{width:100%}.w-screen{width:100vw}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.rounded{border-radius:.25rem}.border-primary{border-color:var(--color-primary)}.bg-primary{background-color:var(--color-primary)}.bg-secondary{background-color:var(--color-secondary)}.bg-slate-200{--tw-bg-opacity:1;background-color:rgb(226 232 240/var(--tw-bg-opacity))}.bg-tertiary{background-color:var(--color-tertiary)}.p-5{padding:1.25rem}.p-6{padding:1.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-4{padding-left:1rem;padding-right:1rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.pb-5{padding-bottom:1.25rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.font-bold{font-weight:700}.text-ptext{color:var(--color-primary-text)}.text-stext{color:var(--color-secondary-text)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.hover\:bg-primary:hover{background-color:var(--color-primary)}.hover\:bg-tertiary:hover{background-color:var(--color-tertiary)}@media (min-width:768px){.md\:h-24{height:6rem}.md\:w-4\/6{width:66.666667%}.md\:w-5\/6{width:83.333333%}.md\:px-6{padding-left:1.5rem;padding-right:1.5rem}} \ No newline at end of file diff --git a/vreader/templates/article.html b/vreader/templates/article.html index 8b74b6e..8e8e5d2 100644 --- a/vreader/templates/article.html +++ b/vreader/templates/article.html @@ -2,45 +2,59 @@ - - VReader - {{ metadata.title }} - + + + + + + + + + VReader - {{ metadata.title }} + + + + - -
+ +
-
-
- -
- {{ markdown_html|safe }} -
+
+
+
+
+
+ + + +
+
+ {{ markdown_html|safe }} +
+
+
diff --git a/vreader/templates/index.html b/vreader/templates/index.html index e740bdd..bcdf398 100644 --- a/vreader/templates/index.html +++ b/vreader/templates/index.html @@ -2,39 +2,50 @@ - + + + + + + VReader - Home - + + + + - -
+ +
- VReader + + + VReader +
-
-
- - -
+
+
+
+ + +
- {% for article in articles %} - - - {{ article.title }} - - {% endfor %} + {% for article in articles %} + + + {{ article.title }} + + {% endfor %} +
+