Skip to content

Commit

Permalink
chore(prose): revert diff code
Browse files Browse the repository at this point in the history
  • Loading branch information
neurosnap committed Sep 16, 2024
1 parent db58021 commit 11beaab
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 53 deletions.
1 change: 0 additions & 1 deletion db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions prose/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 0 additions & 7 deletions prose/html/post.page.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,6 @@
</div>
</header>
<main>
{{if .Diff}}
<details>
<summary>diff</summary>
<div class="md">{{.Diff}}</div>
</details>
{{end}}

<article class="md">
{{.Contents}}
<div id="post-footer" class="box">{{.Footer}}</div>
Expand Down
30 changes: 0 additions & 30 deletions prose/scp_hooks.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package prose

import (
"bytes"
"fmt"
"strings"

Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down
7 changes: 0 additions & 7 deletions shared/mdparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ type MetaData struct {
ImageCard string
Favicon string
Hidden bool
Live bool
}

type ParsedText struct {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 11beaab

Please sign in to comment.