65 Commits

Author SHA1 Message Date
0b0be06a4d Only scan when there is a new build 2025-07-21 22:16:12 +01:00
d10f4ceb69 move SVGs to lfs 2025-07-21 22:08:51 +01:00
805a60db72 track SVGs 2025-07-21 22:06:58 +01:00
ab18085b8c Design improvements on mobile, updated technology section 2025-07-21 22:06:05 +01:00
1e4a188acb Make cert logos smaller on desktop 2025-07-19 00:26:22 +01:00
61b3f2da7b Add Oracle cert 2025-07-19 00:06:11 +01:00
09bb22ea1a Jenkinsfile fixes 2025-07-18 23:11:48 +01:00
da013ff6ce Fix GCP Deployment 2025-07-18 15:06:02 +01:00
edf9665502 Fix typo 2025-07-18 15:01:20 +01:00
8b2c19b7c6 Specify GCP project 2025-07-18 15:00:28 +01:00
cf4827c09c Automate deployment to GCP 2025-07-18 14:57:02 +01:00
c424f0b32a Improved logging 2025-07-18 14:45:01 +01:00
33c27c1cba Improved logging 2025-07-18 14:38:14 +01:00
ac5c83506d Add push to GCP 2025-07-18 13:33:29 +01:00
0f3b0ccafa Move registry to Gitea 2025-07-18 10:51:28 +01:00
7e3bd6f665 Always use HTTPS 2025-06-15 15:57:32 +01:00
4e860d14e6 Add site map 2025-06-15 15:41:17 +01:00
3b96c59bcf Upgrade to Python 3.13 2025-06-11 21:46:41 +01:00
d933723fce Fix scrollbars 2025-06-08 18:50:54 +01:00
b7f9afb3f0 Fix build 2025-06-08 16:16:17 +01:00
9b25a0b93a Changes for code blocks 2025-06-08 15:59:49 +01:00
c9861ddbfc Bump setuptools to avoid GHSA-5rjg-fvgr-3xxf 2025-06-04 22:12:33 +01:00
4a386dd4dc Upgrade pip 2025-06-04 21:58:42 +01:00
c1e9013353 Fix typo 2025-06-04 21:55:27 +01:00
bd510b5e89 Fix typo 2025-06-04 21:53:31 +01:00
4c1fcc60ed Fix typo 2025-06-04 21:51:47 +01:00
9cf9067a64 Merge branch 'master' of git.jakecharman.co.uk:jake/jc-ng 2025-06-04 21:49:48 +01:00
9f34c2d544 Scan for vulnerabilities on build 2025-06-04 21:46:00 +01:00
624cf64c3b Update Jenkinsfile 2025-05-01 21:21:25 +01:00
3fe4659377 Fix mistakes 2025-03-25 14:44:38 +00:00
12b14da970 Fix mistakes 2025-03-25 14:38:54 +00:00
0271538b80 Fix mistakes 2025-03-25 14:37:16 +00:00
2696e635e2 Sanity check error codes 2025-03-25 14:29:48 +00:00
17e3296774 Fix image sizing 2025-03-08 11:44:00 +00:00
fd07ddf976 Remove typo 2025-03-08 11:17:39 +00:00
cb01a25c7d Fix category dropdown 2025-02-16 12:57:37 +00:00
5c5330d93f Fix error 2025-02-16 12:56:03 +00:00
52eb6a9c85 PEP-8 updates 2025-02-16 12:53:53 +00:00
72e1f9d9bf Fix typo in Jenkinsfile 2025-02-16 12:14:56 +00:00
d347310dc4 Add Discord logging 2025-02-16 12:13:11 +00:00
d38bea0cc2 Add page titles 2025-02-15 22:57:23 +00:00
baabe90000 Fix Zone ID 2025-02-15 21:41:25 +00:00
9d2f92060f Add gitignore 2025-02-15 21:38:53 +00:00
49a291ba5a Add message to projects page 2025-02-15 21:38:04 +00:00
50de5ebd95 Add message to projects page 2025-02-15 21:37:51 +00:00
0f295956ca Fix container name 2025-02-15 21:31:44 +00:00
03f2ffb1f2 Add Jenkinsfile 2025-02-15 21:29:39 +00:00
ea9e8825c3 Icon and description 2025-02-12 01:09:00 +00:00
643370f4f8 Icon and description 2025-02-12 01:08:33 +00:00
460c511de7 Fix helper 2025-02-04 21:09:17 +00:00
63a0fa1b22 Fix helper 2025-02-04 21:08:43 +00:00
1d42d1efa6 Fix helper 2025-02-04 21:06:03 +00:00
ed4bf51c1c Fix helper 2025-02-04 21:04:59 +00:00
f4999f4d19 add helper scripts 2025-02-04 21:01:10 +00:00
1805d0531b Minor CSS Tweak to Project Images 2025-02-03 23:58:15 +00:00
ff3d5ef48d Add fallback for images PIL can't handle 2025-02-03 19:48:14 +00:00
da1210d682 fix image sizing 2025-02-02 23:21:41 +00:00
bd1488c78a Experimental change to image manipulation 2025-02-02 23:14:10 +00:00
89ef938af4 reinstate error pages 2025-01-19 23:52:48 +00:00
ca3825660b Make project image clickable - fixed 2025-01-19 23:47:58 +00:00
50501a3d37 Make project image clickable 2025-01-19 23:43:20 +00:00
613c906626 Add Google analytics 2025-01-19 23:38:19 +00:00
b91245c8a1 Improvements to projects and dynamic image resizing 2025-01-19 21:19:45 +00:00
56e771c454 Fix nav bug 2025-01-08 22:25:52 +00:00
faa1c5437b Merge pull request 'Create contact page' (#2) from contact into master
Reviewed-on: #2
2025-01-08 22:14:49 +00:00
63 changed files with 655 additions and 79 deletions

5
.gitattributes vendored Normal file → Executable file
View File

@@ -1,3 +1,8 @@
*.jpeg filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.svg filter=lfs diff=lfs merge=lfs -text
src/static/images/technology/hadoop.svg filter=lfs diff=lfs merge=lfs -text
src/static/images/technology/hive.svg filter=lfs diff=lfs merge=lfs -text
src/static/images/technology/nginx.svg filter=lfs diff=lfs merge=lfs -text
src/static/images/technology/svn.svg filter=lfs diff=lfs merge=lfs -text

2
.gitignore vendored Executable file
View File

@@ -0,0 +1,2 @@
__pycache__
.vscode

5
.pylintrc Executable file
View File

@@ -0,0 +1,5 @@
[FORMAT]
max-line-length=140
[MESSAGES CONTROL]
disable=import-error

13
Dockerfile Normal file → Executable file
View File

@@ -1,8 +1,11 @@
FROM httpd:2.4
FROM python:3.13-bookworm
RUN apt-get update
RUN apt-get -y install libapache2-mod-wsgi-py3 python3 python3-pip
RUN apt-get -y install apache2 apache2-dev
COPY src/requirements.txt /var/www/jc/requirements.txt
RUN pip3 install -r /var/www/jc/requirements.txt || pip3 install --break-system-packages -r /var/www/jc/requirements.txt
COPY --chown=www-data:www-data config/httpd.conf /usr/local/apache2/conf/httpd.conf
RUN /usr/local/bin/pip3 install --upgrade pip
RUN /usr/local/bin/pip3 install -r /var/www/jc/requirements.txt
COPY --chown=www-data:www-data config/httpd.conf /etc/apache2/apache2.conf
COPY --chown=www-data:www-data src/ /var/www/jc
RUN httpd -t
RUN apache2 -t
EXPOSE 80
ENTRYPOINT ["apache2", "-D", "FOREGROUND"]

152
Jenkinsfile vendored Executable file
View File

@@ -0,0 +1,152 @@
pipeline {
agent any
environment {
TS = credentials('jc_turnstile')
DISCORD = credentials('jc_discord')
DISCORD_ERR_STAGING = credentials('jc_discord_err_staging')
DISCORD_ERR_PROD = credentials('jc_discord_err_prod')
}
stages{
stage ('Set up parameters') {
steps {
script{
properties ([
parameters([
booleanParam(defaultValue: true, description: 'Build from source', name: 'Build'),
booleanParam(defaultValue: true, description: 'Deploy to servers', name: 'Deploy'),
booleanParam(defaultValue: true, description: 'Update posts', name: 'Update'),
])
])
}
}
}
stage('Build') {
when {
expression {
return params.Build == true
}
}
steps {
git branch: 'master',
credentialsId: 'Git',
url: 'git@git.jakecharman.co.uk:jake/jc-ng.git'
sh "./build.sh git.jakecharman.co.uk/jake/jakecharman.co.uk $BUILD_NUMBER"
sh "./build.sh europe-west2-docker.pkg.dev/jakecharman/web/jakecharman.co.uk $BUILD_NUMBER"
}
}
stage('Security scan') {
when {
expression {
return params.Build == true
}
}
steps {
sh "docker kill sectest || true"
sh "docker rm sectest || true"
sh "docker run -d --name sectest git.jakecharman.co.uk/jake/jakecharman.co.uk:$BUILD_NUMBER"
sh "docker exec sectest pip3 install pip-audit --break-system-packages"
sh "docker exec sectest pip-audit"
sh "docker stop sectest"
sh "docker rm sectest"
}
}
stage('Push to local registry') {
when {
expression {
return params.Build == true
}
}
steps {
sh "docker push git.jakecharman.co.uk/jake/jakecharman.co.uk:$BUILD_NUMBER"
sh "docker push git.jakecharman.co.uk/jake/jakecharman.co.uk:latest"
}
}
stage('Deploy to staging server') {
when {
expression {
return params.Deploy == true
}
}
steps{
node('web-staging') {
sh "docker pull git.jakecharman.co.uk/jake/jakecharman.co.uk:latest"
sh "docker stop jake || true"
sh "docker rm jake || true"
sh "docker run --name jake -e DISCORD_ERR_HOOK=$DISCORD_ERR_STAGING -e DISCORD_WEBHOOK=$DISCORD -e TURNSTILE_SECRET=$TS --restart always --network containers_default -v /opt/containers/jc/projects/:/var/www/jc/projects/ -d git.jakecharman.co.uk/jake/jakecharman.co.uk:latest"
}
}
}
stage('Update content on staging server') {
when {
expression {
return params.Update == true
}
}
steps {
node('web-staging') {
git branch: 'master',
credentialsId: 'Git',
url: 'git@git.jakecharman.co.uk:jake/jc-content.git'
sh "rsync -rv --delete ./ /opt/containers/jc/projects/"
}
}
}
stage('Wait for confirmation to push to prod') {
steps {
timeout(time: 30, unit: 'MINUTES') {
input "Deploy to production?"
}
}
}
stage('Push to GCP registry') {
when {
expression {
return params.Build == true
}
}
steps {
sh "docker push europe-west2-docker.pkg.dev/jakecharman/web/jakecharman.co.uk:latest"
}
}
stage('Deploy to production') {
when {
expression {
return params.Deploy == true
}
}
steps{
sh "gcloud run deploy --project jakecharman --region europe-west1 --image europe-west2-docker.pkg.dev/jakecharman/web/jakecharman.co.uk:latest jakecharman-co-uk"
}
}
stage('Update content on production server') {
when {
expression {
return params.Update == true
}
}
steps {
git branch: 'master',
credentialsId: 'Git',
url: 'git@git.jakecharman.co.uk:jake/jc-content.git'
sh "gsutil rsync -rcd . gs://jakecharman.co.uk"
}
}
stage('Clear cache') {
steps{
sh "/var/lib/jenkins/clearCFCache/clearCache.py a514fb61e1413b88aabbb19df16b8508"
}
}
}
}

20
build.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/bash --noprofile
set -x -o pipefail
tag=$1
build=$2
cat <<EOF >src/.buildinfo.json
{
"tag": "${tag}:${build}",
"date": "$(date -I)",
"host": "$(hostname -f)",
"user": "${USER}"
}
EOF
docker build -t ${tag}:latest .
if [[ $build != "" ]]; then
docker build -t ${tag}:${build} .
fi

22
config/httpd.conf Normal file → Executable file
View File

@@ -28,7 +28,7 @@
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
ServerRoot "/usr/local/apache2"
ServerRoot "/usr/lib/apache2"
#
# Mutex: Allows you to set the mutex mechanism and mutex file directory
@@ -123,7 +123,7 @@ LoadModule deflate_module modules/mod_deflate.so
#LoadModule brotli_module modules/mod_brotli.so
LoadModule mime_module modules/mod_mime.so
#LoadModule ldap_module modules/mod_ldap.so
LoadModule log_config_module modules/mod_log_config.so
#LoadModule log_config_module modules/mod_log_config.so
#LoadModule log_debug_module modules/mod_log_debug.so
#LoadModule log_forensic_module modules/mod_log_forensic.so
#LoadModule logio_module modules/mod_logio.so
@@ -137,7 +137,7 @@ LoadModule headers_module modules/mod_headers.so
#LoadModule usertrack_module modules/mod_usertrack.so
#LoadModule unique_id_module modules/mod_unique_id.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
#LoadModule version_module modules/mod_version.so
#LoadModule remoteip_module modules/mod_remoteip.so
#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
@@ -171,7 +171,7 @@ LoadModule version_module modules/mod_version.so
#LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so
#LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so
#LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so
LoadModule unixd_module modules/mod_unixd.so
#LoadModule unixd_module modules/mod_unixd.so
#LoadModule heartbeat_module modules/mod_heartbeat.so
#LoadModule heartmonitor_module modules/mod_heartmonitor.so
#LoadModule dav_module modules/mod_dav.so
@@ -198,8 +198,7 @@ LoadModule dir_module modules/mod_dir.so
LoadModule alias_module modules/mod_alias.so
#LoadModule rewrite_module modules/mod_rewrite.somod_wsgi-express start-server
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so
LoadModule wsgi_module /usr/local/lib/python3.13/site-packages/mod_wsgi/server/mod_wsgi-py313.cpython-313-x86_64-linux-gnu.so
<IfModule unixd_module>
#
@@ -368,7 +367,7 @@ LogLevel warn
# TypesConfig points to the file containing the list of mappings from
# filename extension to MIME-type.
#
TypesConfig conf/mime.types
TypesConfig /etc/mime.types
#
# AddType allows you to add to or override the MIME configuration
@@ -423,7 +422,6 @@ ErrorDocument 503 /error/503
ErrorDocument 505 /error/505
WSGISocketPrefix /var/run/wsgi
WSGIDaemonProcess jc-wsgi user=www-data group=www-data threads=5
WSGIProcessGroup jc-wsgi
WSGIScriptAlias / /var/www/jc/projects.wsgi
@@ -434,6 +432,14 @@ WSGIScriptAlias / /var/www/jc/projects.wsgi
Require all granted
</Directory>
Alias "/static" "/var/www/jc/static/"
<Directory /var/www/jc/static>
Order allow,Deny
Allow from all
</Directory>
Alias "/robots.txt" "/var/www/jc/static/robots.txt"
<Files jc.wsgi>
Require all granted
</Files>

9
debug_local.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash --noprofile
run() {
python3 src/projects.wsgi || run
}
export DISCORD_ERR_HOOK='dummy'
run
unset DISCORD_ERR_HOOK

12
run_local.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/bash --noprofile
set -x -o pipefail
./build.sh "jc-ng-localtest"
content_dir=""
if [[ -d "../jc-content" ]]; then
content_dir="-v $(realpath ../jc-content):/var/www/jc/projects"
fi
docker run -e DISCORD_ERR_HOOK=dummy $1 -v $(pwd)/src/:/var/www/jc $content_dir jc-ng-localtest

6
src/.buildinfo.json Executable file
View File

@@ -0,0 +1,6 @@
{
"tag": "jc-ng-localtest:",
"date": "2025-07-21",
"host": "jake-pc",
"user": "jake"
}

19
src/contact.py Normal file → Executable file
View File

@@ -6,7 +6,7 @@ from flask import request, render_template
from requests import post, get
from uuid import uuid4
from textwrap import dedent
from traceback import format_exc
def validate_turnstile(response: str, ip: str) -> bool:
turnstile_secret = environ['TURNSTILE_SECRET']
cf_response = post(
@@ -16,7 +16,8 @@ def validate_turnstile(response: str, ip: str) -> bool:
'response': response,
'remoteip': ip,
'idempotency_key': uuid4()
}
},
timeout=30
).json()
return cf_response.get('success', False)
@@ -24,7 +25,8 @@ def validate_turnstile(response: str, ip: str) -> bool:
def send_to_discord(form: dict) -> bool:
try:
discord_hook = environ['DISCORD_WEBHOOK']
except:
except KeyError:
app.logger.error(format_exc())
return False
discord_msg = dedent(
f'''
@@ -42,11 +44,12 @@ def send_to_discord(form: dict) -> bool:
data={
'username': form.get('name'),
'content': discord_msg
}
).status_code
if discord_response == 204:
},
timeout=30
)
if discord_response.status_code == 204:
return True
app.logger.error(discord_response.status_code, discord_response.text)
return False
@app.route('/contact/', methods=('GET', 'POST'))
@@ -59,4 +62,4 @@ def contact():
return render_template('contact.html', user_message='Your message has been sent!')
return render_template('contact.html', error=True, user_message='An error occurred.')
else:
return render_template('contact.html')
return render_template('contact.html', page_title='Contact - ')

57
src/index.py Normal file → Executable file
View File

@@ -1,18 +1,60 @@
#!/usr/bin/python3
import traceback
from os import environ
import threading
import logging
from requests import post
from flask import Flask, render_template, Response
app = Flask(__name__)
import projects
import contact
# These imports need to come after our app is defined as they add routes to it.
import projects # pylint: disable=wrong-import-position,unused-import
import contact # pylint: disable=wrong-import-position,unused-import
import sitemap # pylint: disable=wrong-import-position,unused-import
class DiscordLogger(logging.Handler):
''' Simple logging handler to send a message to Discord '''
level = logging.ERROR
def __init__(self, webhook):
super().__init__()
self._webhook = webhook
def send_to_discord(self, msg: logging.LogRecord):
''' Send the message '''
if msg.exc_info is not None:
message_to_send = f'{msg.msg}\n\n{"".join(traceback.format_exception(*msg.exc_info))}'
else:
message_to_send = msg.msg
if len(message_to_send) > 2000:
chars_to_lose = len(message_to_send) - 2000
if msg.exc_info is not None:
message_to_send = f'{msg.msg}\n\n{"".join(traceback.format_exception(*msg.exc_info))[-chars_to_lose:]}'
else:
message_to_send = msg.msg[-chars_to_lose:]
post(self._webhook, data={'content': message_to_send}, timeout=30)
def emit(self, record: logging.LogRecord) -> None:
''' Take in the record and start a new thread to send it to Discord '''
app.logger.info('Sending error to Discord')
dc_thread = threading.Thread(target=self.send_to_discord, args=[record])
dc_thread.start()
discord_logger = DiscordLogger(environ['DISCORD_ERR_HOOK'])
app.logger.addHandler(discord_logger)
@app.route('/')
def index():
def index() -> str:
''' Load the homepage '''
return render_template('index.html')
@app.route('/error/<code>')
def error(code):
def error(code) -> str:
''' Render a nicer error page for a given code '''
error_definitions = {
400: 'Bad Request',
403: 'Forbidden',
@@ -32,6 +74,11 @@ def error(code):
505: 'Your browser tried to use a HTTP version I don\'t support. Check it is up to date.'
}
return render_template('error.html',
if not code.isdigit():
code=400
elif int(code) not in error_definitions:
return Response(status=code)
return render_template('error.html',
error=f'{code}: {error_definitions.get(int(code))}',
description=error_desc.get(int(code)))

92
src/projects.py Normal file → Executable file
View File

@@ -2,19 +2,22 @@
from os import path
import json
from flask import Flask, render_template, Response, send_from_directory
from markdown import markdown
import frontmatter
from glob import glob
from datetime import datetime
from index import app
from io import BytesIO
from glob import glob
from PIL import Image, UnidentifiedImageError
import frontmatter
from markdown import markdown
from bs4 import BeautifulSoup
from flask import render_template, Response, send_from_directory, request, make_response
from index import app
md_directory = path.join(path.realpath(path.dirname(__file__)), path.normpath('projects/'))
@app.context_processor
def processor():
def get_excerpt(post):
def processor() -> dict:
''' Jninja processors '''
def get_excerpt(post: frontmatter.Post) -> str:
html = markdown(post.content)
post_soup = BeautifulSoup(html, 'html.parser')
all_text = ' '.join([x.get_text() for x in post_soup.findAll('p')])
@@ -23,31 +26,37 @@ def processor():
@app.template_filter('category_title')
def category_title(category_id: str) -> str:
with open(path.join(md_directory, 'categories.json')) as categories_file:
''' Jninja filter to get a category title by its ID '''
with open(path.join(md_directory, 'categories.json'), encoding='utf8') as categories_file:
categories = json.load(categories_file)
return categories.get(category_id).get('title', '')
@app.template_filter('human_date')
def human_date(iso_date: str) -> str:
''' Jninja filter to convert an ISO date to human readable. '''
try:
return datetime.fromisoformat(str(iso_date)).strftime('%A %d %B %Y')
except ValueError:
return iso_date
@app.template_filter('to_html')
def to_html(content):
def to_html(content: str) -> str:
''' Jninja filter to wrap markdown '''
return markdown(content)
def get_all_posts(directory: str) -> list:
def get_all_posts(directory: str = md_directory) -> list:
''' Get all posts in the posts directory '''
abs_paths = [path.join(directory, x) for x in glob(f'{directory}/*.md')]
return [frontmatter.load(x) for x in abs_paths]
def get_by_meta_key(directory: str, key: str, value: str):
def get_by_meta_key(directory: str, key: str, value: str) -> list:
''' Get posts by a metadata key value pair '''
return [x for x in get_all_posts(directory) if x.get(key) == value or type(x.get(key, [])) is list and value in x.get(key, [])]
@app.route('/projects/')
def projects():
def projects() -> str:
''' Load the projects page '''
articles_to_return = sorted(
get_all_posts(
md_directory),
@@ -60,7 +69,7 @@ def projects():
error='There\'s nothing here... yet.',
description='I\'m still working on this page. Check back soon for some content.')
try:
with open(path.join(md_directory, 'categories.json')) as categories_file:
with open(path.join(md_directory, 'categories.json'), encoding='utf8') as categories_file:
categories = json.load(categories_file)
except FileNotFoundError:
return render_template('error.html',
@@ -71,14 +80,16 @@ def projects():
articles=articles_to_return,
all_categories=categories,
title='Projects',
page_title='Projects - ',
description='A selection of projects I\'ve been involved in')
@app.route('/projects/category/<category>/')
def category(category):
@app.route('/projects/category/<category_id>/')
def category(category_id: str) -> str:
''' Load the page for a given category '''
try:
with open(path.join(md_directory, 'categories.json')) as categories_file:
with open(path.join(md_directory, 'categories.json'), encoding='utf8') as categories_file:
categories = json.load(categories_file)
the_category = categories.get(category)
the_category = categories.get(category_id)
except FileNotFoundError:
return render_template('error.html',
error='There\'s nothing here... yet.',
@@ -89,7 +100,7 @@ def category(category):
articles_to_return = sorted(
get_by_meta_key(
md_directory, 'categories', category),
md_directory, 'categories', category_id),
key=lambda d: d.metadata.get('date'),
reverse=True
)
@@ -104,11 +115,12 @@ def category(category):
description=the_category['long_description'],
page_title=f'{the_category["title"]} - ',
all_categories=categories,
current_category=category)
current_category=category_id)
@app.route('/projects/<article>')
def article(article):
articles = get_by_meta_key(md_directory, 'id', article)
@app.route('/projects/<article_id>')
def article(article_id: str) -> str:
''' Load a single article '''
articles = get_by_meta_key(md_directory, 'id', article_id)
if len(articles) == 0:
return Response(status=404)
@@ -120,6 +132,36 @@ def article(article):
metadata=the_article.metadata,
page_title=f'{the_article.metadata["title"]} - ')
@app.route('/projects/image/<image>')
def image(image):
return send_from_directory(path.join(md_directory, 'images'), image)
@app.route('/projects/image/<image_name>')
def image(image_name: str) -> Response:
''' Resize and return an image. '''
w = int(request.args.get('w', 0))
h = int(request.args.get('h', 0))
if w == 0 and h == 0:
return send_from_directory(md_directory, path.join('images', image_name))
try:
the_image = Image.open(path.join(md_directory, 'images', image_name))
except FileNotFoundError:
return Response(status=404)
except UnidentifiedImageError:
return send_from_directory(md_directory, path.join('images', image_name))
max_width, max_height = the_image.size
if (w >= max_width and h >= max_height):
return send_from_directory(md_directory, path.join('images', image_name))
req_size = [max_width, max_height]
if w > 0:
req_size[0] = w
if h > 0:
req_size[1] = h
resized_img = BytesIO()
the_image.thumbnail(tuple(req_size))
the_image.save(resized_img, format=the_image.format)
response = make_response(resized_img.getvalue())
response.headers.set('Content-Type', f'image/{the_image.format}')
return response

3
src/projects.wsgi Normal file → Executable file
View File

@@ -4,3 +4,6 @@ import sys
sys.path.append('/var/www/jc')
from index import app as application
if __name__ == '__main__':
application.run(debug=True)

3
src/requirements.txt Normal file → Executable file
View File

@@ -1,6 +1,9 @@
setuptools>=78.1.1
flask>=2.2.3
flask-markdown>=0.3
markdown>=3.4.1
beautifulsoup4>=4.11.1
python-frontmatter>=1.1.0
requests>=2.32.3
pillow>=11.0.0
mod_wsgi>=5.0.2

43
src/sitemap.py Executable file
View File

@@ -0,0 +1,43 @@
#!/usr/bin/python3
import xml.etree.ElementTree as ET
import json
from flask import url_for, request, Response
from re import match
from index import app
from projects import get_all_posts
def get_routes() -> list:
routes = []
for rule in app.url_map.iter_rules():
if 0 >= len(rule.arguments):
url = url_for(rule.endpoint, **(rule.defaults or {}))
routes.append(url)
return routes
def get_build_date():
try:
with open('/var/www/jc/.buildinfo.json', encoding='utf8') as build:
build_json = json.load(build)
return build_json['date']
except:
return '1970-01-01'
@app.route('/sitemap.xml')
def sitemap():
date = get_build_date()
root = ET.Element('urlset', xmlns='http://www.sitemaps.org/schemas/sitemap/0.9')
base_url = match(r'^https?:\/\/.+:?\d*(?=\/)', request.base_url).group()
base_url = base_url.replace('http://', 'https://')
for route in get_routes():
url = ET.SubElement(root, 'url')
ET.SubElement(url, 'loc').text = base_url + route
ET.SubElement(url, 'lastmod').text = date
for article in get_all_posts():
if 'link' in article.metadata:
continue
url = ET.SubElement(root, 'url')
ET.SubElement(url, 'loc').text = f'{base_url}/projects/{article.metadata['id']}'
ET.SubElement(url, 'lastmod').text = article.metadata['date'].strftime('%Y-%m-%d')
return Response(ET.tostring(root, encoding='utf-8'), 200, {'content-type': 'application/xml'})

0
src/static/fonts/fontawesome/css/all.min.css vendored Normal file → Executable file
View File

View File

View File

View File

View File

0
src/static/fonts/fontawesome/webfonts/fa-solid-900.ttf Normal file → Executable file
View File

View File

View File

View File

BIN
src/static/images/certs/OCIF2023CA.png (Stored with Git LFS) Executable file

Binary file not shown.

BIN
src/static/images/jc.ico Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

0
src/static/images/njr-code.png Normal file → Executable file
View File

BIN
src/static/images/technology/ansible.png (Stored with Git LFS) Executable file

Binary file not shown.

BIN
src/static/images/technology/aws.png (Stored with Git LFS) Executable file

Binary file not shown.

BIN
src/static/images/technology/azure.png (Stored with Git LFS) Executable file

Binary file not shown.

BIN
src/static/images/technology/csharp.png (Stored with Git LFS) Executable file

Binary file not shown.

BIN
src/static/images/technology/debian.png (Stored with Git LFS) Executable file

Binary file not shown.

BIN
src/static/images/technology/digitalocean.png (Stored with Git LFS) Executable file

Binary file not shown.

BIN
src/static/images/technology/docker.png (Stored with Git LFS) Executable file

Binary file not shown.

BIN
src/static/images/technology/freeipa.png (Stored with Git LFS) Executable file

Binary file not shown.

BIN
src/static/images/technology/gcloud.png (Stored with Git LFS) Executable file

Binary file not shown.

BIN
src/static/images/technology/git.png (Stored with Git LFS) Executable file

Binary file not shown.

BIN
src/static/images/technology/grafana.png (Stored with Git LFS) Executable file

Binary file not shown.

BIN
src/static/images/technology/hadoop.svg (Stored with Git LFS) Executable file

Binary file not shown.

BIN
src/static/images/technology/hive.svg (Stored with Git LFS) Executable file

Binary file not shown.

BIN
src/static/images/technology/java.png (Stored with Git LFS) Executable file

Binary file not shown.

BIN
src/static/images/technology/jenkins.png (Stored with Git LFS) Executable file

Binary file not shown.

BIN
src/static/images/technology/mariadb.png (Stored with Git LFS) Executable file

Binary file not shown.

BIN
src/static/images/technology/nginx.svg (Stored with Git LFS) Executable file

Binary file not shown.

BIN
src/static/images/technology/proxmox.png (Stored with Git LFS) Executable file

Binary file not shown.

BIN
src/static/images/technology/python.png (Stored with Git LFS) Executable file

Binary file not shown.

BIN
src/static/images/technology/redhat.png (Stored with Git LFS) Executable file

Binary file not shown.

BIN
src/static/images/technology/rocky.png (Stored with Git LFS) Executable file

Binary file not shown.

BIN
src/static/images/technology/svn.svg (Stored with Git LFS) Executable file

Binary file not shown.

0
src/static/images/topfuel_startline.jpg.jpeg Normal file → Executable file
View File

0
src/static/js/filter_projects.js Normal file → Executable file
View File

0
src/static/js/update_copyright.js Normal file → Executable file
View File

4
src/static/robots.txt Executable file
View File

@@ -0,0 +1,4 @@
User-agent: *
Allow: /
Sitemap: https://jakecharman.co.uk/sitemap.xml

37
src/static/style/desktop.css Normal file → Executable file
View File

@@ -1,7 +1,7 @@
@media (min-width: 1000px) {
#technology{
background-position-x: 35vw;
height: 75vh;
height: fit-content;
min-height: 75vh;
}
@@ -9,14 +9,16 @@
background-position-y: -180px;
background-position-x: -200px;
background-size: auto;
height: fit-content;
min-height: 75vh;
height: 75vh;
}
.text{
width: 50%;
height: 100%;
align-items: flex-start;
height: fit-content;
min-height: 75vh
}
.text-right{
@@ -29,6 +31,13 @@
margin-right: auto;
}
.gradient {
display: flex;
align-items: flex-end;
background-image: linear-gradient(to top, rgba(23, 22, 20, 1) 70%, rgba(23, 22, 20, 0));
min-height: 75vh;
}
.gradient-left{
background-image: linear-gradient(to right, rgba(23, 22, 20, 1), rgba(23, 22, 20, 1), rgba(23, 22, 20, 0));
}
@@ -42,6 +51,8 @@
justify-content: center;
flex-direction: row;
flex-wrap: wrap;
margin: 0 auto 0 auto;
width: 80vw;
}
.project{
@@ -53,10 +64,32 @@
float: right;
width: fit-content;
padding-right: 20px;
position: relative;
z-index: 999;
}
#logo-container{
position: absolute;
height: 25vh;
}
#article>p>img{
display: inline;
}
#certs>a {
max-width: 15%;
}
#techlogos {
max-height: 40%;
}
#techlogos>a{
max-width: 5%;
}
.spacer {
display: none;
}
}

77
src/static/style/mobile.css Normal file → Executable file
View File

@@ -13,13 +13,13 @@ h1, h2, h3{
}
header{
background-color: 4c4c4c;
background-color: #4c4c4c;
height: 25vh;
width: 100%;
}
footer{
background-color: 4c4c4c;
background-color: #4c4c4c;
display: flex;
justify-content: center;
align-items: center;
@@ -48,33 +48,32 @@ footer h2, section h2{
#technology{
background-image: url(../images/njr-code.png);
height: 100vh;
height: fit-content;
margin: 0;
background-position: center;
background-position-x: -400px;
background-position-y: 400px;
}
#motorsport{
background-image: url(../images/topfuel_startline.jpg.jpeg);
height: 100vh;
height: fit-content;
margin: 0;
background-position: center;
background-position-x: -65px;
background-position-y: -90px;
background-position-y: -100px;
background-size: 200%;
}
.gradient{
width: 100%;
height: 100%;
background-image: linear-gradient(to top, rgba(23, 22, 20, 1) 70%, rgba(23, 22, 20, 0));
display: flex;
align-items: flex-end;
height: fit-content;
}
.text{
height: 70%;
height: fit-content;
width: 100%;
background-color: rgba(23, 22, 20, 1);
}
.text>div{
@@ -118,7 +117,9 @@ a{
.project-thumb{
max-width: 100%;
max-height: 100%;
max-height: 50%;
display: block;
margin: 0 auto 0 auto;
}
#filter {
@@ -203,4 +204,58 @@ label{
#contact-error{
color: red;
}
#article{
padding: 0 10px 0 10px;
}
#article>p>img{
display: block;
margin: 0 auto 0 auto;
max-width: 100%;
}
pre{
overflow-x: auto;
background-color: #36332f;
padding: 10px;
}
#certs {
display: flex;
flex-direction: row;
justify-content: center;
padding: 20px 0;
}
#certs>a {
max-width: 25%;
}
#certs>a>img {
width: 100%;
}
#techlogos {
display: flex;
flex-direction: row;
justify-content: center;
flex-wrap: wrap;
max-height:30%;
}
#techlogos>a {
max-width: 10%;
padding: 10px;
}
#techlogos>a>img {
width: 100%;
}
.spacer {
height: 30vh;
width: 100%;
background-image: linear-gradient(to top, rgba(23, 22, 20, 1) 10%, rgba(23, 22, 20, 0));
}

2
src/templates/article.html Normal file → Executable file
View File

@@ -1,6 +1,6 @@
{% include 'header.html' %}
<main>
<section id="tech-article">
<section id="article">
<h1>{{ metadata.title}} </h1>
<p>{{ metadata.date | human_date }}</p>
<hr />

0
src/templates/contact.html Normal file → Executable file
View File

0
src/templates/error.html Normal file → Executable file
View File

0
src/templates/footer.html Normal file → Executable file
View File

10
src/templates/header.html Normal file → Executable file
View File

@@ -2,6 +2,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Personal website of Jake Charman. A technology professional based in the UK.">
<title>{{ page_title }}Jake Charman</title>
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400..900&family=Tourney:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&family=Orbitron:wght@400..900&family=Tourney:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
@@ -10,9 +11,18 @@
<link rel="stylesheet" href="/static/fonts/fontawesome/css/all.min.css" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="icon" type="image/x-icon" href="/static/images/jc.ico">
<script src="/static/js/filter_projects.js"></script>
<script src="/static/js/update_copyright.js"></script>
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-6WMXXY0RL0"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-6WMXXY0RL0');
</script>
</head>
<body>
<header>

45
src/templates/index.html Normal file → Executable file
View File

@@ -2,18 +2,46 @@
<main>
<section id="technology">
<div class="gradient gradient-left">
<div class="spacer"></div>
<div class="text text-left">
<div>
<h2>Technology</h2>
<hr>
<p>Working with technology is my day job, I currently specialise in:</p>
<ul>
<li>Linux (primarily RHEL & Debian based)</li>
<li>SCM with Git and Subversion</li>
<li>Big Data (Hadoop & Cloud storage)</li>
<li>Programming (Python, Bash & C#)</li>
</ul>
<p>I also run some services for personal use and occasionally write software. I may write about some of the services I run in the future. For now, my code can be found on <a href="https://github.com/jcharman">GitHub</a>.</p>
<p>Technology is my day job. I design and build distributed systems for large companies around the world.</p>
<p>
I also work with technology in my spare time, building systems for <a href="#motorsport">Nitro Junkie</a>, and for me to use personally. For example, the current iteration of this website is written in Python and deployed via a Jenkins pipeline to Google Cloud Run as a Docker container.
</p>
<p>
Below are some of the technologies I'm using most at the moment.
My personal projects can also be found over on the <a href="/projects/">projects</a> page. Be aware though that if I'm able to write about a project here, it most likely wasn't done professionally so some may be a little rough around the edges.
</p>
<div id="techlogos">
<a href="https://ansible.com"><img src="/static/images/technology/ansible.png" /></a>
<a href="https://aws.amazon.com/"><img src="/static/images/technology/aws.png" /></a>
<a href="https://azure.microsoft.com/en-gb"><img src="/static/images/technology/azure.png" /></a>
<a href="https://dotnet.microsoft.com/en-us/languages/csharp"><img src="/static/images/technology/csharp.png" /></a>
<a href="https://www.debian.org/"><img src="/static/images/technology/debian.png" /></a>
<a href="https://www.digitalocean.com/"><img src="/static/images/technology/digitalocean.png" /></a>
<a href="https://www.docker.com/"><img src="/static/images/technology/docker.png" /></a>
<a href="https://www.freeipa.org/"><img src="/static/images/technology/freeipa.png" /></a>
<a href="https://cloud.google.com/"><img src="/static/images/technology/gcloud.png" /></a>
<a href="https://git-scm.com/"><img src="/static/images/technology/git.png" /></a>
<a href="https://www.grafana.com/"><img src="/static/images/technology/grafana.png" /></a>
<a href="https://hadoop.apache.org/"><img src="/static/images/technology/hadoop.svg" /></a>
<a href="https://hive.apache.org/"><img src="/static/images/technology/hive.svg" /></a>
<a href="https://www.java.com/"><img src="/static/images/technology/java.png" /></a>
<a href="https://www.jenkins.io/"><img src="/static/images/technology/jenkins.png" /></a>
<a href="https://mariadb.org/"><img src="/static/images/technology/mariadb.png" /></a>
<a href="https://nginx.org/"><img src="/static/images/technology/nginx.svg" /></a>
<a href="https://www.proxmox.com/"><img src="/static/images/technology/proxmox.png" /></a>
<a href="https://www.python.org/"><img src="/static/images/technology/python.png" /></a>
<a href="https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux"><img src="/static/images/technology/redhat.png" /></a>
<a href="https://rockylinux.org/"><img src="/static/images/technology/rocky.png" /></a>
<a href="https://subversion.apache.org/"><img src="/static/images/technology/svn.svg" /></a>
</div>
<div id="certs">
<a href="https://catalog-education.oracle.com/ords/certview/sharebadge?id=A6C9B3D3D21627EB9C2504395194FAF772E01412911D4ADC78063133D54579ED"><img src="/static/images/certs/OCIF2023CA.png" /></a>
</div>
<div class="social">
<a class="button" href="https://www.linkedin.com/in/jakecharman/"><i class="fa-brands fa-linkedin-in"></i></a>
<a class="button" href="https://github.com/jcharman/"><i class="fa-brands fa-github"></i></a>
@@ -24,6 +52,7 @@
</section>
<section id="motorsport">
<div class="gradient gradient-right">
<div class="spacer"></div>
<div class="text text-right">
<div>
<h2>Racing</h2>

27
src/templates/projects.html Normal file → Executable file
View File

@@ -12,20 +12,35 @@
</nav>
<h2>{{ title }}</h2>
<p>{{ description }}</p>
<p style="text-align: center; font-weight: bold; font-style: italic;">This page is relatively new. I'm adding projects as fast as I can but feel free to <a href="/contact">contact me</a> if you want to know about something in particular.</p>
<section id="projects">
{% for row in articles %}
<div class="project">
<img class="project-thumb" src="/projects/image/{{ row.image }}">
{% if row.get('link') is not none %}
<a href="{{ row.link }}">
{% else %}
<a href="/projects/{{ row.id }}">
{% endif %}
<img class="project-thumb"
srcset="
{% for i in range(200, 5100, 100) %}
/projects/image/{{ row.image }}?w={{i}} {{i}}w{{"," if not loop.last}}
{% endfor %}
"
sizes="
(max-width: 999px) 80vw,
(min-width: 1000px) 20vw
"
src="/projects/image/{{ row.image }}">
</a>
<div class="project-text">
{% if row.get('link') is not none %}
<a href="{{ row.link }}">
<h3>{{ row.title }}</h3>
</a>
<a href="{{ row.link }}">
{% else %}
<a href="/projects/{{ row.id }}">
<a href="/projects/{{ row.id }}">
{% endif %}
<h3>{{ row.title }}</h3>
</a>
{% endif %}
<p class="article-description">{{ row.description }}</p>
<p class="article-date">{{ row.date | human_date }}</p>
{% for category in row.categories %}