-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add chess slides + reveal render tool (#37)
* feat: add chess slides + reveal render tool * update action; * xxx * copy images * || true * Revert "update action;" This reverts commit 6f76780. * Update .github/workflows/github-pages.yml Co-authored-by: Manfred Touron <[email protected]> * Update cmd/reveal/template.go Co-authored-by: Manfred Touron <[email protected]> --------- Co-authored-by: Manfred Touron <[email protected]>
- Loading branch information
Showing
15 changed files
with
776 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,6 @@ | |
# Editor Leftovers | ||
.vscode | ||
.idea | ||
|
||
# generated files from reveal tool | ||
slides.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Command reveal allows you to generate an HTML file, rendering a | ||
// Markdown-based reveal.js presentation. | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"os" | ||
"strings" | ||
|
||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
func main() { | ||
var es int | ||
for _, v := range os.Args[1:] { | ||
if err := convertFile(v); err != nil { | ||
fmt.Fprintf(os.Stderr, "%s: error converting: %v", err) | ||
es = 1 | ||
} | ||
} | ||
os.Exit(es) | ||
} | ||
|
||
func convertFile(fname string) error { | ||
mdSrc, err := os.ReadFile(fname) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
parts := bytes.SplitN(mdSrc, []byte("---\n"), 3) | ||
if len(parts[0]) != 0 { | ||
return fmt.Errorf("invalid front matter") | ||
} | ||
var config combinedConfig | ||
err = yaml.Unmarshal(parts[1], &config) | ||
if err != nil { | ||
return err | ||
} | ||
rd := config.renderData() | ||
rd.Presentation = string(parts[2]) | ||
newFname := stripAnySuffix(fname, ".reveal.md", ".md") + ".html" | ||
dest, err := os.Create(newFname) | ||
if err != nil { | ||
return err | ||
} | ||
defer dest.Close() | ||
if err = tpl.Execute(dest, rd); err != nil { | ||
return err | ||
} | ||
|
||
fmt.Printf("%s converted to %s\n", fname, newFname) | ||
return nil | ||
} | ||
|
||
func stripAnySuffix(s string, suffixes ...string) string { | ||
for _, suff := range suffixes { | ||
if strings.HasSuffix(s, suff) { | ||
return s[:len(s)-len(suff)] | ||
} | ||
} | ||
return s | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package main | ||
|
||
import ( | ||
_ "embed" | ||
"html/template" | ||
) | ||
|
||
// https://revealjs.com/config/ | ||
// pointers everywhere so we don't accidentally copy over stuff we don't need. | ||
type revealConfig struct { | ||
Controls *bool `yaml:"controls" json:"controls,omitempty"` | ||
ControlsTutorial *bool `yaml:"controlsTutorial" json:"controlsTutorial,omitempty"` | ||
ControlsLayout *string `yaml:"controlsLayout" json:"controlsLayout,omitempty"` | ||
ControlsBackArrows *string `yaml:"controlsBackArrows" json:"controlsBackArrows,omitempty"` | ||
Progress *bool `yaml:"progress" json:"progress,omitempty"` | ||
SlideNumber *bool `yaml:"slideNumber" json:"slideNumber,omitempty"` | ||
ShowSlideNumber *string `yaml:"showSlideNumber" json:"showSlideNumber,omitempty"` | ||
HashOneBasedIndex *bool `yaml:"hashOneBasedIndex" json:"hashOneBasedIndex,omitempty"` | ||
Hash *bool `yaml:"hash" json:"hash,omitempty"` | ||
RespondToHashChanges *bool `yaml:"respondToHashChanges" json:"respondToHashChanges,omitempty"` | ||
JumpToSlide *bool `yaml:"jumpToSlide" json:"jumpToSlide,omitempty"` | ||
History *bool `yaml:"history" json:"history,omitempty"` | ||
Keyboard *bool `yaml:"keyboard" json:"keyboard,omitempty"` | ||
KeyboardCondition *string `yaml:"keyboardCondition" json:"keyboardCondition,omitempty"` | ||
DisableLayout *bool `yaml:"disableLayout" json:"disableLayout,omitempty"` | ||
Overview *bool `yaml:"overview" json:"overview,omitempty"` | ||
Center *bool `yaml:"center" json:"center,omitempty"` | ||
Touch *bool `yaml:"touch" json:"touch,omitempty"` | ||
Loop *bool `yaml:"loop" json:"loop,omitempty"` | ||
Rtl *bool `yaml:"rtl" json:"rtl,omitempty"` | ||
NavigationMode *string `yaml:"navigationMode" json:"navigationMode,omitempty"` | ||
Shuffle *bool `yaml:"shuffle" json:"shuffle,omitempty"` | ||
Fragments *bool `yaml:"fragments" json:"fragments,omitempty"` | ||
FragmentInURL *bool `yaml:"fragmentInURL" json:"fragmentInURL,omitempty"` | ||
Embedded *bool `yaml:"embedded" json:"embedded,omitempty"` | ||
Help *bool `yaml:"help" json:"help,omitempty"` | ||
Pause *bool `yaml:"pause" json:"pause,omitempty"` | ||
ShowNotes *bool `yaml:"showNotes" json:"showNotes,omitempty"` | ||
AutoPlayMedia *bool `yaml:"autoPlayMedia" json:"autoPlayMedia,omitempty"` | ||
PreloadIframes *bool `yaml:"preloadIframes" json:"preloadIframes,omitempty"` | ||
AutoAnimate *bool `yaml:"autoAnimate" json:"autoAnimate,omitempty"` | ||
AutoAnimateMatcher *string `yaml:"autoAnimateMatcher" json:"autoAnimateMatcher,omitempty"` | ||
AutoAnimateEasing *string `yaml:"autoAnimateEasing" json:"autoAnimateEasing,omitempty"` | ||
AutoAnimateDuration *int `yaml:"autoAnimateDuration" json:"autoAnimateDuration,omitempty"` | ||
AutoAnimateUnmatched *bool `yaml:"autoAnimateUnmatched" json:"autoAnimateUnmatched,omitempty"` | ||
AutoAnimateStyles *[]string `yaml:"autoAnimateStyles" json:"autoAnimateStyles,omitempty"` | ||
AutoSlide *int `yaml:"autoSlide" json:"autoSlide,omitempty"` | ||
AutoSlideStoppable *bool `yaml:"autoSlideStoppable" json:"autoSlideStoppable,omitempty"` | ||
DefaultTiming *int `yaml:"defaultTiming" json:"defaultTiming,omitempty"` | ||
MouseWheel *bool `yaml:"mouseWheel" json:"mouseWheel,omitempty"` | ||
PreviewLinks *bool `yaml:"previewLinks" json:"previewLinks,omitempty"` | ||
PostMessage *bool `yaml:"postMessage" json:"postMessage,omitempty"` | ||
PostMessageEvents *bool `yaml:"postMessageEvents" json:"postMessageEvents,omitempty"` | ||
FocusBodyOnPageVisibilityChange *bool `yaml:"focusBodyOnPageVisibilityChange" json:"focusBodyOnPageVisibilityChange,omitempty"` | ||
Transition *string `yaml:"transition" json:"transition,omitempty"` | ||
TransitionSpeed *string `yaml:"transitionSpeed" json:"transitionSpeed,omitempty"` | ||
BackgroundTransition *string `yaml:"backgroundTransition" json:"backgroundTransition,omitempty"` | ||
PdfMaxPagesPerSlide *int `yaml:"pdfMaxPagesPerSlide" json:"pdfMaxPagesPerSlide,omitempty"` | ||
PdfSeparateFragments *bool `yaml:"pdfSeparateFragments" json:"pdfSeparateFragments,omitempty"` | ||
PdfPageHeightOffset *int `yaml:"pdfPageHeightOffset" json:"pdfPageHeightOffset,omitempty"` | ||
ViewDistance *int `yaml:"viewDistance" json:"viewDistance,omitempty"` | ||
MobileViewDistance *int `yaml:"mobileViewDistance" json:"mobileViewDistance,omitempty"` | ||
Display *string `yaml:"display" json:"display,omitempty"` | ||
HideInactiveCursor *bool `yaml:"hideInactiveCursor" json:"hideInactiveCursor,omitempty"` | ||
HideCursorTime *int `yaml:"hideCursorTime" json:"hideCursorTime,omitempty"` | ||
|
||
Width *int `yaml:"width" json:"width,omitempty"` | ||
Height *int `yaml:"height" json:"height,omitempty"` | ||
Margin *float64 `yaml:"margin" json:"margin,omitempty"` | ||
MinScale *float64 `yaml:"minScale" json:"minScale,omitempty"` | ||
MaxScale *float64 `yaml:"maxScale" json:"maxScale,omitempty"` | ||
} | ||
|
||
type combinedConfig struct { | ||
Title string `yaml:"title"` | ||
Theme string `yaml:"theme"` | ||
revealConfig `yaml:",inline"` | ||
} | ||
|
||
func (c combinedConfig) renderData() renderData { | ||
r := renderData{ | ||
Title: c.Title, | ||
Theme: c.Theme, | ||
Config: c.revealConfig, | ||
} | ||
r.ApplyDefaults() | ||
return r | ||
} | ||
|
||
type renderData struct { | ||
Title string | ||
Theme string | ||
Presentation string | ||
Config revealConfig | ||
} | ||
|
||
func (r *renderData) ApplyDefaults() { | ||
if r.Title == "" { | ||
r.Title = "Gno Presentation" | ||
} | ||
if r.Theme == "" { | ||
r.Theme = "black" | ||
} | ||
if r.Config.Hash == nil { | ||
r.Config.Hash = ptrTo(true) | ||
} | ||
if r.Config.HashOneBasedIndex == nil { | ||
r.Config.HashOneBasedIndex = ptrTo(true) | ||
} | ||
} | ||
|
||
func ptrTo[T any](v T) *T { | ||
return &v | ||
} | ||
|
||
//go:embed template.html | ||
var tplData string | ||
|
||
var tpl = template.Must(template.New("").Parse(tplData)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>{{ .Title }}</title> | ||
<link | ||
rel="stylesheet" | ||
href="https://unpkg.com/[email protected]/dist/reveal.css" | ||
/> | ||
<link | ||
rel="stylesheet" | ||
href="https://unpkg.com/[email protected]/dist/theme/{{ .Theme }}.css" | ||
/> | ||
{{/* TODO: Make configurable. */}} | ||
<link | ||
rel="stylesheet" | ||
href="https://unpkg.com/[email protected]/plugin/highlight/monokai.css" | ||
/> | ||
<style> | ||
/* While we don't currently have a theme, make it so that our headers are not shouting. */ | ||
:root { | ||
--r-heading-text-transform: none; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="reveal"> | ||
<div class="slides"> | ||
<section data-markdown> | ||
<textarea data-template>{{ .Presentation }}</textarea> | ||
</section> | ||
</div> | ||
</div> | ||
|
||
<script src="https://unpkg.com/[email protected]/dist/reveal.js"></script> | ||
<script src="https://unpkg.com/[email protected]/plugin/markdown/markdown.js"></script> | ||
<script src="https://unpkg.com/[email protected]/plugin/notes/notes.js"></script> | ||
<script src="https://unpkg.com/[email protected]/plugin/highlight/highlight.js"></script> | ||
<script> | ||
Reveal.initialize(Object.assign({ | ||
plugins: [RevealMarkdown, RevealNotes, RevealHighlight], | ||
}, {{ .Config }})); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+121 KB
...ntations/2023-09-26--chess-the-gnolang-way--morgan/bitcoin-paper-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+425 KB
presentations/2023-09-26--chess-the-gnolang-way--morgan/club-penguin.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+122 KB
presentations/2023-09-26--chess-the-gnolang-way--morgan/our-incredible-journey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.