diff --git a/common/parser.go b/common/parser.go index fae73559..9b2caba6 100644 --- a/common/parser.go +++ b/common/parser.go @@ -15,6 +15,7 @@ import ( "unicode/utf8" ) +// TODO: Use the template system? // TODO: Somehow localise these? var SpaceGap = []byte(" ") var httpProtBytes = []byte("http://") @@ -44,9 +45,13 @@ var attachOpen = []byte("Attachment") var sidParam = []byte("?sid=") var stypeParam = []byte("&stype=") -var textOpen = []byte("View / Download") +/*var textShortOpen = []byte("View / Download")*/ +var textOpen = []byte("
") var urlPattern = `(?s)([ {1}])((http|https|ftp|mailto)*)(:{??)\/\/([\.a-zA-Z\/]+)([ {1}])` var urlReg *regexp.Regexp @@ -140,6 +145,7 @@ func tryStepBackward(i, step int, runes []rune) (int, bool) { } // TODO: Preparse Markdown and normalize it into HTML? +// TODO: Use a string builder func PreparseMessage(msg string) string { // TODO: Kick this check down a level into SanitiseBody? if !utf8.ValidString(msg) { @@ -717,7 +723,7 @@ func ParseMessage(msg string, sectionID int, sectionType string, settings *Parse addImage(media.URL) continue case AText: - sb.Write(textOpen) + /*sb.Write(textOpen) sb.WriteString(media.URL) sb.Write(sidParam) sid := strconv.Itoa(sectionID) @@ -733,6 +739,25 @@ func ParseMessage(msg string, sectionID int, sectionType string, settings *Parse sb.Write(textClose) i += urlLen lastItem = i + continue*/ + sb.Write(textOpen) + sb.WriteString(media.URL) + sb.Write(textOpen2) + sb.WriteString(media.URL) + sb.Write(sidParam) + sid := strconv.Itoa(sectionID) + sb.WriteString(sid) + sb.Write(stypeParam) + sb.WriteString(sectionType) + sb.Write(textOpen3) + sb.WriteString(media.URL) + sb.Write(sidParam) + sb.WriteString(sid) + sb.Write(stypeParam) + sb.WriteString(sectionType) + sb.Write(textClose) + i += urlLen + lastItem = i continue case AOther: sb.Write(attachOpen) diff --git a/parser_test.go b/parser_test.go index c85defa0..fbf493b0 100644 --- a/parser_test.go +++ b/parser_test.go @@ -252,7 +252,8 @@ func TestParser(t *testing.T) { l.Add("//"+u+"/attachs/sha256hash.png?sid=1", "") l.Add("//"+u+"/attachs/sha256hash.png?stype=forums", "") - l.Add("//"+u+"/attachs/sha256hash.txt?sid=1&stype=forums", "Attachment") + //l.Add("//"+u+"/attachs/sha256hash.txt?sid=1&stype=forums", "Attachment") + l.Add("//"+u+"/attachs/sha256hash.txt?sid=1&stype=forums", "") l.Add("//example.com/image.png", "") l.Add("https://example.com/image.png", "") diff --git a/themes/nox/public/main.css b/themes/nox/public/main.css index 1eaafd6a..7110bdad 100644 --- a/themes/nox/public/main.css +++ b/themes/nox/public/main.css @@ -932,6 +932,11 @@ red { .hide_spoil img { content: " "; } +.attach_box { + background-color: #5a5555; + border-radius: 3px; + padding: 16px; +} .update_buttons { display: flex; background-color: #444444;