Add editor's notes
This commit is contained in:
parent
9ffc64fcf3
commit
6cec54f8cc
Binary file not shown.
|
@ -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; }
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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(`<span class="note">`)
|
||||
} else {
|
||||
w.WriteString(`</span>`)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
// ----------------------
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
.edu-resource {
|
||||
@extend .pa3, .bg--dim, .br3;
|
||||
.edu-article {
|
||||
.edu-resource {
|
||||
@extend .pa3, .bg--dim, .br3;
|
||||
}
|
||||
|
||||
.note {
|
||||
color: red;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@
|
|||
</div>
|
||||
{{ end }}
|
||||
</form>
|
||||
<div id="preview-container" class="post post-preview mathjax flex-fair-ns overflow-auto mv3 mv0-ns ml3-ns pa3 br3 bg--dim">
|
||||
<div id="preview-container" class="post post-preview mathjax flex-fair-ns overflow-auto mv3 mv0-ns ml3-ns pa3 br3 bg--dim {{ .PreviewClass }}">
|
||||
<div id="preview" class="post-content"></div>
|
||||
</div>
|
||||
<input type="file" multiple name="file_input" id="file_input" class="dn" />{{/* NOTE(asaf): Placing this outside the form to avoid submitting it to the server by accident */}}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
</div>
|
||||
{{ end }}
|
||||
<div class="flex">
|
||||
<div class="flex-grow-1 post-content">
|
||||
<div class="edu-article flex-grow-1 post-content">
|
||||
{{ .Article.Content }}
|
||||
</div>
|
||||
<div class="ml3 flex-shrink-0 w5">
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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(`<span\s*class="note".*?>.*?</span>`)
|
||||
|
||||
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",
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ type editorData struct {
|
|||
EditInitialContents string
|
||||
PostReplyingTo *templates.Post
|
||||
ShowEduOptions bool
|
||||
PreviewClass string
|
||||
|
||||
ParserName string
|
||||
MaxFileSize int
|
||||
|
|
Reference in New Issue