diff --git a/handlers/outline.go b/handlers/outline.go index ecd46e9..e4af47f 100644 --- a/handlers/outline.go +++ b/handlers/outline.go @@ -10,7 +10,6 @@ import ( func NewOutlineHandler(path string, opts *ProxyOptions) fiber.Handler { return func(c *fiber.Ctx) error { - return proxychain. NewProxyChain(). WithAPIPath(path). @@ -27,6 +26,5 @@ func NewOutlineHandler(path string, opts *ProxyOptions) fiber.Handler { ). SetFiberCtx(c). Execute() - } } diff --git a/internal/cli/art.go b/internal/cli/art.go index 145be31..017bd2c 100644 --- a/internal/cli/art.go +++ b/internal/cli/art.go @@ -2,9 +2,10 @@ package cli import ( "fmt" - "golang.org/x/term" "os" "strings" + + "golang.org/x/term" ) var art string = ` diff --git a/proxychain/responsemodifers/api_content.go b/proxychain/responsemodifers/api_content.go index a428344..b664709 100644 --- a/proxychain/responsemodifers/api_content.go +++ b/proxychain/responsemodifers/api_content.go @@ -3,15 +3,16 @@ package responsemodifers import ( "bytes" "encoding/json" - "github.com/markusmobius/go-trafilatura" "io" + + "github.com/markusmobius/go-trafilatura" + "ladder/proxychain" "ladder/proxychain/responsemodifers/api" ) // APIContent creates an JSON representation of the article and returns it as an API response. func APIContent() proxychain.ResponseModification { - return func(chain *proxychain.ProxyChain) error { // we set content-type twice here, in case another response modifier // tries to forward over the original headers @@ -43,5 +44,4 @@ func APIContent() proxychain.ResponseModification { chain.Response.Body = io.NopCloser(bytes.NewReader(jsonData)) return nil } - } diff --git a/proxychain/responsemodifers/generate_readable_outline.go b/proxychain/responsemodifers/generate_readable_outline.go index 05e29b1..bfa8773 100644 --- a/proxychain/responsemodifers/generate_readable_outline.go +++ b/proxychain/responsemodifers/generate_readable_outline.go @@ -6,11 +6,12 @@ import ( "fmt" "html/template" "io" - "ladder/proxychain" "log" "net/url" "strings" + "ladder/proxychain" + "golang.org/x/net/html" "golang.org/x/net/html/atom" @@ -24,7 +25,6 @@ var templateFS embed.FS // GenerateReadableOutline creates an reader-friendly distilled representation of the article. // This is a reliable way of bypassing soft-paywalled articles, where the content is hidden, but still present in the DOM. func GenerateReadableOutline() proxychain.ResponseModification { - // get template only once, and resuse for subsequent calls f := "generate_readable_outline.html" tmpl, err := template.ParseFS(templateFS, f) @@ -33,7 +33,6 @@ func GenerateReadableOutline() proxychain.ResponseModification { } return func(chain *proxychain.ProxyChain) error { - // =========================================================== // 1. extract dom contents using reading mode algo // =========================================================== @@ -90,14 +89,13 @@ func GenerateReadableOutline() proxychain.ResponseModification { defer pw.Close() err := tmpl.Execute(pw, data) // <- render template - if err != nil { log.Printf("WARN: GenerateReadableOutline template rendering error: %s\n", err) } }() chain.Context.Set("content-type", "text/html") - chain.Response.Body = pr // <- replace reponse body reader with our new reader from pipe + chain.Response.Body = pr // <- replace response body reader with our new reader from pipe return nil } } @@ -134,7 +132,6 @@ func rewriteHrefLinks(n *html.Node, baseURL string, apiPath string) { var recurse func(*html.Node) bool recurse = func(n *html.Node) bool { - if n.Type == html.ElementNode && n.DataAtom == atom.A { for i := range n.Attr { attr := n.Attr[i]