Add template samples
authorMikael Berthe <mikael@lilotux.net>
Fri, 28 Apr 2017 17:07:13 +0200
changeset 23 2ba1ea451669
parent 22 5778b09bc6fe
child 24 9fcffbaa8cd0
Add template samples
templates/README.md
templates/ansi-account.tmpl
templates/ansi-status.tmpl
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/README.md	Fri Apr 28 17:07:13 2017 +0200
@@ -0,0 +1,11 @@
+# Templates
+
+This folder contains sample templates to customize madonctl output.
+
+I'd like to eventually have support for themes with collections of templates.
+
+Here's an example using a template with ANSI color escape codes (for UNIX/Linux):
+
+    madonctl timeline --limit 2 --template-file ansi-status.tmpl
+
+Feel free to contribute if you have nice templates of if you want to work on themes as well!
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/ansi-account.tmpl	Fri Apr 28 17:07:13 2017 +0200
@@ -0,0 +1,12 @@
+- Account ID: {{"\x1b[31m"}}{{.id}}{{"\x1b[0m"}}  {{"\x1b[35m"}}@{{.username}}{{"\x1b[0m"}}
+  UID: {{"\x1b[31m"}}{{.acct}}{{"\x1b[0m"}}
+  Display name: {{"\x1b[1m"}}{{.display_name}}{{"\x1b[0m"}}
+  Date: {{.created_at}}
+  URL: {{"\x1b[36m"}}{{.url}}{{"\x1b[0m"}}
+  Statuses: {{.statuses_count}}
+  Followers: {{.followers_count}}
+  Following: {{.following_count}}
+{{- with .note}}
+  Note: {{. | fromhtml}}{{end}}
+{{- if eq .locked true}}
+  Locked: true{{end}}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/ansi-status.tmpl	Fri Apr 28 17:07:13 2017 +0200
@@ -0,0 +1,17 @@
+- Status ID: {{"\x1b[31m"}}{{.id}}{{"\x1b[0m"}}  {{"\x1b[35m"}}@{{.account.acct}}{{"\x1b[0m"}}
+  Name: {{"\x1b[1m"}}{{.account.display_name}}{{"\x1b[0m"}}
+  Date: {{.created_at}}
+  URL: {{.url}}
+{{- if gt .in_reply_to_id 0.0}}
+  Replying to: {{.in_reply_to_id}}{{end}}
+{{- with .spoiler_text}}
+  Spoiler: {{.}}{{end}}
+{{- if .reblog }}{{with .reblog}}
+  {{"\x1b[1m"}}Reblogged from: {{"\x1b[34;1m"}}@{{.account.acct}}{{"\x1b[0m"}}
+    ID: {{.id}}
+    Name: {{"\x1b[1m"}}{{.account.display_name}}{{"\x1b[0m"}}
+    Date: {{.created_at}}
+    Message: {{"\x1b[34m"}}{{.content | fromhtml}}{{"\x1b[0m"}}
+{{end}}{{else}}
+  Message: {{"\x1b[34m"}}{{.content | fromhtml}}{{"\x1b[0m"}}
+{{end -}}