- commit
- 11beaab
- parent
- db58021
- author
- Eric Bower
- date
- 2024-09-16 02:44:17 +0000 UTC
chore(prose): revert diff code
5 files changed,
+0,
-53
M
db/db.go
+0,
-1
1@@ -32,7 +32,6 @@ type User struct {
2 type PostData struct {
3 ImgPath string `json:"img_path"`
4 LastDigest *time.Time `json:"last_digest"`
5- Diff string `json:"diff"`
6 }
7
8 // Make the Attrs struct implement the driver.Valuer interface. This method
+0,
-8
1@@ -416,14 +416,6 @@ func postHandler(w http.ResponseWriter, r *http.Request) {
2 ogImageCard = parsedText.ImageCard
3 }
4
5- // if parsedText.Live {
6- if post.Data.Diff != "" {
7- str := "```diff\n" + post.Data.Diff + "\n```"
8- diffParsed, _ := shared.ParseText(str)
9- diff = diffParsed.Html
10- }
11- // }
12-
13 // track visit
14 view, err := shared.AnalyticsVisitFromRequest(r, user.ID, cfg.Secret)
15 if err == nil {
+0,
-7
1@@ -62,13 +62,6 @@
2 </div>
3 </header>
4 <main>
5- {{if .Diff}}
6- <details>
7- <summary>diff</summary>
8- <div class="md">{{.Diff}}</div>
9- </details>
10- {{end}}
11-
12 <article class="md">
13 {{.Contents}}
14 <div id="post-footer" class="box">{{.Footer}}</div>
+0,
-30
1@@ -1,7 +1,6 @@
2 package prose
3
4 import (
5- "bytes"
6 "fmt"
7 "strings"
8
9@@ -11,7 +10,6 @@ import (
10 "github.com/picosh/pico/db"
11 "github.com/picosh/pico/filehandlers"
12 "github.com/picosh/pico/shared"
13- "github.com/sergi/go-diff/diffmatchpatch"
14 )
15
16 type MarkdownHooks struct {
17@@ -48,26 +46,6 @@ func (p *MarkdownHooks) FileValidate(s ssh.Session, data *filehandlers.PostMetaD
18 return true, nil
19 }
20
21-func diffText(diffs []diffmatchpatch.Diff) string {
22- var buff bytes.Buffer
23- for _, diff := range diffs {
24- text := diff.Text
25-
26- switch diff.Type {
27- case diffmatchpatch.DiffInsert:
28- _, _ = buff.WriteString("+")
29- _, _ = buff.WriteString(text)
30- case diffmatchpatch.DiffDelete:
31- _, _ = buff.WriteString("-")
32- _, _ = buff.WriteString(text)
33- case diffmatchpatch.DiffEqual:
34- _, _ = buff.WriteString(text)
35- }
36- }
37-
38- return buff.String()
39-}
40-
41 func (p *MarkdownHooks) FileMeta(s ssh.Session, data *filehandlers.PostMetaData) error {
42 parsedText, err := shared.ParseText(data.Text)
43 if err != nil {
44@@ -84,14 +62,6 @@ func (p *MarkdownHooks) FileMeta(s ssh.Session, data *filehandlers.PostMetaData)
45 data.Tags = parsedText.Tags
46 data.Description = parsedText.Description
47
48- if data.Cur.Text == data.Text {
49- } else {
50- dmp := diffmatchpatch.New()
51- diffs := dmp.DiffMain(data.Cur.Text, data.Text, false)
52- fmt.Println(diffs)
53- data.Data.Diff = diffText(diffs)
54- }
55-
56 if parsedText.PublishAt != nil && !parsedText.PublishAt.IsZero() {
57 data.PublishAt = parsedText.MetaData.PublishAt
58 }
1@@ -40,7 +40,6 @@ type MetaData struct {
2 ImageCard string
3 Favicon string
4 Hidden bool
5- Live bool
6 }
7
8 type ParsedText struct {
9@@ -304,12 +303,6 @@ func ParseText(text string) (*ParsedText, error) {
10 }
11 parsed.MetaData.Favicon = favicon
12
13- live, err := toBool(metaData["live"])
14- if err != nil {
15- return &parsed, fmt.Errorf("front-matter field (%s): %w", "live", err)
16- }
17- parsed.MetaData.Live = live
18-
19 var publishAt *time.Time = nil
20 date, err := toString(metaData["date"])
21 if err != nil {