this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: open links in new tab

+19 -6
+1 -1
internal/handler/handlers.go
··· 72 72 if len(l.Title) > 30 { 73 73 l.Title = l.Title[:30] + "..." 74 74 } 75 - content := fmt.Sprintf(`<a href="http://%s/irclink/?%d">%s</a>`, h.Config.BaseURL, l.ID, l.Title) 75 + content := fmt.Sprintf(`<a href="http://%s/irclink/?%d" target="_blank">%s</a>`, h.Config.BaseURL, l.ID, l.Title) 76 76 data := map[string]interface{}{ 77 77 "Content": template.HTML(content), 78 78 }
+5 -5
internal/service/content.go
··· 84 84 // standard embed code 85 85 // Force twitter.com domain for embed compatibility as widgets.js might not support x.com fully yet 86 86 embedURL := strings.Replace(item.URL, "x.com", "twitter.com", 1) 87 - embed := fmt.Sprintf(`<blockquote class="twitter-tweet"><a href="%s">%s</a></blockquote><script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>`, embedURL, item.Title) 87 + embed := fmt.Sprintf(`<blockquote class="twitter-tweet"><a href="%s" target="_blank">%s</a></blockquote><script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>`, embedURL, item.Title) 88 88 d.Content = template.HTML(embed) 89 89 isTwitter = true 90 90 } ··· 106 106 // This avoids server-side rate limits (HTTP 429) and speeds up response time. 107 107 // Note: We wrap it in the anchor tag in the Go code, but the onerror replaces the VIDEO tag specifically. 108 108 embed := fmt.Sprintf( 109 - `<a href="%s"><video autoplay loop muted playsinline style="max-width: 500px;" src="%s" onerror="this.onerror=null;this.outerHTML='<img src=\'%s\' style=\'max-width: 500px;\' />'"></video></a>`, 109 + `<a href="%s" target="_blank"><video autoplay loop muted playsinline style="max-width: 500px;" src="%s" onerror="this.onerror=null;this.outerHTML='<img src=\'%s\' style=\'max-width: 500px;\' />'"></video></a>`, 110 110 item.URL, videoURL, imgURL) 111 111 112 112 d.Content = template.HTML(embed) ··· 126 126 photoID := matches[1] 127 127 photoPage := fmt.Sprintf("https://www.flickr.com/photo.gne?id=%s", photoID) 128 128 // Use standard image tag but linked to photo page 129 - embed := fmt.Sprintf(`<a href="%s"><img src="%s" alt="%s" /></a>`, photoPage, item.URL, item.Title) 129 + embed := fmt.Sprintf(`<a href="%s" target="_blank"><img src="%s" alt="%s" /></a>`, photoPage, item.URL, item.Title) 130 130 d.Content = template.HTML(embed) 131 131 isFlickr = true 132 132 } ··· 137 137 138 138 if !isYoutube && !isTwitter && !isImgur && !isFlickr { 139 139 baseURL := s.Config.BaseURL 140 - content := fmt.Sprintf(`<a href="http://%s/irclink/?%d">%s</a>`, baseURL, item.ID, linkFiller) 140 + content := fmt.Sprintf(`<a href="http://%s/irclink/?%d" target="_blank">%s</a>`, baseURL, item.ID, linkFiller) 141 141 d.Content = template.HTML(content) 142 142 } 143 143 ··· 164 164 photoID := matches[1] 165 165 photoPage := fmt.Sprintf("https://www.flickr.com/photo.gne?id=%s", photoID) 166 166 // Linked Thumbnail 167 - d.Content = template.HTML(fmt.Sprintf(`<a href="%s"><img src="%s" alt="image" /></a>`, photoPage, item.URL)) 167 + d.Content = template.HTML(fmt.Sprintf(`<a href="%s" target="_blank"><img src="%s" alt="image" /></a>`, photoPage, item.URL)) 168 168 return d 169 169 } 170 170 }
+13
internal/service/content_test.go
··· 56 56 if !strings.Contains(html, tt.wantURL) { 57 57 t.Errorf("ProcessIRCLink() html = %v, want to contain %v", html, tt.wantURL) 58 58 } 59 + 59 60 // Verify it's an anchor tag 60 61 if !strings.HasPrefix(html, "<a href=") { 61 62 t.Errorf("ProcessIRCLink() html should start with anchor tag, got %v", html) 63 + } 64 + // Verify target blank 65 + if !strings.Contains(html, `target="_blank"`) { 66 + t.Errorf("ProcessIRCLink() html should contain target=_blank, got %v", html) 62 67 } 63 68 } else { 64 69 if !strings.Contains(html, tt.wantURL) { 65 70 t.Errorf("ProcessIRCLink() html = %v, want to contain %v", html, tt.wantURL) 71 + } 72 + // Verify target blank for default links too 73 + if !strings.Contains(html, `target="_blank"`) { 74 + t.Errorf("ProcessIRCLink() html should contain target=_blank, got %v", html) 66 75 } 67 76 } 68 77 }) ··· 115 124 // Verify it's an anchor tag 116 125 if !strings.HasPrefix(html, "<a href=") { 117 126 t.Errorf("ProcessImage() html should start with anchor tag, got %v", html) 127 + } 128 + // Verify target blank 129 + if !strings.Contains(html, `target="_blank"`) { 130 + t.Errorf("ProcessImage() html should contain target=_blank, got %v", html) 118 131 } 119 132 } else { 120 133 if !strings.Contains(html, tt.wantURL) {