Merge pull request #2 from chrishrb/fix/1-template-missing-in-binary
1 Fix template folder missing in binary bug
This commit is contained in:
9
defaults/embed.go
Normal file
9
defaults/embed.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package defaults
|
||||
|
||||
import "embed"
|
||||
|
||||
//go:embed templates
|
||||
var Templates embed.FS
|
||||
|
||||
//go:embed static
|
||||
var StaticFiles embed.FS
|
||||
@@ -1,17 +1,22 @@
|
||||
/* custom dark */
|
||||
.container {
|
||||
max-width: 896px;
|
||||
margin: 0 auto;
|
||||
@media (min-width: 940px) {
|
||||
.container {
|
||||
max-width: 896px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.container-inner {
|
||||
border-width: 1px;
|
||||
border-color: #30363d;
|
||||
border-style: solid;
|
||||
border-radius: 6px;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
.container-inner {
|
||||
padding: 32px;
|
||||
border-width: 1px;
|
||||
border-color: #30363d;
|
||||
border-style: solid;
|
||||
border-radius: 6px;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.footer {
|
||||
@@ -1,17 +1,22 @@
|
||||
/* custom light */
|
||||
.container {
|
||||
max-width: 896px;
|
||||
margin: 0 auto;
|
||||
@media (min-width: 940px) {
|
||||
.container {
|
||||
max-width: 896px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.container-inner {
|
||||
border-width: 1px;
|
||||
border-color: #d0d7de;
|
||||
border-style: solid;
|
||||
border-radius: 6px;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
.container-inner {
|
||||
padding: 32px;
|
||||
border-width: 1px;
|
||||
border-color: #d0d7de;
|
||||
border-style: solid;
|
||||
border-radius: 6px;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.footer {
|
||||
@@ -28,7 +33,8 @@
|
||||
margin: 0;
|
||||
color: #1f2328;
|
||||
background-color: #ffffff;
|
||||
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans',
|
||||
Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
|
||||
font-size: 16px;
|
||||
line-height: 1.5;
|
||||
word-wrap: break-word;
|
||||
@@ -92,9 +98,9 @@
|
||||
}
|
||||
|
||||
.markdown-body h1 {
|
||||
margin: .67em 0;
|
||||
margin: 0.67em 0;
|
||||
font-weight: 600;
|
||||
padding-bottom: .3em;
|
||||
padding-bottom: 0.3em;
|
||||
font-size: 2em;
|
||||
border-bottom: 1px solid #d1d9e0b3;
|
||||
}
|
||||
@@ -147,7 +153,7 @@
|
||||
overflow: hidden;
|
||||
background: transparent;
|
||||
border-bottom: 1px solid #d1d9e0b3;
|
||||
height: .25em;
|
||||
height: 0.25em;
|
||||
padding: 0;
|
||||
margin: 1.5rem 0;
|
||||
background-color: #d1d9e0;
|
||||
@@ -163,33 +169,33 @@
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
.markdown-body [type=button],
|
||||
.markdown-body [type=reset],
|
||||
.markdown-body [type=submit] {
|
||||
.markdown-body [type='button'],
|
||||
.markdown-body [type='reset'],
|
||||
.markdown-body [type='submit'] {
|
||||
-webkit-appearance: button;
|
||||
appearance: button;
|
||||
}
|
||||
|
||||
.markdown-body [type=checkbox],
|
||||
.markdown-body [type=radio] {
|
||||
.markdown-body [type='checkbox'],
|
||||
.markdown-body [type='radio'] {
|
||||
box-sizing: border-box;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.markdown-body [type=number]::-webkit-inner-spin-button,
|
||||
.markdown-body [type=number]::-webkit-outer-spin-button {
|
||||
.markdown-body [type='number']::-webkit-inner-spin-button,
|
||||
.markdown-body [type='number']::-webkit-outer-spin-button {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.markdown-body [type=search]::-webkit-search-cancel-button,
|
||||
.markdown-body [type=search]::-webkit-search-decoration {
|
||||
.markdown-body [type='search']::-webkit-search-cancel-button,
|
||||
.markdown-body [type='search']::-webkit-search-decoration {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
}
|
||||
|
||||
.markdown-body ::-webkit-input-placeholder {
|
||||
color: inherit;
|
||||
opacity: .54;
|
||||
opacity: 0.54;
|
||||
}
|
||||
|
||||
.markdown-body ::-webkit-file-upload-button {
|
||||
@@ -209,13 +215,13 @@
|
||||
|
||||
.markdown-body hr::before {
|
||||
display: table;
|
||||
content: "";
|
||||
content: '';
|
||||
}
|
||||
|
||||
.markdown-body hr::after {
|
||||
display: table;
|
||||
clear: both;
|
||||
content: "";
|
||||
content: '';
|
||||
}
|
||||
|
||||
.markdown-body table {
|
||||
@@ -237,25 +243,25 @@
|
||||
}
|
||||
|
||||
.markdown-body a:focus,
|
||||
.markdown-body [role=button]:focus,
|
||||
.markdown-body input[type=radio]:focus,
|
||||
.markdown-body input[type=checkbox]:focus {
|
||||
.markdown-body [role='button']:focus,
|
||||
.markdown-body input[type='radio']:focus,
|
||||
.markdown-body input[type='checkbox']:focus {
|
||||
outline: 2px solid #0969da;
|
||||
outline-offset: -2px;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.markdown-body a:focus:not(:focus-visible),
|
||||
.markdown-body [role=button]:focus:not(:focus-visible),
|
||||
.markdown-body input[type=radio]:focus:not(:focus-visible),
|
||||
.markdown-body input[type=checkbox]:focus:not(:focus-visible) {
|
||||
.markdown-body [role='button']:focus:not(:focus-visible),
|
||||
.markdown-body input[type='radio']:focus:not(:focus-visible),
|
||||
.markdown-body input[type='checkbox']:focus:not(:focus-visible) {
|
||||
outline: solid 1px transparent;
|
||||
}
|
||||
|
||||
.markdown-body a:focus-visible,
|
||||
.markdown-body [role=button]:focus-visible,
|
||||
.markdown-body input[type=radio]:focus-visible,
|
||||
.markdown-body input[type=checkbox]:focus-visible {
|
||||
.markdown-body [role='button']:focus-visible,
|
||||
.markdown-body input[type='radio']:focus-visible,
|
||||
.markdown-body input[type='checkbox']:focus-visible {
|
||||
outline: 2px solid #0969da;
|
||||
outline-offset: -2px;
|
||||
box-shadow: none;
|
||||
@@ -263,17 +269,24 @@
|
||||
|
||||
.markdown-body a:not([class]):focus,
|
||||
.markdown-body a:not([class]):focus-visible,
|
||||
.markdown-body input[type=radio]:focus,
|
||||
.markdown-body input[type=radio]:focus-visible,
|
||||
.markdown-body input[type=checkbox]:focus,
|
||||
.markdown-body input[type=checkbox]:focus-visible {
|
||||
.markdown-body input[type='radio']:focus,
|
||||
.markdown-body input[type='radio']:focus-visible,
|
||||
.markdown-body input[type='checkbox']:focus,
|
||||
.markdown-body input[type='checkbox']:focus-visible {
|
||||
outline-offset: 0;
|
||||
}
|
||||
|
||||
.markdown-body kbd {
|
||||
display: inline-block;
|
||||
padding: 0.25rem;
|
||||
font: 11px ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;
|
||||
font:
|
||||
11px ui-monospace,
|
||||
SFMono-Regular,
|
||||
SF Mono,
|
||||
Menlo,
|
||||
Consolas,
|
||||
Liberation Mono,
|
||||
monospace;
|
||||
line-height: 10px;
|
||||
color: #1f2328;
|
||||
vertical-align: middle;
|
||||
@@ -298,7 +311,7 @@
|
||||
|
||||
.markdown-body h2 {
|
||||
font-weight: 600;
|
||||
padding-bottom: .3em;
|
||||
padding-bottom: 0.3em;
|
||||
font-size: 1.5em;
|
||||
border-bottom: 1px solid #d1d9e0b3;
|
||||
}
|
||||
@@ -315,12 +328,12 @@
|
||||
|
||||
.markdown-body h5 {
|
||||
font-weight: 600;
|
||||
font-size: .875em;
|
||||
font-size: 0.875em;
|
||||
}
|
||||
|
||||
.markdown-body h6 {
|
||||
font-weight: 600;
|
||||
font-size: .85em;
|
||||
font-size: 0.85em;
|
||||
color: #59636e;
|
||||
}
|
||||
|
||||
@@ -333,7 +346,7 @@
|
||||
margin: 0;
|
||||
padding: 0 1em;
|
||||
color: #59636e;
|
||||
border-left: .25em solid #d1d9e0;
|
||||
border-left: 0.25em solid #d1d9e0;
|
||||
}
|
||||
|
||||
.markdown-body ul,
|
||||
@@ -362,14 +375,28 @@
|
||||
.markdown-body tt,
|
||||
.markdown-body code,
|
||||
.markdown-body samp {
|
||||
font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;
|
||||
font-family:
|
||||
ui-monospace,
|
||||
SFMono-Regular,
|
||||
SF Mono,
|
||||
Menlo,
|
||||
Consolas,
|
||||
Liberation Mono,
|
||||
monospace;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.markdown-body pre {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;
|
||||
font-family:
|
||||
ui-monospace,
|
||||
SFMono-Regular,
|
||||
SF Mono,
|
||||
Menlo,
|
||||
Consolas,
|
||||
Liberation Mono,
|
||||
monospace;
|
||||
font-size: 12px;
|
||||
word-wrap: normal;
|
||||
}
|
||||
@@ -394,13 +421,13 @@
|
||||
|
||||
.markdown-body::before {
|
||||
display: table;
|
||||
content: "";
|
||||
content: '';
|
||||
}
|
||||
|
||||
.markdown-body::after {
|
||||
display: table;
|
||||
clear: both;
|
||||
content: "";
|
||||
content: '';
|
||||
}
|
||||
|
||||
.markdown-body>*:first-child {
|
||||
@@ -443,11 +470,11 @@
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.markdown-body blockquote>:first-child {
|
||||
.markdown-body blockquote> :first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.markdown-body blockquote>:last-child {
|
||||
.markdown-body blockquote> :last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
@@ -492,7 +519,7 @@
|
||||
.markdown-body h5 code,
|
||||
.markdown-body h6 tt,
|
||||
.markdown-body h6 code {
|
||||
padding: 0 .2em;
|
||||
padding: 0 0.2em;
|
||||
font-size: inherit;
|
||||
}
|
||||
|
||||
@@ -526,23 +553,23 @@
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
.markdown-body ol[type="a s"] {
|
||||
.markdown-body ol[type='a s'] {
|
||||
list-style-type: lower-alpha;
|
||||
}
|
||||
|
||||
.markdown-body ol[type="A s"] {
|
||||
.markdown-body ol[type='A s'] {
|
||||
list-style-type: upper-alpha;
|
||||
}
|
||||
|
||||
.markdown-body ol[type="i s"] {
|
||||
.markdown-body ol[type='i s'] {
|
||||
list-style-type: lower-roman;
|
||||
}
|
||||
|
||||
.markdown-body ol[type="I s"] {
|
||||
.markdown-body ol[type='I s'] {
|
||||
list-style-type: upper-roman;
|
||||
}
|
||||
|
||||
.markdown-body ol[type="1"] {
|
||||
.markdown-body ol[type='1'] {
|
||||
list-style-type: decimal;
|
||||
}
|
||||
|
||||
@@ -563,7 +590,7 @@
|
||||
}
|
||||
|
||||
.markdown-body li+li {
|
||||
margin-top: .25em;
|
||||
margin-top: 0.25em;
|
||||
}
|
||||
|
||||
.markdown-body dl {
|
||||
@@ -593,7 +620,7 @@
|
||||
border: 1px solid #d1d9e0;
|
||||
}
|
||||
|
||||
.markdown-body table td>:last-child {
|
||||
.markdown-body table td> :last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
@@ -610,11 +637,11 @@
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.markdown-body img[align=right] {
|
||||
.markdown-body img[align='right'] {
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.markdown-body img[align=left] {
|
||||
.markdown-body img[align='left'] {
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
@@ -714,7 +741,7 @@
|
||||
|
||||
.markdown-body code,
|
||||
.markdown-body tt {
|
||||
padding: .2em .4em;
|
||||
padding: 0.2em 0.4em;
|
||||
margin: 0;
|
||||
font-size: 85%;
|
||||
white-space: break-spaces;
|
||||
@@ -809,11 +836,11 @@
|
||||
}
|
||||
|
||||
.markdown-body [data-footnote-ref]::before {
|
||||
content: "[";
|
||||
content: '[';
|
||||
}
|
||||
|
||||
.markdown-body [data-footnote-ref]::after {
|
||||
content: "]";
|
||||
content: ']';
|
||||
}
|
||||
|
||||
.markdown-body .footnotes {
|
||||
@@ -838,12 +865,12 @@
|
||||
|
||||
.markdown-body .footnotes li:target::before {
|
||||
position: absolute;
|
||||
top: calc(0.5rem*-1);
|
||||
right: calc(0.5rem*-1);
|
||||
bottom: calc(0.5rem*-1);
|
||||
left: calc(1.5rem*-1);
|
||||
top: calc(0.5rem * -1);
|
||||
right: calc(0.5rem * -1);
|
||||
bottom: calc(0.5rem * -1);
|
||||
left: calc(1.5rem * -1);
|
||||
pointer-events: none;
|
||||
content: "";
|
||||
content: '';
|
||||
border: 2px solid #0969da;
|
||||
border-radius: 6px;
|
||||
}
|
||||
@@ -976,8 +1003,8 @@
|
||||
color: #0a3069;
|
||||
}
|
||||
|
||||
.markdown-body [role=button]:focus:not(:focus-visible),
|
||||
.markdown-body [role=tabpanel][tabindex="0"]:focus:not(:focus-visible),
|
||||
.markdown-body [role='button']:focus:not(:focus-visible),
|
||||
.markdown-body [role='tabpanel'][tabindex='0']:focus:not(:focus-visible),
|
||||
.markdown-body button:focus:not(:focus-visible),
|
||||
.markdown-body summary:focus:not(:focus-visible),
|
||||
.markdown-body a:focus:not(:focus-visible) {
|
||||
@@ -985,7 +1012,7 @@
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.markdown-body [tabindex="0"]:focus:not(:focus-visible),
|
||||
.markdown-body [tabindex='0']:focus:not(:focus-visible),
|
||||
.markdown-body details-dialog:focus:not(:focus-visible) {
|
||||
outline: none;
|
||||
}
|
||||
@@ -993,7 +1020,7 @@
|
||||
.markdown-body g-emoji {
|
||||
display: inline-block;
|
||||
min-width: 1ch;
|
||||
font-family: "Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
|
||||
font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
||||
font-size: 1em;
|
||||
font-style: normal !important;
|
||||
font-weight: 400;
|
||||
@@ -1027,16 +1054,16 @@
|
||||
}
|
||||
|
||||
.markdown-body .task-list-item-checkbox {
|
||||
margin: 0 .2em .25em -1.4em;
|
||||
margin: 0 0.2em 0.25em -1.4em;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.markdown-body ul:dir(rtl) .task-list-item-checkbox {
|
||||
margin: 0 -1.6em .25em .2em;
|
||||
margin: 0 -1.6em 0.25em 0.2em;
|
||||
}
|
||||
|
||||
.markdown-body ol:dir(rtl) .task-list-item-checkbox {
|
||||
margin: 0 -1.6em .25em .2em;
|
||||
margin: 0 -1.6em 0.25em 0.2em;
|
||||
}
|
||||
|
||||
.markdown-body .contains-task-list:hover .task-list-item-convert-container,
|
||||
@@ -1056,14 +1083,14 @@
|
||||
padding: 0.5rem 1rem;
|
||||
margin-bottom: 1rem;
|
||||
color: inherit;
|
||||
border-left: .25em solid #d1d9e0;
|
||||
border-left: 0.25em solid #d1d9e0;
|
||||
}
|
||||
|
||||
.markdown-body .markdown-alert>:first-child {
|
||||
.markdown-body .markdown-alert> :first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.markdown-body .markdown-alert>:last-child {
|
||||
.markdown-body .markdown-alert> :last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
@@ -1117,4 +1144,3 @@
|
||||
.markdown-body>*:first-child>.heading-element:first-child {
|
||||
margin-top: 0 !important;
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
@@ -10,6 +10,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/chroma/v2/quick"
|
||||
"github.com/chrishrb/go-grip/defaults"
|
||||
"github.com/gomarkdown/markdown"
|
||||
"github.com/gomarkdown/markdown/ast"
|
||||
"github.com/gomarkdown/markdown/html"
|
||||
@@ -187,7 +188,7 @@ func renderHookListItem(w io.Writer, node ast.Node, entering bool) (ast.WalkStat
|
||||
|
||||
func createBlockquoteStart(alert string) (string, error) {
|
||||
lp := filepath.Join("templates/alert", fmt.Sprintf("%s.html", alert))
|
||||
tmpl, err := template.ParseFiles(lp)
|
||||
tmpl, err := template.ParseFS(defaults.Templates, lp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"text/template"
|
||||
|
||||
"github.com/aarol/reload"
|
||||
"github.com/chrishrb/go-grip/defaults"
|
||||
)
|
||||
|
||||
type htmlStruct struct {
|
||||
@@ -20,11 +21,15 @@ type htmlStruct struct {
|
||||
}
|
||||
|
||||
func (client *Client) Serve(file string) error {
|
||||
reload := reload.New("./")
|
||||
directory := filepath.Dir(file)
|
||||
filename := filepath.Base(file)
|
||||
|
||||
reload := reload.New(directory)
|
||||
reload.Log = log.New(io.Discard, "", 0)
|
||||
|
||||
dir := http.Dir("./")
|
||||
dir := http.Dir(directory)
|
||||
chttp := http.NewServeMux()
|
||||
chttp.Handle("/static/", http.FileServer(http.FS(defaults.StaticFiles)))
|
||||
chttp.Handle("/", http.FileServer(dir))
|
||||
|
||||
// Regex for markdown
|
||||
@@ -69,7 +74,7 @@ func (client *Client) Serve(file string) error {
|
||||
addr, _ = url.JoinPath(addr, readme)
|
||||
}
|
||||
} else {
|
||||
addr, _ = url.JoinPath(addr, file)
|
||||
addr, _ = url.JoinPath(addr, filename)
|
||||
}
|
||||
|
||||
fmt.Printf("🚀 Starting server: %s\n", addr)
|
||||
@@ -103,8 +108,7 @@ func readToString(dir http.Dir, filename string) ([]byte, error) {
|
||||
|
||||
func serveTemplate(w http.ResponseWriter, html htmlStruct) error {
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
lp := filepath.Join("templates", "layout.html")
|
||||
tmpl, err := template.ParseFiles(lp)
|
||||
tmpl, err := template.ParseFS(defaults.Templates, "templates/layout.html")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user