diff --git a/public/parsing.wasm b/public/parsing.wasm index 4301d11..65a23b5 100755 Binary files a/public/parsing.wasm and b/public/parsing.wasm differ diff --git a/public/style.css b/public/style.css index e5ca63e..4a0eada 100644 --- a/public/style.css +++ b/public/style.css @@ -1176,7 +1176,7 @@ img, video { .br2, .post-content code, .post-content pre > code, .post-content pre.hmn-code { border-radius: 0.25rem; } -.br3, .edu-resource { +.br3, .edu-article .edu-resource { border-radius: 0.5rem; } .br4 { @@ -4602,7 +4602,7 @@ code, .code { .pa2, .tab, header .root-item > a, header .submenu > a { padding: 0.5rem; } -.pa3, .edu-resource, header #login-popup { +.pa3, .edu-article .edu-resource, header #login-popup { padding: 1rem; } .pa4 { @@ -7426,7 +7426,7 @@ article code { border-color: #ccc; border-color: var(--theme-color-dimmest); } -.bg--dim, .post-content code, .post-content pre > code, .post-content pre.hmn-code, .edu-resource { +.bg--dim, .post-content code, .post-content pre > code, .post-content pre.hmn-code, .edu-article .edu-resource { background-color: #f0f0f0; background-color: var(--dim-background); } @@ -8301,6 +8301,9 @@ nav.timecodes { text-align: center; margin: 10px 0; } +.edu-article .note { + color: red; } + form { margin: 0; } diff --git a/src/hmnurl/hmnurl.go b/src/hmnurl/hmnurl.go index a502944..bd02736 100644 --- a/src/hmnurl/hmnurl.go +++ b/src/hmnurl/hmnurl.go @@ -28,13 +28,13 @@ func QFromURL(u *url.URL) []Q { } var baseUrlParsed url.URL -var cacheBust string +var cacheBustVersion string var S3BaseUrl string var isTest bool func init() { SetGlobalBaseUrl(config.Config.BaseUrl) - SetCacheBust(fmt.Sprint(time.Now().Unix())) + SetCacheBustVersion(fmt.Sprint(time.Now().Unix())) SetS3BaseUrl(config.Config.DigitalOcean.AssetsPublicUrlRoot) } @@ -50,8 +50,8 @@ func SetGlobalBaseUrl(fullBaseUrl string) { baseUrlParsed = *parsed } -func SetCacheBust(newCacheBust string) { - cacheBust = newCacheBust +func SetCacheBustVersion(newCacheBustVersion string) { + cacheBustVersion = newCacheBustVersion } func SetS3BaseUrl(base string) { diff --git a/src/hmnurl/urls.go b/src/hmnurl/urls.go index a7c3d21..2789fff 100644 --- a/src/hmnurl/urls.go +++ b/src/hmnurl/urls.go @@ -837,7 +837,7 @@ func BuildPublic(filepath string, cachebust bool) string { } var query []Q if cachebust { - query = []Q{{"v", cacheBust}} + query = []Q{{"v", cacheBustVersion}} } return Url(builder.String(), query) } diff --git a/src/parsing/ggcode.go b/src/parsing/ggcode.go index 19b591e..d6bae80 100644 --- a/src/parsing/ggcode.go +++ b/src/parsing/ggcode.go @@ -63,6 +63,14 @@ var ggcodeTags = map[string]ggcodeRenderer{ } return nil }, + "note": func(w util.BufWriter, n *ggcodeNode, entering bool) error { + if entering { + w.WriteString(``) + } else { + w.WriteString(``) + } + return nil + }, } // ---------------------- diff --git a/src/rawdata/scss/_education.scss b/src/rawdata/scss/_education.scss index 13ef1ac..f3c7d71 100644 --- a/src/rawdata/scss/_education.scss +++ b/src/rawdata/scss/_education.scss @@ -1,3 +1,9 @@ -.edu-resource { - @extend .pa3, .bg--dim, .br3; +.edu-article { + .edu-resource { + @extend .pa3, .bg--dim, .br3; + } + + .note { + color: red; + } } diff --git a/src/templates/src/editor.html b/src/templates/src/editor.html index a03fd0b..dbabc5f 100644 --- a/src/templates/src/editor.html +++ b/src/templates/src/editor.html @@ -108,7 +108,7 @@ {{ end }} -
+
{{/* NOTE(asaf): Placing this outside the form to avoid submitting it to the server by accident */}} diff --git a/src/templates/src/education_article.html b/src/templates/src/education_article.html index d06a546..cb8ce9d 100644 --- a/src/templates/src/education_article.html +++ b/src/templates/src/education_article.html @@ -9,7 +9,7 @@
{{ end }}
-
+
{{ .Article.Content }}
diff --git a/src/templates/src/markdown_worker.js b/src/templates/src/markdown_worker.js index ad65130..357e925 100644 --- a/src/templates/src/markdown_worker.js +++ b/src/templates/src/markdown_worker.js @@ -1,4 +1,4 @@ -importScripts('/public/go_wasm_exec.js'); +importScripts('{{ static "go_wasm_exec.js" }}'); // wowee good javascript yeah const global = Function('return this')(); @@ -18,7 +18,7 @@ onmessage = ({ data }) => { } const go = new Go(); -WebAssembly.instantiateStreaming(fetch('/public/parsing.wasm'), go.importObject) +WebAssembly.instantiateStreaming(fetch('{{ static "parsing.wasm" }}'), go.importObject) .then(result => { go.run(result.instance); // don't await this; we want it to be continuously running wasmLoaded = true; diff --git a/src/website/education.go b/src/website/education.go index 9aafe49..ad69ea2 100644 --- a/src/website/education.go +++ b/src/website/education.go @@ -4,8 +4,10 @@ import ( "context" "errors" "fmt" + "html/template" "net/http" "net/url" + "regexp" "time" "git.handmade.network/hmn/hmn/src/db" @@ -58,6 +60,8 @@ func EducationGlossary(c *RequestContext) ResponseData { return res } +var reEduEditorsNote = regexp.MustCompile(`.*?`) + func EducationArticle(c *RequestContext) ResponseData { type articleData struct { templates.BaseData @@ -87,6 +91,11 @@ func EducationArticle(c *RequestContext) ResponseData { {Name: article.Title, Url: hmnurl.BuildEducationArticle(article.Slug)}, } + // Remove editor's notes + if c.CurrentUser == nil || !c.CurrentUser.CanAuthorEducation() { + tmpl.Article.Content = template.HTML(reEduEditorsNote.ReplaceAllLiteralString(string(tmpl.Article.Content), "")) + } + var res ResponseData res.MustWriteTemplate("education_article.html", tmpl, c.Perf) return res @@ -311,6 +320,7 @@ func getEditorDataForEduArticle( MaxFileSize: AssetMaxSize(currentUser), UploadUrl: urlContext.BuildAssetUpload(), ShowEduOptions: true, + PreviewClass: "edu-article", ParserName: "parseMarkdownEdu", } diff --git a/src/website/forums.go b/src/website/forums.go index 9feb826..dbf44ab 100644 --- a/src/website/forums.go +++ b/src/website/forums.go @@ -49,6 +49,7 @@ type editorData struct { EditInitialContents string PostReplyingTo *templates.Post ShowEduOptions bool + PreviewClass string ParserName string MaxFileSize int