Compare commits

...

2 Commits

Author SHA1 Message Date
Will Webberley
c924bf184f Update build file
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2023-04-12 18:15:37 +00:00
Will Webberley
c02e5f1b12 add deploy phase for Gemini 2023-04-12 18:12:31 +00:00
4 changed files with 85 additions and 1 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ resources/
hugo_build.lock
.DS_Store
.vercel
gemini/capsule/log

View File

@ -14,3 +14,12 @@ pipeline:
- s3cmd --configure --access_key=$S3_ACCESS_KEY --secret_key=$S3_SECRET_ACCESS_KEY --host=https://eu-central-1.linodeobjects.com --host-bucket="%(bucket)s.eu-central-1.linodeobjects.com" --dump-config > /root/.s3cfg
- s3cmd -c /root/.s3cfg sync public/* s3://wilw.dev
- 'curl -X POST -H "AccessKey: $BUNNY_KEY" https://api.bunny.net/pullzone/907104/purgeCache'
deploy_gemini:
image: python:3.10
secrets: [ CAPSULE_TOWN_KEY ]
commands:
- cd gemini
- pip install python-frontmatter
- python process_capsule.py
- 'curl -X PUT -H "Content-Type: application/json" -H "api-key: $CAPSULE_TOWN_KEY" -d "{\"capsuleArchive\": \"$(tar -czf /tmp/c.tar.gz -C capsule . && cat /tmp/c.tar.gz | base64)\"}" https://api.capsule.town/capsule'

29
gemini/capsule/index.gmi Normal file
View File

@ -0,0 +1,29 @@
▄ ▄ ▄▄▄ ▄▄▄ ▄ ▄
█ █ ▄ █ █ █ █ █ █ ▄ █ █
█ ██ ██ █ █ █ █ ██ ██ █
█ █ █ █ █ █
█ █ █ █▄▄▄█ █
█ ▄ █ █ █ ▄ █
█▄▄█ █▄▄█▄▄▄█▄▄▄▄▄▄▄█▄▄█ █▄▄█
# 👋 Welcome to my Gemini capsule!
Hi, I'm Will. I'm a tech lead and enthusiast based in Wales, in the UK.
This capsule contains my gemlog, and I will be adding more to this over time.
=> gemini://wilw.capsule.town/log Gemlog
# 💁‍♂️ About this capsule
This capsule is hosted on Capsule Town. The gemlog is automatically generated from my weblog.
=> gemini://capsule.town Find out more about Capsule Town
# 🪧 Contact me
=> https://fosstodon.org/@wilw Mastodon
=> https://pixelfed.social/@wilw Pixelfed
=> https://t.me/wilw88 Telegram
=> https://wilw.dev View my website

45
gemini/process_capsule.py Normal file
View File

@ -0,0 +1,45 @@
import os
import frontmatter
# Create new directories
needed_directories = ['capsule/log']
for dir in needed_directories:
if not os.path.exists(dir):
os.makedirs(dir)
# Process blog posts
logs = []
for file in os.listdir('../content/blog'):
if not file.startswith('_'):
post = frontmatter.load(f'../content/blog/{file}')
print(post['title'])
new_content = '''
=> gemini://wilw.capsule.town 🏡 Home
=> gemini://wilw.capsule.town/log Back to gemlog
# {}
{}
=> mailto:blog@wilw.dev Reply via email
=> gemini://wilw.capsule.town/log Back to gemlog
'''.format(post['title'], post.content)
new_file_name = file.split('.')[0] + '.gmi'
logs.append({'file': new_file_name, 'title': post['title']})
gem_file = open(f'capsule/log/{new_file_name}', 'w')
gem_file.write(new_content)
logs.sort(key = lambda entry: entry['file'], reverse = True)
log_index_content = '''
=> gemini://wilw.capsule.town 🏡 Home
# Gemlog
{}
'''.format(
'\n'.join(['=> {} {}'.format(l['file'], l['title']) for l in logs])
)
gem_index_file = open(f'capsule/log/index.gmi', 'w')
gem_index_file.write(log_index_content)