Skip to content

Commit

Permalink
Provide initial implementation of cheatsheet concept
Browse files Browse the repository at this point in the history
Signed-off-by: lucperkins <lucperkins@gmail.com>
  • Loading branch information
lucperkins committed Jul 23, 2019
1 parent 8b85669 commit 61210c2
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 0 deletions.
3 changes: 3 additions & 0 deletions content/cheatsheet/forbidden-thing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- rule: forbid_something
desc: This thing shouldn't happen
condition: not thing in (allowed_thing, other_allowed_thing)
1 change: 1 addition & 0 deletions content/cheatsheet/other-thing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
key: value
6 changes: 6 additions & 0 deletions content/docs/cheatsheet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Falco Cheatsheet
draft: true
---

{{< cheatsheet >}}
4 changes: 4 additions & 0 deletions data/cheatsheet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
forbidden-thing:
title: Do a thing
other-thing:
title: Some other thing
27 changes: 27 additions & 0 deletions themes/falco-fresh/assets/cheatsheet.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.cheatsheet
display: flex

+desktop
flex-flow: row nowrap
+mobile
flex-flow: column nowrap

flex-flow: row nowrap
justify-content: space-between

.cheat
padding: 1rem
background-color: $light

+desktop
width: calc(50% - .25rem)
+mobile
width: 100%

& + .cheat
margin-top: 1rem

&-title
font-size: 1.25rem
font-weight: 700

1 change: 1 addition & 0 deletions themes/falco-fresh/assets/style.sass
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ $colors: mergeColorMaps(("twitter-blue": ($twitter-blue, $white)), $colors)
@import "bulma-dashboard/src/bulma-dashboard"

@import "toc"
@import "cheatsheet"

.is-cncf-logo
margin-top: 2rem
Expand Down
8 changes: 8 additions & 0 deletions themes/falco-fresh/layouts/shortcodes/cheat.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{ $key := .Get 0 }}
{{ $cheat := index site.Data.cheatsheet $key }}
{{ $title := $cheat.title }}
{{ $file := printf "cheatsheet/%s.yaml" $key }}
{{ $yaml := readFile $file }}
<h2>{{ $title }}</h2>

{{ highlight $yaml "yaml" "" }}
14 changes: 14 additions & 0 deletions themes/falco-fresh/layouts/shortcodes/cheatsheet.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{ $cheats := site.Data.cheatsheet }}
<div class="cheatsheet">
{{ range $k, $v := $cheats }}
{{ $yaml := readFile (printf "cheatsheet/%s.yaml" $k) }}
{{ $title := $v.title | markdownify }}
<div class="cheat">
<p class="cheat-title">
{{ $title }}
</p>

{{ highlight $yaml "yaml" "" }}
</div>
{{ end }}
</div>

0 comments on commit 61210c2

Please sign in to comment.