Compare commits
239 Commits
793789bdf2
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3929f22f3 | ||
|
|
bad12160ac | ||
|
|
c43679fda9 | ||
|
|
9cc28f6f0d | ||
|
|
d2256b8333 | ||
|
|
fa8753077a | ||
|
|
0420f58d02 | ||
|
|
0250aa106e | ||
|
|
ca1c456571 | ||
|
|
4403980e2e | ||
|
|
dbfbce955d | ||
|
|
2e08d2e59a | ||
|
|
9f14534c10 | ||
|
|
4e34ebc29e | ||
|
|
8d85d5ef79 | ||
|
|
7d73a3c948 | ||
|
|
c501f7cedc | ||
|
|
41927764fc | ||
|
|
75a763569b | ||
|
|
c67eb32774 | ||
|
|
04952895cf | ||
|
|
749f6d7a55 | ||
|
|
c4cf814f8d | ||
|
|
3245e830d2 | ||
|
|
57eb1b81ec | ||
|
|
c601c8697a | ||
|
|
4ea1a46705 | ||
|
|
4cc04bda46 | ||
|
|
7e934cd360 | ||
|
|
e34e2ef75f | ||
|
|
c067ca9cc8 | ||
|
|
b06424cb17 | ||
|
|
ae6f18d19c | ||
|
|
c371b999d5 | ||
|
|
073ac0ac25 | ||
|
|
1c356737c1 | ||
|
|
339bd433f6 | ||
|
|
bb5fa6a487 | ||
|
|
71b6db14d5 | ||
|
|
69fb91db37 | ||
|
|
5fd93fc648 | ||
|
|
033a17e355 | ||
|
|
824f34bd4c | ||
|
|
d93e91c625 | ||
|
|
db21bd8a55 | ||
|
|
69729bd329 | ||
|
|
ddea8fdceb | ||
|
|
71f639e503 | ||
|
|
8714d3b650 | ||
|
|
88064409a6 | ||
|
|
7c17087920 | ||
|
|
c1837addd0 | ||
|
|
79c36476bd | ||
|
|
4a0cbf3ba5 | ||
|
|
59ee13345e | ||
|
|
bf7f37260c | ||
|
|
ff478253c3 | ||
|
|
3e952ef0f4 | ||
|
|
4e0f66401d | ||
|
|
3867f965d2 | ||
|
|
5cac44c625 | ||
|
|
463be34302 | ||
|
|
8fd37cbf22 | ||
|
|
4fb67c18ae | ||
|
|
eb18185131 | ||
|
|
7c92b602bc | ||
|
|
aeca958cef | ||
|
|
495a3c0b4e | ||
|
|
9402c453da | ||
|
|
328b2ba520 | ||
|
|
4a76f61aa7 | ||
|
|
2c9396615e | ||
|
|
e7b6dc9059 | ||
|
|
bcdf441d77 | ||
|
|
884a28e63a | ||
|
|
1c3e2ca4d9 | ||
|
|
2081d25066 | ||
|
|
7ddc4011b3 | ||
|
|
379850fe3d | ||
|
|
8ab69e480e | ||
|
|
c5621212bc | ||
|
|
b9f74b7eca | ||
|
|
493adb4688 | ||
|
|
b6cc7a70b7 | ||
|
|
8868cfb63f | ||
|
|
ae3add9c81 | ||
|
|
98fa43575d | ||
|
|
5d3a6c4174 | ||
|
|
be467c8074 | ||
|
|
0da375c529 | ||
|
|
1b740b1f2f | ||
|
|
d94ecefab9 | ||
|
|
7501a018fd | ||
|
|
ce31397372 | ||
|
|
7e1e070e23 | ||
|
|
fa16a7dd39 | ||
|
|
59a91331cc | ||
|
|
d2ea6b6a0f | ||
|
|
fdff5a667b | ||
|
|
35cf675c87 | ||
|
|
3b63bbdfde | ||
|
|
24218f2979 | ||
|
|
6a086d57de | ||
|
|
93e0a2fe98 | ||
|
|
86d4e25aa0 | ||
|
|
cb5d131097 | ||
|
|
eb67327574 | ||
|
|
5228851c0e | ||
|
|
4fc08f4375 | ||
|
|
8905c9356b | ||
|
|
424a970014 | ||
|
|
138d694b27 | ||
|
|
397d4ea0bc | ||
|
|
818fca87f2 | ||
|
|
df339f20fa | ||
|
|
d5572c93cd | ||
|
|
322dbb8f4f | ||
|
|
904f834c86 | ||
|
|
48af194da0 | ||
|
|
bcb6b2d75f | ||
|
|
134444b2c3 | ||
|
|
4447f1ed4a | ||
|
|
457ff9e759 | ||
|
|
6f244a0a5f | ||
|
|
cb5838345e | ||
|
|
1107a653cf | ||
|
|
95d4ee7080 | ||
|
|
fa2dd96f78 | ||
|
|
7741e192f5 | ||
|
|
5dfd46852f | ||
|
|
88e10010d8 | ||
|
|
52c564d4fd | ||
|
|
f7874c1843 | ||
|
|
40120667f7 | ||
|
|
b06798f23f | ||
|
|
35dff5cdaf | ||
|
|
d641c8d638 | ||
|
|
7e2fd70212 | ||
|
|
4fb08bc7d0 | ||
|
|
01b55b7256 | ||
|
|
bd68681e44 | ||
|
|
27ff13e675 | ||
|
|
2914e42ba1 | ||
|
|
a8969f141d | ||
|
|
6f049e00d4 | ||
|
|
45a1076d18 | ||
|
|
775c88d67a | ||
|
|
efbf6cfc0c | ||
|
|
5af4a372ae | ||
|
|
72952adb6b | ||
|
|
8b85c02ef1 | ||
|
|
2ae4839ce0 | ||
|
|
5654c40d03 | ||
|
|
b538750287 | ||
|
|
65ed754bfe | ||
|
|
80cdf5166b | ||
|
|
3968121d54 | ||
|
|
a29b625631 | ||
|
|
e193fcc2ba | ||
|
|
050b426f6f | ||
|
|
da81f93e4a | ||
|
|
1581e5c401 | ||
|
|
2e1c979127 | ||
|
|
d4b290ebe6 | ||
|
|
4bb1f9983a | ||
|
|
261fe8a1a2 | ||
|
|
add267d616 | ||
|
|
cb3278aba5 | ||
|
|
94d9a95967 | ||
|
|
6511115b95 | ||
|
|
53cd55932b | ||
|
|
cbe2010407 | ||
|
|
2ba4a5e3d7 | ||
|
|
c3482cf1e4 | ||
|
|
fdf84e3d0b | ||
|
|
0a4376dfb8 | ||
|
|
e8ed4a4f4a | ||
|
|
60555999db | ||
|
|
6968a5b02c | ||
|
|
c84cfdc02b | ||
|
|
c98489cacb | ||
|
|
35dbab0ceb | ||
|
|
1ff41940a5 | ||
|
|
884215a7e1 | ||
|
|
20c55f0708 | ||
|
|
9e3d72972c | ||
|
|
806c45a453 | ||
|
|
270c42a509 | ||
|
|
e8963e107b | ||
|
|
0b64551a23 | ||
|
|
b654ca4859 | ||
|
|
386af57ce6 | ||
|
|
ef4d315bf2 | ||
|
|
2142b01967 | ||
|
|
159d8fb72a | ||
|
|
0fae417610 | ||
|
|
ae933b491e | ||
|
|
5e476e189a | ||
|
|
533997dbf5 | ||
|
|
8695cf17c5 | ||
|
|
e2f9938437 | ||
|
|
ada11816fb | ||
|
|
ff57242434 | ||
|
|
0da37b25e3 | ||
|
|
ff03140007 | ||
|
|
0ae492f8d3 | ||
|
|
613d49c6ec | ||
|
|
0f7e5eea25 | ||
|
|
2e7cfd5637 | ||
|
|
afe62de2b6 | ||
|
|
1f3b5262b8 | ||
|
|
f63620b547 | ||
|
|
671159cb82 | ||
|
|
f1e985fb32 | ||
|
|
a966be8122 | ||
|
|
24b9782146 | ||
|
|
3d44d20384 | ||
|
|
f98a09bc59 | ||
|
|
ba511b7f9e | ||
|
|
3720558d93 | ||
|
|
b66ec507ef | ||
|
|
645ae26701 | ||
|
|
6109902945 | ||
|
|
cd27869122 | ||
|
|
795945f0da | ||
|
|
cb7c28c1ae | ||
|
|
52ca300de3 | ||
|
|
06dcd22e69 | ||
|
|
f87c453459 | ||
|
|
e42edb3f49 | ||
|
|
6d83828012 | ||
|
|
eaea37f448 | ||
|
|
fb99fd2b39 | ||
|
|
313313ae53 | ||
|
|
d9a3b13780 | ||
|
|
8d9a50226a | ||
|
|
f164838953 | ||
|
|
fe3f2642fe | ||
|
|
3d89492518 |
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
**/.git
|
||||||
|
target/
|
||||||
|
org_test_documents/
|
||||||
224
.webhook_bridge/pipeline-build-hash.yaml
Normal file
224
.webhook_bridge/pipeline-build-hash.yaml
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
apiVersion: tekton.dev/v1
|
||||||
|
kind: PipelineRun
|
||||||
|
metadata:
|
||||||
|
name: build
|
||||||
|
spec:
|
||||||
|
timeouts:
|
||||||
|
pipeline: "2h0m0s"
|
||||||
|
tasks: "1h0m0s"
|
||||||
|
finally: "0h30m0s"
|
||||||
|
taskRunTemplate:
|
||||||
|
serviceAccountName: build-bot
|
||||||
|
pipelineSpec:
|
||||||
|
params:
|
||||||
|
- name: image-name
|
||||||
|
description: The name for the built image
|
||||||
|
type: string
|
||||||
|
- name: target-name
|
||||||
|
description: The dockerfile target to build
|
||||||
|
type: string
|
||||||
|
- name: path-to-image-context
|
||||||
|
description: The path to the build context
|
||||||
|
type: string
|
||||||
|
- name: path-to-dockerfile
|
||||||
|
description: The path to the Dockerfile
|
||||||
|
type: string
|
||||||
|
tasks:
|
||||||
|
- name: report-pending
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
|
params:
|
||||||
|
- name: CONTEXT
|
||||||
|
value: "$(params.JOB_NAME)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has started"
|
||||||
|
- name: STATE
|
||||||
|
value: pending
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: fetch-repository
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/git-clone/0.9/git-clone.yaml
|
||||||
|
workspaces:
|
||||||
|
- name: output
|
||||||
|
workspace: git-source
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: $(params.REPO_URL)
|
||||||
|
- name: revision
|
||||||
|
value: $(params.PULL_BASE_SHA)
|
||||||
|
- name: deleteExisting
|
||||||
|
value: "true"
|
||||||
|
- name: get-git-commit-time
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 600Mi
|
||||||
|
workingDir: "$(workspaces.repo.path)"
|
||||||
|
results:
|
||||||
|
- name: unix-time
|
||||||
|
description: The time of the git commit in unix timestamp format.
|
||||||
|
steps:
|
||||||
|
- image: alpine/git:v2.34.2
|
||||||
|
name: detect-tag-step
|
||||||
|
script: |
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
set -euo pipefail
|
||||||
|
echo -n "$(git log -1 --pretty=%ct)" | tee $(results.unix-time.path)
|
||||||
|
workspaces:
|
||||||
|
- name: repo
|
||||||
|
workspace: git-source
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
|
- name: build-image
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: 7ee31a185243ee6da13dcd26a592c585b64c80e5
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/buildkit-rootless-daemonless/0.1/buildkit-rootless-daemonless.yaml
|
||||||
|
params:
|
||||||
|
- name: OUTPUT
|
||||||
|
value: >-
|
||||||
|
type=image,"name=$(params.image-name):latest,$(params.image-name):$(tasks.fetch-repository.results.commit)",push=true,compression=zstd,compression-level=22,oci-mediatypes=true
|
||||||
|
- name: CONTEXT
|
||||||
|
value: $(params.path-to-image-context)
|
||||||
|
- name: DOCKERFILE
|
||||||
|
value: $(params.path-to-dockerfile)
|
||||||
|
- name: EXTRA_ARGS
|
||||||
|
value:
|
||||||
|
- "--opt"
|
||||||
|
- "target=$(params.target-name)"
|
||||||
|
- --import-cache
|
||||||
|
- "type=registry,ref=$(params.image-name):buildcache"
|
||||||
|
- --export-cache
|
||||||
|
- "type=registry,ref=$(params.image-name):buildcache,mode=max,compression=zstd,compression-level=22,rewrite-timestamp=true,image-manifest=true,oci-mediatypes=true"
|
||||||
|
- --opt
|
||||||
|
- build-arg:SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time)
|
||||||
|
- name: BUILDKITD_TOML
|
||||||
|
value: |
|
||||||
|
debug = true
|
||||||
|
[registry."docker.io"]
|
||||||
|
mirrors = ["dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
[registry."dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
http = true
|
||||||
|
insecure = true
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: dockerconfig
|
||||||
|
workspace: docker-credentials
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
|
finally:
|
||||||
|
- name: report-success
|
||||||
|
when:
|
||||||
|
- input: "$(tasks.status)"
|
||||||
|
operator: in
|
||||||
|
values: ["Succeeded", "Completed"]
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
|
params:
|
||||||
|
- name: CONTEXT
|
||||||
|
value: "$(params.JOB_NAME)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has succeeded"
|
||||||
|
- name: STATE
|
||||||
|
value: success
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: report-failure
|
||||||
|
when:
|
||||||
|
- input: "$(tasks.status)"
|
||||||
|
operator: in
|
||||||
|
values: ["Failed"]
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
|
params:
|
||||||
|
- name: CONTEXT
|
||||||
|
value: "$(params.JOB_NAME)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has failed"
|
||||||
|
- name: STATE
|
||||||
|
value: failure
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
workspaces:
|
||||||
|
- name: git-source
|
||||||
|
- name: docker-credentials
|
||||||
|
workspaces:
|
||||||
|
- name: git-source
|
||||||
|
volumeClaimTemplate:
|
||||||
|
spec:
|
||||||
|
storageClassName: "local-path"
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 10Gi
|
||||||
|
subPath: rust-source
|
||||||
|
- name: docker-credentials
|
||||||
|
secret:
|
||||||
|
secretName: harbor-plain
|
||||||
|
params:
|
||||||
|
- name: image-name
|
||||||
|
value: "harbor.fizz.buzz/private/natter"
|
||||||
|
- name: target-name
|
||||||
|
value: ""
|
||||||
|
- name: path-to-image-context
|
||||||
|
value: .
|
||||||
|
- name: path-to-dockerfile
|
||||||
|
value: docker/natter/
|
||||||
369
.webhook_bridge/pipeline-format.yaml
Normal file
369
.webhook_bridge/pipeline-format.yaml
Normal file
@@ -0,0 +1,369 @@
|
|||||||
|
apiVersion: tekton.dev/v1
|
||||||
|
kind: PipelineRun
|
||||||
|
metadata:
|
||||||
|
name: rust-format
|
||||||
|
spec:
|
||||||
|
timeouts:
|
||||||
|
pipeline: "2h0m0s"
|
||||||
|
tasks: "1h0m0s"
|
||||||
|
finally: "0h30m0s"
|
||||||
|
taskRunTemplate:
|
||||||
|
serviceAccountName: build-bot
|
||||||
|
pipelineSpec:
|
||||||
|
params:
|
||||||
|
- name: image-name
|
||||||
|
description: The name for the built image
|
||||||
|
type: string
|
||||||
|
- name: target-name
|
||||||
|
description: The dockerfile target to build
|
||||||
|
type: string
|
||||||
|
- name: path-to-image-context
|
||||||
|
description: The path to the build context
|
||||||
|
type: string
|
||||||
|
- name: path-to-dockerfile
|
||||||
|
description: The path to the Dockerfile
|
||||||
|
type: string
|
||||||
|
tasks:
|
||||||
|
- name: report-pending
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
|
params:
|
||||||
|
- name: CONTEXT
|
||||||
|
value: "$(params.JOB_NAME)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has started"
|
||||||
|
- name: STATE
|
||||||
|
value: pending
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: fetch-repository
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/git-clone/0.9/git-clone.yaml
|
||||||
|
workspaces:
|
||||||
|
- name: output
|
||||||
|
workspace: git-source
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: $(params.REPO_URL)
|
||||||
|
- name: revision
|
||||||
|
value: $(params.PULL_BASE_SHA)
|
||||||
|
- name: deleteExisting
|
||||||
|
value: "true"
|
||||||
|
- name: get-git-commit-time
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 600Mi
|
||||||
|
workingDir: "$(workspaces.repo.path)"
|
||||||
|
results:
|
||||||
|
- name: unix-time
|
||||||
|
description: The time of the git commit in unix timestamp format.
|
||||||
|
steps:
|
||||||
|
- image: alpine/git:v2.34.2
|
||||||
|
name: detect-tag-step
|
||||||
|
script: |
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
set -euo pipefail
|
||||||
|
echo -n "$(git log -1 --pretty=%ct)" | tee $(results.unix-time.path)
|
||||||
|
workspaces:
|
||||||
|
- name: repo
|
||||||
|
workspace: git-source
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
|
- name: build-image
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: 7ee31a185243ee6da13dcd26a592c585b64c80e5
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/buildkit-rootless-daemonless/0.1/buildkit-rootless-daemonless.yaml
|
||||||
|
params:
|
||||||
|
- name: OUTPUT
|
||||||
|
value: >-
|
||||||
|
type=image,"name=$(params.image-name):latest,$(params.image-name):$(tasks.fetch-repository.results.commit)",push=true,compression=zstd,compression-level=22,oci-mediatypes=true
|
||||||
|
- name: CONTEXT
|
||||||
|
value: $(params.path-to-image-context)
|
||||||
|
- name: DOCKERFILE
|
||||||
|
value: $(params.path-to-dockerfile)
|
||||||
|
- name: EXTRA_ARGS
|
||||||
|
value:
|
||||||
|
- "--opt"
|
||||||
|
- "target=$(params.target-name)"
|
||||||
|
- --import-cache
|
||||||
|
- "type=registry,ref=$(params.image-name):buildcache"
|
||||||
|
- --export-cache
|
||||||
|
- "type=registry,ref=$(params.image-name):buildcache,mode=max,compression=zstd,compression-level=22,rewrite-timestamp=true,image-manifest=true,oci-mediatypes=true"
|
||||||
|
- --opt
|
||||||
|
- build-arg:SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time)
|
||||||
|
- name: BUILDKITD_TOML
|
||||||
|
value: |
|
||||||
|
debug = true
|
||||||
|
[registry."docker.io"]
|
||||||
|
mirrors = ["dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
[registry."dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
http = true
|
||||||
|
insecure = true
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: dockerconfig
|
||||||
|
workspace: docker-credentials
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
|
- name: run-cargo-fmt
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
type: string
|
||||||
|
description: Docker image to run.
|
||||||
|
default: alpine:3.20
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 600Mi
|
||||||
|
workingDir: /workspace/source
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
mountPath: /source
|
||||||
|
- name: cargo-cache
|
||||||
|
mountPath: /usr/local/cargo/registry
|
||||||
|
optional: true
|
||||||
|
steps:
|
||||||
|
- name: run
|
||||||
|
image: $(params.docker-image)
|
||||||
|
workingDir: "$(workspaces.source.path)"
|
||||||
|
command: ["cargo", "fmt"]
|
||||||
|
args: []
|
||||||
|
env:
|
||||||
|
- name: CARGO_TARGET_DIR
|
||||||
|
value: /target
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
runAfter:
|
||||||
|
- build-image
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
- name: run-prettier
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
type: string
|
||||||
|
description: Docker image to run.
|
||||||
|
default: alpine:3.20
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 600Mi
|
||||||
|
workingDir: /workspace/source
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
mountPath: /source
|
||||||
|
steps:
|
||||||
|
- name: run
|
||||||
|
image: $(params.docker-image)
|
||||||
|
workingDir: "$(workspaces.source.path)"
|
||||||
|
command: ["sh", "-c"]
|
||||||
|
args:
|
||||||
|
- |
|
||||||
|
prettier --write --no-error-on-unmatched-pattern "default_environment/**/*.js" "default_environment/**/*.css"
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
runAfter:
|
||||||
|
- build-image
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
- name: commit-changes
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/git-cli/0.4/git-cli.yaml
|
||||||
|
params:
|
||||||
|
- name: GIT_USER_NAME
|
||||||
|
value: fluxcdbot
|
||||||
|
- name: GIT_USER_EMAIL
|
||||||
|
value: "fluxcdbot@users.noreply.github.com"
|
||||||
|
- name: GIT_SCRIPT
|
||||||
|
value: |
|
||||||
|
pwd
|
||||||
|
git config --global --add safe.directory /workspace/source
|
||||||
|
git_status=$(git status --porcelain)
|
||||||
|
if [ -n "$git_status" ]; then
|
||||||
|
git commit -a -m "CI: autofix rust code."
|
||||||
|
git push origin HEAD:$(params.PULL_BASE_REF)
|
||||||
|
else
|
||||||
|
echo "No changes to commit."
|
||||||
|
fi
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
runAfter:
|
||||||
|
- run-cargo-fmt
|
||||||
|
- run-prettier
|
||||||
|
finally:
|
||||||
|
- name: report-success
|
||||||
|
when:
|
||||||
|
- input: "$(tasks.status)"
|
||||||
|
operator: in
|
||||||
|
values: ["Succeeded", "Completed"]
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
|
params:
|
||||||
|
- name: CONTEXT
|
||||||
|
value: "$(params.JOB_NAME)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has succeeded"
|
||||||
|
- name: STATE
|
||||||
|
value: success
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: report-failure
|
||||||
|
when:
|
||||||
|
- input: "$(tasks.status)"
|
||||||
|
operator: in
|
||||||
|
values: ["Failed"]
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
|
params:
|
||||||
|
- name: CONTEXT
|
||||||
|
value: "$(params.JOB_NAME)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has failed"
|
||||||
|
- name: STATE
|
||||||
|
value: failure
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: cargo-cache-autoclean
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
type: string
|
||||||
|
description: Docker image to run.
|
||||||
|
default: alpine:3.20
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 600Mi
|
||||||
|
workingDir: /workspace/source
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
mountPath: /source
|
||||||
|
- name: cargo-cache
|
||||||
|
mountPath: /usr/local/cargo/registry
|
||||||
|
optional: true
|
||||||
|
steps:
|
||||||
|
- name: run
|
||||||
|
image: $(params.docker-image)
|
||||||
|
workingDir: "$(workspaces.source.path)"
|
||||||
|
command: [cargo, cache, --autoclean]
|
||||||
|
args: []
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
workspaces:
|
||||||
|
- name: git-source
|
||||||
|
- name: docker-credentials
|
||||||
|
- name: cargo-cache
|
||||||
|
workspaces:
|
||||||
|
- name: git-source
|
||||||
|
volumeClaimTemplate:
|
||||||
|
spec:
|
||||||
|
storageClassName: "local-path"
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 10Gi
|
||||||
|
subPath: rust-source
|
||||||
|
- name: cargo-cache
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: natter-cargo-cache-fmt
|
||||||
|
- name: docker-credentials
|
||||||
|
secret:
|
||||||
|
secretName: harbor-plain
|
||||||
|
params:
|
||||||
|
- name: image-name
|
||||||
|
value: "harbor.fizz.buzz/private/natter-development-format"
|
||||||
|
- name: target-name
|
||||||
|
value: ""
|
||||||
|
- name: path-to-image-context
|
||||||
|
value: docker/natter_development/
|
||||||
|
- name: path-to-dockerfile
|
||||||
|
value: docker/natter_development/
|
||||||
313
.webhook_bridge/pipeline-rust-clippy.yaml
Normal file
313
.webhook_bridge/pipeline-rust-clippy.yaml
Normal file
@@ -0,0 +1,313 @@
|
|||||||
|
apiVersion: tekton.dev/v1
|
||||||
|
kind: PipelineRun
|
||||||
|
metadata:
|
||||||
|
name: rust-clippy
|
||||||
|
spec:
|
||||||
|
taskRunTemplate:
|
||||||
|
serviceAccountName: build-bot
|
||||||
|
timeouts:
|
||||||
|
pipeline: "2h0m0s"
|
||||||
|
tasks: "1h0m40s"
|
||||||
|
finally: "0h30m0s"
|
||||||
|
pipelineSpec:
|
||||||
|
params:
|
||||||
|
- name: image-name
|
||||||
|
description: The name for the built image
|
||||||
|
type: string
|
||||||
|
- name: target-name
|
||||||
|
description: The dockerfile target to build
|
||||||
|
type: string
|
||||||
|
- name: path-to-image-context
|
||||||
|
description: The path to the build context
|
||||||
|
type: string
|
||||||
|
- name: path-to-dockerfile
|
||||||
|
description: The path to the Dockerfile
|
||||||
|
type: string
|
||||||
|
tasks:
|
||||||
|
- name: report-pending
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
|
params:
|
||||||
|
- name: CONTEXT
|
||||||
|
value: "$(params.JOB_NAME)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has started"
|
||||||
|
- name: STATE
|
||||||
|
value: pending
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: fetch-repository
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/git-clone/0.9/git-clone.yaml
|
||||||
|
workspaces:
|
||||||
|
- name: output
|
||||||
|
workspace: git-source
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: $(params.REPO_URL)
|
||||||
|
- name: revision
|
||||||
|
value: $(params.PULL_BASE_SHA)
|
||||||
|
- name: deleteExisting
|
||||||
|
value: "true"
|
||||||
|
- name: get-git-commit-time
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 600Mi
|
||||||
|
workingDir: "$(workspaces.repo.path)"
|
||||||
|
results:
|
||||||
|
- name: unix-time
|
||||||
|
description: The time of the git commit in unix timestamp format.
|
||||||
|
steps:
|
||||||
|
- image: alpine/git:v2.34.2
|
||||||
|
name: detect-tag-step
|
||||||
|
script: |
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
set -euo pipefail
|
||||||
|
echo -n "$(git log -1 --pretty=%ct)" | tee $(results.unix-time.path)
|
||||||
|
workspaces:
|
||||||
|
- name: repo
|
||||||
|
workspace: git-source
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
|
- name: build-image
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: 7ee31a185243ee6da13dcd26a592c585b64c80e5
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/buildkit-rootless-daemonless/0.1/buildkit-rootless-daemonless.yaml
|
||||||
|
params:
|
||||||
|
- name: OUTPUT
|
||||||
|
value: >-
|
||||||
|
type=image,"name=$(params.image-name):latest,$(params.image-name):$(tasks.fetch-repository.results.commit)",push=true,compression=zstd,compression-level=22,oci-mediatypes=true
|
||||||
|
- name: CONTEXT
|
||||||
|
value: $(params.path-to-image-context)
|
||||||
|
- name: DOCKERFILE
|
||||||
|
value: $(params.path-to-dockerfile)
|
||||||
|
- name: EXTRA_ARGS
|
||||||
|
value:
|
||||||
|
- "--opt"
|
||||||
|
- "target=$(params.target-name)"
|
||||||
|
- --import-cache
|
||||||
|
- "type=registry,ref=$(params.image-name):buildcache"
|
||||||
|
- --export-cache
|
||||||
|
- "type=registry,ref=$(params.image-name):buildcache,mode=max,compression=zstd,compression-level=22,rewrite-timestamp=true,image-manifest=true,oci-mediatypes=true"
|
||||||
|
- --opt
|
||||||
|
- build-arg:SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time)
|
||||||
|
- name: BUILDKITD_TOML
|
||||||
|
value: |
|
||||||
|
debug = true
|
||||||
|
[registry."docker.io"]
|
||||||
|
mirrors = ["dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
[registry."dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
http = true
|
||||||
|
insecure = true
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: dockerconfig
|
||||||
|
workspace: docker-credentials
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
|
- name: run-cargo-clippy
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
type: string
|
||||||
|
description: Docker image to run.
|
||||||
|
default: alpine:3.20
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 600Mi
|
||||||
|
workingDir: /workspace/source
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
mountPath: /source
|
||||||
|
- name: cargo-cache
|
||||||
|
mountPath: /usr/local/cargo/registry
|
||||||
|
optional: true
|
||||||
|
steps:
|
||||||
|
- name: run
|
||||||
|
image: $(params.docker-image)
|
||||||
|
workingDir: "$(workspaces.source.path)"
|
||||||
|
command:
|
||||||
|
[
|
||||||
|
"cargo",
|
||||||
|
"clippy",
|
||||||
|
"--no-deps",
|
||||||
|
"--all-targets",
|
||||||
|
"--all-features",
|
||||||
|
"--",
|
||||||
|
"-D",
|
||||||
|
"warnings",
|
||||||
|
]
|
||||||
|
args: []
|
||||||
|
env:
|
||||||
|
- name: CARGO_TARGET_DIR
|
||||||
|
value: /target
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
runAfter:
|
||||||
|
- build-image
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
finally:
|
||||||
|
- name: report-success
|
||||||
|
when:
|
||||||
|
- input: "$(tasks.status)"
|
||||||
|
operator: in
|
||||||
|
values: ["Succeeded", "Completed"]
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
|
params:
|
||||||
|
- name: CONTEXT
|
||||||
|
value: "$(params.JOB_NAME)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has succeeded"
|
||||||
|
- name: STATE
|
||||||
|
value: success
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: report-failure
|
||||||
|
when:
|
||||||
|
- input: "$(tasks.status)"
|
||||||
|
operator: in
|
||||||
|
values: ["Failed"]
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
|
params:
|
||||||
|
- name: CONTEXT
|
||||||
|
value: "$(params.JOB_NAME)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has failed"
|
||||||
|
- name: STATE
|
||||||
|
value: failure
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: cargo-cache-autoclean
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
type: string
|
||||||
|
description: Docker image to run.
|
||||||
|
default: alpine:3.20
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 600Mi
|
||||||
|
workingDir: /workspace/source
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
mountPath: /source
|
||||||
|
- name: cargo-cache
|
||||||
|
mountPath: /usr/local/cargo/registry
|
||||||
|
optional: true
|
||||||
|
steps:
|
||||||
|
- name: run
|
||||||
|
image: $(params.docker-image)
|
||||||
|
workingDir: "$(workspaces.source.path)"
|
||||||
|
command: [cargo, cache, --autoclean]
|
||||||
|
args: []
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
workspaces:
|
||||||
|
- name: git-source
|
||||||
|
- name: docker-credentials
|
||||||
|
- name: cargo-cache
|
||||||
|
workspaces:
|
||||||
|
- name: git-source
|
||||||
|
volumeClaimTemplate:
|
||||||
|
spec:
|
||||||
|
storageClassName: "local-path"
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 10Gi
|
||||||
|
subPath: rust-source
|
||||||
|
- name: cargo-cache
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: natter-cargo-cache-clippy
|
||||||
|
- name: docker-credentials
|
||||||
|
secret:
|
||||||
|
secretName: harbor-plain
|
||||||
|
params:
|
||||||
|
- name: image-name
|
||||||
|
value: "harbor.fizz.buzz/private/natter-development-clippy"
|
||||||
|
- name: target-name
|
||||||
|
value: ""
|
||||||
|
- name: path-to-image-context
|
||||||
|
value: docker/natter_development/
|
||||||
|
- name: path-to-dockerfile
|
||||||
|
value: docker/natter_development/
|
||||||
303
.webhook_bridge/pipeline-rust-test.yaml
Normal file
303
.webhook_bridge/pipeline-rust-test.yaml
Normal file
@@ -0,0 +1,303 @@
|
|||||||
|
apiVersion: tekton.dev/v1
|
||||||
|
kind: PipelineRun
|
||||||
|
metadata:
|
||||||
|
name: rust-test
|
||||||
|
spec:
|
||||||
|
timeouts:
|
||||||
|
pipeline: "2h0m0s"
|
||||||
|
tasks: "1h0m40s"
|
||||||
|
finally: "0h30m0s"
|
||||||
|
taskRunTemplate:
|
||||||
|
serviceAccountName: build-bot
|
||||||
|
pipelineSpec:
|
||||||
|
params:
|
||||||
|
- name: image-name
|
||||||
|
description: The name for the built image
|
||||||
|
type: string
|
||||||
|
- name: target-name
|
||||||
|
description: The dockerfile target to build
|
||||||
|
type: string
|
||||||
|
- name: path-to-image-context
|
||||||
|
description: The path to the build context
|
||||||
|
type: string
|
||||||
|
- name: path-to-dockerfile
|
||||||
|
description: The path to the Dockerfile
|
||||||
|
type: string
|
||||||
|
tasks:
|
||||||
|
- name: report-pending
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
|
params:
|
||||||
|
- name: CONTEXT
|
||||||
|
value: "$(params.JOB_NAME)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has started"
|
||||||
|
- name: STATE
|
||||||
|
value: pending
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: fetch-repository
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/git-clone/0.9/git-clone.yaml
|
||||||
|
workspaces:
|
||||||
|
- name: output
|
||||||
|
workspace: git-source
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: $(params.REPO_URL)
|
||||||
|
- name: revision
|
||||||
|
value: $(params.PULL_BASE_SHA)
|
||||||
|
- name: deleteExisting
|
||||||
|
value: "true"
|
||||||
|
- name: get-git-commit-time
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 600Mi
|
||||||
|
workingDir: "$(workspaces.repo.path)"
|
||||||
|
results:
|
||||||
|
- name: unix-time
|
||||||
|
description: The time of the git commit in unix timestamp format.
|
||||||
|
steps:
|
||||||
|
- image: alpine/git:v2.34.2
|
||||||
|
name: detect-tag-step
|
||||||
|
script: |
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
set -euo pipefail
|
||||||
|
echo -n "$(git log -1 --pretty=%ct)" | tee $(results.unix-time.path)
|
||||||
|
workspaces:
|
||||||
|
- name: repo
|
||||||
|
workspace: git-source
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
|
- name: build-image
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: 7ee31a185243ee6da13dcd26a592c585b64c80e5
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/buildkit-rootless-daemonless/0.1/buildkit-rootless-daemonless.yaml
|
||||||
|
params:
|
||||||
|
- name: OUTPUT
|
||||||
|
value: >-
|
||||||
|
type=image,"name=$(params.image-name):latest,$(params.image-name):$(tasks.fetch-repository.results.commit)",push=true,compression=zstd,compression-level=22,oci-mediatypes=true
|
||||||
|
- name: CONTEXT
|
||||||
|
value: $(params.path-to-image-context)
|
||||||
|
- name: DOCKERFILE
|
||||||
|
value: $(params.path-to-dockerfile)
|
||||||
|
- name: EXTRA_ARGS
|
||||||
|
value:
|
||||||
|
- "--opt"
|
||||||
|
- "target=$(params.target-name)"
|
||||||
|
- --import-cache
|
||||||
|
- "type=registry,ref=$(params.image-name):buildcache"
|
||||||
|
- --export-cache
|
||||||
|
- "type=registry,ref=$(params.image-name):buildcache,mode=max,compression=zstd,compression-level=22,rewrite-timestamp=true,image-manifest=true,oci-mediatypes=true"
|
||||||
|
- --opt
|
||||||
|
- build-arg:SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time)
|
||||||
|
- name: BUILDKITD_TOML
|
||||||
|
value: |
|
||||||
|
debug = true
|
||||||
|
[registry."docker.io"]
|
||||||
|
mirrors = ["dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
[registry."dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
http = true
|
||||||
|
insecure = true
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: dockerconfig
|
||||||
|
workspace: docker-credentials
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
|
- name: run-cargo-test
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
type: string
|
||||||
|
description: Docker image to run.
|
||||||
|
default: alpine:3.20
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 600Mi
|
||||||
|
workingDir: /workspace/source
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
mountPath: /source
|
||||||
|
- name: cargo-cache
|
||||||
|
mountPath: /usr/local/cargo/registry
|
||||||
|
optional: true
|
||||||
|
steps:
|
||||||
|
- name: run
|
||||||
|
image: $(params.docker-image)
|
||||||
|
workingDir: "$(workspaces.source.path)"
|
||||||
|
command: [cargo, test, --no-fail-fast]
|
||||||
|
args: []
|
||||||
|
env:
|
||||||
|
- name: CARGO_TARGET_DIR
|
||||||
|
value: /target
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
runAfter:
|
||||||
|
- build-image
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
finally:
|
||||||
|
- name: report-success
|
||||||
|
when:
|
||||||
|
- input: "$(tasks.status)"
|
||||||
|
operator: in
|
||||||
|
values: ["Succeeded", "Completed"]
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
|
params:
|
||||||
|
- name: CONTEXT
|
||||||
|
value: "$(params.JOB_NAME)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has succeeded"
|
||||||
|
- name: STATE
|
||||||
|
value: success
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: report-failure
|
||||||
|
when:
|
||||||
|
- input: "$(tasks.status)"
|
||||||
|
operator: in
|
||||||
|
values: ["Failed"]
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
|
params:
|
||||||
|
- name: CONTEXT
|
||||||
|
value: "$(params.JOB_NAME)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has failed"
|
||||||
|
- name: STATE
|
||||||
|
value: failure
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: cargo-cache-autoclean
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
type: string
|
||||||
|
description: Docker image to run.
|
||||||
|
default: alpine:3.20
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 600Mi
|
||||||
|
workingDir: /workspace/source
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
mountPath: /source
|
||||||
|
- name: cargo-cache
|
||||||
|
mountPath: /usr/local/cargo/registry
|
||||||
|
optional: true
|
||||||
|
steps:
|
||||||
|
- name: run
|
||||||
|
image: $(params.docker-image)
|
||||||
|
workingDir: "$(workspaces.source.path)"
|
||||||
|
command: [cargo, cache, --autoclean]
|
||||||
|
args: []
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
workspaces:
|
||||||
|
- name: git-source
|
||||||
|
- name: docker-credentials
|
||||||
|
- name: cargo-cache
|
||||||
|
workspaces:
|
||||||
|
- name: git-source
|
||||||
|
volumeClaimTemplate:
|
||||||
|
spec:
|
||||||
|
storageClassName: "local-path"
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 10Gi
|
||||||
|
subPath: rust-source
|
||||||
|
- name: cargo-cache
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: natter-cargo-cache-test
|
||||||
|
- name: docker-credentials
|
||||||
|
secret:
|
||||||
|
secretName: harbor-plain
|
||||||
|
params:
|
||||||
|
- name: image-name
|
||||||
|
value: "harbor.fizz.buzz/private/natter-development-test"
|
||||||
|
- name: target-name
|
||||||
|
value: ""
|
||||||
|
- name: path-to-image-context
|
||||||
|
value: docker/natter_development/
|
||||||
|
- name: path-to-dockerfile
|
||||||
|
value: docker/natter_development/
|
||||||
25
.webhook_bridge/webhook_bridge.toml
Normal file
25
.webhook_bridge/webhook_bridge.toml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
version = "0.0.1"
|
||||||
|
|
||||||
|
[[push]]
|
||||||
|
name = "rust-test"
|
||||||
|
source = "pipeline-rust-test.yaml"
|
||||||
|
clone_uri = "git@code.fizz.buzz:talexander/natter.git"
|
||||||
|
skip_branches = [ "^v[0-9]+\\.[0-9]+\\.[0-9]+$" ]
|
||||||
|
|
||||||
|
[[push]]
|
||||||
|
name = "clippy"
|
||||||
|
source = "pipeline-rust-clippy.yaml"
|
||||||
|
clone_uri = "git@code.fizz.buzz:talexander/natter.git"
|
||||||
|
skip_branches = [ "^v[0-9]+\\.[0-9]+\\.[0-9]+$" ]
|
||||||
|
|
||||||
|
[[push]]
|
||||||
|
name = "format"
|
||||||
|
source = "pipeline-format.yaml"
|
||||||
|
clone_uri = "git@code.fizz.buzz:talexander/natter.git"
|
||||||
|
skip_branches = [ "^v[0-9]+\\.[0-9]+\\.[0-9]+$" ]
|
||||||
|
|
||||||
|
[[push]]
|
||||||
|
name = "build"
|
||||||
|
source = "pipeline-build-hash.yaml"
|
||||||
|
clone_uri = "git@code.fizz.buzz:talexander/natter.git"
|
||||||
|
branches = [ "^main$", "^master$" ]
|
||||||
1497
Cargo.lock
generated
1497
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
48
Cargo.toml
48
Cargo.toml
@@ -1,20 +1,54 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "writer"
|
name = "natter"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
edition = "2021"
|
edition = "2024"
|
||||||
|
authors = ["Tom Alexander <tom@fizz.buzz>"]
|
||||||
|
description = "A static site generator using org source files."
|
||||||
|
license = "0BSD"
|
||||||
|
repository = "https://code.fizz.buzz/talexander/natter"
|
||||||
|
readme = "README.md"
|
||||||
|
keywords = ["static", "site", "generator"]
|
||||||
|
categories = ["command-line-utilities"]
|
||||||
|
resolver = "2"
|
||||||
|
include = [
|
||||||
|
"LICENSE",
|
||||||
|
"**/*.rs",
|
||||||
|
"Cargo.toml",
|
||||||
|
"Cargo.lock",
|
||||||
|
"default_environment/"
|
||||||
|
]
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.4.6", default-features = false, features = ["std", "color", "help", "derive"] }
|
clap = { version = "4.4.6", default-features = false, features = ["std", "color", "help", "derive"] }
|
||||||
duster = { git = "https://code.fizz.buzz/talexander/duster.git", branch = "master" }
|
duster = "0.1.1"
|
||||||
futures = "0.3.29"
|
futures = "0.3.29"
|
||||||
include_dir = "0.7.3"
|
include_dir = "0.7.3"
|
||||||
# TODO: This is temporary to work on the latest organic code. Eventually switch back to using the published crate.
|
# TODO: This is temporary to work on the latest organic code. Eventually switch back to using the published crate.
|
||||||
organic = { path = "../organic" }
|
# organic = { path = "../organic" }
|
||||||
# organic = "0.1.12"
|
organic = "0.1.16"
|
||||||
serde = { version = "1.0.189", default-features = false, features = ["std", "derive"] }
|
serde = { version = "1.0.189", default-features = false, features = ["std", "derive"] }
|
||||||
serde_json = "1.0.107"
|
serde_json = "1.0.107"
|
||||||
tokio = { version = "1.30.0", default-features = false, features = ["rt", "rt-multi-thread", "fs", "io-util"] }
|
tokio = { version = "1.30.0", default-features = false, features = ["rt", "rt-multi-thread", "fs", "io-util"] }
|
||||||
toml = "0.8.2"
|
toml = "0.8.2"
|
||||||
walkdir = "2.4.0"
|
tree-sitter-bash = "0.23.3"
|
||||||
|
tree-sitter-highlight = "0.25.2"
|
||||||
|
tree-sitter-nix = "0.0.2"
|
||||||
|
tree-sitter-python = "0.23.6"
|
||||||
|
url = "2.5.0"
|
||||||
|
tracing = { version = "0.1.37", optional = true }
|
||||||
|
tracing-opentelemetry = { version = "0.20.0", optional = true }
|
||||||
|
tracing-subscriber = { version = "0.3.17", optional = true, features = ["env-filter"] }
|
||||||
|
opentelemetry = { version = "0.20.0", optional = true, default-features = false, features = ["trace", "rt-tokio"] }
|
||||||
|
opentelemetry-otlp = { version = "0.13.0", optional = true }
|
||||||
|
opentelemetry-semantic-conventions = { version = "0.12.0", optional = true }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["tracing"]
|
||||||
|
tracing = ["dep:opentelemetry", "dep:opentelemetry-otlp", "dep:opentelemetry-semantic-conventions", "dep:tracing", "dep:tracing-opentelemetry", "dep:tracing-subscriber"]
|
||||||
|
|
||||||
|
# Optimized build for any sort of release.
|
||||||
|
[profile.release-lto]
|
||||||
|
inherits = "release"
|
||||||
|
lto = true
|
||||||
|
strip = "symbols"
|
||||||
|
|||||||
39
Makefile
Normal file
39
Makefile
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
SHELL := bash
|
||||||
|
.ONESHELL:
|
||||||
|
.SHELLFLAGS := -eu -o pipefail -c
|
||||||
|
.DELETE_ON_ERROR:
|
||||||
|
MAKEFLAGS += --warn-undefined-variables
|
||||||
|
MAKEFLAGS += --no-builtin-rules
|
||||||
|
OS:=$(shell uname -s)
|
||||||
|
|
||||||
|
ifeq ($(origin .RECIPEPREFIX), undefined)
|
||||||
|
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
|
||||||
|
endif
|
||||||
|
.RECIPEPREFIX = >
|
||||||
|
|
||||||
|
IMAGE_NAME:=natter
|
||||||
|
TARGET :=
|
||||||
|
|
||||||
|
.PHONY: help
|
||||||
|
help:
|
||||||
|
> @grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -E 's/^([^:]*): *## */\1: /'
|
||||||
|
|
||||||
|
.PHONY: docker_test
|
||||||
|
docker_test: ## Run the rust tests
|
||||||
|
> $(MAKE) -C docker/natter_development build
|
||||||
|
> docker run --rm -i -t --mount type=tmpfs,destination=/tmp -v "$(shell readlink -f .):/source" --workdir=/source --env CARGO_TARGET_DIR=/target -v "natter-cargo-registry:/usr/local/cargo/registry" natter-development cargo test
|
||||||
|
|
||||||
|
.PHONY: docker_clippy
|
||||||
|
docker_clippy: ## Run static analysis of the code.
|
||||||
|
> $(MAKE) -C docker/natter_development build
|
||||||
|
> docker run --rm -i -t --mount type=tmpfs,destination=/tmp -v "$(shell readlink -f .):/source" --workdir=/source --env CARGO_TARGET_DIR=/target -v "natter-cargo-registry:/usr/local/cargo/registry" natter-development cargo clippy --no-deps --all-targets --all-features -- -D warnings
|
||||||
|
|
||||||
|
.PHONY: docker_format
|
||||||
|
docker_format: ## Auto-format source files.
|
||||||
|
> $(MAKE) -C docker/natter_development build
|
||||||
|
> docker run --rm -i -t --mount type=tmpfs,destination=/tmp -v "$(shell readlink -f .):/source" --workdir=/source --env CARGO_TARGET_DIR=/target -v "natter-cargo-registry:/usr/local/cargo/registry" natter-development cargo fmt
|
||||||
|
> docker run --rm -i -t --mount type=tmpfs,destination=/tmp -v "$(shell readlink -f .):/source" --workdir=/source --env CARGO_TARGET_DIR=/target -v "natter-cargo-registry:/usr/local/cargo/registry" natter-development prettier --write --no-error-on-unmatched-pattern "default_environment/**/*.js" "default_environment/**/*.css"
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
> $(MAKE) -C docker/natter_development clean
|
||||||
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Natter
|
||||||
|
|
||||||
|
Natter is a static site generator for blogs using org as an input format. It is at a very early stage, and will have deep sweeping changes.
|
||||||
21
TODO.org
Normal file
21
TODO.org
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
* Things to do [6/17]
|
||||||
|
** DONE If the paragraph only contains an image, text-align center
|
||||||
|
** DONE Syntax highlighting for code blocks
|
||||||
|
** TODO Render gnuplot
|
||||||
|
** TODO Pretty-print the timestamps
|
||||||
|
** TODO Support Table of Contents
|
||||||
|
** TODO Support line numbers in code blocks
|
||||||
|
** TODO Support references to code block lines
|
||||||
|
** TODO Only include text up to first heading on homepage and include a "read more" link
|
||||||
|
** DONE Make loading language-specific CSS files conditional on the presence of src blocks using those languages
|
||||||
|
** DONE Set up tracing so I can use warning and such
|
||||||
|
** TODO Make copying of language-specific CSS files conditional on the presence of src blocks using those languages
|
||||||
|
** TODO Switch to an entirely lazily-evaluated output tree
|
||||||
|
** TODO Add highlighting for languages [1/2]
|
||||||
|
*** DONE bash
|
||||||
|
*** TODO gnuplot
|
||||||
|
https://github.com/dpezto/tree-sitter-gnuplot is not on crates.io so I'd have to add a git dependency to use it. This would prevent publishing this crate to crates.io.
|
||||||
|
** DONE Bug: carry over highlight starts when breaking lines
|
||||||
|
** TODO Add dates to posts
|
||||||
|
** DONE Add support for unlisted posts (posts that do not show up on the homepage).
|
||||||
|
** TODO Add support for showing file name where we currently show language
|
||||||
39
default_environment/stylesheet/language_bash.css
Normal file
39
default_environment/stylesheet/language_bash.css
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
:root {
|
||||||
|
--srclg-bash-srchl-comment-color: #048a81;
|
||||||
|
--srclg-bash-srchl-function-color: #e95a62;
|
||||||
|
--srclg-bash-srchl-keyword-color: #1a936f;
|
||||||
|
--srclg-bash-srchl-property-color: inherit;
|
||||||
|
--srclg-bash-srchl-string-color: #ecc30b;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: light) {
|
||||||
|
:root {
|
||||||
|
--srclg-bash-srchl-comment-color: #fb757e;
|
||||||
|
--srclg-bash-srchl-function-color: #16a59d;
|
||||||
|
--srclg-bash-srchl-keyword-color: #e56c90;
|
||||||
|
--srclg-bash-srchl-property-color: inherit;
|
||||||
|
--srclg-bash-srchl-string-color: #133cf4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.main_content {
|
||||||
|
.src_block {
|
||||||
|
&.srclg_bash {
|
||||||
|
.srchl_comment {
|
||||||
|
color: var(--srclg-bash-srchl-comment-color);
|
||||||
|
}
|
||||||
|
.srchl_function {
|
||||||
|
color: var(--srclg-bash-srchl-function-color);
|
||||||
|
}
|
||||||
|
.srchl_keyword {
|
||||||
|
color: var(--srclg-bash-srchl-keyword-color);
|
||||||
|
}
|
||||||
|
.srchl_property {
|
||||||
|
color: var(--srclg-bash-srchl-property-color);
|
||||||
|
}
|
||||||
|
.srchl_string {
|
||||||
|
color: var(--srclg-bash-srchl-string-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
39
default_environment/stylesheet/language_nix.css
Normal file
39
default_environment/stylesheet/language_nix.css
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
:root {
|
||||||
|
--srclg-nix-srchl-keyword-color: #1a936f;
|
||||||
|
--srclg-nix-srchl-comment-color: #048a81;
|
||||||
|
--srclg-nix-srchl-property-color: #bfbccb;
|
||||||
|
--srclg-nix-srchl-string-color: #ecc30b;
|
||||||
|
--srclg-nix-srchl-string-special-path-color: #067bc2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: light) {
|
||||||
|
:root {
|
||||||
|
--srclg-nix-srchl-keyword-color: #e56c90;
|
||||||
|
--srclg-nix-srchl-comment-color: #fb757e;
|
||||||
|
--srclg-nix-srchl-property-color: #404334;
|
||||||
|
--srclg-nix-srchl-string-color: #133cf4;
|
||||||
|
--srclg-nix-srchl-string-special-path-color: #f9843d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.main_content {
|
||||||
|
.src_block {
|
||||||
|
&.srclg_nix {
|
||||||
|
.srchl_keyword {
|
||||||
|
color: var(--srclg-nix-srchl-keyword-color);
|
||||||
|
}
|
||||||
|
.srchl_comment {
|
||||||
|
color: var(--srclg-nix-srchl-comment-color);
|
||||||
|
}
|
||||||
|
.srchl_property {
|
||||||
|
color: var(--srclg-nix-srchl-property-color);
|
||||||
|
}
|
||||||
|
.srchl_string {
|
||||||
|
color: var(--srclg-nix-srchl-string-color);
|
||||||
|
}
|
||||||
|
.srchl_string_special_path {
|
||||||
|
color: var(--srclg-nix-srchl-string-special-path-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
51
default_environment/stylesheet/language_python.css
Normal file
51
default_environment/stylesheet/language_python.css
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/* ea912c */
|
||||||
|
/* e95a62 */
|
||||||
|
:root {
|
||||||
|
--srclg-python-srchl-comment-color: #048a81;
|
||||||
|
--srclg-python-srchl-function-builtin-color: #e95a62;
|
||||||
|
--srclg-python-srchl-keyword-color: #1a936f;
|
||||||
|
--srclg-python-srchl-property-color: inherit;
|
||||||
|
--srclg-python-srchl-string-color: #ecc30b;
|
||||||
|
--srclg-python-srchl-type-color: #067bc2;
|
||||||
|
--srclg-python-srchl-variable-color: #ea912c;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: light) {
|
||||||
|
:root {
|
||||||
|
--srclg-python-srchl-comment-color: #fb757e;
|
||||||
|
--srclg-python-srchl-function-builtin-color: #16a59d;
|
||||||
|
--srclg-python-srchl-keyword-color: #e56c90;
|
||||||
|
--srclg-python-srchl-property-color: inherit;
|
||||||
|
--srclg-python-srchl-string-color: #133cf4;
|
||||||
|
--srclg-python-srchl-type-color: #f9843d;
|
||||||
|
--srclg-python-srchl-variable-color: #156ed3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.main_content {
|
||||||
|
.src_block {
|
||||||
|
&.srclg_python {
|
||||||
|
.srchl_comment {
|
||||||
|
color: var(--srclg-python-srchl-comment-color);
|
||||||
|
}
|
||||||
|
.srchl_function_builtin {
|
||||||
|
color: var(--srclg-python-srchl-function-builtin-color);
|
||||||
|
}
|
||||||
|
.srchl_keyword {
|
||||||
|
color: var(--srclg-python-srchl-keyword-color);
|
||||||
|
}
|
||||||
|
.srchl_property {
|
||||||
|
color: var(--srclg-python-srchl-property-color);
|
||||||
|
}
|
||||||
|
.srchl_string {
|
||||||
|
color: var(--srclg-python-srchl-string-color);
|
||||||
|
}
|
||||||
|
.srchl_type {
|
||||||
|
color: var(--srclg-python-srchl-type-color);
|
||||||
|
}
|
||||||
|
.srchl_variable {
|
||||||
|
color: var(--srclg-python-srchl-variable-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
358
default_environment/stylesheet/main.css
Normal file
358
default_environment/stylesheet/main.css
Normal file
@@ -0,0 +1,358 @@
|
|||||||
|
:root {
|
||||||
|
--main-max-width: 800px;
|
||||||
|
--site-background-color: #0a0a0a;
|
||||||
|
--site-text-color: #fffffc;
|
||||||
|
--header-divider-color: #6a687a;
|
||||||
|
|
||||||
|
--stream-divider-color: #6ccff6;
|
||||||
|
--stream-post-background-color: #0a0a0a;
|
||||||
|
|
||||||
|
--blog-post-background-color: #0a0a0a;
|
||||||
|
|
||||||
|
--src-font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo,
|
||||||
|
Consolas, "DejaVu Sans Mono", monospace;
|
||||||
|
|
||||||
|
--src-block-background-color: #141414;
|
||||||
|
--src-block-border-color: #84828f;
|
||||||
|
--src-block-language-color: #0a0a0a;
|
||||||
|
--src-block-language-background: #84828f;
|
||||||
|
|
||||||
|
--quote-block-border-color: #84828f;
|
||||||
|
|
||||||
|
--table-border-color: #6a687a;
|
||||||
|
--table-odd-background-color: #0a0a0a;
|
||||||
|
--table-even-background-color: #141414;
|
||||||
|
|
||||||
|
--header-nav-regular-font-color: var(--site-text-color);
|
||||||
|
--header-nav-regular-background-color: var(--site-background-color);
|
||||||
|
--header-nav-hover-font-color: var(--site-background-color);
|
||||||
|
--header-nav-hover-background-color: var(--site-text-color);
|
||||||
|
--header-home-regular-font-color: var(--site-text-color);
|
||||||
|
--header-home-hover-font-color: #6ccff6;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: light) {
|
||||||
|
:root {
|
||||||
|
--site-background-color: #f5f5f5;
|
||||||
|
--site-text-color: #000003;
|
||||||
|
--header-divider-color: #959785;
|
||||||
|
|
||||||
|
--stream-divider-color: #933009;
|
||||||
|
--stream-post-background-color: #f5f5f5;
|
||||||
|
|
||||||
|
--blog-post-background-color: #f5f5f5;
|
||||||
|
|
||||||
|
--src-block-background-color: #ebebeb;
|
||||||
|
--src-block-border-color: #7b7d70;
|
||||||
|
--src-block-language-color: #f5f5f5;
|
||||||
|
--src-block-language-background: #7b7d70;
|
||||||
|
|
||||||
|
--quote-block-border-color: #7b7d70;
|
||||||
|
|
||||||
|
--table-border-color: #959785;
|
||||||
|
--table-odd-background-color: #f5f5f5;
|
||||||
|
--table-even-background-color: #ebebeb;
|
||||||
|
|
||||||
|
--header-nav-regular-font-color: var(--site-text-color);
|
||||||
|
--header-nav-regular-background-color: var(--site-background-color);
|
||||||
|
--header-nav-hover-font-color: var(--site-background-color);
|
||||||
|
--header-nav-hover-background-color: var(--site-text-color);
|
||||||
|
--header-home-regular-font-color: var(--site-text-color);
|
||||||
|
--header-home-hover-font-color: #933009;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
color: var(--site-text-color);
|
||||||
|
background-color: var(--site-background-color);
|
||||||
|
font-family: source-sans-pro, Seravek, "Gill Sans Nova", Ubuntu, Calibri,
|
||||||
|
"DejaVu Sans", sans-serif;
|
||||||
|
|
||||||
|
a:link,
|
||||||
|
a:visited {
|
||||||
|
/* TODO: Should I use a different color for links? */
|
||||||
|
color: var(--site-text-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.page_centering {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page_header {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: stretch;
|
||||||
|
width: 100%;
|
||||||
|
max-width: var(--main-max-width);
|
||||||
|
border-bottom: 0.1rem solid var(--header-divider-color);
|
||||||
|
|
||||||
|
.home_link {
|
||||||
|
display: block;
|
||||||
|
font-size: 2rem;
|
||||||
|
font-weight: 600;
|
||||||
|
text-decoration: none;
|
||||||
|
color: var(--header-home-regular-font-color);
|
||||||
|
transition-property: color;
|
||||||
|
transition-duration: 0.1s;
|
||||||
|
transition-timing-function: ease-out;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: var(--header-home-hover-font-color) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:link,
|
||||||
|
&:visited {
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.header_nav_bar {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: end;
|
||||||
|
align-items: stretch;
|
||||||
|
column-gap: 1rem;
|
||||||
|
|
||||||
|
.nav_link {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-around;
|
||||||
|
color: var(--header-nav-regular-font-color);
|
||||||
|
background: var(--header-nav-regular-background-color);
|
||||||
|
padding: 0 0.5rem;
|
||||||
|
transition-property: background, color;
|
||||||
|
transition-duration: 0.1s;
|
||||||
|
transition-timing-function: ease-out;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: var(--header-nav-hover-font-color);
|
||||||
|
background: var(--header-nav-hover-background-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.main_content {
|
||||||
|
width: 100%;
|
||||||
|
max-width: var(--main-max-width);
|
||||||
|
font-size: 1.2rem;
|
||||||
|
line-height: 1.4;
|
||||||
|
padding-bottom: 8rem;
|
||||||
|
|
||||||
|
/* A stand-alone blog post (not in a blog stream). */
|
||||||
|
.blog_post {
|
||||||
|
padding: 1rem 0.2rem 0 0.2rem;
|
||||||
|
background: var(--blog-post-background-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.blog_stream {
|
||||||
|
.stream_divider {
|
||||||
|
color: var(--stream-divider-color);
|
||||||
|
margin: 40px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stream_nav {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
> a {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0.2rem 0.5rem;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
> .spacer {
|
||||||
|
display: inline-block;
|
||||||
|
flex: 1 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* A blog post in a blog stream (for example, the homepage). */
|
||||||
|
.blog_stream_post {
|
||||||
|
background: var(--stream-post-background-color);
|
||||||
|
padding: 0 0.2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.blog_stream_post {
|
||||||
|
background: var(--stream-post-background-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.blog_stream_post:nth-child(1) {
|
||||||
|
padding-top: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.blog_post_title {
|
||||||
|
font-size: 2.9rem;
|
||||||
|
font-weight: 700;
|
||||||
|
padding-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 1rem 0;
|
||||||
|
|
||||||
|
&.image {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.src_block {
|
||||||
|
background: var(--src-block-background-color);
|
||||||
|
border-radius: 3px;
|
||||||
|
border: 1px solid var(--src-block-border-color);
|
||||||
|
font-size: 1rem;
|
||||||
|
font-family: var(--src-font-family);
|
||||||
|
margin: 1rem 0;
|
||||||
|
font-variant-ligatures: none;
|
||||||
|
|
||||||
|
.src_language {
|
||||||
|
display: inline-block;
|
||||||
|
color: var(--src-block-language-color);
|
||||||
|
background: var(--src-block-language-background);
|
||||||
|
border-radius: 0 0 3px 0;
|
||||||
|
padding: 0.1rem 0.5rem;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
.src_body {
|
||||||
|
margin: 0.5rem;
|
||||||
|
|
||||||
|
.src_line {
|
||||||
|
white-space: pre-wrap;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.inline_source_block {
|
||||||
|
font-family: var(--src-font-family);
|
||||||
|
font-size: 1.2rem;
|
||||||
|
font-variant-ligatures: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.code,
|
||||||
|
.verbatim {
|
||||||
|
font-family: var(--src-font-family);
|
||||||
|
font-variant-ligatures: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote_block {
|
||||||
|
border-left: 1px solid var(--quote-block-border-color);
|
||||||
|
padding: 0 0 0 1rem;
|
||||||
|
margin: 1rem 0 1rem 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2,
|
||||||
|
h3 {
|
||||||
|
margin: 1rem 0;
|
||||||
|
padding-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
font-size: 2.3rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-size: 2.1rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.plain_list {
|
||||||
|
&.unordered {
|
||||||
|
list-style-type: disc;
|
||||||
|
padding-left: 2.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.ordered {
|
||||||
|
list-style-type: decimal;
|
||||||
|
padding-left: 2.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.descriptive {
|
||||||
|
font-size: 1rem;
|
||||||
|
> dt {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
> dd {
|
||||||
|
padding-left: 2.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.footnote_reference {
|
||||||
|
vertical-align: super;
|
||||||
|
font-size: 80%;
|
||||||
|
> a {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.footnote_definition {
|
||||||
|
.label {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.definition {
|
||||||
|
display: inline;
|
||||||
|
|
||||||
|
> p {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.org_table {
|
||||||
|
table-layout: fixed;
|
||||||
|
border-collapse: collapse;
|
||||||
|
border: 1px solid var(--table-border-color);
|
||||||
|
> tbody {
|
||||||
|
border-width: 1px 0;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: var(--table-border-color);
|
||||||
|
> tr {
|
||||||
|
> td {
|
||||||
|
padding: 0.2rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
> tr:nth-child(odd) {
|
||||||
|
background-color: var(--table-odd-background-color);
|
||||||
|
}
|
||||||
|
> tr:nth-child(even) {
|
||||||
|
background-color: var(--table-even-background-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
> thead {
|
||||||
|
border-width: 1px 0;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: var(--table-border-color);
|
||||||
|
> tr {
|
||||||
|
> th {
|
||||||
|
padding: 0.2rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
b {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Never have media larger than its container */
|
||||||
|
img,
|
||||||
|
picture,
|
||||||
|
video {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
129
default_environment/stylesheet/reset.css
Normal file
129
default_environment/stylesheet/reset.css
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
/* http://meyerweb.com/eric/tools/css/reset/
|
||||||
|
v2.0 | 20110126
|
||||||
|
License: none (public domain)
|
||||||
|
*/
|
||||||
|
|
||||||
|
html,
|
||||||
|
body,
|
||||||
|
div,
|
||||||
|
span,
|
||||||
|
applet,
|
||||||
|
object,
|
||||||
|
iframe,
|
||||||
|
h1,
|
||||||
|
h2,
|
||||||
|
h3,
|
||||||
|
h4,
|
||||||
|
h5,
|
||||||
|
h6,
|
||||||
|
p,
|
||||||
|
blockquote,
|
||||||
|
pre,
|
||||||
|
a,
|
||||||
|
abbr,
|
||||||
|
acronym,
|
||||||
|
address,
|
||||||
|
big,
|
||||||
|
cite,
|
||||||
|
code,
|
||||||
|
del,
|
||||||
|
dfn,
|
||||||
|
em,
|
||||||
|
img,
|
||||||
|
ins,
|
||||||
|
kbd,
|
||||||
|
q,
|
||||||
|
s,
|
||||||
|
samp,
|
||||||
|
small,
|
||||||
|
strike,
|
||||||
|
strong,
|
||||||
|
sub,
|
||||||
|
sup,
|
||||||
|
tt,
|
||||||
|
var,
|
||||||
|
b,
|
||||||
|
u,
|
||||||
|
i,
|
||||||
|
center,
|
||||||
|
dl,
|
||||||
|
dt,
|
||||||
|
dd,
|
||||||
|
ol,
|
||||||
|
ul,
|
||||||
|
li,
|
||||||
|
fieldset,
|
||||||
|
form,
|
||||||
|
label,
|
||||||
|
legend,
|
||||||
|
table,
|
||||||
|
caption,
|
||||||
|
tbody,
|
||||||
|
tfoot,
|
||||||
|
thead,
|
||||||
|
tr,
|
||||||
|
th,
|
||||||
|
td,
|
||||||
|
article,
|
||||||
|
aside,
|
||||||
|
canvas,
|
||||||
|
details,
|
||||||
|
embed,
|
||||||
|
figure,
|
||||||
|
figcaption,
|
||||||
|
footer,
|
||||||
|
header,
|
||||||
|
hgroup,
|
||||||
|
menu,
|
||||||
|
nav,
|
||||||
|
output,
|
||||||
|
ruby,
|
||||||
|
section,
|
||||||
|
summary,
|
||||||
|
time,
|
||||||
|
mark,
|
||||||
|
audio,
|
||||||
|
video {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
font-size: 100%;
|
||||||
|
font: inherit;
|
||||||
|
vertical-align: baseline;
|
||||||
|
}
|
||||||
|
/* HTML5 display-role reset for older browsers */
|
||||||
|
article,
|
||||||
|
aside,
|
||||||
|
details,
|
||||||
|
figcaption,
|
||||||
|
figure,
|
||||||
|
footer,
|
||||||
|
header,
|
||||||
|
hgroup,
|
||||||
|
menu,
|
||||||
|
nav,
|
||||||
|
section {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
ol,
|
||||||
|
ul {
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
blockquote,
|
||||||
|
q {
|
||||||
|
quotes: none;
|
||||||
|
}
|
||||||
|
blockquote:before,
|
||||||
|
blockquote:after,
|
||||||
|
q:before,
|
||||||
|
q:after {
|
||||||
|
content: "";
|
||||||
|
content: none;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
border-spacing: 0;
|
||||||
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
angle_link
|
!!!!!!!! angle_link
|
||||||
|
|||||||
58
default_environment/templates/html/ast_node.dust
Normal file
58
default_environment/templates/html/ast_node.dust
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
{@select key=.type}
|
||||||
|
{@eq value="heading"}{>heading/}{/eq}
|
||||||
|
{@eq value="section"}{>section/}{/eq}
|
||||||
|
{@eq value="paragraph"}{>paragraph/}{/eq}
|
||||||
|
{@eq value="plain_list"}{>plain_list/}{/eq}
|
||||||
|
{@eq value="center_block"}{>center_block/}{/eq}
|
||||||
|
{@eq value="quote_block"}{>quote_block/}{/eq}
|
||||||
|
{@eq value="special_block"}{>special_block/}{/eq}
|
||||||
|
{@eq value="dynamic_block"}{>dynamic_block/}{/eq}
|
||||||
|
{@eq value="footnote_definition"}{>footnote_definition/}{/eq}
|
||||||
|
{@eq value="comment"}{>comment/}{/eq}
|
||||||
|
{@eq value="drawer"}{>drawer/}{/eq}
|
||||||
|
{@eq value="property_drawer"}{>property_drawer/}{/eq}
|
||||||
|
{@eq value="table"}{>table/}{/eq}
|
||||||
|
{@eq value="verse_block"}{>verse_block/}{/eq}
|
||||||
|
{@eq value="comment_block"}{>comment_block/}{/eq}
|
||||||
|
{@eq value="example_block"}{>example_block/}{/eq}
|
||||||
|
{@eq value="export_block"}{>export_block/}{/eq}
|
||||||
|
{@eq value="src_block"}{>src_block/}{/eq}
|
||||||
|
{@eq value="clock"}{>clock/}{/eq}
|
||||||
|
{@eq value="diary_sexp"}{>diary_sexp/}{/eq}
|
||||||
|
{@eq value="planning"}{>planning/}{/eq}
|
||||||
|
{@eq value="fixed_width_area"}{>fixed_width_area/}{/eq}
|
||||||
|
{@eq value="horizontal_rule"}{>horizontal_rule/}{/eq}
|
||||||
|
{@eq value="keyword"}{>keyword/}{/eq}
|
||||||
|
{@eq value="babel_call"}{>babel_call/}{/eq}
|
||||||
|
{@eq value="latex_environment"}{>latex_environment/}{/eq}
|
||||||
|
{@eq value="bold"}{>bold/}{/eq}
|
||||||
|
{@eq value="italic"}{>italic/}{/eq}
|
||||||
|
{@eq value="underline"}{>underline/}{/eq}
|
||||||
|
{@eq value="strike_through"}{>strike_through/}{/eq}
|
||||||
|
{@eq value="code"}{>code/}{/eq}
|
||||||
|
{@eq value="verbatim"}{>verbatim/}{/eq}
|
||||||
|
{@eq value="plain_text"}{>plain_text/}{/eq}
|
||||||
|
{@eq value="regular_link_anchor"}{>regular_link_anchor/}{/eq}
|
||||||
|
{@eq value="regular_link_image"}{>regular_link_image/}{/eq}
|
||||||
|
{@eq value="radio_link"}{>radio_link/}{/eq}
|
||||||
|
{@eq value="radio_target"}{>radio_target/}{/eq}
|
||||||
|
{@eq value="plain_link"}{>plain_link/}{/eq}
|
||||||
|
{@eq value="angle_link"}{>angle_link/}{/eq}
|
||||||
|
{@eq value="org_macro"}{>org_macro/}{/eq}
|
||||||
|
{@eq value="entity"}{>entity/}{/eq}
|
||||||
|
{@eq value="latex_fragment"}{>latex_fragment/}{/eq}
|
||||||
|
{@eq value="export_snippet"}{>export_snippet/}{/eq}
|
||||||
|
{@eq value="footnote_reference"}{>footnote_reference/}{/eq}
|
||||||
|
{@eq value="citation"}{>citation/}{/eq}
|
||||||
|
{@eq value="citation_reference"}{>citation_reference/}{/eq}
|
||||||
|
{@eq value="inline_babel_call"}{>inline_babel_call/}{/eq}
|
||||||
|
{@eq value="inline_source_block"}{>inline_source_block/}{/eq}
|
||||||
|
{@eq value="line_break"}{>line_break/}{/eq}
|
||||||
|
{@eq value="target"}{>target/}{/eq}
|
||||||
|
{@eq value="statistics_cookie"}{>statistics_cookie/}{/eq}
|
||||||
|
{@eq value="subscript"}{>subscript/}{/eq}
|
||||||
|
{@eq value="superscript"}{>superscript/}{/eq}
|
||||||
|
{@eq value="timestamp"}{>timestamp/}{/eq}
|
||||||
|
{@none}{!TODO: make this panic!}ERROR: Unrecognized type {.type}.{/none}
|
||||||
|
{/select}
|
||||||
|
{! TODO: Maybe the final space should be conditional on end blank in the org source !}
|
||||||
@@ -1 +1 @@
|
|||||||
babel_call
|
!!!!!!!! babel_call
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
<div class="blog_post">
|
<article class="blog_post">
|
||||||
<div class="blog_post_intro">
|
{?.title}<h1 class="blog_post_title"><span>{.title}</span></h1>{/.title}
|
||||||
{?.title}{?.self_link}<a class="blog_post_title" href="{.link}">{.title}</a>{:else}<div class="blog_post_title">{.title}</div>{/.self_link}{/.title}
|
{! TODO: date? !}
|
||||||
{! TODO: date? !}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{! TODO: Table of contents? !}
|
{! TODO: Table of contents? !}
|
||||||
|
|
||||||
@@ -10,5 +8,12 @@
|
|||||||
{#.children}
|
{#.children}
|
||||||
{>document_element/}
|
{>document_element/}
|
||||||
{/.children}
|
{/.children}
|
||||||
|
|
||||||
|
{?.footnotes}
|
||||||
|
<h2>Footnotes:</h2>
|
||||||
|
{#.footnotes}
|
||||||
|
{>real_footnote_definition/}
|
||||||
|
{/.footnotes}
|
||||||
|
{/.footnotes}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</article>
|
||||||
|
|||||||
34
default_environment/templates/html/blog_stream.dust
Normal file
34
default_environment/templates/html/blog_stream.dust
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<div class="blog_stream">
|
||||||
|
{#.children}
|
||||||
|
{@gt key=$idx value=0}<hr class="stream_divider" />{/gt}
|
||||||
|
<div class="blog_stream_post">
|
||||||
|
<div class="blog_post_intro">
|
||||||
|
{?.title}{?.self_link}<a class="blog_post_title" href="{.self_link}">{.title}</a>{:else}<div class="blog_post_title">{.title}</div>{/.self_link}{/.title}
|
||||||
|
{! TODO: date? !}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{! TODO: Table of contents? !}
|
||||||
|
|
||||||
|
<div class="blog_post_body">
|
||||||
|
{#.children}
|
||||||
|
{>document_element/}
|
||||||
|
{/.children}
|
||||||
|
|
||||||
|
{?.footnotes}
|
||||||
|
<h2>Footnotes:</h2>
|
||||||
|
{#.footnotes}
|
||||||
|
{>real_footnote_definition/}
|
||||||
|
{/.footnotes}
|
||||||
|
{/.footnotes}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/.children}
|
||||||
|
{#.stream_pagination}
|
||||||
|
<hr class="stream_divider" />
|
||||||
|
<div class="stream_nav">
|
||||||
|
{?.older_link}<a href="{.older_link}">Older</a>{/.older_link}
|
||||||
|
<div class="spacer"></div>
|
||||||
|
{?.newer_link}<a href="{.newer_link}">Newer</a>{/.newer_link}
|
||||||
|
</div>
|
||||||
|
{/.stream_pagination}
|
||||||
|
</div>
|
||||||
@@ -1 +1 @@
|
|||||||
center_block
|
!!!!!!!! center_block
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
citation
|
!!!!!!!! citation
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
citation_reference
|
!!!!!!!! citation_reference
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
clock
|
!!!!!!!! clock
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
<code>{.source}</code>
|
<code class="code">{.contents}</code>
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
diary_sexp
|
!!!!!!!! diary_sexp
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
drawer
|
!!!!!!!! drawer
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
dynamic_block
|
!!!!!!!! dynamic_block
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{@select key=.type}
|
{@select key=.type}
|
||||||
{@eq value="paragraph"}{>paragraph/}{/eq}
|
{@eq value="paragraph"}{>paragraph/}{/eq}
|
||||||
{@eq value="plain_list"}{>plain_list/}{/eq}
|
{@eq value="plain_list"}{>plain_list/}{/eq}
|
||||||
|
{@eq value="plain_list_simple_item"}{>plain_list_simple_item/}{/eq}
|
||||||
{@eq value="center_block"}{>center_block/}{/eq}
|
{@eq value="center_block"}{>center_block/}{/eq}
|
||||||
{@eq value="quote_block"}{>quote_block/}{/eq}
|
{@eq value="quote_block"}{>quote_block/}{/eq}
|
||||||
{@eq value="special_block"}{>special_block/}{/eq}
|
{@eq value="special_block"}{>special_block/}{/eq}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
example_block
|
!!!!!!!! example_block
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export_block
|
!!!!!!!! export_block
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export_snippet
|
!!!!!!!! export_snippet
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
fixed_width_area
|
!!!!!!!! fixed_width_area
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
footnote_definition
|
{! noop !}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
footnote_reference
|
<sup class="footnote_reference"><a id="{.reference_id}" href="{.definition_link}">{.label}</a></sup>
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
global_settings
|
!!!!!!!! global_settings
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
horizontal_rule
|
!!!!!!!! horizontal_rule
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
inline_babel_call
|
!!!!!!!! inline_babel_call
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
inline_source_block
|
<code class="inline_source_block">{.value}</code>
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
latex_environment
|
!!!!!!!! latex_environment
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
latex_fragment
|
{! TODO: Should I be including MathJax somewhere? !}
|
||||||
|
{.value}
|
||||||
|
|||||||
@@ -1,18 +1,21 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||||
{#global_settings.css_files}<link rel="stylesheet" href="{.}">{/global_settings.css_files}
|
{#global_settings.css_files}<link rel="stylesheet" href="{.}">{/global_settings.css_files}
|
||||||
{#global_settings.js_files}<script type="text/javascript" src="{.}"></script>{/global_settings.js_files}
|
{#global_settings.js_files}<script type="text/javascript" src="{.}"></script>{/global_settings.js_files}
|
||||||
{?global_settings.page_title}<title>{global_settings.page_title}</title>{/global_settings.page_title}
|
{?global_settings.page_title}<title>{global_settings.page_title}</title>{/global_settings.page_title}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body class="page_centering">
|
||||||
{! TODO: Header bar with links? !}
|
{#.page_header}{>page_header/}{/.page_header}
|
||||||
<div class="main_content">
|
<main class="main_content">
|
||||||
{@select key=.type}
|
{@select key=.type}
|
||||||
|
{@eq value="page"}{>page/}{/eq}
|
||||||
{@eq value="blog_post_page"}{>blog_post_page/}{/eq}
|
{@eq value="blog_post_page"}{>blog_post_page/}{/eq}
|
||||||
|
{@eq value="blog_stream"}{>blog_stream/}{/eq}
|
||||||
{@none}{!TODO: make this panic!}ERROR: Unrecognized page content type{/none}
|
{@none}{!TODO: make this panic!}ERROR: Unrecognized page content type{/none}
|
||||||
{/select}
|
{/select}
|
||||||
</div>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
{@eq value="code"}{>code/}{/eq}
|
{@eq value="code"}{>code/}{/eq}
|
||||||
{@eq value="verbatim"}{>verbatim/}{/eq}
|
{@eq value="verbatim"}{>verbatim/}{/eq}
|
||||||
{@eq value="plain_text"}{>plain_text/}{/eq}
|
{@eq value="plain_text"}{>plain_text/}{/eq}
|
||||||
{@eq value="regular_link"}{>regular_link/}{/eq}
|
{@eq value="regular_link_anchor"}{>regular_link_anchor/}{/eq}
|
||||||
|
{@eq value="regular_link_image"}{>regular_link_image/}{/eq}
|
||||||
{@eq value="radio_link"}{>radio_link/}{/eq}
|
{@eq value="radio_link"}{>radio_link/}{/eq}
|
||||||
{@eq value="radio_target"}{>radio_target/}{/eq}
|
{@eq value="radio_target"}{>radio_target/}{/eq}
|
||||||
{@eq value="plain_link"}{>plain_link/}{/eq}
|
{@eq value="plain_link"}{>plain_link/}{/eq}
|
||||||
@@ -27,4 +28,4 @@
|
|||||||
{@eq value="superscript"}{>superscript/}{/eq}
|
{@eq value="superscript"}{>superscript/}{/eq}
|
||||||
{@eq value="timestamp"}{>timestamp/}{/eq}
|
{@eq value="timestamp"}{>timestamp/}{/eq}
|
||||||
{@none}{!TODO: make this panic!}ERROR: Unrecognized type {.type}.{/none}
|
{@none}{!TODO: make this panic!}ERROR: Unrecognized type {.type}.{/none}
|
||||||
{/select}
|
{/select}{@gt key=.post_blank value=0}{~s}{/gt}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
org_macro
|
!!!!!!!! org_macro
|
||||||
|
|||||||
19
default_environment/templates/html/page.dust
Normal file
19
default_environment/templates/html/page.dust
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<article class="page">
|
||||||
|
{?.title}<h1 class="blog_post_title"><span>{.title}</span></h1>{/.title}
|
||||||
|
{! TODO: date? !}
|
||||||
|
|
||||||
|
{! TODO: Table of contents? !}
|
||||||
|
|
||||||
|
<div class="blog_post_body">
|
||||||
|
{#.children}
|
||||||
|
{>document_element/}
|
||||||
|
{/.children}
|
||||||
|
|
||||||
|
{?.footnotes}
|
||||||
|
<h2>Footnotes:</h2>
|
||||||
|
{#.footnotes}
|
||||||
|
{>real_footnote_definition/}
|
||||||
|
{/.footnotes}
|
||||||
|
{/.footnotes}
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
9
default_environment/templates/html/page_header.dust
Normal file
9
default_environment/templates/html/page_header.dust
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<header class="page_header">
|
||||||
|
<a class="home_link" href="{.home_link}">{.website_title}</a>
|
||||||
|
{! TODO: Additional links? Probably using the nav semantic element. !}
|
||||||
|
<nav class="header_nav_bar">
|
||||||
|
{#.nav_links}
|
||||||
|
<a class="nav_link" href="{.url}"><div>{.text}</div></a>
|
||||||
|
{/.nav_links}
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
<p>{#.children}
|
<p class="{?.is_single_image}image{/.is_single_image}">{#.children}
|
||||||
{>object/}
|
{>object/}
|
||||||
{/.children}</p>
|
{/.children}</p>
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
plain_link
|
<a href="{.raw_link}">{.raw_link}</a>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{@select key=.list_type}
|
{@select key=.list_type}
|
||||||
{@eq value="unordered"}<ul>{#.children}{>plain_list_item/}{/.children}</ul>{/eq}
|
{@eq value="unordered"}<ul class="plain_list unordered">{#.children}{>plain_list_item/}{/.children}</ul>{/eq}
|
||||||
{@eq value="ordered"}<ol>{#.children}{>plain_list_item/}{/.children}</ol>{/eq}
|
{@eq value="ordered"}<ol class="plain_list ordered">{#.children}{>plain_list_item/}{/.children}</ol>{/eq}
|
||||||
{@eq value="descriptive"}<dl>{#.children}{>plain_list_item/}{/.children}</dl>{/eq}
|
{@eq value="descriptive"}<dl class="plain_list descriptive">{#.children}{>plain_list_item/}{/.children}</dl>{/eq}
|
||||||
{@none}{!TODO: make this panic!}ERROR: Unrecognized list type {.list_type}.{/none}
|
{@none}{!TODO: make this panic!}ERROR: Unrecognized list type {.list_type}.{/none}
|
||||||
{/select}
|
{/select}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{#.children}
|
||||||
|
{>object/}
|
||||||
|
{/.children}
|
||||||
@@ -1 +1 @@
|
|||||||
planning
|
!!!!!!!! planning
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
property_drawer
|
!!!!!!!! property_drawer
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
<blockquote>{#.children}
|
<blockquote class="quote_block">{#.children}
|
||||||
{>element/}
|
{>element/}
|
||||||
{/.children}</blockquote>
|
{/.children}</blockquote>
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
radio_link
|
!!!!!!!! radio_link
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
radio_target
|
!!!!!!!! radio_target
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
<div class="footnote_definition"><a id="{.definition_id}" href="{.reference_link}" class="label">{.label}.</a> <div class="definition">{#.contents}{>ast_node/}{/.contents}</div></div>
|
||||||
@@ -1 +0,0 @@
|
|||||||
regular_link
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<a href="{.target}">{#.children}{>object/}{/.children}</a>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<img src="{.src}" alt="{.alt}" />
|
||||||
@@ -1 +1 @@
|
|||||||
special_block
|
!!!!!!!! special_block
|
||||||
|
|||||||
@@ -1 +1,17 @@
|
|||||||
src_block
|
<div class="src_block{?.language} srclg_{.language}{/.language}">
|
||||||
|
{?.language}<div class="src_language">{.language}</div>{/.language}
|
||||||
|
<table class="src_body">
|
||||||
|
<tbody>
|
||||||
|
{#.lines}
|
||||||
|
<tr>
|
||||||
|
<td>{#.children}{@select key=.type}
|
||||||
|
{@eq value="raw_text"}<code class="src_line">{.content}</code>{/eq}
|
||||||
|
{@eq value="highlight_start"}<span class="srchl_{.name}">{/eq}
|
||||||
|
{@eq value="highlight_end"}</span>{/eq}
|
||||||
|
{@none}{!TODO: make this panic!}ERROR: Unrecognized type {.type}.{/none}
|
||||||
|
{/select}{/.children}</td>
|
||||||
|
</tr>
|
||||||
|
{/.lines}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
statistics_cookie
|
!!!!!!!! statistics_cookie
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
subscript
|
!!!!!!!! subscript
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
superscript
|
!!!!!!!! superscript
|
||||||
|
|||||||
@@ -1 +1,5 @@
|
|||||||
table
|
<table class="org_table">{#.children}{@select key=.type}
|
||||||
|
{@eq value="head"}{>table_head/}{/eq}
|
||||||
|
{@eq value="body"}{>table_body/}{/eq}
|
||||||
|
{@none}{!TODO: make this panic!}ERROR: Unrecognized type {.type}.{/none}
|
||||||
|
{/select}{/.children}</table>
|
||||||
|
|||||||
1
default_environment/templates/html/table_body.dust
Normal file
1
default_environment/templates/html/table_body.dust
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<tbody>{#.children}{>table_row/}{/.children}</tbody>
|
||||||
1
default_environment/templates/html/table_cell.dust
Normal file
1
default_environment/templates/html/table_cell.dust
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<td>{#.children}{>object/}{/.children}</td>
|
||||||
1
default_environment/templates/html/table_head.dust
Normal file
1
default_environment/templates/html/table_head.dust
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<thead>{#.children}{>table_head_row/}{/.children}</thead>
|
||||||
1
default_environment/templates/html/table_head_cell.dust
Normal file
1
default_environment/templates/html/table_head_cell.dust
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<th scope="col">{#.children}{>object/}{/.children}</th>
|
||||||
1
default_environment/templates/html/table_head_row.dust
Normal file
1
default_environment/templates/html/table_head_row.dust
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<tr>{#.children}{>table_head_cell/}{/.children}</tr>
|
||||||
1
default_environment/templates/html/table_row.dust
Normal file
1
default_environment/templates/html/table_row.dust
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<tr>{#.children}{>table_cell/}{/.children}</tr>
|
||||||
@@ -1 +1 @@
|
|||||||
timestamp
|
<span class="timestamp">{.source}</span>
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
<code>{.source}</code>
|
<code class="verbatim">{.contents}</code>
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
verse_block
|
!!!!!!!! verse_block
|
||||||
|
|||||||
16
docker/natter/Dockerfile
Normal file
16
docker/natter/Dockerfile
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
ARG ALPINE_VERSION="3.20"
|
||||||
|
|
||||||
|
FROM rustlang/rust:nightly-alpine$ALPINE_VERSION AS builder
|
||||||
|
|
||||||
|
RUN apk add --no-cache musl-dev
|
||||||
|
|
||||||
|
RUN mkdir /root/natter
|
||||||
|
WORKDIR /root/natter
|
||||||
|
COPY --link . .
|
||||||
|
# TODO: Add static build, which currently errors due to proc_macro. RUSTFLAGS="-C target-feature=+crt-static"
|
||||||
|
RUN --mount=type=tmpfs,target=/tmp --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked CARGO_TARGET_DIR=/target cargo build --profile release-lto
|
||||||
|
|
||||||
|
FROM alpine:$ALPINE_VERSION AS runner
|
||||||
|
|
||||||
|
COPY --link --from=builder /target/release-lto/natter /usr/bin/
|
||||||
32
docker/natter/Makefile
Normal file
32
docker/natter/Makefile
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
SHELL := bash
|
||||||
|
.ONESHELL:
|
||||||
|
.SHELLFLAGS := -eu -o pipefail -c
|
||||||
|
.DELETE_ON_ERROR:
|
||||||
|
MAKEFLAGS += --warn-undefined-variables
|
||||||
|
MAKEFLAGS += --no-builtin-rules
|
||||||
|
OS:=$(shell uname -s)
|
||||||
|
|
||||||
|
ifeq ($(origin .RECIPEPREFIX), undefined)
|
||||||
|
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
|
||||||
|
endif
|
||||||
|
.RECIPEPREFIX = >
|
||||||
|
|
||||||
|
IMAGE_NAME:=natter
|
||||||
|
TARGET :=
|
||||||
|
|
||||||
|
.PHONY: help
|
||||||
|
help:
|
||||||
|
> @grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -E 's/^([^:]*): *## */\1: /'
|
||||||
|
|
||||||
|
.PHONY: build
|
||||||
|
build: ## Build the docker image.
|
||||||
|
> docker build --tag $(IMAGE_NAME) --target=$(TARGET) --file Dockerfile ../../
|
||||||
|
|
||||||
|
.PHONY: shell
|
||||||
|
shell: ## Launch an interactive shell inside the docker image.
|
||||||
|
shell: build
|
||||||
|
> docker run --rm -i -t --entrypoint /bin/sh --mount type=tmpfs,destination=/tmp $(IMAGE_NAME)
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
> docker rmi $(IMAGE_NAME)
|
||||||
14
docker/natter_development/Dockerfile
Normal file
14
docker/natter_development/Dockerfile
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
ARG ALPINE_VERSION="3.20"
|
||||||
|
|
||||||
|
FROM rustlang/rust:nightly-alpine$ALPINE_VERSION AS builder
|
||||||
|
|
||||||
|
RUN apk add --no-cache musl-dev
|
||||||
|
RUN --mount=type=tmpfs,target=/tmp --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked cargo install --locked --no-default-features --features ci-autoclean cargo-cache
|
||||||
|
RUN rustup component add rustfmt
|
||||||
|
RUN rustup component add clippy
|
||||||
|
|
||||||
|
FROM builder AS javascript
|
||||||
|
|
||||||
|
RUN apk add --no-cache npm
|
||||||
|
RUN --mount=type=tmpfs,target=/tmp --mount=type=cache,target=/npmcache,sharing=locked npm set cache /npmcache && npm install --global prettier@3.1.0
|
||||||
33
docker/natter_development/Makefile
Normal file
33
docker/natter_development/Makefile
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
SHELL := bash
|
||||||
|
.ONESHELL:
|
||||||
|
.SHELLFLAGS := -eu -o pipefail -c
|
||||||
|
.DELETE_ON_ERROR:
|
||||||
|
MAKEFLAGS += --warn-undefined-variables
|
||||||
|
MAKEFLAGS += --no-builtin-rules
|
||||||
|
|
||||||
|
ifeq ($(origin .RECIPEPREFIX), undefined)
|
||||||
|
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
|
||||||
|
endif
|
||||||
|
.RECIPEPREFIX = >
|
||||||
|
|
||||||
|
IMAGE_NAME:=natter-development
|
||||||
|
TARGET :=
|
||||||
|
|
||||||
|
.PHONY: help
|
||||||
|
help:
|
||||||
|
> @grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -E 's/^([^:]*): *## */\1: /'
|
||||||
|
|
||||||
|
.PHONY: build
|
||||||
|
build: ## Build the docker image.
|
||||||
|
> docker build --tag $(IMAGE_NAME) --target=$(TARGET) --file Dockerfile .
|
||||||
|
> docker volume create natter-cargo-registry
|
||||||
|
|
||||||
|
.PHONY: shell
|
||||||
|
shell: ## Launch an interactive shell inside the docker image with the source repository mounted at /source.
|
||||||
|
shell: build
|
||||||
|
> docker run --rm -i -t --entrypoint /bin/sh --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source" --workdir=/source --env CARGO_TARGET_DIR=/target -v "natter-cargo-registry:/usr/local/cargo/registry" $(IMAGE_NAME)
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
> docker rmi $(IMAGE_NAME)
|
||||||
|
> docker volume rm natter-cargo-registry
|
||||||
21
org_test_documents/footnote/reference_in_definition.org
Normal file
21
org_test_documents/footnote/reference_in_definition.org
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# This test shows that footnote references only count if the definition containing them is rendered.
|
||||||
|
|
||||||
|
foo[fn:a:bar]
|
||||||
|
|
||||||
|
[fn:a] lorem
|
||||||
|
|
||||||
|
[fn:b] ipsum
|
||||||
|
|
||||||
|
[fn:d] fizz
|
||||||
|
|
||||||
|
[fn:c] dolar
|
||||||
|
|
||||||
|
yo[fn:b]
|
||||||
|
|
||||||
|
|
||||||
|
hello[fn:c]
|
||||||
|
|
||||||
|
|
||||||
|
[fn:e] buzz
|
||||||
|
|
||||||
|
sup[fn:d]
|
||||||
25
org_test_documents/footnote/simple.org
Normal file
25
org_test_documents/footnote/simple.org
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Test proves that:
|
||||||
|
#
|
||||||
|
# - Anonymous references with identical content get unique IDs.
|
||||||
|
# - Unreferenced footnote definitions are dropped.
|
||||||
|
# - Footnote definitions that come before their first reference are dropped.
|
||||||
|
|
||||||
|
foo[fn:2:something]
|
||||||
|
|
||||||
|
bar[fn::something]
|
||||||
|
|
||||||
|
baz[fn::something]
|
||||||
|
|
||||||
|
cat[fn::something]
|
||||||
|
|
||||||
|
dog[fn:3]
|
||||||
|
|
||||||
|
[fn:3] ipsum
|
||||||
|
|
||||||
|
[fn:4] lorem
|
||||||
|
|
||||||
|
[fn:3] dolar
|
||||||
|
|
||||||
|
[fn:5] not referenced
|
||||||
|
|
||||||
|
stuff[fn:4] and things
|
||||||
36
org_test_documents/latex_fragment/notes.org
Normal file
36
org_test_documents/latex_fragment/notes.org
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
* Double dollar
|
||||||
|
#+begin_src org
|
||||||
|
$$CONTENTS$$
|
||||||
|
#+end_src
|
||||||
|
becomes
|
||||||
|
#+begin_src text
|
||||||
|
\[CONTENTS\]
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+begin_src org
|
||||||
|
$$1+1=2$$
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+begin_src text
|
||||||
|
\[1+1=2\]
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
This gets interpreted by mathjax.
|
||||||
|
* Single Dollar
|
||||||
|
#+begin_src org
|
||||||
|
PRE$BORDER1 BODY BORDER2$POST
|
||||||
|
#+end_src
|
||||||
|
becomes
|
||||||
|
#+begin_src text
|
||||||
|
\(BORDER1 BODY BORDER2\)
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+begin_src org
|
||||||
|
foo$a bar b$.
|
||||||
|
#+end_src
|
||||||
|
becomes
|
||||||
|
#+begin_src text
|
||||||
|
foo\(a bar b\).
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
This gets interpreted by mathjax.
|
||||||
22
org_test_documents/regular_link/image_links.org
Normal file
22
org_test_documents/regular_link/image_links.org
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
[[file:image.svg]]
|
||||||
|
|
||||||
|
[[file:/image.svg]]
|
||||||
|
|
||||||
|
[[file:./image.svg]]
|
||||||
|
|
||||||
|
[[/image.svg]]
|
||||||
|
|
||||||
|
[[./image.svg]]
|
||||||
|
|
||||||
|
# Check capitalization of extension
|
||||||
|
[[./image.SVG]]
|
||||||
|
|
||||||
|
# Check spaces in path
|
||||||
|
[[./image and stuff.SVG]]
|
||||||
|
|
||||||
|
[[/ssh:admin@test.example:important/file.svg]]
|
||||||
|
|
||||||
|
[[file:/ssh:admin@test.example:important/file.svg]]
|
||||||
|
|
||||||
|
# Check multiple parts in the path
|
||||||
|
[[file:/foo/bar/baz/image.svg]]
|
||||||
4
rust-toolchain.toml
Normal file
4
rust-toolchain.toml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
[toolchain]
|
||||||
|
channel = "nightly"
|
||||||
|
profile = "default"
|
||||||
|
components = ["clippy", "rustfmt"]
|
||||||
@@ -4,7 +4,7 @@ use clap::Subcommand;
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(name = "Writer")]
|
#[command(name = "Natter")]
|
||||||
#[command(version = env!("CARGO_PKG_VERSION"))]
|
#[command(version = env!("CARGO_PKG_VERSION"))]
|
||||||
#[command(about = "Generate a static site.", long_about = None)]
|
#[command(about = "Generate a static site.", long_about = None)]
|
||||||
#[command(propagate_version = true)]
|
#[command(propagate_version = true)]
|
||||||
@@ -24,14 +24,14 @@ pub(crate) enum Commands {
|
|||||||
|
|
||||||
#[derive(Args, Debug)]
|
#[derive(Args, Debug)]
|
||||||
pub(crate) struct InitArgs {
|
pub(crate) struct InitArgs {
|
||||||
/// Path where you want the initial writer structure to be located.
|
/// Path where you want the initial natter structure to be located.
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
pub(crate) path: PathBuf,
|
pub(crate) path: PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args, Debug)]
|
#[derive(Args, Debug)]
|
||||||
pub(crate) struct BuildArgs {
|
pub(crate) struct BuildArgs {
|
||||||
/// Path to the writer config file.
|
/// Path to the natter config file.
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
pub(crate) config: PathBuf,
|
pub(crate) config: PathBuf,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
mod render;
|
mod render;
|
||||||
mod runner;
|
mod runner;
|
||||||
|
mod stylesheet;
|
||||||
|
|
||||||
pub(crate) use runner::build_site;
|
pub(crate) use runner::build_site;
|
||||||
|
|||||||
@@ -1,34 +1,57 @@
|
|||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use include_dir::include_dir;
|
|
||||||
use include_dir::Dir;
|
use include_dir::Dir;
|
||||||
|
use include_dir::include_dir;
|
||||||
|
use tokio::fs::DirEntry;
|
||||||
|
use tokio::task::JoinHandle;
|
||||||
|
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
|
use crate::context::DependencyManager;
|
||||||
|
use crate::context::RenderBlogPostPage;
|
||||||
|
use crate::context::RenderBlogPostPageInput;
|
||||||
|
use crate::context::RenderBlogStream;
|
||||||
|
use crate::context::RenderBlogStreamInput;
|
||||||
|
use crate::context::RenderContext;
|
||||||
|
use crate::context::RenderPage;
|
||||||
use crate::error::CustomError;
|
use crate::error::CustomError;
|
||||||
use crate::intermediate::convert_blog_post_page_to_render_context;
|
|
||||||
use crate::intermediate::BlogPost;
|
use crate::intermediate::BlogPost;
|
||||||
|
use crate::intermediate::IPage;
|
||||||
|
use crate::intermediate::PublishStatus;
|
||||||
|
use crate::intermediate::get_web_path;
|
||||||
use crate::render::DusterRenderer;
|
use crate::render::DusterRenderer;
|
||||||
use crate::render::RendererIntegration;
|
use crate::render::RendererIntegration;
|
||||||
|
use crate::walk_fs::WalkAction;
|
||||||
|
use crate::walk_fs::WalkFsFilterResult;
|
||||||
|
use crate::walk_fs::walk_fs;
|
||||||
|
|
||||||
|
use super::stylesheet::Stylesheet;
|
||||||
|
|
||||||
static MAIN_TEMPLATES: Dir = include_dir!("$CARGO_MANIFEST_DIR/default_environment/templates/html");
|
static MAIN_TEMPLATES: Dir = include_dir!("$CARGO_MANIFEST_DIR/default_environment/templates/html");
|
||||||
|
|
||||||
pub(crate) struct SiteRenderer {
|
pub(crate) struct SiteRenderer {
|
||||||
output_directory: PathBuf,
|
output_directory: PathBuf,
|
||||||
blog_posts: Vec<BlogPost>,
|
blog_posts: Vec<BlogPost>,
|
||||||
|
stylesheets: Vec<Stylesheet>,
|
||||||
|
pages: Vec<IPage>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SiteRenderer {
|
impl SiteRenderer {
|
||||||
pub(crate) fn new<P: Into<PathBuf>>(
|
pub(crate) fn new<P: Into<PathBuf>>(
|
||||||
output_directory: P,
|
output_directory: P,
|
||||||
blog_posts: Vec<BlogPost>,
|
blog_posts: Vec<BlogPost>,
|
||||||
|
stylesheets: Vec<Stylesheet>,
|
||||||
|
pages: Vec<IPage>,
|
||||||
) -> SiteRenderer {
|
) -> SiteRenderer {
|
||||||
SiteRenderer {
|
SiteRenderer {
|
||||||
output_directory: output_directory.into(),
|
output_directory: output_directory.into(),
|
||||||
blog_posts,
|
blog_posts,
|
||||||
|
stylesheets,
|
||||||
|
pages,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub(crate) async fn render_blog_posts(&self, config: &Config) -> Result<(), CustomError> {
|
|
||||||
|
fn init_renderer_integration(&self) -> Result<DusterRenderer<'_>, CustomError> {
|
||||||
let mut renderer_integration = DusterRenderer::new();
|
let mut renderer_integration = DusterRenderer::new();
|
||||||
|
|
||||||
let sources: Vec<_> = MAIN_TEMPLATES
|
let sources: Vec<_> = MAIN_TEMPLATES
|
||||||
@@ -56,32 +79,231 @@ impl SiteRenderer {
|
|||||||
renderer_integration.load_template(name, contents)?;
|
renderer_integration.load_template(name, contents)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
for blog_post in &self.blog_posts {
|
Ok(renderer_integration)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn render_pages(&self, config: &Config) -> Result<(), CustomError> {
|
||||||
|
let renderer_integration = self.init_renderer_integration()?;
|
||||||
|
|
||||||
|
for page in self.pages.iter().filter(|page| match page.natter_publish {
|
||||||
|
PublishStatus::Full => true,
|
||||||
|
PublishStatus::Unlisted => true,
|
||||||
|
PublishStatus::Unpublished => false,
|
||||||
|
}) {
|
||||||
|
let output_path = self.output_directory.join(page.get_output_path());
|
||||||
|
let dependency_manager =
|
||||||
|
std::sync::Arc::new(std::sync::Mutex::new(DependencyManager::new()));
|
||||||
|
let render_context = RenderContext::new(
|
||||||
|
config,
|
||||||
|
self.output_directory.as_path(),
|
||||||
|
output_path.as_path(),
|
||||||
|
None,
|
||||||
|
dependency_manager.clone(),
|
||||||
|
)?;
|
||||||
|
let dust_context = RenderPage::new(render_context.clone(), page)?;
|
||||||
|
let rendered_output = renderer_integration.render(dust_context)?;
|
||||||
|
let parent_directory = output_path
|
||||||
|
.parent()
|
||||||
|
.ok_or("Output file should have a containing directory.")?;
|
||||||
|
tokio::fs::create_dir_all(parent_directory).await?;
|
||||||
|
tokio::fs::write(&output_path, rendered_output).await?;
|
||||||
|
|
||||||
|
let dependencies = dependency_manager.lock().unwrap().take_dependencies();
|
||||||
|
for dependency in dependencies {
|
||||||
|
dependency.perform(render_context.clone()).await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn render_blog_posts(&self, config: &Config) -> Result<(), CustomError> {
|
||||||
|
let renderer_integration = self.init_renderer_integration()?;
|
||||||
|
|
||||||
|
for blog_post in self.blog_posts.iter().filter(|blog_post| {
|
||||||
|
match blog_post
|
||||||
|
.get_index_page()
|
||||||
|
.expect("Blog posts should have an index page.")
|
||||||
|
.natter_publish
|
||||||
|
{
|
||||||
|
PublishStatus::Full => true,
|
||||||
|
PublishStatus::Unlisted => true,
|
||||||
|
PublishStatus::Unpublished => false,
|
||||||
|
}
|
||||||
|
}) {
|
||||||
for blog_post_page in &blog_post.pages {
|
for blog_post_page in &blog_post.pages {
|
||||||
let output_path = self
|
let output_path = self
|
||||||
.output_directory
|
.output_directory
|
||||||
.join("posts")
|
.join(config.get_relative_path_to_post(&blog_post.id))
|
||||||
.join(&blog_post.id)
|
|
||||||
.join(blog_post_page.get_output_path());
|
.join(blog_post_page.get_output_path());
|
||||||
|
|
||||||
let render_context = convert_blog_post_page_to_render_context(
|
let dependency_manager =
|
||||||
|
std::sync::Arc::new(std::sync::Mutex::new(DependencyManager::new()));
|
||||||
|
let convert_input = RenderBlogPostPageInput::new(blog_post, blog_post_page);
|
||||||
|
let render_context = RenderContext::new(
|
||||||
config,
|
config,
|
||||||
&self.output_directory,
|
self.output_directory.as_path(),
|
||||||
&output_path,
|
output_path.as_path(),
|
||||||
blog_post,
|
None,
|
||||||
blog_post_page,
|
dependency_manager.clone(),
|
||||||
)?;
|
)?;
|
||||||
let rendered_output = renderer_integration.render(render_context)?;
|
let dust_context = RenderBlogPostPage::new(render_context.clone(), &convert_input)?;
|
||||||
|
let rendered_output = renderer_integration.render(dust_context)?;
|
||||||
let parent_directory = output_path
|
let parent_directory = output_path
|
||||||
.parent()
|
.parent()
|
||||||
.ok_or("Output file should have a containing directory.")?;
|
.ok_or("Output file should have a containing directory.")?;
|
||||||
tokio::fs::create_dir_all(parent_directory).await?;
|
tokio::fs::create_dir_all(parent_directory).await?;
|
||||||
tokio::fs::write(output_path, rendered_output).await?;
|
tokio::fs::write(&output_path, rendered_output).await?;
|
||||||
|
|
||||||
|
let dependencies = dependency_manager.lock().unwrap().take_dependencies();
|
||||||
|
for dependency in dependencies {
|
||||||
|
dependency.perform(render_context.clone()).await?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn render_blog_stream(&self, config: &Config) -> Result<(), CustomError> {
|
||||||
|
let renderer_integration = self.init_renderer_integration()?;
|
||||||
|
|
||||||
|
// Sort blog posts by date, newest first.
|
||||||
|
let sorted_blog_posts = {
|
||||||
|
let mut sorted_blog_posts: Vec<_> = self
|
||||||
|
.blog_posts
|
||||||
|
.iter()
|
||||||
|
.filter(|blog_post| {
|
||||||
|
match blog_post
|
||||||
|
.get_index_page()
|
||||||
|
.expect("Blog posts should have an index page.")
|
||||||
|
.natter_publish
|
||||||
|
{
|
||||||
|
PublishStatus::Full => true,
|
||||||
|
PublishStatus::Unlisted => false,
|
||||||
|
PublishStatus::Unpublished => false,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
sorted_blog_posts
|
||||||
|
.sort_by_key(|blog_post| (blog_post.get_date(), blog_post.id.as_str()));
|
||||||
|
sorted_blog_posts.reverse();
|
||||||
|
sorted_blog_posts
|
||||||
|
};
|
||||||
|
|
||||||
|
for blog_post in &sorted_blog_posts {
|
||||||
|
if blog_post.get_date().is_none() {
|
||||||
|
return Err(format!("Blog post {} does not have a date.", blog_post.id).into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group blog posts based on # of posts per page.
|
||||||
|
let stream_chunks: Vec<_> = sorted_blog_posts
|
||||||
|
.chunks(config.get_stream_entries_per_page())
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
// For each group, create a RenderBlogStream.
|
||||||
|
let num_stream_pages = stream_chunks.len();
|
||||||
|
for (page_num, chunk) in stream_chunks.into_iter().enumerate() {
|
||||||
|
let output_file = if page_num == 0 {
|
||||||
|
self.output_directory.join("index.html")
|
||||||
|
} else {
|
||||||
|
self.output_directory
|
||||||
|
.join("stream")
|
||||||
|
.join(format!("{}.html", page_num))
|
||||||
|
};
|
||||||
|
let newer_link = if page_num == 0 {
|
||||||
|
None
|
||||||
|
} else if page_num == 1 {
|
||||||
|
Some(get_web_path(
|
||||||
|
config,
|
||||||
|
&self.output_directory,
|
||||||
|
&output_file,
|
||||||
|
"index.html",
|
||||||
|
)?)
|
||||||
|
} else {
|
||||||
|
Some(get_web_path(
|
||||||
|
config,
|
||||||
|
&self.output_directory,
|
||||||
|
&output_file,
|
||||||
|
format!("stream/{}.html", page_num - 1),
|
||||||
|
)?)
|
||||||
|
};
|
||||||
|
let older_link = if page_num == (num_stream_pages - 1) {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(get_web_path(
|
||||||
|
config,
|
||||||
|
&self.output_directory,
|
||||||
|
&output_file,
|
||||||
|
format!("stream/{}.html", page_num + 1),
|
||||||
|
)?)
|
||||||
|
};
|
||||||
|
|
||||||
|
let dependency_manager =
|
||||||
|
std::sync::Arc::new(std::sync::Mutex::new(DependencyManager::new()));
|
||||||
|
let convert_input = RenderBlogStreamInput::new(chunk, older_link, newer_link);
|
||||||
|
let render_context = RenderContext::new(
|
||||||
|
config,
|
||||||
|
self.output_directory.as_path(),
|
||||||
|
output_file.as_path(),
|
||||||
|
None,
|
||||||
|
dependency_manager.clone(),
|
||||||
|
)?;
|
||||||
|
let blog_stream = RenderBlogStream::new(render_context.clone(), &convert_input)?;
|
||||||
|
|
||||||
|
// Pass each RenderBlogStream to dust as the context to render index.html and any additional stream pages.
|
||||||
|
let rendered_output = renderer_integration.render(blog_stream)?;
|
||||||
|
let parent_directory = output_file
|
||||||
|
.parent()
|
||||||
|
.ok_or("Output file should have a containing directory.")?;
|
||||||
|
tokio::fs::create_dir_all(parent_directory).await?;
|
||||||
|
tokio::fs::write(&output_file, rendered_output).await?;
|
||||||
|
|
||||||
|
let dependencies = dependency_manager.lock().unwrap().take_dependencies();
|
||||||
|
for dependency in dependencies {
|
||||||
|
dependency.perform(render_context.clone()).await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn render_stylesheets(&self) -> Result<(), CustomError> {
|
||||||
|
let stylesheet_output_directory = self.output_directory.join("stylesheet");
|
||||||
|
if !stylesheet_output_directory.exists() {
|
||||||
|
tokio::fs::create_dir(&stylesheet_output_directory).await?;
|
||||||
|
}
|
||||||
|
for stylesheet in &self.stylesheets {
|
||||||
|
let file_output_path = stylesheet_output_directory.join(&stylesheet.path);
|
||||||
|
let parent_directory = file_output_path
|
||||||
|
.parent()
|
||||||
|
.ok_or("Output file should have a containing directory.")?;
|
||||||
|
tokio::fs::create_dir_all(parent_directory).await?;
|
||||||
|
tokio::fs::write(file_output_path, stylesheet.contents.as_bytes()).await?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn copy_static_files(&self, config: &Config) -> Result<(), CustomError> {
|
||||||
|
let static_files_directory = config
|
||||||
|
.get_root_directory()
|
||||||
|
.join(config.get_relative_path_to_static_files());
|
||||||
|
if !static_files_directory.exists() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
let static_files = get_all_files(&static_files_directory).await?;
|
||||||
|
for entry in static_files {
|
||||||
|
let (path, contents) = entry.await??;
|
||||||
|
let relative_path = path.strip_prefix(&static_files_directory)?;
|
||||||
|
let output_path = self.output_directory.join(relative_path);
|
||||||
|
let parent_directory = output_path
|
||||||
|
.parent()
|
||||||
|
.ok_or("Output file should have a containing directory.")?;
|
||||||
|
tokio::fs::create_dir_all(parent_directory).await?;
|
||||||
|
tokio::fs::write(output_path, contents).await?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_name_contents_pairs<'a>(
|
fn build_name_contents_pairs<'a>(
|
||||||
@@ -96,3 +318,32 @@ fn build_name_contents_pairs<'a>(
|
|||||||
let contents = std::str::from_utf8(entry.contents())?;
|
let contents = std::str::from_utf8(entry.contents())?;
|
||||||
Ok((name, contents))
|
Ok((name, contents))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ReadFileResult = std::io::Result<(PathBuf, Vec<u8>)>;
|
||||||
|
|
||||||
|
async fn filter_to_files(entry: &DirEntry) -> WalkFsFilterResult {
|
||||||
|
let file_type = entry.file_type().await?;
|
||||||
|
if file_type.is_dir() {
|
||||||
|
return Ok(WalkAction::Recurse);
|
||||||
|
}
|
||||||
|
if file_type.is_file() {
|
||||||
|
return Ok(WalkAction::HaltAndCapture);
|
||||||
|
}
|
||||||
|
|
||||||
|
unreachable!("Unhandled file type.");
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_all_files<P: Into<PathBuf>>(
|
||||||
|
root_dir: P,
|
||||||
|
) -> Result<impl Iterator<Item = JoinHandle<ReadFileResult>>, CustomError> {
|
||||||
|
let files = walk_fs(root_dir, filter_to_files).await?;
|
||||||
|
let files_and_content = files
|
||||||
|
.into_iter()
|
||||||
|
.map(|entry| tokio::spawn(read_file(entry.path())));
|
||||||
|
Ok(files_and_content)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn read_file(path: PathBuf) -> ReadFileResult {
|
||||||
|
let contents = tokio::fs::read(&path).await?;
|
||||||
|
Ok((path, contents))
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,16 +1,45 @@
|
|||||||
|
use std::ffi::OsStr;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::sync::Arc;
|
||||||
|
use std::sync::Mutex;
|
||||||
|
|
||||||
|
use super::stylesheet::Stylesheet;
|
||||||
use crate::cli::parameters::BuildArgs;
|
use crate::cli::parameters::BuildArgs;
|
||||||
use crate::command::build::render::SiteRenderer;
|
use crate::command::build::render::SiteRenderer;
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::error::CustomError;
|
use crate::error::CustomError;
|
||||||
use crate::intermediate::BlogPost;
|
use crate::intermediate::BlogPost;
|
||||||
|
use crate::intermediate::IPage;
|
||||||
|
use crate::intermediate::IntermediateContext;
|
||||||
|
use crate::intermediate::PageInput;
|
||||||
|
use crate::intermediate::Registry;
|
||||||
|
use crate::intermediate::get_org_files;
|
||||||
|
use crate::walk_fs::WalkAction;
|
||||||
|
use crate::walk_fs::WalkFsFilterResult;
|
||||||
|
use crate::walk_fs::walk_fs;
|
||||||
|
use include_dir::Dir;
|
||||||
|
use include_dir::include_dir;
|
||||||
|
use tokio::fs::DirEntry;
|
||||||
|
|
||||||
|
static DEFAULT_STYLESHEETS: Dir =
|
||||||
|
include_dir!("$CARGO_MANIFEST_DIR/default_environment/stylesheet");
|
||||||
|
|
||||||
pub(crate) async fn build_site(args: BuildArgs) -> Result<(), CustomError> {
|
pub(crate) async fn build_site(args: BuildArgs) -> Result<(), CustomError> {
|
||||||
let config = Config::load_from_file(args.config).await?;
|
let config = Config::load_from_file(args.config).await?;
|
||||||
let blog_posts = load_blog_posts(&config).await?;
|
let blog_posts = load_blog_posts(&config).await?;
|
||||||
let renderer = SiteRenderer::new(get_output_directory(&config).await?, blog_posts);
|
let stylesheets = load_stylesheets().await?;
|
||||||
|
let pages = load_pages(&config).await?;
|
||||||
|
let renderer = SiteRenderer::new(
|
||||||
|
get_output_directory(&config).await?,
|
||||||
|
blog_posts,
|
||||||
|
stylesheets,
|
||||||
|
pages,
|
||||||
|
);
|
||||||
renderer.render_blog_posts(&config).await?;
|
renderer.render_blog_posts(&config).await?;
|
||||||
|
renderer.render_blog_stream(&config).await?;
|
||||||
|
renderer.render_pages(&config).await?;
|
||||||
|
renderer.render_stylesheets().await?;
|
||||||
|
renderer.copy_static_files(&config).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -34,27 +63,128 @@ async fn get_output_directory(config: &Config) -> Result<PathBuf, CustomError> {
|
|||||||
Ok(output_directory)
|
Ok(output_directory)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_post_directories(config: &Config) -> Result<Vec<PathBuf>, CustomError> {
|
async fn filter_to_highest_folders_containing_org_files(entry: &DirEntry) -> WalkFsFilterResult {
|
||||||
let mut ret = Vec::new();
|
let file_type = entry.file_type().await?;
|
||||||
let mut entries = tokio::fs::read_dir(config.get_posts_directory()).await?;
|
if !file_type.is_dir() {
|
||||||
|
return Ok(WalkAction::Halt);
|
||||||
|
}
|
||||||
|
let mut entries = tokio::fs::read_dir(entry.path()).await?;
|
||||||
while let Some(entry) = entries.next_entry().await? {
|
while let Some(entry) = entries.next_entry().await? {
|
||||||
let file_type = entry.file_type().await?;
|
let entry_type = entry.file_type().await?;
|
||||||
if file_type.is_dir() {
|
if !entry_type.is_file() {
|
||||||
ret.push(entry.path());
|
continue;
|
||||||
|
}
|
||||||
|
match entry.path().extension().and_then(OsStr::to_str) {
|
||||||
|
Some(ext) if ext.eq_ignore_ascii_case("org") => {
|
||||||
|
return Ok(WalkAction::HaltAndCapture);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(ret)
|
Ok(WalkAction::Recurse)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_post_directories(config: &Config) -> Result<Vec<PathBuf>, CustomError> {
|
||||||
|
if !config.get_posts_directory().exists() {
|
||||||
|
return Ok(Vec::new());
|
||||||
|
}
|
||||||
|
|
||||||
|
let top_level_org_folders = walk_fs(
|
||||||
|
config.get_posts_directory(),
|
||||||
|
filter_to_highest_folders_containing_org_files,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
Ok(top_level_org_folders
|
||||||
|
.into_iter()
|
||||||
|
.map(|entry| entry.path())
|
||||||
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn load_blog_posts(config: &Config) -> Result<Vec<BlogPost>, CustomError> {
|
async fn load_blog_posts(config: &Config) -> Result<Vec<BlogPost>, CustomError> {
|
||||||
let root_directory = config.get_root_directory().to_owned();
|
let root_directory = config.get_root_directory().to_owned();
|
||||||
let post_directories = get_post_directories(&config).await?;
|
let posts_directory = config.get_posts_directory();
|
||||||
let load_jobs = post_directories
|
let post_directories = get_post_directories(config).await?;
|
||||||
.into_iter()
|
let load_jobs = post_directories.into_iter().map(|path| {
|
||||||
.map(|path| tokio::spawn(BlogPost::load_blog_post(root_directory.clone(), path)));
|
tokio::spawn(BlogPost::load_blog_post(
|
||||||
|
root_directory.clone(),
|
||||||
|
posts_directory.clone(),
|
||||||
|
path,
|
||||||
|
))
|
||||||
|
});
|
||||||
let mut blog_posts = Vec::new();
|
let mut blog_posts = Vec::new();
|
||||||
for job in load_jobs {
|
for job in load_jobs {
|
||||||
blog_posts.push(job.await??);
|
blog_posts.push(job.await??);
|
||||||
}
|
}
|
||||||
Ok(blog_posts)
|
Ok(blog_posts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn load_pages(config: &Config) -> Result<Vec<IPage>, CustomError> {
|
||||||
|
let pages_source = config
|
||||||
|
.get_root_directory()
|
||||||
|
.join(config.get_relative_path_to_pages());
|
||||||
|
if !pages_source.exists() {
|
||||||
|
return Ok(Vec::new());
|
||||||
|
}
|
||||||
|
let page_files = get_org_files(&pages_source).await?;
|
||||||
|
let org_files = {
|
||||||
|
let mut ret = Vec::new();
|
||||||
|
for page in page_files {
|
||||||
|
ret.push(page.await??);
|
||||||
|
}
|
||||||
|
ret
|
||||||
|
};
|
||||||
|
let parsed_org_files = {
|
||||||
|
let mut ret = Vec::new();
|
||||||
|
for (path, contents) in org_files.iter() {
|
||||||
|
let parsed = organic::parser::parse_file(contents.as_str(), Some(path))
|
||||||
|
.map_err(|_| CustomError::Static("Failed to parse org-mode document."))?;
|
||||||
|
ret.push((path, contents, parsed));
|
||||||
|
}
|
||||||
|
ret
|
||||||
|
};
|
||||||
|
|
||||||
|
let pages = {
|
||||||
|
let mut ret = Vec::new();
|
||||||
|
for (real_path, _contents, parsed_document) in parsed_org_files.iter() {
|
||||||
|
let mut registry = Registry::new();
|
||||||
|
|
||||||
|
// Assign IDs to the targets
|
||||||
|
organic::types::AstNode::from(parsed_document)
|
||||||
|
.iter_all_ast_nodes()
|
||||||
|
.for_each(|node| {
|
||||||
|
if let organic::types::AstNode::Target(target) = node {
|
||||||
|
registry.get_target(target.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let registry = Arc::new(Mutex::new(registry));
|
||||||
|
let intermediate_context = IntermediateContext::new(registry)?;
|
||||||
|
let relative_to_pages_dir_path = real_path.strip_prefix(&pages_source)?;
|
||||||
|
ret.push(
|
||||||
|
IPage::new(
|
||||||
|
intermediate_context,
|
||||||
|
PageInput::new(relative_to_pages_dir_path, real_path, parsed_document),
|
||||||
|
)
|
||||||
|
.await?,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
ret
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(pages)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn load_stylesheets() -> Result<Vec<Stylesheet>, CustomError> {
|
||||||
|
let sources: Vec<_> = DEFAULT_STYLESHEETS
|
||||||
|
.files()
|
||||||
|
.filter(|f| f.path().extension() == Some(OsStr::new("css")))
|
||||||
|
.collect();
|
||||||
|
let mut ret = Vec::with_capacity(sources.len());
|
||||||
|
for entry in sources {
|
||||||
|
let path = entry.path().to_path_buf();
|
||||||
|
let contents = String::from_utf8(entry.contents().to_vec())?;
|
||||||
|
let stylesheet = Stylesheet::new(path, contents).await?;
|
||||||
|
ret.push(stylesheet);
|
||||||
|
}
|
||||||
|
Ok(ret)
|
||||||
|
}
|
||||||
|
|||||||
15
src/command/build/stylesheet.rs
Normal file
15
src/command/build/stylesheet.rs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use crate::error::CustomError;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub(crate) struct Stylesheet {
|
||||||
|
pub(crate) path: PathBuf,
|
||||||
|
pub(crate) contents: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Stylesheet {
|
||||||
|
pub(crate) async fn new(path: PathBuf, contents: String) -> Result<Stylesheet, CustomError> {
|
||||||
|
Ok(Stylesheet { path, contents })
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
mod runner;
|
mod runner;
|
||||||
|
|
||||||
pub(crate) use runner::init_writer_folder;
|
pub(crate) use runner::init_natter_folder;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use crate::cli::parameters::InitArgs;
|
|||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::error::CustomError;
|
use crate::error::CustomError;
|
||||||
|
|
||||||
pub(crate) async fn init_writer_folder(args: InitArgs) -> Result<(), CustomError> {
|
pub(crate) async fn init_natter_folder(args: InitArgs) -> Result<(), CustomError> {
|
||||||
if args.path.exists() && !args.path.is_dir() {
|
if args.path.exists() && !args.path.is_dir() {
|
||||||
return Err("The supplied path exists but is not a directory. Aborting.".into());
|
return Err("The supplied path exists but is not a directory. Aborting.".into());
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ pub(crate) async fn init_writer_folder(args: InitArgs) -> Result<(), CustomError
|
|||||||
|
|
||||||
let mut existing_entries = tokio::fs::read_dir(&args.path).await?;
|
let mut existing_entries = tokio::fs::read_dir(&args.path).await?;
|
||||||
let first_entry = existing_entries.next_entry().await?;
|
let first_entry = existing_entries.next_entry().await?;
|
||||||
if let Some(_) = first_entry {
|
if first_entry.is_some() {
|
||||||
return Err("The directory is not empty. Aborting.".into());
|
return Err("The directory is not empty. Aborting.".into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use crate::error::CustomError;
|
|||||||
use super::raw::RawConfig;
|
use super::raw::RawConfig;
|
||||||
|
|
||||||
/// This is the config struct used by most of the code, which is an interpreted version of the RawConfig struct which is the raw disk-representation of the config.
|
/// This is the config struct used by most of the code, which is an interpreted version of the RawConfig struct which is the raw disk-representation of the config.
|
||||||
|
#[derive(Debug)]
|
||||||
pub(crate) struct Config {
|
pub(crate) struct Config {
|
||||||
raw: RawConfig,
|
raw: RawConfig,
|
||||||
config_path: PathBuf,
|
config_path: PathBuf,
|
||||||
@@ -16,7 +17,7 @@ pub(crate) struct Config {
|
|||||||
impl Config {
|
impl Config {
|
||||||
pub(crate) fn new<P: AsRef<Path>>(root_dir: P) -> Result<Config, CustomError> {
|
pub(crate) fn new<P: AsRef<Path>>(root_dir: P) -> Result<Config, CustomError> {
|
||||||
fn inner(root_dir: &Path) -> Result<Config, CustomError> {
|
fn inner(root_dir: &Path) -> Result<Config, CustomError> {
|
||||||
let file_path = root_dir.join("writer.toml");
|
let file_path = root_dir.join("natter.toml");
|
||||||
Ok(Config {
|
Ok(Config {
|
||||||
raw: RawConfig::default(),
|
raw: RawConfig::default(),
|
||||||
config_path: file_path,
|
config_path: file_path,
|
||||||
@@ -46,8 +47,7 @@ impl Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_root_directory(&self) -> &Path {
|
pub(crate) fn get_root_directory(&self) -> &Path {
|
||||||
&self
|
self.config_path
|
||||||
.config_path
|
|
||||||
.parent()
|
.parent()
|
||||||
.expect("Config file must exist inside a directory.")
|
.expect("Config file must exist inside a directory.")
|
||||||
}
|
}
|
||||||
@@ -56,6 +56,15 @@ impl Config {
|
|||||||
self.get_root_directory().join("posts")
|
self.get_root_directory().join("posts")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the relative path to the folder containing a blog post.
|
||||||
|
///
|
||||||
|
/// This could be appended to the output root directory to get the
|
||||||
|
/// blog post output folder or it could be used to generate a link
|
||||||
|
/// to the blog post.
|
||||||
|
pub(crate) fn get_relative_path_to_post<P: AsRef<Path>>(&self, post_id: P) -> PathBuf {
|
||||||
|
Path::new("posts").join(post_id)
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn get_output_directory(&self) -> PathBuf {
|
pub(crate) fn get_output_directory(&self) -> PathBuf {
|
||||||
self.get_root_directory().join("output")
|
self.get_root_directory().join("output")
|
||||||
}
|
}
|
||||||
@@ -67,4 +76,24 @@ impl Config {
|
|||||||
pub(crate) fn get_web_root(&self) -> Option<&str> {
|
pub(crate) fn get_web_root(&self) -> Option<&str> {
|
||||||
self.raw.web_root.as_deref()
|
self.raw.web_root.as_deref()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_site_title(&self) -> Option<&str> {
|
||||||
|
self.raw.site_title.as_deref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_stream_entries_per_page(&self) -> usize {
|
||||||
|
self.raw
|
||||||
|
.stream
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|stream| stream.entries_per_page)
|
||||||
|
.unwrap_or(5)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_relative_path_to_static_files(&self) -> PathBuf {
|
||||||
|
Path::new("static").into()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_relative_path_to_pages(&self) -> PathBuf {
|
||||||
|
Path::new("pages").into()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,18 @@
|
|||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
/// This is the struct for the writer.toml config file that ends up in each site's root directory.
|
/// This is the struct for the natter.toml config file that ends up in each site's root directory.
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||||
pub(crate) struct RawConfig {
|
pub(crate) struct RawConfig {
|
||||||
site_title: String,
|
pub(super) site_title: Option<String>,
|
||||||
author: Option<String>,
|
author: Option<String>,
|
||||||
email: Option<String>,
|
email: Option<String>,
|
||||||
pub(super) use_relative_paths: Option<bool>,
|
pub(super) use_relative_paths: Option<bool>,
|
||||||
pub(super) web_root: Option<String>,
|
pub(super) web_root: Option<String>,
|
||||||
|
pub(super) stream: Option<RawConfigStream>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for RawConfig {
|
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||||
fn default() -> Self {
|
pub(crate) struct RawConfigStream {
|
||||||
RawConfig {
|
pub(super) entries_per_page: Option<usize>,
|
||||||
site_title: "My super awesome website".to_owned(),
|
|
||||||
author: None,
|
|
||||||
email: None,
|
|
||||||
use_relative_paths: None,
|
|
||||||
web_root: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,16 @@
|
|||||||
use std::path::Path;
|
|
||||||
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::config::Config;
|
use super::render_context::RenderContext;
|
||||||
use crate::error::CustomError;
|
use crate::error::CustomError;
|
||||||
use crate::intermediate::IAngleLink;
|
use crate::intermediate::IAngleLink;
|
||||||
|
|
||||||
|
use super::macros::rnoop;
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
#[serde(rename = "angle_link")]
|
#[serde(rename = "angle_link")]
|
||||||
pub(crate) struct RenderAngleLink {}
|
pub(crate) struct RenderAngleLink {
|
||||||
|
post_blank: organic::types::PostBlank,
|
||||||
impl RenderAngleLink {
|
|
||||||
pub(crate) fn new(
|
|
||||||
config: &Config,
|
|
||||||
output_directory: &Path,
|
|
||||||
output_file: &Path,
|
|
||||||
comment: &IAngleLink,
|
|
||||||
) -> Result<RenderAngleLink, CustomError> {
|
|
||||||
Ok(RenderAngleLink {})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rnoop!(RenderAngleLink, IAngleLink);
|
||||||
|
|||||||
327
src/context/ast_node.rs
Normal file
327
src/context/ast_node.rs
Normal file
@@ -0,0 +1,327 @@
|
|||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use crate::error::CustomError;
|
||||||
|
use crate::intermediate::IAstNode;
|
||||||
|
|
||||||
|
use super::RenderHeading;
|
||||||
|
use super::RenderSection;
|
||||||
|
use super::angle_link::RenderAngleLink;
|
||||||
|
use super::babel_call::RenderBabelCall;
|
||||||
|
use super::bold::RenderBold;
|
||||||
|
use super::center_block::RenderCenterBlock;
|
||||||
|
use super::citation::RenderCitation;
|
||||||
|
use super::citation_reference::RenderCitationReference;
|
||||||
|
use super::clock::RenderClock;
|
||||||
|
use super::code::RenderCode;
|
||||||
|
use super::comment::RenderComment;
|
||||||
|
use super::comment_block::RenderCommentBlock;
|
||||||
|
use super::diary_sexp::RenderDiarySexp;
|
||||||
|
use super::drawer::RenderDrawer;
|
||||||
|
use super::dynamic_block::RenderDynamicBlock;
|
||||||
|
use super::entity::RenderEntity;
|
||||||
|
use super::example_block::RenderExampleBlock;
|
||||||
|
use super::export_block::RenderExportBlock;
|
||||||
|
use super::export_snippet::RenderExportSnippet;
|
||||||
|
use super::fixed_width_area::RenderFixedWidthArea;
|
||||||
|
use super::footnote_definition::RenderFootnoteDefinition;
|
||||||
|
use super::footnote_reference::RenderFootnoteReference;
|
||||||
|
use super::horizontal_rule::RenderHorizontalRule;
|
||||||
|
use super::inline_babel_call::RenderInlineBabelCall;
|
||||||
|
use super::inline_source_block::RenderInlineSourceBlock;
|
||||||
|
use super::italic::RenderItalic;
|
||||||
|
use super::keyword::RenderKeyword;
|
||||||
|
use super::latex_environment::RenderLatexEnvironment;
|
||||||
|
use super::latex_fragment::RenderLatexFragment;
|
||||||
|
use super::line_break::RenderLineBreak;
|
||||||
|
use super::org_macro::RenderOrgMacro;
|
||||||
|
use super::paragraph::RenderParagraph;
|
||||||
|
use super::plain_link::RenderPlainLink;
|
||||||
|
use super::plain_list::RenderPlainList;
|
||||||
|
use super::plain_text::RenderPlainText;
|
||||||
|
use super::planning::RenderPlanning;
|
||||||
|
use super::property_drawer::RenderPropertyDrawer;
|
||||||
|
use super::quote_block::RenderQuoteBlock;
|
||||||
|
use super::radio_link::RenderRadioLink;
|
||||||
|
use super::radio_target::RenderRadioTarget;
|
||||||
|
use super::regular_link::RenderRegularLink;
|
||||||
|
use super::render_context::RenderContext;
|
||||||
|
use super::special_block::RenderSpecialBlock;
|
||||||
|
use super::src_block::RenderSrcBlock;
|
||||||
|
use super::statistics_cookie::RenderStatisticsCookie;
|
||||||
|
use super::strike_through::RenderStrikeThrough;
|
||||||
|
use super::subscript::RenderSubscript;
|
||||||
|
use super::superscript::RenderSuperscript;
|
||||||
|
use super::table::RenderTable;
|
||||||
|
use super::target::RenderTarget;
|
||||||
|
use super::timestamp::RenderTimestamp;
|
||||||
|
use super::underline::RenderUnderline;
|
||||||
|
use super::verbatim::RenderVerbatim;
|
||||||
|
use super::verse_block::RenderVerseBlock;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub(crate) enum RenderAstNode {
|
||||||
|
Heading(RenderHeading),
|
||||||
|
Section(RenderSection),
|
||||||
|
Paragraph(RenderParagraph),
|
||||||
|
PlainList(RenderPlainList),
|
||||||
|
CenterBlock(RenderCenterBlock),
|
||||||
|
QuoteBlock(RenderQuoteBlock),
|
||||||
|
SpecialBlock(RenderSpecialBlock),
|
||||||
|
DynamicBlock(RenderDynamicBlock),
|
||||||
|
FootnoteDefinition(RenderFootnoteDefinition),
|
||||||
|
Comment(RenderComment),
|
||||||
|
Drawer(RenderDrawer),
|
||||||
|
PropertyDrawer(RenderPropertyDrawer),
|
||||||
|
Table(RenderTable),
|
||||||
|
VerseBlock(RenderVerseBlock),
|
||||||
|
CommentBlock(RenderCommentBlock),
|
||||||
|
ExampleBlock(RenderExampleBlock),
|
||||||
|
ExportBlock(RenderExportBlock),
|
||||||
|
SrcBlock(RenderSrcBlock),
|
||||||
|
Clock(RenderClock),
|
||||||
|
DiarySexp(RenderDiarySexp),
|
||||||
|
Planning(RenderPlanning),
|
||||||
|
FixedWidthArea(RenderFixedWidthArea),
|
||||||
|
HorizontalRule(RenderHorizontalRule),
|
||||||
|
Keyword(RenderKeyword),
|
||||||
|
BabelCall(RenderBabelCall),
|
||||||
|
LatexEnvironment(RenderLatexEnvironment),
|
||||||
|
Bold(RenderBold),
|
||||||
|
Italic(RenderItalic),
|
||||||
|
Underline(RenderUnderline),
|
||||||
|
StrikeThrough(RenderStrikeThrough),
|
||||||
|
Code(RenderCode),
|
||||||
|
Verbatim(RenderVerbatim),
|
||||||
|
PlainText(RenderPlainText),
|
||||||
|
RegularLink(RenderRegularLink),
|
||||||
|
RadioLink(RenderRadioLink),
|
||||||
|
RadioTarget(RenderRadioTarget),
|
||||||
|
PlainLink(RenderPlainLink),
|
||||||
|
AngleLink(RenderAngleLink),
|
||||||
|
OrgMacro(RenderOrgMacro),
|
||||||
|
Entity(RenderEntity),
|
||||||
|
LatexFragment(RenderLatexFragment),
|
||||||
|
ExportSnippet(RenderExportSnippet),
|
||||||
|
FootnoteReference(RenderFootnoteReference),
|
||||||
|
Citation(RenderCitation),
|
||||||
|
CitationReference(RenderCitationReference),
|
||||||
|
InlineBabelCall(RenderInlineBabelCall),
|
||||||
|
InlineSourceBlock(RenderInlineSourceBlock),
|
||||||
|
LineBreak(RenderLineBreak),
|
||||||
|
Target(RenderTarget),
|
||||||
|
StatisticsCookie(RenderStatisticsCookie),
|
||||||
|
Subscript(RenderSubscript),
|
||||||
|
Superscript(RenderSuperscript),
|
||||||
|
Timestamp(RenderTimestamp),
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) trait IntoRenderAstNode {
|
||||||
|
fn as_render_ast_node(
|
||||||
|
&self,
|
||||||
|
render_context: RenderContext<'_>,
|
||||||
|
) -> Result<RenderAstNode, CustomError>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl IntoRenderAstNode for IAstNode {
|
||||||
|
fn as_render_ast_node(
|
||||||
|
&self,
|
||||||
|
render_context: RenderContext<'_>,
|
||||||
|
) -> Result<RenderAstNode, CustomError> {
|
||||||
|
match self {
|
||||||
|
IAstNode::Heading(inner) => Ok(RenderAstNode::Heading(RenderHeading::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::Section(inner) => Ok(RenderAstNode::Section(RenderSection::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::Paragraph(inner) => Ok(RenderAstNode::Paragraph(RenderParagraph::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::PlainList(inner) => Ok(RenderAstNode::PlainList(RenderPlainList::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::CenterBlock(inner) => Ok(RenderAstNode::CenterBlock(RenderCenterBlock::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::QuoteBlock(inner) => Ok(RenderAstNode::QuoteBlock(RenderQuoteBlock::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::SpecialBlock(inner) => Ok(RenderAstNode::SpecialBlock(
|
||||||
|
RenderSpecialBlock::new(render_context, inner)?,
|
||||||
|
)),
|
||||||
|
IAstNode::DynamicBlock(inner) => Ok(RenderAstNode::DynamicBlock(
|
||||||
|
RenderDynamicBlock::new(render_context, inner)?,
|
||||||
|
)),
|
||||||
|
IAstNode::FootnoteDefinition(inner) => Ok(RenderAstNode::FootnoteDefinition(
|
||||||
|
RenderFootnoteDefinition::new(render_context, inner)?,
|
||||||
|
)),
|
||||||
|
IAstNode::Comment(inner) => Ok(RenderAstNode::Comment(RenderComment::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::Drawer(inner) => Ok(RenderAstNode::Drawer(RenderDrawer::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::PropertyDrawer(inner) => Ok(RenderAstNode::PropertyDrawer(
|
||||||
|
RenderPropertyDrawer::new(render_context, inner)?,
|
||||||
|
)),
|
||||||
|
IAstNode::Table(inner) => Ok(RenderAstNode::Table(RenderTable::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::VerseBlock(inner) => Ok(RenderAstNode::VerseBlock(RenderVerseBlock::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::CommentBlock(inner) => Ok(RenderAstNode::CommentBlock(
|
||||||
|
RenderCommentBlock::new(render_context, inner)?,
|
||||||
|
)),
|
||||||
|
IAstNode::ExampleBlock(inner) => Ok(RenderAstNode::ExampleBlock(
|
||||||
|
RenderExampleBlock::new(render_context, inner)?,
|
||||||
|
)),
|
||||||
|
IAstNode::ExportBlock(inner) => Ok(RenderAstNode::ExportBlock(RenderExportBlock::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::SrcBlock(inner) => Ok(RenderAstNode::SrcBlock(RenderSrcBlock::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::Clock(inner) => Ok(RenderAstNode::Clock(RenderClock::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::DiarySexp(inner) => Ok(RenderAstNode::DiarySexp(RenderDiarySexp::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::Planning(inner) => Ok(RenderAstNode::Planning(RenderPlanning::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::FixedWidthArea(inner) => Ok(RenderAstNode::FixedWidthArea(
|
||||||
|
RenderFixedWidthArea::new(render_context, inner)?,
|
||||||
|
)),
|
||||||
|
IAstNode::HorizontalRule(inner) => Ok(RenderAstNode::HorizontalRule(
|
||||||
|
RenderHorizontalRule::new(render_context, inner)?,
|
||||||
|
)),
|
||||||
|
IAstNode::Keyword(inner) => Ok(RenderAstNode::Keyword(RenderKeyword::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::BabelCall(inner) => Ok(RenderAstNode::BabelCall(RenderBabelCall::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::LatexEnvironment(inner) => Ok(RenderAstNode::LatexEnvironment(
|
||||||
|
RenderLatexEnvironment::new(render_context, inner)?,
|
||||||
|
)),
|
||||||
|
IAstNode::Bold(inner) => {
|
||||||
|
Ok(RenderAstNode::Bold(RenderBold::new(render_context, inner)?))
|
||||||
|
}
|
||||||
|
IAstNode::Italic(inner) => Ok(RenderAstNode::Italic(RenderItalic::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::Underline(inner) => Ok(RenderAstNode::Underline(RenderUnderline::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::StrikeThrough(inner) => Ok(RenderAstNode::StrikeThrough(
|
||||||
|
RenderStrikeThrough::new(render_context, inner)?,
|
||||||
|
)),
|
||||||
|
IAstNode::Code(inner) => {
|
||||||
|
Ok(RenderAstNode::Code(RenderCode::new(render_context, inner)?))
|
||||||
|
}
|
||||||
|
IAstNode::Verbatim(inner) => Ok(RenderAstNode::Verbatim(RenderVerbatim::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::PlainText(inner) => Ok(RenderAstNode::PlainText(RenderPlainText::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::RegularLink(inner) => Ok(RenderAstNode::RegularLink(RenderRegularLink::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::RadioLink(inner) => Ok(RenderAstNode::RadioLink(RenderRadioLink::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::RadioTarget(inner) => Ok(RenderAstNode::RadioTarget(RenderRadioTarget::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::PlainLink(inner) => Ok(RenderAstNode::PlainLink(RenderPlainLink::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::AngleLink(inner) => Ok(RenderAstNode::AngleLink(RenderAngleLink::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::OrgMacro(inner) => Ok(RenderAstNode::OrgMacro(RenderOrgMacro::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::Entity(inner) => Ok(RenderAstNode::Entity(RenderEntity::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::LatexFragment(inner) => Ok(RenderAstNode::LatexFragment(
|
||||||
|
RenderLatexFragment::new(render_context, inner)?,
|
||||||
|
)),
|
||||||
|
IAstNode::ExportSnippet(inner) => Ok(RenderAstNode::ExportSnippet(
|
||||||
|
RenderExportSnippet::new(render_context, inner)?,
|
||||||
|
)),
|
||||||
|
IAstNode::FootnoteReference(inner) => Ok(RenderAstNode::FootnoteReference(
|
||||||
|
RenderFootnoteReference::new(render_context, inner)?,
|
||||||
|
)),
|
||||||
|
IAstNode::Citation(inner) => Ok(RenderAstNode::Citation(RenderCitation::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::CitationReference(inner) => Ok(RenderAstNode::CitationReference(
|
||||||
|
RenderCitationReference::new(render_context, inner)?,
|
||||||
|
)),
|
||||||
|
IAstNode::InlineBabelCall(inner) => Ok(RenderAstNode::InlineBabelCall(
|
||||||
|
RenderInlineBabelCall::new(render_context, inner)?,
|
||||||
|
)),
|
||||||
|
IAstNode::InlineSourceBlock(inner) => Ok(RenderAstNode::InlineSourceBlock(
|
||||||
|
RenderInlineSourceBlock::new(render_context, inner)?,
|
||||||
|
)),
|
||||||
|
IAstNode::LineBreak(inner) => Ok(RenderAstNode::LineBreak(RenderLineBreak::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::Target(inner) => Ok(RenderAstNode::Target(RenderTarget::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::StatisticsCookie(inner) => Ok(RenderAstNode::StatisticsCookie(
|
||||||
|
RenderStatisticsCookie::new(render_context, inner)?,
|
||||||
|
)),
|
||||||
|
IAstNode::Subscript(inner) => Ok(RenderAstNode::Subscript(RenderSubscript::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::Superscript(inner) => Ok(RenderAstNode::Superscript(RenderSuperscript::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
IAstNode::Timestamp(inner) => Ok(RenderAstNode::Timestamp(RenderTimestamp::new(
|
||||||
|
render_context,
|
||||||
|
inner,
|
||||||
|
)?)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,23 +1,16 @@
|
|||||||
use std::path::Path;
|
|
||||||
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::config::Config;
|
use super::render_context::RenderContext;
|
||||||
use crate::error::CustomError;
|
use crate::error::CustomError;
|
||||||
use crate::intermediate::IBabelCall;
|
use crate::intermediate::IBabelCall;
|
||||||
|
|
||||||
|
use super::macros::rnoop;
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
#[serde(rename = "babel_call")]
|
#[serde(rename = "babel_call")]
|
||||||
pub(crate) struct RenderBabelCall {}
|
pub(crate) struct RenderBabelCall {
|
||||||
|
post_blank: organic::types::PostBlank,
|
||||||
impl RenderBabelCall {
|
|
||||||
pub(crate) fn new(
|
|
||||||
config: &Config,
|
|
||||||
output_directory: &Path,
|
|
||||||
output_file: &Path,
|
|
||||||
original: &IBabelCall,
|
|
||||||
) -> Result<RenderBabelCall, CustomError> {
|
|
||||||
Ok(RenderBabelCall {})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rnoop!(RenderBabelCall, IBabelCall);
|
||||||
|
|||||||
@@ -1,7 +1,32 @@
|
|||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::render_context::RenderContext;
|
||||||
|
use crate::context::macros::push_file;
|
||||||
|
use crate::error::CustomError;
|
||||||
|
use crate::intermediate::BlogPost;
|
||||||
|
use crate::intermediate::BlogPostPage;
|
||||||
|
use crate::intermediate::get_web_path;
|
||||||
|
|
||||||
use super::GlobalSettings;
|
use super::GlobalSettings;
|
||||||
|
use super::PageHeader;
|
||||||
use super::RenderDocumentElement;
|
use super::RenderDocumentElement;
|
||||||
|
use super::footnote_definition::RenderRealFootnoteDefinition;
|
||||||
|
use super::macros::render;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub(crate) struct RenderBlogPostPageInput<'a> {
|
||||||
|
#[allow(dead_code)]
|
||||||
|
post: &'a BlogPost,
|
||||||
|
page: &'a BlogPostPage,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> RenderBlogPostPageInput<'a> {
|
||||||
|
pub(crate) fn new(post: &'a BlogPost, page: &'a BlogPostPage) -> RenderBlogPostPageInput<'a> {
|
||||||
|
RenderBlogPostPageInput { post, page }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
@@ -9,26 +34,121 @@ use super::RenderDocumentElement;
|
|||||||
pub(crate) struct RenderBlogPostPage {
|
pub(crate) struct RenderBlogPostPage {
|
||||||
global_settings: GlobalSettings,
|
global_settings: GlobalSettings,
|
||||||
|
|
||||||
|
page_header: Option<PageHeader>,
|
||||||
|
|
||||||
/// The title that will be shown visibly on the page.
|
/// The title that will be shown visibly on the page.
|
||||||
title: Option<String>,
|
title: Option<String>,
|
||||||
|
|
||||||
self_link: Option<String>,
|
self_link: Option<String>,
|
||||||
|
|
||||||
children: Vec<RenderDocumentElement>,
|
children: Vec<RenderDocumentElement>,
|
||||||
|
|
||||||
|
footnotes: Vec<RenderRealFootnoteDefinition>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderBlogPostPage {
|
render!(
|
||||||
pub(crate) fn new(
|
RenderBlogPostPage,
|
||||||
global_settings: GlobalSettings,
|
RenderBlogPostPageInput,
|
||||||
title: Option<String>,
|
original,
|
||||||
self_link: Option<String>,
|
render_context,
|
||||||
children: Vec<RenderDocumentElement>,
|
{
|
||||||
) -> RenderBlogPostPage {
|
push_file!(render_context, &original.page.src, {
|
||||||
RenderBlogPostPage {
|
let page_header = PageHeader::new(
|
||||||
global_settings,
|
render_context.config.get_site_title().map(str::to_string),
|
||||||
title,
|
Some(get_web_path(
|
||||||
self_link,
|
render_context.config,
|
||||||
children,
|
render_context.output_root_directory,
|
||||||
}
|
render_context.output_file,
|
||||||
|
"",
|
||||||
|
)?),
|
||||||
|
Some(get_web_path(
|
||||||
|
render_context.config,
|
||||||
|
render_context.output_root_directory,
|
||||||
|
render_context.output_file,
|
||||||
|
"about_me",
|
||||||
|
)?),
|
||||||
|
);
|
||||||
|
let link_to_blog_post = get_web_path(
|
||||||
|
render_context.config,
|
||||||
|
render_context.output_root_directory,
|
||||||
|
render_context.output_file,
|
||||||
|
render_context
|
||||||
|
.output_file
|
||||||
|
.strip_prefix(render_context.output_root_directory)?,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let children = {
|
||||||
|
let mut children = Vec::new();
|
||||||
|
|
||||||
|
for child in original.page.children.iter() {
|
||||||
|
children.push(RenderDocumentElement::new(render_context.clone(), child)?);
|
||||||
|
}
|
||||||
|
|
||||||
|
children
|
||||||
|
};
|
||||||
|
|
||||||
|
let footnotes = {
|
||||||
|
let mut ret = Vec::new();
|
||||||
|
|
||||||
|
for footnote in original.page.footnotes.iter() {
|
||||||
|
ret.push(RenderRealFootnoteDefinition::new(
|
||||||
|
render_context.clone(),
|
||||||
|
footnote,
|
||||||
|
)?);
|
||||||
|
}
|
||||||
|
|
||||||
|
ret
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut css_files = vec![
|
||||||
|
get_web_path(
|
||||||
|
render_context.config,
|
||||||
|
render_context.output_root_directory,
|
||||||
|
render_context.output_file,
|
||||||
|
"stylesheet/reset.css",
|
||||||
|
)?,
|
||||||
|
get_web_path(
|
||||||
|
render_context.config,
|
||||||
|
render_context.output_root_directory,
|
||||||
|
render_context.output_file,
|
||||||
|
"stylesheet/main.css",
|
||||||
|
)?,
|
||||||
|
];
|
||||||
|
let additional_css_files = render_context
|
||||||
|
.dependency_manager
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.list_css()?
|
||||||
|
.map(|css_name| {
|
||||||
|
get_web_path(
|
||||||
|
render_context.config,
|
||||||
|
render_context.output_root_directory,
|
||||||
|
render_context.output_file,
|
||||||
|
format!("stylesheet/{}", css_name),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect::<Result<HashSet<_>, _>>()?;
|
||||||
|
css_files.extend(additional_css_files.into_iter());
|
||||||
|
|
||||||
|
let js_files = vec![get_web_path(
|
||||||
|
render_context.config,
|
||||||
|
render_context.output_root_directory,
|
||||||
|
render_context.output_file,
|
||||||
|
"blog_post.js",
|
||||||
|
)?];
|
||||||
|
|
||||||
|
let global_settings =
|
||||||
|
GlobalSettings::new(original.page.title.clone(), css_files, js_files);
|
||||||
|
|
||||||
|
let ret = RenderBlogPostPage {
|
||||||
|
global_settings,
|
||||||
|
page_header: Some(page_header),
|
||||||
|
title: original.page.title.clone(),
|
||||||
|
self_link: Some(link_to_blog_post),
|
||||||
|
children,
|
||||||
|
footnotes,
|
||||||
|
};
|
||||||
|
Ok(ret)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
|
|||||||
242
src/context/blog_stream.rs
Normal file
242
src/context/blog_stream.rs
Normal file
@@ -0,0 +1,242 @@
|
|||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::render;
|
||||||
|
use super::render_context::RenderContext;
|
||||||
|
use crate::context::RenderDocumentElement;
|
||||||
|
use crate::context::RenderRealFootnoteDefinition;
|
||||||
|
use crate::context::macros::push_file;
|
||||||
|
use crate::error::CustomError;
|
||||||
|
use crate::intermediate::BlogPost;
|
||||||
|
use crate::intermediate::get_web_path;
|
||||||
|
|
||||||
|
use super::GlobalSettings;
|
||||||
|
use super::PageHeader;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub(crate) struct RenderBlogStreamInput<'a, 'b> {
|
||||||
|
original: &'a [&'b BlogPost],
|
||||||
|
older_link: Option<String>,
|
||||||
|
newer_link: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, 'b> RenderBlogStreamInput<'a, 'b> {
|
||||||
|
pub(crate) fn new(
|
||||||
|
original: &'a [&'b BlogPost],
|
||||||
|
older_link: Option<String>,
|
||||||
|
newer_link: Option<String>,
|
||||||
|
) -> RenderBlogStreamInput<'a, 'b> {
|
||||||
|
RenderBlogStreamInput {
|
||||||
|
original,
|
||||||
|
older_link,
|
||||||
|
newer_link,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "type")]
|
||||||
|
#[serde(rename = "blog_stream")]
|
||||||
|
pub(crate) struct RenderBlogStream {
|
||||||
|
global_settings: GlobalSettings,
|
||||||
|
page_header: Option<PageHeader>,
|
||||||
|
children: Vec<RenderBlogStreamEntry>,
|
||||||
|
stream_pagination: Option<RenderBlogStreamPagination>,
|
||||||
|
}
|
||||||
|
|
||||||
|
render!(
|
||||||
|
RenderBlogStream,
|
||||||
|
RenderBlogStreamInput,
|
||||||
|
original,
|
||||||
|
render_context,
|
||||||
|
{
|
||||||
|
let page_header = PageHeader::new(
|
||||||
|
render_context.config.get_site_title().map(str::to_string),
|
||||||
|
Some(get_web_path(
|
||||||
|
render_context.config,
|
||||||
|
render_context.output_root_directory,
|
||||||
|
render_context.output_file,
|
||||||
|
"",
|
||||||
|
)?),
|
||||||
|
Some(get_web_path(
|
||||||
|
render_context.config,
|
||||||
|
render_context.output_root_directory,
|
||||||
|
render_context.output_file,
|
||||||
|
"about_me",
|
||||||
|
)?),
|
||||||
|
);
|
||||||
|
|
||||||
|
let children = original
|
||||||
|
.original
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.map(|(i, blog_post)| {
|
||||||
|
RenderBlogStreamEntry::new(
|
||||||
|
render_context.clone(),
|
||||||
|
&RenderBlogStreamEntryInput::new(blog_post, i),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
|
let stream_pagination = if original.older_link.is_some() || original.newer_link.is_some() {
|
||||||
|
Some(RenderBlogStreamPagination::new(
|
||||||
|
original.older_link.clone(),
|
||||||
|
original.newer_link.clone(),
|
||||||
|
)?)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut css_files = vec![
|
||||||
|
get_web_path(
|
||||||
|
render_context.config,
|
||||||
|
render_context.output_root_directory,
|
||||||
|
render_context.output_file,
|
||||||
|
"stylesheet/reset.css",
|
||||||
|
)?,
|
||||||
|
get_web_path(
|
||||||
|
render_context.config,
|
||||||
|
render_context.output_root_directory,
|
||||||
|
render_context.output_file,
|
||||||
|
"stylesheet/main.css",
|
||||||
|
)?,
|
||||||
|
];
|
||||||
|
let additional_css_files = render_context
|
||||||
|
.dependency_manager
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.list_css()?
|
||||||
|
.map(|css_name| {
|
||||||
|
get_web_path(
|
||||||
|
render_context.config,
|
||||||
|
render_context.output_root_directory,
|
||||||
|
render_context.output_file,
|
||||||
|
format!("stylesheet/{}", css_name),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect::<Result<HashSet<_>, _>>()?;
|
||||||
|
css_files.extend(additional_css_files.into_iter());
|
||||||
|
|
||||||
|
let js_files = vec![get_web_path(
|
||||||
|
render_context.config,
|
||||||
|
render_context.output_root_directory,
|
||||||
|
render_context.output_file,
|
||||||
|
"blog_post.js",
|
||||||
|
)?];
|
||||||
|
|
||||||
|
let global_settings = GlobalSettings::new(
|
||||||
|
render_context.config.get_site_title().map(str::to_string),
|
||||||
|
css_files,
|
||||||
|
js_files,
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(RenderBlogStream {
|
||||||
|
global_settings,
|
||||||
|
page_header: Some(page_header),
|
||||||
|
children,
|
||||||
|
stream_pagination,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub(crate) struct RenderBlogStreamEntryInput<'a> {
|
||||||
|
original: &'a BlogPost,
|
||||||
|
offset: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> RenderBlogStreamEntryInput<'a> {
|
||||||
|
fn new(original: &'a BlogPost, offset: usize) -> RenderBlogStreamEntryInput<'a> {
|
||||||
|
RenderBlogStreamEntryInput { original, offset }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
pub(crate) struct RenderBlogStreamEntry {
|
||||||
|
/// The title that will be shown visibly on the page.
|
||||||
|
title: Option<String>,
|
||||||
|
|
||||||
|
self_link: Option<String>,
|
||||||
|
|
||||||
|
children: Vec<RenderDocumentElement>,
|
||||||
|
|
||||||
|
footnotes: Vec<RenderRealFootnoteDefinition>,
|
||||||
|
}
|
||||||
|
|
||||||
|
render!(
|
||||||
|
RenderBlogStreamEntry,
|
||||||
|
RenderBlogStreamEntryInput,
|
||||||
|
original,
|
||||||
|
render_context,
|
||||||
|
{
|
||||||
|
let offset_string = original.offset.to_string();
|
||||||
|
let render_context = {
|
||||||
|
let mut render_context = render_context.clone();
|
||||||
|
render_context.id_addition = Some(offset_string.as_str());
|
||||||
|
render_context
|
||||||
|
};
|
||||||
|
let link_to_blog_post = get_web_path(
|
||||||
|
render_context.config,
|
||||||
|
render_context.output_root_directory,
|
||||||
|
render_context.output_file,
|
||||||
|
render_context
|
||||||
|
.config
|
||||||
|
.get_relative_path_to_post(&original.original.id),
|
||||||
|
)?;
|
||||||
|
|
||||||
|
// TODO: Should I guess an index page instead of erroring out?
|
||||||
|
let index_page = original
|
||||||
|
.original
|
||||||
|
.get_index_page()
|
||||||
|
.ok_or_else(|| format!("Blog post {} needs an index page.", original.original.id))?;
|
||||||
|
|
||||||
|
push_file!(render_context, &index_page.src, {
|
||||||
|
let title = index_page.title.clone();
|
||||||
|
|
||||||
|
let children = index_page
|
||||||
|
.children
|
||||||
|
.iter()
|
||||||
|
.map(|child| RenderDocumentElement::new(render_context.clone(), child))
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
|
let footnotes = {
|
||||||
|
let mut ret = Vec::new();
|
||||||
|
|
||||||
|
for footnote in index_page.footnotes.iter() {
|
||||||
|
ret.push(RenderRealFootnoteDefinition::new(
|
||||||
|
render_context.clone(),
|
||||||
|
footnote,
|
||||||
|
)?);
|
||||||
|
}
|
||||||
|
|
||||||
|
ret
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(RenderBlogStreamEntry {
|
||||||
|
title,
|
||||||
|
self_link: Some(link_to_blog_post),
|
||||||
|
children,
|
||||||
|
footnotes,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
pub(crate) struct RenderBlogStreamPagination {
|
||||||
|
older_link: Option<String>,
|
||||||
|
newer_link: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RenderBlogStreamPagination {
|
||||||
|
fn new(
|
||||||
|
older_link: Option<String>,
|
||||||
|
newer_link: Option<String>,
|
||||||
|
) -> Result<RenderBlogStreamPagination, CustomError> {
|
||||||
|
Ok(RenderBlogStreamPagination {
|
||||||
|
older_link,
|
||||||
|
newer_link,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,23 +1,31 @@
|
|||||||
use std::path::Path;
|
|
||||||
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::config::Config;
|
|
||||||
use crate::error::CustomError;
|
use crate::error::CustomError;
|
||||||
use crate::intermediate::IBold;
|
use crate::intermediate::IBold;
|
||||||
|
|
||||||
|
use super::RenderObject;
|
||||||
|
use super::macros::render;
|
||||||
|
use super::render_context::RenderContext;
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
#[serde(rename = "bold")]
|
#[serde(rename = "bold")]
|
||||||
pub(crate) struct RenderBold {}
|
pub(crate) struct RenderBold {
|
||||||
|
children: Vec<RenderObject>,
|
||||||
impl RenderBold {
|
post_blank: organic::types::PostBlank,
|
||||||
pub(crate) fn new(
|
|
||||||
config: &Config,
|
|
||||||
output_directory: &Path,
|
|
||||||
output_file: &Path,
|
|
||||||
comment: &IBold,
|
|
||||||
) -> Result<RenderBold, CustomError> {
|
|
||||||
Ok(RenderBold {})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
render!(RenderBold, IBold, original, render_context, {
|
||||||
|
let children = {
|
||||||
|
let mut ret = Vec::new();
|
||||||
|
for obj in original.children.iter() {
|
||||||
|
ret.push(RenderObject::new(render_context.clone(), obj)?);
|
||||||
|
}
|
||||||
|
ret
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(RenderBold {
|
||||||
|
children,
|
||||||
|
post_blank: original.post_blank,
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user