diff --git a/db/db.go b/db/db.go index 855f6fa..bc8316b 100644 --- a/db/db.go +++ b/db/db.go @@ -32,7 +32,6 @@ type User struct { type PostData struct { ImgPath string `json:"img_path"` LastDigest *time.Time `json:"last_digest"` - Diff string `json:"diff"` } // Make the Attrs struct implement the driver.Valuer interface. This method diff --git a/prose/api.go b/prose/api.go index 19c4e35..67f3747 100644 --- a/prose/api.go +++ b/prose/api.go @@ -416,14 +416,6 @@ func postHandler(w http.ResponseWriter, r *http.Request) { ogImageCard = parsedText.ImageCard } - // if parsedText.Live { - if post.Data.Diff != "" { - str := "```diff\n" + post.Data.Diff + "\n```" - diffParsed, _ := shared.ParseText(str) - diff = diffParsed.Html - } - // } - // track visit view, err := shared.AnalyticsVisitFromRequest(r, user.ID, cfg.Secret) if err == nil { diff --git a/prose/html/post.page.tmpl b/prose/html/post.page.tmpl index e667978..53f9ff5 100644 --- a/prose/html/post.page.tmpl +++ b/prose/html/post.page.tmpl @@ -62,13 +62,6 @@
- {{if .Diff}} -
- diff -
{{.Diff}}
-
- {{end}} -
{{.Contents}}
{{.Footer}}
diff --git a/prose/scp_hooks.go b/prose/scp_hooks.go index 707bb61..577790c 100644 --- a/prose/scp_hooks.go +++ b/prose/scp_hooks.go @@ -1,7 +1,6 @@ package prose import ( - "bytes" "fmt" "strings" @@ -11,7 +10,6 @@ import ( "github.com/picosh/pico/db" "github.com/picosh/pico/filehandlers" "github.com/picosh/pico/shared" - "github.com/sergi/go-diff/diffmatchpatch" ) type MarkdownHooks struct { @@ -48,26 +46,6 @@ func (p *MarkdownHooks) FileValidate(s ssh.Session, data *filehandlers.PostMetaD return true, nil } -func diffText(diffs []diffmatchpatch.Diff) string { - var buff bytes.Buffer - for _, diff := range diffs { - text := diff.Text - - switch diff.Type { - case diffmatchpatch.DiffInsert: - _, _ = buff.WriteString("+") - _, _ = buff.WriteString(text) - case diffmatchpatch.DiffDelete: - _, _ = buff.WriteString("-") - _, _ = buff.WriteString(text) - case diffmatchpatch.DiffEqual: - _, _ = buff.WriteString(text) - } - } - - return buff.String() -} - func (p *MarkdownHooks) FileMeta(s ssh.Session, data *filehandlers.PostMetaData) error { parsedText, err := shared.ParseText(data.Text) if err != nil { @@ -84,14 +62,6 @@ func (p *MarkdownHooks) FileMeta(s ssh.Session, data *filehandlers.PostMetaData) data.Tags = parsedText.Tags data.Description = parsedText.Description - if data.Cur.Text == data.Text { - } else { - dmp := diffmatchpatch.New() - diffs := dmp.DiffMain(data.Cur.Text, data.Text, false) - fmt.Println(diffs) - data.Data.Diff = diffText(diffs) - } - if parsedText.PublishAt != nil && !parsedText.PublishAt.IsZero() { data.PublishAt = parsedText.MetaData.PublishAt } diff --git a/shared/mdparser.go b/shared/mdparser.go index 1ddf0b1..54f234b 100644 --- a/shared/mdparser.go +++ b/shared/mdparser.go @@ -40,7 +40,6 @@ type MetaData struct { ImageCard string Favicon string Hidden bool - Live bool } type ParsedText struct { @@ -304,12 +303,6 @@ func ParseText(text string) (*ParsedText, error) { } parsed.MetaData.Favicon = favicon - live, err := toBool(metaData["live"]) - if err != nil { - return &parsed, fmt.Errorf("front-matter field (%s): %w", "live", err) - } - parsed.MetaData.Live = live - var publishAt *time.Time = nil date, err := toString(metaData["date"]) if err != nil {