Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 31 additions & 23 deletions .github/workflows/comments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,49 @@ jobs:
- name: checkout
uses: actions/checkout@v2
- name: collect-titles
run: "grep -E '@name\\s*\\=' ./src/blog/ -R > posts.txt && cat posts.txt"
run: "grep -E '^name\\s*\\:' ./src/blog/ -R > posts.txt && cat posts.txt"
- name: deps
run: |
npm install -g js-yaml
- uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require("fs")
const { owner, repo } = context.repo
const result = await github.issues.listForRepo({ owner, repo })
const issues = Object.fromEntries(result.data.map(x => [x.title, x]))
let lines = fs.readFileSync('posts.txt').toString().split('\n')
const fs = require("fs");
const yaml = require("js-yaml");
const { owner, repo } = context.repo;
const result = await github.issues.listForRepo({ owner, repo });
const issues = Object.fromEntries(result.data.map(x => [x.title, x]));
let lines = fs.readFileSync('posts.txt').toString().split('\n');
lines.forEach(l => {
l = l.trim()
if (!l) return
let [f, nameLine] = l.split(':')
let labels = ["blog-post"]
const body = fs.readFileSync(f).toString().split('\n').map(x => {
if (x.match(/^\s*@labels/)) {
labels = labels.concat(x.trim().slice(x.indexOf('=')+1).split(",").map(l => l.trim()))
l = l.trim()
if (!l) return;
let [f, nameLine] = l.split(':', 2);
let title = nameLine.slice(nameLine.indexOf(':')+1).trim();
let labels = ["blog-post"];
let contents = fs.readFileSync(f).toString().trim();
if contents.startsWith('---') {
const [_, metaString, rest] = contents.split('---', 3);
const meta = yaml.load(metaString);
labels = labels.concat(meta['labels'] || []);
if (meta['name']) {
title = meta['name'].trim();
}
return x
}).filter(x => !x.match(/^@/))
.join('\n')
contents = rest;
}
const body = contents
.replace(/(!\[[^\]]*\]\()(\/[^\)]+\))/g, `$1https://github.com/${owner}/${repo}/raw/master$2`) // MD image
.replace(/(\[[^\]]*\]\()(\/[^\)]+\))/g, `$1https://github.com/${owner}/${repo}/blob/master$2`) // MD link
.replace(/(src=")(\/[^"]+")/g, `$1https://github.com/${owner}/${repo}/raw/master$2`) // <img> tag
const title = nameLine.slice(nameLine.indexOf('=')+1).trim()
.replace(/(src=")(\/[^"]+")/g, `$1https://github.com/${owner}/${repo}/raw/master$2`); // <img> tag
if (title in issues) {
const found = issues[title]
const found = issues[title];
github.issues.update({
owner, repo,
issue_number: found.number,
labels: found.labels.concat(labels),
title, body,
})
return
});
return;
}
github.issues.create({ owner, repo, title, body, labels })
})
github.issues.create({ owner, repo, title, body, labels });
});
37 changes: 19 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,34 @@ jobs:
announce:
runs-on: ubuntu-latest
steps:
- run: npm install -g js-yaml
- uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const pr = context.payload.pull_request
const yaml = require("js-yaml");
const pr = context.payload.pull_request;
if (pr.state !== "open" && pr.merged_at === null) {
console.log("pr was not merged, skipping")
return
console.log("pr was not merged, skipping");
return;
}
let urlBase = "https://kylemtravis.com/blog"
let urlBase = "https://kylemtravis.com/blog";
if (pr.state === "open")
urlBase = `https://deploy-preview-${pr.number}--kylemtravis.netlify.app/blog`
urlBase = `https://deploy-preview-${pr.number}--kylemtravis.netlify.app/blog`;
const result = await github.pulls.listFiles({
pull_number: pr.number,
owner: context.repo.owner,
repo: context.repo.repo,
})
const added = result.data.filter(f => f.status === "added")
const newBlogPosts = added.filter(f => f.filename.match(/src\/blog\//) !== null)
});
const added = result.data.filter(f => f.status === "added");
const newBlogPosts = added.filter(f => f.filename.match(/src\/blog\//) !== null);
if (newBlogPosts.length < 1)
return
return;

const releaseName = newBlogPosts[0].patch.match(/@name\s*=\s*(.+)/)[1]
let slug = releaseName.toLowerCase().replace(/\s+/g, "-").replace(/[^a-zA-Z0-9\-]/g, "")
const slugMatch = newBlogPosts[0].patch.match(/@slug\s*=\s*(.+)/)
if (slugMatch && slugMatch.length > 1)
slug = slugMatch[1]
const [_, metaString, _] = newBlogPosts[0].patch.split('---', 3);
const meta = yaml.load(metaString);
const releaseName = meta['name'];
const slug = meta['slug'] || releaseName.toLowerCase().replace(/\s+/g, "-").replace(/[^a-zA-Z0-9\-]/g, "");

const rel = {
owner: context.repo.owner,
Expand All @@ -43,17 +44,17 @@ jobs:
name: `[Blog Post] ${releaseName}`,
body: `New blog post, read it [here](${urlBase}/${slug})!`,
draft: pr.state === "open",
}
};
const rels = await github.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
})
const found = rels.data.filter(r => r.draft && r.tag_name == rel.tag_name)
});
const found = rels.data.filter(r => r.draft && r.tag_name == rel.tag_name);
await (found.length > 1 ?
github.repos.updateRelease({
release_id: found[0].id,
...rel
}) :
github.repos.createRelease(rel)
)
);

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
build/*
bin/

# Local Netlify folder
.netlify
21 changes: 16 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
.PHONY: clean build deploy

clean:
rm -rf build/* bin/*
# annoying workaround to handle netlify
GOPATH := $(or $(GOPATH),$(shell go env GOPATH))
GOBIN := $(or $(shell go env GOBIN),$(GOPATH)/bin)
SSGEN := $(GOBIN)/ssgen
PORT := 8081

build:
command -v ssgen || go install github.com/ktravis/ssgen@latest
PATH=$$(go env GOPATH)/bin:$$PATH ssgen -in src -out build
build: $(SSGEN)
$(SSGEN) -in src -out build
cp -R static/ build/

$(SSGEN):
go install github.com/ktravis/ssgen@latest

serve: $(SSGEN)
$(SSGEN) -serve localhost:$(PORT)

clean:
rm -rf build/* bin/*
7 changes: 7 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build]
command = "make build"
publish = "build"

[build.environment]
GO_VERSION = "1.25"
GO111MODULE = "on"
4 changes: 3 additions & 1 deletion src/about.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@title = about
---
title: about
---

```json
{
Expand Down
4 changes: 3 additions & 1 deletion src/blog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@template = blog
---
template: blog
---

testing
13 changes: 7 additions & 6 deletions src/blog/blog-comments.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
@name = Blog Comments With GitHub
@slug = blog-comments
@published = 2020-09-09
@labels = meta

[//]: # (testing)
---
name: Blog Comments With GitHub
slug: blog-comments
published: 2020-09-09
labels: meta
previewLines: 3
---

_For more background, see my [previous post](https://kylemtravis.com/blog/blogging-with-github) about GitHub Actions._

Expand Down
12 changes: 7 additions & 5 deletions src/blog/blogging-on-github.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
@name = Blogging With GitHub
@published = 2020-08-28
@labels = meta

---
name: Blogging With GitHub
published: 2020-08-28
labels: meta
previewLines: 15
---
_Obligatory "wow it's been so long since I've written here!"_

In an effort to reduce the (admittedly already low) friction of writing blog posts, I'm now hosting this site on
[netlify](https://netlify.com), which makes it pretty effortless to generate site previews off of pull requests, as well
as perform the usual tasks like updating DNS, provisioning a Let's Encrypt cert, etc. I'm still using [my own static site generator](https://github.com/ktravis/ssgen) which was easy to integrate with netlify's GitHub App: I set my site's "build command" to `make build`, which runs:

```make
```makefile
SSGEN_BIN ?= ./ssgen

build: $(SSGEN_BIN)
Expand Down
9 changes: 6 additions & 3 deletions src/blog/cultivate-post-mortem.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
@name = Cultivate Post-Mortem
@published = 2016-01-03
@labels = game,ludum-dare,unity
---
name: Cultivate Post-Mortem
published: 2016-01-03
labels: game,ludum-dare,unity
previewLines: 3
---

Hello there! With just over a day remaining in the voting period, it seemed like a great time to finally write up a post-mortem for my experience this time around. I've included my favorites/recommendations of the entries that I've played so far **at the end of this post.**

Expand Down
8 changes: 5 additions & 3 deletions src/blog/flappyjam.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@name = FlappyJam
@published = 2014-02-24
@labels = haxe,game
---
name: FlappyJam
published: 2014-02-24
labels: haxe,game
---

I've just submitted my entry to [itch.io](http://itch.io)'s [FLAPPYJAM](http://itch.io/jam/flappyjam)! See it/[play it here](http://kmakai.itch.io/flee-lethal-avian-pests).

Expand Down
11 changes: 7 additions & 4 deletions src/blog/haxe-and-google-play-services.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
@name = Haxe and Google Play Services
@slug = play-haxe
@published = 2014-10-07
@labels = haxe
---
name: Haxe and Google Play Services
slug: play-haxe
published: 2014-10-07
labels: haxe
previewLines: 1
---

Recently I decided I wanted to integrate Google Play Services -- leaderboards, achievements, etc -- with a Haxe/OpenFL project targetting Android devices. I assumed this should be easy enough given the ability to hook into Android/Java frameworks via native extensions. Overall it was simple, but not necessarily straightforward, so I'm writing this post as a quick start guide for others.

Expand Down
9 changes: 6 additions & 3 deletions src/blog/haxe-signals.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
@name = Haxe Signals
@published = 2014-05-16
@labels = haxe
---
name: Haxe Signals
published: 2014-05-16
labels: haxe
previewLines: 2
---

A common pattern I find myself following in game development is the message-subscription/callback model -- notifying a group of objects that a certain event has happened, at which point they all go about their business responding in the appropriate ways.

Expand Down
8 changes: 5 additions & 3 deletions src/blog/trying-twine-textjam.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@name = Trying Twine (TextJam)
@published = 2014-06-24
@labels = game,twine
---
name: Trying Twine (TextJam)
published: 2014-06-24
labels: game,twine
---

I was determined to participate in [TextJam](http://textjam.tumblr.com) last weekend, and without much time to devote I thought it could be smart to give Twine a try. Starting with a solid framework meant that once I had learned the syntax (and installed a few essential macros,) I could devote my remaining time to content and styling.

Expand Down
4 changes: 3 additions & 1 deletion src/projects.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
@template = projects
---
template: projects
---
12 changes: 7 additions & 5 deletions src/projects/cultivate.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
@name = Cultivate
@year = 2015
@type = Game
@thumbnail = /static/images/cultivate-1@120.jpg
@url = http://kmakai.itch.io/cultivate
---
name: Cultivate
year: 2015
type: Game
thumbnail: /static/images/cultivate-1@120.jpg
url: http://kmakai.itch.io/cultivate
---

Made for Ludum Dare 34, in 48 hours. Unity.
12 changes: 7 additions & 5 deletions src/projects/isolation.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
@name = Isolation
@year = 2013
@type = Game
@thumbnail = /static/images/iso@120.png
@url = http://kmakai.itch.io/isolation
---
name: Isolation
year: 2013
type: Game
thumbnail: /static/images/iso@120.png
url: http://kmakai.itch.io/isolation
---

A game about personal space.
12 changes: 7 additions & 5 deletions src/projects/lark.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
@name = Lark
@year = 2015
@type = Language
@thumbnail = /static/images/screen-shot-2016-01-10-at-9.50.03-pm@120.png
@url = https://github.com/ktravis/lark
---
name: Lark
year: 2015
type: Language
thumbnail: /static/images/screen-shot-2016-01-10-at-9.50.03-pm@120.png
url: https://github.com/ktravis/lark
---

An odd dynamic programming language, interpreted by Python
12 changes: 7 additions & 5 deletions src/projects/lvrg.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
@name = LVRG
@year = 2014
@type = Game
@thumbnail = /static/images/lvrg-icon@120.png
@url = https://play.google.com/store/apps/details?id=com.kmakai.lvrg
---
name: LVRG
year: 2014
type: Game
thumbnail: /static/images/lvrg-icon@120.png
url: https://play.google.com/store/apps/details?id=com.kmakai.lvrg
---

A simple Android game about self-control and timing. Made with Haxe and OpenFL.
12 changes: 7 additions & 5 deletions src/projects/maera.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
@name = Maera
@url = https://play.google.com/store/apps/details?id=com.kmakai.maera
@year = 2014
@type = App
@thumbnail = /static/images/maera@120.png
---
name: Maera
url: https://play.google.com/store/apps/details?id=com.kmakai.maera
year: 2014
type: App
thumbnail: /static/images/maera@120.png
---

A minimal Android camera app, inspired by [Noirca](https://wiki.xxiivv.com/noirca) by [Devine Lu
Linvega](https://twitter.com/aliceffekt)
10 changes: 6 additions & 4 deletions src/projects/scraps.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@name = Scraps
@year = 2013
@thumbnail = /static/images/scraps@120.png
@url = https://gist.github.com/ktravis
---
name: Scraps
year: 2013
thumbnail: /static/images/scraps@120.png
url: https://gist.github.com/ktravis
---

Minor works of code.
Loading
Loading