-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3527ea
commit de388bb
Showing
14 changed files
with
130 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from pathlib import Path | ||
from typing import TYPE_CHECKING | ||
|
||
from bs4 import BeautifulSoup | ||
from markata.hookspec import hook_impl | ||
|
||
if TYPE_CHECKING: | ||
from bs4.element import Tag | ||
|
||
|
||
def boosted_links(soup): | ||
from urllib.parse import urljoin, urlparse | ||
|
||
from bs4 import BeautifulSoup | ||
|
||
base_url = "https://waylonwalker.com" | ||
|
||
# Parse the HTML content | ||
# soup = BeautifulSoup(html_content, 'html.parser') | ||
site_domain = urlparse(base_url).netloc | ||
|
||
# Find all <a> tags | ||
for a_tag in soup.find_all("a", href=True): | ||
# Resolve relative links to absolute URLs | ||
absolute_url = urljoin(base_url, a_tag["href"]) | ||
parsed_url = urlparse(absolute_url) | ||
|
||
# Check if the link points to the site's domain | ||
if parsed_url.netloc == site_domain and not a_tag.has_attr("hx-boost"): | ||
a_tag["hx-boost"] = "true" | ||
# for a_tag in soup.find_all("a"): | ||
# if not a_tag.has_attr("hx-boost"): | ||
# a_tag["hx-boost"] = "true" | ||
return soup | ||
|
||
|
||
@hook_impl | ||
def post_render(markata): | ||
"Hook to replace youtubes on images.waylonwalker.com with mp4's if they exist" | ||
should_prettify = markata.config.get("prettify_html", False) | ||
with markata.cache as cache: | ||
for article in markata.articles: | ||
key = markata.make_hash("boosted_link", article.html) | ||
|
||
html_from_cache = markata.precache.get(key) | ||
|
||
if html_from_cache is None: | ||
soup = BeautifulSoup(article.html, "lxml") | ||
boosted_links(soup) | ||
if should_prettify: | ||
html = soup.prettify() | ||
else: | ||
html = str(soup) | ||
cache.add(key, html) | ||
|
||
else: | ||
html = html_from_cache | ||
article.html = html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,52 +8,6 @@ | |
<meta name="og:type" content="website" /> | ||
<title>{{post.title|e}}</title> | ||
{% include 'head.html' %} | ||
<!-- <meta name="og:title" name="og:title" content="{{post.title|e}}" /> --> | ||
<!-- <meta name="twitter:title" name="twitter:title" content="{{post.title|e}}" /> --> | ||
<!-- <meta name="twitter:card" content="summary_large_image"> --> | ||
<!-- <meta name="og:image" name="og:image" --> | ||
<!-- content="http://shots.wayl.one/shot/?url={{config.url}}{{slug}}&height=640&width=1280&scaled_width=1280&scaled_height=640" /> --> | ||
<!-- <meta name="twitter:image" name="twitter:image" --> | ||
<!-- content="http://shots.wayl.one/shot/?url={{config.url}}{{slug}}&height=600&width=1200&scaled_width=1200&scaled_height=600" /> --> | ||
<!-- <meta name="og:image:height" content="640" /> --> | ||
<!-- <meta name="og:image:width" content="1280" /> --> | ||
<!-- <meta name="og:url" name="og:url" content="{{config.url}}/{{slug}}" /> --> | ||
<!-- <meta name="description" name="description" content="{{description|e}}" /> --> | ||
<!-- <meta name="og:description" name="og:description" content="{{description|e}}" /> --> | ||
<!-- <meta name="twitter:description" name="twitter:description" content="{{description|e}}" /> --> | ||
<!----> | ||
<!-- <meta name="twitter:creator" content="@_waylonwalker"> --> | ||
<!-- <meta name="og:author" content="Waylon Walker"> --> | ||
<!-- <meta name="og:site_name" content="Waylon Walker"> --> | ||
<!-- <meta name="og:author_email" content="[email protected]"> --> | ||
<!-- <meta content="markata {{ __version__ }}" name="generator"> --> | ||
<!-- <meta name="monetization" content="$ilp.uphold.com/MGN2ni2YMXaQ"> --> | ||
<!-- <meta name="theme-color" content="#322D39"> --> | ||
<!-- <link rel="authorization_endpoint" href="https://indieauth.com/auth"> --> | ||
<!-- <link rel="token_endpoint" href="https://tokens.indieauth.com/token"> --> | ||
<!-- <link rel="micropub" href="https://waylonwalker.com/archive"> --> | ||
<!-- <link rel="webmention" href="https://webmention.io/waylonwalker.com/webmention" /> --> | ||
<!----> | ||
<!-- <link href="{{canonical_url}}" rel="canonical" /> --> | ||
<!----> | ||
<!-- <link rel="amphtml" href="https://waylonwalker.com/{{ slug }}/amp/" /> --> | ||
<!-- <meta property="monetization" name="monetization" content="$ilp.uphold.com/MGN2ni2YMXaQ" /> --> | ||
|
||
<!-- <link rel="preload" href="/app.css" as="style" onload="this.onload=null;this.rel='stylesheet'" /> --> | ||
<!-- <noscript> --> | ||
<!-- <link rel="stylesheet" href="/app.css" /> --> | ||
<!-- </noscript> --> | ||
|
||
<!-- <link rel="stylesheet" href="/app.css" /> --> | ||
<!----> | ||
<!-- <link href="/8bitcc_48x48.png" rel="apple-touch-icon" sizes="48x48" /> --> | ||
<!-- <link href="/8bitcc_72x72.png" rel="apple-touch-icon" sizes="72x72" /> --> | ||
<!-- <link href="/8bitcc_96x96.png" rel="apple-touch-icon" sizes="96x96" /> --> | ||
<!-- <link href="/8bitcc_144x144.png" rel="apple-touch-icon" sizes="144x144" /> --> | ||
<!-- <link href="/8bitcc_192x192.png" rel="apple-touch-icon" sizes="192x192" /> --> | ||
<!-- <link href="/8bitcc_256x256.png" rel="apple-touch-icon" sizes="256x256" /> --> | ||
<!-- <link href="/8bitcc_384x384.png" rel="apple-touch-icon" sizes="384x384" /> --> | ||
<!-- <link href="/8bitcc_512x512.png" rel="apple-touch-icon" sizes="512x512" /> --> | ||
<script> | ||
navigator.serviceWorker.getRegistrations().then(function (registrations) { | ||
for (let registration of registrations) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<article id="posts" class="h-feed hfeed list archive-list"> | ||
<ul> | ||
{% for post in feed.posts %} | ||
{% include feed.config.card_template %} | ||
{% endfor %} | ||
</ul> | ||
</article> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<nav class='w-full bg-gray-950 py-4 mb-8 sticky border-b border-pink-500'> | ||
<ul> | ||
<li><a href="/">Home</a></li> | ||
<li><a href="/archive/">Archive</a></li> | ||
<li><a href="/about/">About</a></li> | ||
<li><a href="/feeds/">RSS</a></li> | ||
<li><a href="/archive/" hx-boost="true">Archive</a></li> | ||
<li><a href="/about/" hx-boost="true">About</a></li> | ||
<li><a href="/feeds/" hx-boost="true">RSS</a></li> | ||
</ul> | ||
</nav> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
{% extends "base.html" %} | ||
{% block content %} | ||
{% include "nav.html" %} | ||
<article class="blog-post h-entry"> | ||
{% include 'post-title.html' %} | ||
{% include 'tags.html' %} | ||
<div class="e-content" id="post-body" {{ 'data-pagefind-body' if post in markata.feeds.pagefind.posts else '' }}> | ||
{{ body }} | ||
</div> | ||
<div id="show"></div> | ||
</article> | ||
{% include 'footer.html' %} | ||
{% include "nav.html" %} | ||
<article class="blog-post h-entry"> | ||
{% include 'post-title.html' %} | ||
{% include 'tags.html' %} | ||
<div class="e-content" id="post-body" {{ 'data-pagefind-body' if post in markata.feeds.pagefind.posts else '' }}> | ||
{{ body }} | ||
</div> | ||
<div id="show"></div> | ||
</article> | ||
{% include 'recent.html' %} | ||
{% include 'footer.html' %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<h2 class="m-auto max-w-md text-sm text-center text-zinc-500 no-link">Recent Posts</h2> | ||
<div hx-get='/recent/partial' hx-trigger='intersect once'></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters