Minor update
1
makefile
@@ -57,6 +57,7 @@ deploy: clean characters ## Ready to deploy
|
||||
@npm update
|
||||
@hugo mod get -u
|
||||
@hugo --minify
|
||||
@python mastodon2hugo.py @fundor333@micro.blog
|
||||
|
||||
brodcast: clean ## Brodcast the site
|
||||
@hugo server --disableFastRender --buildFuture --buildDrafts -bind=0.0.0.0
|
||||
|
||||
88
mastodon2hugo.py
Normal file
@@ -0,0 +1,88 @@
|
||||
# Mastodon 2 Hugo
|
||||
# By Francesco Maida (https://github.com/fmaida)
|
||||
#
|
||||
# This script will download a copy of the
|
||||
# .well-known/webfinger file from your mastodon account
|
||||
# and will place it under your 'static' directory
|
||||
#
|
||||
# Why you should use it?
|
||||
# ----------------------
|
||||
# This way, if any user try to search on mastodon by using
|
||||
# your domain, Hugo will tell Mastodon to fetch the proper
|
||||
# mastodon account
|
||||
#
|
||||
# Requires a Hugo Project (https://www.gohugo.io)
|
||||
# Requires Python 3.7 or higher
|
||||
|
||||
import os
|
||||
import sys
|
||||
from urllib.request import urlretrieve
|
||||
from urllib.error import URLError
|
||||
|
||||
|
||||
# Let's try to fetch the Mastodon account
|
||||
# from the command line argument
|
||||
if len(sys.argv) > 1:
|
||||
account = sys.argv[1]
|
||||
else:
|
||||
# The user didn't provide a Mastodon account
|
||||
# Let's ask them for it
|
||||
print("Please Enter your Mastodon account")
|
||||
account = input("[Example: @name@domain.com]: ")
|
||||
|
||||
# Now let's split the mastodon account into
|
||||
# its username and domain
|
||||
valid_account = True
|
||||
domain = None
|
||||
if len(account) < 8 or account.count("@") != 2:
|
||||
# The user didn't provide a valid Mastodon account
|
||||
valid_account = False
|
||||
else:
|
||||
domain = account.split("@")[-1]
|
||||
if len(domain) < 5:
|
||||
# The user didn't provide a valid Mastodon domain
|
||||
valid_account = False
|
||||
|
||||
# Now let's check if the user provided a valid account
|
||||
if not valid_account:
|
||||
# Sorry, it's a no go.
|
||||
print(f"'{account}' doesn't look like a valid Mastodon account.")
|
||||
exit(-1)
|
||||
|
||||
# If the user provided a valid account,
|
||||
url = f"https://{domain}/.well-known/webfinger"
|
||||
url += f"?resource=acct:{account[1:]}"
|
||||
|
||||
# Let's prepare some variables with the paths to
|
||||
# the static and .well-known directories, as well
|
||||
# as the path to the webfinger file
|
||||
current_dir = os.getcwd()
|
||||
static_dir = os.path.join(current_dir, "static")
|
||||
well_known_dir = os.path.join(static_dir, ".well-known")
|
||||
webfinger_file = os.path.join(well_known_dir, "webfinger")
|
||||
|
||||
# Let's check if a 'static' directory already exists
|
||||
if not os.path.exists(static_dir):
|
||||
# Nope. We need to create it
|
||||
print(f"Creating static directory at '{static_dir}'")
|
||||
os.makedirs(static_dir)
|
||||
|
||||
# Let's check if a '.well-known' sub-directory
|
||||
# already exists inside of the 'static' directory
|
||||
if not os.path.exists(well_known_dir):
|
||||
# Nope. We need to create it
|
||||
print(f"Creating static/.well-known directory at '{well_known_dir}'")
|
||||
os.makedirs(well_known_dir)
|
||||
|
||||
# Let's download the Mastodon account's webfinger file
|
||||
# and place it in the static/.well-known directory
|
||||
try:
|
||||
urlretrieve(url, webfinger_file)
|
||||
except URLError:
|
||||
# Uh Oh, something went wrong
|
||||
print(f"Couldn't connect to '{url}'")
|
||||
quit(-1)
|
||||
|
||||
# Everything is done
|
||||
print("Done! Have a nice day!")
|
||||
quit(0)
|
||||
@@ -1,19 +1 @@
|
||||
{
|
||||
"links": [
|
||||
{
|
||||
"href": "https://micro.blog/activitypub/fundor333",
|
||||
"rel": "http://webfinger.net/rel/profile-page",
|
||||
"type": "text/html"
|
||||
},
|
||||
{
|
||||
"href": "https://micro.blog/activitypub/fundor333",
|
||||
"rel": "self",
|
||||
"type": "application/activity+json"
|
||||
},
|
||||
{
|
||||
"rel": "http://ostatus.org/schema/1.0/subscribe",
|
||||
"template": "https://micro.blog/mastodon/follow?url={uri}"
|
||||
}
|
||||
],
|
||||
"subject": "acct:fundor333@micro.blog"
|
||||
}
|
||||
{"subject":"acct:fundor333@micro.blog","links":[{"rel":"http://webfinger.net/rel/profile-page","type":"text/html","href":"https://micro.blog/activitypub/fundor333"},{"rel":"self","type":"application/activity+json","href":"https://micro.blog/activitypub/fundor333"},{"rel":"http://ostatus.org/schema/1.0/subscribe","template":"https://micro.blog/mastodon/follow?url={uri}"}]}
|
||||
|
Before Width: | Height: | Size: 186 KiB After Width: | Height: | Size: 300 KiB |
|
Before Width: | Height: | Size: 616 KiB After Width: | Height: | Size: 253 KiB |
|
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 329 KiB |
|
Before Width: | Height: | Size: 530 KiB After Width: | Height: | Size: 248 KiB |
|
Before Width: | Height: | Size: 138 KiB After Width: | Height: | Size: 187 KiB |
|
Before Width: | Height: | Size: 285 KiB After Width: | Height: | Size: 983 KiB |
|
Before Width: | Height: | Size: 176 KiB After Width: | Height: | Size: 433 KiB |
|
Before Width: | Height: | Size: 248 KiB After Width: | Height: | Size: 197 KiB |
|
Before Width: | Height: | Size: 269 KiB After Width: | Height: | Size: 324 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 185 KiB |
|
Before Width: | Height: | Size: 205 KiB After Width: | Height: | Size: 159 KiB |
|
Before Width: | Height: | Size: 390 KiB After Width: | Height: | Size: 764 KiB |
|
Before Width: | Height: | Size: 187 KiB After Width: | Height: | Size: 191 KiB |
|
Before Width: | Height: | Size: 329 KiB After Width: | Height: | Size: 545 KiB |
|
Before Width: | Height: | Size: 194 KiB After Width: | Height: | Size: 166 KiB |
|
Before Width: | Height: | Size: 185 KiB After Width: | Height: | Size: 239 KiB |
|
Before Width: | Height: | Size: 321 KiB After Width: | Height: | Size: 160 KiB |
|
Before Width: | Height: | Size: 280 KiB After Width: | Height: | Size: 646 KiB |
|
Before Width: | Height: | Size: 433 KiB After Width: | Height: | Size: 256 KiB |
|
Before Width: | Height: | Size: 646 KiB After Width: | Height: | Size: 530 KiB |
|
Before Width: | Height: | Size: 176 KiB After Width: | Height: | Size: 205 KiB |
|
Before Width: | Height: | Size: 180 KiB After Width: | Height: | Size: 492 KiB |
|
Before Width: | Height: | Size: 192 KiB After Width: | Height: | Size: 171 KiB |
|
Before Width: | Height: | Size: 153 KiB After Width: | Height: | Size: 149 KiB |
|
Before Width: | Height: | Size: 2.7 MiB After Width: | Height: | Size: 209 KiB |
|
Before Width: | Height: | Size: 115 KiB After Width: | Height: | Size: 218 KiB |
|
Before Width: | Height: | Size: 160 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 149 KiB After Width: | Height: | Size: 176 KiB |
|
Before Width: | Height: | Size: 253 KiB After Width: | Height: | Size: 2.7 MiB |
|
Before Width: | Height: | Size: 171 KiB After Width: | Height: | Size: 115 KiB |
|
Before Width: | Height: | Size: 300 KiB After Width: | Height: | Size: 279 KiB |
|
Before Width: | Height: | Size: 545 KiB After Width: | Height: | Size: 235 KiB |
|
Before Width: | Height: | Size: 240 KiB After Width: | Height: | Size: 390 KiB |
|
Before Width: | Height: | Size: 214 KiB After Width: | Height: | Size: 138 KiB |
|
Before Width: | Height: | Size: 127 KiB After Width: | Height: | Size: 187 KiB |
|
Before Width: | Height: | Size: 235 KiB After Width: | Height: | Size: 567 KiB |
|
Before Width: | Height: | Size: 459 KiB After Width: | Height: | Size: 127 KiB |
|
Before Width: | Height: | Size: 281 KiB After Width: | Height: | Size: 280 KiB |
|
Before Width: | Height: | Size: 764 KiB After Width: | Height: | Size: 136 KiB |
|
Before Width: | Height: | Size: 567 KiB After Width: | Height: | Size: 240 KiB |
|
Before Width: | Height: | Size: 324 KiB After Width: | Height: | Size: 591 KiB |
|
Before Width: | Height: | Size: 492 KiB After Width: | Height: | Size: 285 KiB |
|
Before Width: | Height: | Size: 197 KiB After Width: | Height: | Size: 321 KiB |
|
Before Width: | Height: | Size: 209 KiB After Width: | Height: | Size: 269 KiB |
|
Before Width: | Height: | Size: 983 KiB After Width: | Height: | Size: 530 KiB |
|
Before Width: | Height: | Size: 191 KiB After Width: | Height: | Size: 192 KiB |
|
Before Width: | Height: | Size: 166 KiB After Width: | Height: | Size: 520 KiB |
|
Before Width: | Height: | Size: 313 KiB After Width: | Height: | Size: 153 KiB |
|
Before Width: | Height: | Size: 239 KiB After Width: | Height: | Size: 175 KiB |
|
Before Width: | Height: | Size: 187 KiB After Width: | Height: | Size: 180 KiB |
|
Before Width: | Height: | Size: 182 KiB After Width: | Height: | Size: 186 KiB |
|
Before Width: | Height: | Size: 520 KiB After Width: | Height: | Size: 176 KiB |
|
Before Width: | Height: | Size: 136 KiB After Width: | Height: | Size: 459 KiB |
|
Before Width: | Height: | Size: 256 KiB After Width: | Height: | Size: 182 KiB |
|
Before Width: | Height: | Size: 591 KiB After Width: | Height: | Size: 99 KiB |
|
Before Width: | Height: | Size: 175 KiB After Width: | Height: | Size: 194 KiB |
|
Before Width: | Height: | Size: 279 KiB After Width: | Height: | Size: 281 KiB |
|
Before Width: | Height: | Size: 218 KiB After Width: | Height: | Size: 616 KiB |
|
Before Width: | Height: | Size: 530 KiB After Width: | Height: | Size: 313 KiB |
|
Before Width: | Height: | Size: 159 KiB After Width: | Height: | Size: 214 KiB |