diff --git a/README.md b/README.md index c4ca216..93db5dc 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ python -m pytest tests/ If you would like to update the snapshot tests, you can use the following command. ```bash -python -m pytest tests/ --update-snapshot +python -m pytest tests/ --snapshot-update ``` # License diff --git a/tests/snapshots/goodbye-cruel-world.snapshot.html b/tests/snapshots/goodbye-cruel-world.snapshot.html index 1e22415..5baac50 100644 --- a/tests/snapshots/goodbye-cruel-world.snapshot.html +++ b/tests/snapshots/goodbye-cruel-world.snapshot.html @@ -23,11 +23,11 @@ Goodbye Cruel World - Johnathan Irvin -
-
Johnathan Irvin -
-
-
+
+
Johnathan IrvinImages +
+
+

Goodbye Cruel World

JohnathanIrvin.com commits seppuku. Now an Isekai, the website is reborn.

@@ -295,31 +295,31 @@

Other Changes

Next Sprint

The manager said "Enjoy the weekend! Next sprint will be here on Monday."

The engineer grunted and said "I'll be back on Monday!"

-
-
- -
+
+
+ +
\ No newline at end of file diff --git a/tests/snapshots/hello-world.snapshot.html b/tests/snapshots/hello-world.snapshot.html index 047c283..e55c253 100644 --- a/tests/snapshots/hello-world.snapshot.html +++ b/tests/snapshots/hello-world.snapshot.html @@ -23,11 +23,11 @@ Hello World - Johnathan Irvin -
-
Johnathan Irvin -
-
-
+
+
Johnathan IrvinImages +
+
+

Hello World

For many programmers, the first program they write in any given language is the "Hello World" program first found in A Tutorial Introduction to the Language B by Bell Laboratories. It seemed apt to label this article accordingly and incorporate "Hello World" into the content. As an homage to the history of programming, let's write this simple program.

@@ -44,31 +44,31 @@

First Program

Conclusion

We've barely scratched the surface of programming. Ask yourself a few of the following questions: What exactly is print? Can I change Hello World! to any text I'd like? Try changing Hello World! to Hello Johnny! and rerunning the program. What happened? Is there a way that I could have a different output time I run the program? While the Hello World! program ensures that our environment is set up correctly; it doesn't do much.

What's next? I recommend researching variables in Python.

