Personal website with markdown blog & syntax highlighting
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Adam Piontek 3fbc8e50ab edited poem 2 years ago
assets updated dependencies 2 years ago
config added custom error templates, and fun error testing routes 2 years ago
lib switched to source serif pro as main font, fixed some other styling 2 years ago
priv edited poem 2 years ago
test added content, post display 2 years ago
.formatter.exs initial commit 2 years ago
.gitignore fixing purgecss issue with chroma styles 2 years ago
.iex.exs syntax highlighting and blog/post liveviews working; numerous other styling updates 2 years ago
.sobelow-conf adding proper CSP header plug and setting ignore config for mix sobelow 2 years ago improving code styling 2 years ago
mix.exs added content, post display 2 years ago
mix.lock updated dependencies 2 years ago


Personal website with blog.

Blog posts

Posts are markdown files stored under priv/content and parsed by Earmark. This can be configured in config.exs under config :home73k, :app_global_vars, blog_content: "path/to/content"

Syntax highlighting

For the challenge of it, and to keep user's browsers from having to run javascript just to highlight some code, I chose to do server-side syntax highlighting.

Due to the lexer limitations of elixir-native solutions, the highlighter uses Chroma by calling its command-linie-interface via System.cmd

However, this requires installing golang as well as chroma. You can add go to your path, but once chroma is installed, just make sure Home73k's config.exs is configured to point directly to the chroma binary under config :home73k, :app_global_vars, chroma_bin: "path/to/bin/chroma" -- "priv/go/bin/chroma" by default.


New versions

When improvements are made, we can update the deployed version like so:

cd /opt/home73k
git pull
mix deps.get --only prod
MIX_ENV=prod mix compile
# update chroma in priv gopath
GOPATH=$(pwd)/priv/go go get -u
# rebuild static assets:
rm -rf priv/static/*
npm run deploy --prefix ./assets
MIX_ENV=prod mix phx.digest
MIX_ENV=prod mix release --overwrite
# test starting it:
MIX_ENV=prod _build/prod/rel/home73k/bin/home73k start

systemd unit:

Description=Home73k service

ExecStart=/opt/home73k/_build/prod/rel/home73k/bin/home73k start
ExecStop=/opt/home73k/_build/prod/rel/home73k/bin/home73k stop


nginx config:

    upstream phoenixhome {
      server max_fails=5 fail_timeout=60s;
    server {
      location / {
        allow all;
        # Proxy Headers
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-Cluster-Client-Ip $remote_addr;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_redirect off;
        # WebSockets
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_pass http://phoenixhome;