]> git.r.bdr.sh - rbdr/blog.unlimited.pizza/blame - archive/1669903029203/blog-tooling.gmi
blog-sync-up-1670604055620
[rbdr/blog.unlimited.pizza] / archive / 1669903029203 / blog-tooling.gmi
CommitLineData
86fd7017
RBR
1# Blog Tooling
2
3With so many of the bloggers I follow talking about the the latest release of MarsEdit[1], I've been getting tooling envy. While my blog[2] is a full-featured enterprise-grade state-of-the-art piece of software, it's not compatible with any of these tools :(. Surely, a lack of appropriate tooling is the real reason why I don't update as often.
4
5=> https://redsweater.com/marsedit/ [1] MarsEdit
6=> https://git.sr.ht/~rbdr/blog [2] Blog
7
8After a dozen misguided minutes of reading the atompub spec[3], I decided to integrate my tooling directly to my editor of choice: `nvim`.
9
10=> https://datatracker.ietf.org/doc/rfc5023/ [3] The atompub spec
11
12Thanks to the marvels of VimScriptâ„¢ I can now add a text file to my blog with `:Blog add`, update the latest post with `:Blog update`, and publish to staging and live with `:Blog stage` and `:Blog publish`. And all it took was a couple of hours of searching how to write commands in vim[4], learning the difference between `<args>` and `<q-args>`, and a ton of sunken cost bias.
13
14=> https://vimhelp.org/usr_40.txt.html#40.2 [4] How to write commands in vim
15
16Here you can see the code in its entirety (with a couple replacements):
17
18
19```
20command -nargs=? Blog :call Blog(<q-args>)
21
22function! Blog(...)
23
24 let command = get(a:, 1, 0)
25 let path = expand("%:p")
26
27 if command == "add"
28 if path == ""
29 echo "This buffer is not a text file"
30 else
31 echo "Adding ".path." to blog"
32 call system("blog --add ".path)
33 endif
34 return
35 endif
36
37 if command == "update"
38 if path == ""
39 echo "This buffer is not a text file"
40 else
41 echo "Updating ".path." to blog"
42 call system("blog --update ".path)
43 endif
44 return
45 endif
46
47 if command == "stage"
48 echo "Publishing blog to staging"
49 call system("blog --publish <staging_url>")
50 return
51 endif
52
53 if command == "publish"
54 echo "Publishing blog"
55 call system("blog --publish <blog_url>")
56 call system("blog --publish-archive <gemini_url>")
57 return
58 endif
59
60 if command == "help"
61 echo "Available commands:"
62 echo "\tadd\t\tadds current file to blog"
63 echo "\tupdate\t\tupdates latest entry of blog with current file"
64 echo "\tstage\t\tpublish blog to staging"
65 echo "\tpublish\t\tpublish blog to production"
66 echo "\thelp\t\tthis message"
67 return
68 endif
69
70 echo "Unknown command, run :Blog help for help"
71
72endfunction
73```
74
75Surely, this is all I need to form a publishing habit.
76
77Written, published, edited, republished, debugged, and republished with nvim.