-
-
- -
+
+
+ +
\ No newline at end of file diff --git a/website/__init__.py b/website/__init__.py index dbdbc1c..7f741cc 100644 --- a/website/__init__.py +++ b/website/__init__.py @@ -18,6 +18,8 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +import os + import flask import markdown @@ -25,23 +27,58 @@ app = flask.Flask(__name__) app.jinja_env.add_extension('pypugjs.ext.jinja.PyPugJSExtension') -repo = blog_repositories.PostRepository('blog') +blog_repo = blog_repositories.PostRepository('blog') @app.route('/') def index() -> str: return flask.render_template( 'index.pug', posts=sorted( - repo.get_all(), + blog_repo.get_all(), key=lambda post: post.date, reverse=True, ) ) +@app.route('/images') +def images() -> str: + """ + Returns a list of all images in the images directory. + + Returns: + str: The rendered template. + """ + images = [] + directory = os.path.join('website', 'images') + + for image in os.listdir(directory): + images.append(image.replace(' ', '_')) + + return flask.render_template( + 'images.pug', + images=images + ) + +@app.route('/images/') +def image(name: str) -> str: + """ + Returns the image with the given name. + + Args: + name: The name of the image. + + Returns: + str: The rendered template. + """ + return flask.send_from_directory( + "images", + name.lower().replace('_', ' ') + ) + @app.route('/articles////') def article(year: int, month: int, day: int, description: str) -> str: try: - post = repo.get(f"{year}/{month}/{day}/{description}") + post = blog_repo.get(f"{year}/{month}/{day}/{description}") except Repository.NotFound: flask.abort(404) @@ -62,7 +99,7 @@ def article(year: int, month: int, day: int, description: str) -> str: @app.route('/feed') def rss() -> str: sorted_items = sorted( - repo.get_all(), + blog_repo.get_all(), key=lambda post: post.date, reverse=True, ) @@ -83,7 +120,7 @@ def rss() -> str: @app.route('/sitemap') def sitemap() -> str: sorted_items = sorted( - repo.get_all(), + blog_repo.get_all(), key=lambda post: post.date, reverse=True, ) diff --git a/website/images/attorney starship.png b/website/images/attorney starship.png new file mode 100644 index 0000000..e9da7c1 Binary files /dev/null and b/website/images/attorney starship.png differ diff --git a/website/images/dog 1.png b/website/images/dog 1.png new file mode 100644 index 0000000..5855316 Binary files /dev/null and b/website/images/dog 1.png differ diff --git a/website/images/dog 2.png b/website/images/dog 2.png new file mode 100644 index 0000000..bb82592 Binary files /dev/null and b/website/images/dog 2.png differ diff --git a/website/images/dog 3.png b/website/images/dog 3.png new file mode 100644 index 0000000..d832745 Binary files /dev/null and b/website/images/dog 3.png differ diff --git a/website/images/dog 4.png b/website/images/dog 4.png new file mode 100644 index 0000000..962b8e8 Binary files /dev/null and b/website/images/dog 4.png differ diff --git a/website/images/engine 1.png b/website/images/engine 1.png new file mode 100644 index 0000000..d734c86 Binary files /dev/null and b/website/images/engine 1.png differ diff --git a/website/images/engine 2.png b/website/images/engine 2.png new file mode 100644 index 0000000..b790a50 Binary files /dev/null and b/website/images/engine 2.png differ diff --git a/website/images/engine 3.png b/website/images/engine 3.png new file mode 100644 index 0000000..c2fddd3 Binary files /dev/null and b/website/images/engine 3.png differ diff --git a/website/images/engine 4.png b/website/images/engine 4.png new file mode 100644 index 0000000..ba98027 Binary files /dev/null and b/website/images/engine 4.png differ diff --git a/website/images/engine 5.png b/website/images/engine 5.png new file mode 100644 index 0000000..f05a613 Binary files /dev/null and b/website/images/engine 5.png differ diff --git a/website/images/engine 6.png b/website/images/engine 6.png new file mode 100644 index 0000000..b6eebe6 Binary files /dev/null and b/website/images/engine 6.png differ diff --git a/website/images/engine 7.png b/website/images/engine 7.png new file mode 100644 index 0000000..a3b5e26 Binary files /dev/null and b/website/images/engine 7.png differ diff --git a/website/images/engine 8.png b/website/images/engine 8.png new file mode 100644 index 0000000..7d56218 Binary files /dev/null and b/website/images/engine 8.png differ diff --git a/website/images/fenix 1.png b/website/images/fenix 1.png new file mode 100644 index 0000000..7e0a194 Binary files /dev/null and b/website/images/fenix 1.png differ diff --git a/website/images/penguin bubble gum 1.png b/website/images/penguin bubble gum 1.png new file mode 100644 index 0000000..f24c123 Binary files /dev/null and b/website/images/penguin bubble gum 1.png differ diff --git a/website/images/penguin bubble gum 2.png b/website/images/penguin bubble gum 2.png new file mode 100644 index 0000000..a1e779f Binary files /dev/null and b/website/images/penguin bubble gum 2.png differ diff --git a/website/images/sheep 1.png b/website/images/sheep 1.png new file mode 100644 index 0000000..dd7c4e1 Binary files /dev/null and b/website/images/sheep 1.png differ diff --git a/website/images/sheep 2.png b/website/images/sheep 2.png new file mode 100644 index 0000000..b7eabff Binary files /dev/null and b/website/images/sheep 2.png differ diff --git a/website/images/sheep 3.png b/website/images/sheep 3.png new file mode 100644 index 0000000..fc37504 Binary files /dev/null and b/website/images/sheep 3.png differ diff --git a/website/templates/article.pug b/website/templates/article.pug index 3fe97a2..d862406 100644 --- a/website/templates/article.pug +++ b/website/templates/article.pug @@ -6,7 +6,7 @@ block title block styles link(href="{{ url_for('static', filename='css/article.css') }}", rel="stylesheet") -block body +block content h1.post-title.h1 {{title}} p.post-date {{date}} article {{content}} diff --git a/website/templates/document.pug b/website/templates/document.pug new file mode 100644 index 0000000..38e4b64 --- /dev/null +++ b/website/templates/document.pug @@ -0,0 +1,47 @@ +!!! 5 +html + head + block meta + meta(charset="utf-8") + meta(name="viewport", content="width=device-width, initial-scale=1") + meta(name="description", content="Johnathan Irvin is a software engineer and researcher based in the Lehigh Valley, PA area.") + meta(name="keywords", content="Vue,JavaScript,HTML,CSS,Python,VueJS,Bootstrap,C#,Engineer,Software,Coding,Development") + meta(name="author", content="Johnathan Irvin") + + link(rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}") + link( + href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" + rel="stylesheet" + integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" + crossorigin="anonymous" + ) + script( + src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/js/bootstrap.bundle.min.js" + integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" + crossorigin="anonymous" + ) + + // {% if not config.DEBUG %} + // Global site tag (gtag.js) - Google Analytics + script( + async src="https://www.googletagmanager.com/gtag/js?id=G-TRBJKSZ5W1" + ) + script. + window.dataLayer = window.dataLayer || []; + function gtag(){dataLayer.push(arguments);} + gtag('js', new Date()); + gtag('config', 'G-TRBJKSZ5W1'); + // {% endif %} + + block scripts + block styles + block title + title Engineer, Researcher, Entrepreneur - Johnathan Irvin + + body + block header + + block body + main#main.container + + block footer diff --git a/website/templates/images.pug b/website/templates/images.pug new file mode 100644 index 0000000..59bf2dd --- /dev/null +++ b/website/templates/images.pug @@ -0,0 +1,14 @@ +extends layout.pug + +block title + title Images - Johnathan Irvin + +block content + .d-flex.justify-content-center.flex-wrap + // {% for image in images %} + img.flex( + src='/images/{{ image }}', + width='200px', + height='200px' + ) + // {% endfor %} \ No newline at end of file diff --git a/website/templates/index.pug b/website/templates/index.pug index 9eaf2a7..9ae815a 100644 --- a/website/templates/index.pug +++ b/website/templates/index.pug @@ -1,6 +1,6 @@ extends layout.pug -block body +block content h1.d-none Johnathan Irvin's Blog // {% for post in posts %} .post diff --git a/website/templates/layout.pug b/website/templates/layout.pug index cbb09e1..71dfec2 100644 --- a/website/templates/layout.pug +++ b/website/templates/layout.pug @@ -1,65 +1,32 @@ -!!! 5 -html - head - block meta - meta(charset="utf-8") - meta(name="viewport", content="width=device-width, initial-scale=1") - meta(name="description", content="Johnathan Irvin is a software engineer and researcher based in the Lehigh Valley, PA area.") - meta(name="keywords", content="Vue,JavaScript,HTML,CSS,Python,VueJS,Bootstrap,C#,Engineer,Software,Coding,Development") - meta(name="author", content="Johnathan Irvin") - - link(rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}") - link( - href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" - rel="stylesheet" - integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" - crossorigin="anonymous" - ) - script( - src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/js/bootstrap.bundle.min.js" - integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" - crossorigin="anonymous" - ) +extends document.pug - // {% if not config.DEBUG %} - // Global site tag (gtag.js) - Google Analytics - script( - async src="https://www.googletagmanager.com/gtag/js?id=G-TRBJKSZ5W1" - ) - script. - window.dataLayer = window.dataLayer || []; - function gtag(){dataLayer.push(arguments);} - gtag('js', new Date()); - gtag('config', 'G-TRBJKSZ5W1'); - // {% endif %} +block header + .container: header.d-flex.flex-wrap.justify-content-between.align-items-center.py-3.mb-4.border-bottom + a(href="/").d-flex.align-items-center.mb-3.mb-md-0.me-md-auto.text-dark.text-decoration-none + span.fs-4 Johnathan Irvin + a(href="{{ url_for('images') }}").text-muted + span Images - block scripts - block styles - block title - title Engineer, Researcher, Entrepreneur - Johnathan Irvin +block body + main#main.container + block content - body - .container: header.d-flex.flex-wrap.justify-content-between.align-items-center.py-3.mb-4.border-bottom - a(href="/").d-flex.align-items-center.mb-3.mb-md-0.me-md-auto.text-dark.text-decoration-none - span.fs-4 Johnathan Irvin - main#main.container - block body - - .container - footer.d-flex.flex-wrap.justify-content-between.align-items-center.py-3.my-4.border-top - p.col-md.4.mb-0.text-muted © 2020 - 2022 Johnathan Irvin - ul.nav.col-md-4.justify-content-end.list-unstyled.d-flex - li.ms-3: a.text-muted(href="mailto:irvinjohnathan@gmail.com" target="_blank") - img(src="{{url_for('static', filename='img/envelope.svg')}}", alt="Email") - li.ms-3: a.text-muted(href="https://github.com/JohnnyIrvin" target="_blank") - img(src="{{url_for('static', filename='img/github.svg')}}", alt="Github") - li.ms-3: a.text-muted(href="https://twitter.com/_JohnnyIrvin" target="_blank") - img(src="{{url_for('static', filename='img/twitter.svg')}}", alt="Twitter") - li.ms-3: a.text-muted(href="https://www.instagram.com/j0hnnyirvin/" target="_blank") - img(src="{{url_for('static', filename='img/instagram.svg')}}", alt="Instagram") - li.ms-3: a.text-muted(href="https://www.linkedin.com/in/johnnyirvin/" target="_blank") - img(src="{{url_for('static', filename='img/linkedin.svg')}}", alt="LinkedIn") - ul.nav.list-unstyled.d-flex.col-md-12.justify-content-start.d-flex - li.ms-3: a.text-muted(href="/rss.xml") RSS Feed - li.ms-3: span | - li.ms-3: a.text-muted(href="/sitemap.xml") Sitemap +block footer + .container + footer.d-flex.flex-wrap.justify-content-between.align-items-center.py-3.my-4.border-top + p.col-md.4.mb-0.text-muted © 2020 - 2022 Johnathan Irvin + ul.nav.col-md-4.justify-content-end.list-unstyled.d-flex + li.ms-3: a.text-muted(href="mailto:irvinjohnathan@gmail.com" target="_blank") + img(src="{{url_for('static', filename='img/envelope.svg')}}", alt="Email") + li.ms-3: a.text-muted(href="https://github.com/JohnnyIrvin" target="_blank") + img(src="{{url_for('static', filename='img/github.svg')}}", alt="Github") + li.ms-3: a.text-muted(href="https://twitter.com/_JohnnyIrvin" target="_blank") + img(src="{{url_for('static', filename='img/twitter.svg')}}", alt="Twitter") + li.ms-3: a.text-muted(href="https://www.instagram.com/j0hnnyirvin/" target="_blank") + img(src="{{url_for('static', filename='img/instagram.svg')}}", alt="Instagram") + li.ms-3: a.text-muted(href="https://www.linkedin.com/in/johnnyirvin/" target="_blank") + img(src="{{url_for('static', filename='img/linkedin.svg')}}", alt="LinkedIn") + ul.nav.list-unstyled.d-flex.col-md-12.justify-content-start.d-flex + li.ms-3: a.text-muted(href="/rss.xml") RSS Feed + li.ms-3: span | + li.ms-3: a.text-muted(href="/sitemap.xml") Sitemap