From ae62e543d3a1173cd39f1910cb67c95a56a7a6a4 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sat, 2 Dec 2017 21:12:03 -0800 Subject: Add Instapaper integration --- integration/instapaper/instapaper.go | 39 ++++++++++++++++++++++++++++++++++ integration/integration.go | 32 ++++++++++++++++++++++++++++ integration/pinboard/pinboard.go | 2 +- locale/translations.go | 9 +++++--- locale/translations/fr_FR.json | 5 ++++- model/integration.go | 3 +++ server/static/bin.go | 2 +- server/static/css.go | 10 ++++----- server/static/css/black.css | 1 + server/static/css/common.css | 8 ++++++- server/static/js.go | 2 +- server/template/common.go | 2 +- server/template/html/integrations.html | 35 +++++++++++++++++++++--------- server/template/views.go | 39 +++++++++++++++++++++++----------- server/ui/controller/integrations.go | 16 ++++++-------- server/ui/form/integration.go | 9 ++++++++ sql/schema_version_5.sql | 3 +++ sql/sql.go | 7 ++++-- storage/integration.go | 18 +++++++++++++--- 19 files changed, 191 insertions(+), 51 deletions(-) create mode 100644 integration/instapaper/instapaper.go create mode 100644 integration/integration.go diff --git a/integration/instapaper/instapaper.go b/integration/instapaper/instapaper.go new file mode 100644 index 0000000..c484573 --- /dev/null +++ b/integration/instapaper/instapaper.go @@ -0,0 +1,39 @@ +// Copyright 2017 Frédéric Guillot. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package instapaper + +import ( + "fmt" + "net/url" + + "github.com/miniflux/miniflux2/http" +) + +// Client represents an Instapaper client. +type Client struct { + username string + password string +} + +// AddURL sends a link to Instapaper. +func (c *Client) AddURL(link, title string) error { + values := url.Values{} + values.Add("url", link) + values.Add("title", title) + + apiURL := "https://www.instapaper.com/api/add?" + values.Encode() + client := http.NewClientWithCredentials(apiURL, c.username, c.password) + response, err := client.Get() + if response.HasServerFailure() { + return fmt.Errorf("unable to send bookmark to instapaper, status=%d", response.StatusCode) + } + + return err +} + +// NewClient returns a new Instapaper client. +func NewClient(username, password string) *Client { + return &Client{username: username, password: password} +} diff --git a/integration/integration.go b/integration/integration.go new file mode 100644 index 0000000..074ce6d --- /dev/null +++ b/integration/integration.go @@ -0,0 +1,32 @@ +// Copyright 2017 Frédéric Guillot. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package integration + +import ( + "log" + + "github.com/miniflux/miniflux2/integration/instapaper" + "github.com/miniflux/miniflux2/integration/pinboard" + "github.com/miniflux/miniflux2/model" +) + +// SendEntry send the entry to the activated providers. +func SendEntry(entry *model.Entry, integration *model.Integration) { + if integration.PinboardEnabled { + client := pinboard.NewClient(integration.PinboardToken) + err := client.AddBookmark(entry.URL, entry.Title, integration.PinboardTags, integration.PinboardMarkAsUnread) + if err != nil { + log.Println("[Pinboard]", err) + } + } + + if integration.InstapaperEnabled { + client := instapaper.NewClient(integration.InstapaperUsername, integration.InstapaperPassword) + err := client.AddURL(entry.URL, entry.Title) + if err != nil { + log.Println("[Instapaper]", err) + } + } +} diff --git a/integration/pinboard/pinboard.go b/integration/pinboard/pinboard.go index d965458..7e33065 100644 --- a/integration/pinboard/pinboard.go +++ b/integration/pinboard/pinboard.go @@ -11,7 +11,7 @@ import ( "github.com/miniflux/miniflux2/http" ) -// Client represents a Pinboard token. +// Client represents a Pinboard client. type Client struct { authToken string } diff --git a/locale/translations.go b/locale/translations.go index 49c241c..5803665 100644 --- a/locale/translations.go +++ b/locale/translations.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2017-12-02 19:31:37.042505019 -0800 PST m=+0.027446145 +// 2017-12-02 21:11:24.028184492 -0800 PST m=+0.019358340 package locale @@ -160,12 +160,15 @@ var translations = map[string]string{ "Mark bookmark as unread": "Marquer le lien comme non lu", "Pinboard Tags": "Libellés de Pinboard", "Pinboard API Token": "Jeton de sécurité de l'API de Pinboard", - "Enable Pinboard": "Activer Pinboard" + "Enable Pinboard": "Activer Pinboard", + "Enable Instapaper": "Activer Instapaper", + "Instapaper Username": "Nom d'utilisateur Instapaper", + "Instapaper Password": "Mot de passe Instapaper" } `, } var translationsChecksums = map[string]string{ "en_US": "6fe95384260941e8a5a3c695a655a932e0a8a6a572c1e45cb2b1ae8baa01b897", - "fr_FR": "fce31dfc3b8d45ee1c5d0c7aca4449553a8228a2428491e5cf5cf9e507dddb31", + "fr_FR": "17a85afeb45665dc1a74cfb1fde83e0ed4ba335a8da56a328cf20ee4baec7567", } diff --git a/locale/translations/fr_FR.json b/locale/translations/fr_FR.json index c349a99..4fb615e 100644 --- a/locale/translations/fr_FR.json +++ b/locale/translations/fr_FR.json @@ -144,5 +144,8 @@ "Mark bookmark as unread": "Marquer le lien comme non lu", "Pinboard Tags": "Libellés de Pinboard", "Pinboard API Token": "Jeton de sécurité de l'API de Pinboard", - "Enable Pinboard": "Activer Pinboard" + "Enable Pinboard": "Activer Pinboard", + "Enable Instapaper": "Activer Instapaper", + "Instapaper Username": "Nom d'utilisateur Instapaper", + "Instapaper Password": "Mot de passe Instapaper" } diff --git a/model/integration.go b/model/integration.go index 91a4595..7afa9b3 100644 --- a/model/integration.go +++ b/model/integration.go @@ -11,4 +11,7 @@ type Integration struct { PinboardToken string PinboardTags string PinboardMarkAsUnread bool + InstapaperEnabled bool + InstapaperUsername string + InstapaperPassword string } diff --git a/server/static/bin.go b/server/static/bin.go index ab92ae3..5191604 100644 --- a/server/static/bin.go +++ b/server/static/bin.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2017-12-02 19:31:37.021832102 -0800 PST m=+0.006773228 +// 2017-12-02 21:11:24.016429412 -0800 PST m=+0.007603260 package static diff --git a/server/static/css.go b/server/static/css.go index 243ba82..eab3bda 100644 --- a/server/static/css.go +++ b/server/static/css.go @@ -1,14 +1,14 @@ // Code generated by go generate; DO NOT EDIT. -// 2017-12-02 19:31:37.024320147 -0800 PST m=+0.009261273 +// 2017-12-02 21:11:24.017204599 -0800 PST m=+0.008378447 package static var Stylesheets = map[string]string{ - "black": `body{background:#222;color:#efefef}h1,h2,h3{color:#aaa}a{color:#aaa}a:focus,a:hover{color:#ddd}.header li{border-color:#333}.header a{color:#ddd;font-weight:400}.header .active a{font-weight:400;color:#9b9494}.header a:focus,.header a:hover{color:rgba(82,168,236,.85)}.page-header h1{border-color:#333}.logo a:hover span{color:#555}table,th,td{border:1px solid #555}th{background:#333;color:#aaa;font-weight:400}tr:hover{background-color:#333;color:#aaa}input[type=url],input[type=password],input[type=text]{border:1px solid #555;background:#333;color:#ccc}input[type=url]:focus,input[type=password]:focus,input[type=text]:focus{color:#efefef;border-color:rgba(82,168,236,.8);box-shadow:0 0 8px rgba(82,168,236,.6)}.button-primary{border-color:#444;background:#333;color:#efefef}.button-primary:hover,.button-primary:focus{border-color:#888;background:#555}.alert,.alert-success,.alert-error,.alert-info,.alert-normal{color:#efefef;background-color:#333;border-color:#444}.panel{background:#333;border-color:#555}.unread-counter{color:#bbb}.category{color:#efefef;background-color:#333;border-color:#444}.category a{color:#999}.category a:hover,.category a:focus{color:#aaa}.pagination a{color:#aaa}.pagination-bottom{border-color:#333}.item{border-color:#666;padding:4px}.item.current-item{border-width:2px;border-color:rgba(82,168,236,.8);box-shadow:0 0 8px rgba(82,168,236,.6)}.item-title a{font-weight:400}.item-status-read .item-title a{color:#666}.item-status-read .item-title a:focus,.item-status-read .item-title a:hover{color:rgba(82,168,236,.6)}.item-meta a:hover,.item-meta a:focus{color:#aaa}.item-meta li:after{color:#ddd}.entry header{border-color:#333}.entry header h1 a{color:#bbb}.entry-content,.entry-content p,ul{color:#999}.entry-content pre,.entry-content code{color:#fff;background:#555;border-color:#888}.entry-enclosure{border-color:#333}`, - "common": `*{margin:0;padding:0;box-sizing:border-box}body{font-family:helvetica neue,Helvetica,Arial,sans-serif;text-rendering:optimizeLegibility}main{padding-left:5px;padding-right:5px}a{color:#36c}a:focus{outline:0;color:red;text-decoration:none;border:1px dotted #aaa}a:hover{color:#333;text-decoration:none}.header{margin-top:10px;margin-bottom:20px}.header nav ul{display:none}.header li{cursor:pointer;padding-left:10px;line-height:2.1em;font-size:1.2em;border-bottom:1px dotted #ddd}.header li:hover a{color:#888}.header a{font-size:.9em;color:#444;text-decoration:none;border:0}.header .active a{font-weight:600}.header a:hover,.header a:focus{color:#888}.page-header{margin-bottom:25px}.page-header h1{font-weight:500;border-bottom:1px dotted #ddd}.page-header ul{margin-left:25px}.page-header li{list-style-type:circle;line-height:1.8em}.logo{cursor:pointer;text-align:center}.logo a{color:#000;letter-spacing:1px}.logo a:hover{color:#396}.logo a span{color:#396}.logo a:hover span{color:#000}@media(min-width:600px){body{margin:auto;max-width:750px}.logo{text-align:left;float:left;margin-right:15px}.header nav ul{display:block}.header li{display:inline;padding:0;padding-right:15px;line-height:normal;border:0;font-size:1em}.page-header ul{margin-left:0}.page-header li{display:inline;padding-right:15px}}table{width:100%;border-collapse:collapse}table,th,td{border:1px solid #ddd}th,td{padding:5px;text-align:left}td{vertical-align:top}th{background:#fcfcfc}tr:hover{background-color:#f9f9f9}.column-40{width:40%}.column-25{width:25%}.column-20{width:20%}label{cursor:pointer;display:block}.radio-group{line-height:1.9em}div.radio-group label{display:inline-block}select{margin-bottom:15px}input[type=url],input[type=password],input[type=text]{border:1px solid #ccc;padding:3px;line-height:20px;width:250px;font-size:99%;margin-bottom:10px;margin-top:5px;-webkit-appearance:none}input[type=url]:focus,input[type=password]:focus,input[type=text]:focus{color:#000;border-color:rgba(82,168,236,.8);outline:0;box-shadow:0 0 8px rgba(82,168,236,.6)}input[type=checkbox]{margin-bottom:10px}::-moz-placeholder,::-ms-input-placeholder,::-webkit-input-placeholder{color:#ddd;padding-top:2px}.form-help{font-size:.9em;color:brown;margin-bottom:15px}a.button{text-decoration:none}.button{display:inline-block;-webkit-appearance:none;-moz-appearance:none;font-size:1.1em;cursor:pointer;padding:3px 10px;border:1px solid;border-radius:unset}.button-primary{border-color:#3079ed;background:#4d90fe;color:#fff}.button-primary:hover,.button-primary:focus{border-color:#2f5bb7;background:#357ae8}.button-danger{border-color:#b0281a;background:#d14836;color:#fff}.button-danger:hover,.button-danger:focus{color:#fff;background:#c53727}.button:disabled{color:#ccc;background:#f7f7f7;border-color:#ccc}.buttons{margin-top:10px;margin-bottom:20px}.alert{padding:8px 35px 8px 14px;margin-bottom:20px;color:#c09853;background-color:#fcf8e3;border:1px solid #fbeed5;border-radius:4px;overflow:auto}.alert h3{margin-top:0;margin-bottom:15px}.alert-success{color:#468847;background-color:#dff0d8;border-color:#d6e9c6}.alert-error{color:#b94a48;background-color:#f2dede;border-color:#eed3d7}.alert-error a{color:#b94a48}.alert-info{color:#3a87ad;background-color:#d9edf7;border-color:#bce8f1}.panel{color:#333;background-color:#fcfcfc;border:1px solid #ddd;border-radius:5px;padding:10px;margin-bottom:15px}.panel h3{font-weight:500;margin-top:0;margin-bottom:20px}.panel ul{margin-left:30px}.login-form{margin:50px auto 0;max-width:280px}.unread-counter{font-size:.8em;font-weight:300;color:#666}.category{font-size:.75em;background-color:#fffcd7;border:1px solid #d5d458;border-radius:5px;margin-left:.25em;padding:1px .4em;white-space:nowrap}.category a{color:#555;text-decoration:none}.category a:hover,.category a:focus{color:#000}.pagination{font-size:1.1em;display:flex;align-items:center;padding-top:8px}.pagination-bottom{border-top:1px dotted #ddd;margin-bottom:15px;margin-top:50px}.pagination>div{flex:1}.pagination-next{text-align:right}.pagination-prev:before{content:"« "}.pagination-next:after{content:" »"}.pagination a{color:#333}.pagination a:hover,.pagination a:focus{text-decoration:none}.item{border:1px dotted #ddd;margin-bottom:20px;padding:5px;overflow:hidden}.item.current-item{border:3px solid #bce;padding:3px}.item-title a{text-decoration:none;font-weight:600}.item-status-read .item-title a{color:#777}.item-meta{color:#777;font-size:.8em}.item-meta a{color:#777;text-decoration:none}.item-meta a:hover,.item-meta a:focus{color:#333}.item-meta ul{margin-top:5px}.item-meta li{display:inline}.item-meta li:after{content:"|";color:#aaa}.item-meta li:last-child:after{content:""}.hide-read-items .item-status-read{display:none}.entry header{padding-bottom:5px;border-bottom:1px dotted #ddd}.entry header h1{font-size:2em;line-height:1.25em;margin:30px 0}.entry header h1 a{text-decoration:none;color:#333}.entry header h1 a:hover,.entry header h1 a:focus{color:#666}.entry-actions{margin-bottom:20px}.entry-meta{font-size:.95em;margin:0 0 20px;color:#666;overflow-wrap:break-word}.entry-website img{vertical-align:top}.entry-website a{color:#666;vertical-align:top;text-decoration:none}.entry-website a:hover,.entry-website a:focus{text-decoration:underline}.entry-date{font-size:.65em;font-style:italic;color:#555}.entry-content{padding-top:15px;font-size:1.2em;font-weight:300;font-family:Georgia,times new roman,Times,serif;color:#555;line-height:1.4em;overflow-wrap:break-word}.entry-content h1,h2,h3,h4,h5,h6{margin-top:15px;margin-bottom:10px}.entry-content iframe,.entry-content video,.entry-content img{max-width:100%}.entry-content figure img{border:1px solid #000}.entry-content figcaption{font-size:.75em;text-transform:uppercase;color:#777}.entry-content p{margin-top:10px;margin-bottom:15px}.entry-content a{overflow-wrap:break-word}.entry-content a:visited{color:purple}.entry-content dt{font-weight:500;margin-top:15px;color:#555}.entry-content dd{margin-left:15px;margin-top:5px;padding-left:20px;border-left:3px solid #ddd;color:#777;font-weight:300;line-height:1.4em}.entry-content blockquote{border-left:4px solid #ddd;padding-left:25px;margin-left:20px;margin-top:20px;margin-bottom:20px;color:#888;line-height:1.4em;font-family:Georgia,serif}.entry-content blockquote+p{color:#555;font-style:italic;font-weight:200}.entry-content q{color:purple;font-family:Georgia,serif;font-style:italic}.entry-content q:before{content:"“"}.entry-content q:after{content:"”"}.entry-content pre{padding:5px;background:#f0f0f0;border:1px solid #ddd;overflow:scroll;overflow-wrap:initial}.entry-content table{table-layout:fixed;max-width:100%}.entry-content ul,.entry-content ol{margin-left:30px}.entry-content ul{list-style-type:square}.entry-enclosures h3{font-weight:500}.entry-enclosure{border:1px dotted #ddd;padding:5px;margin-top:10px;max-width:100%}.entry-enclosure-download{font-size:.85em}.enclosure-video video,.enclosure-image img{max-width:100%}.confirm{font-weight:500;color:#ed2d04}.confirm a{color:#ed2d04}.loading{font-style:italic}.bookmarklet{border:1px dashed #ccc;border-radius:5px;padding:15px;margin:15px;text-align:center}.bookmarklet a{font-weight:600;text-decoration:none;font-size:1.2em}`, + "black": `body{background:#222;color:#efefef}h1,h2,h3{color:#aaa}a{color:#aaa}a:focus,a:hover{color:#ddd}.header li{border-color:#333}.header a{color:#ddd;font-weight:400}.header .active a{font-weight:400;color:#9b9494}.header a:focus,.header a:hover{color:rgba(82,168,236,.85)}.page-header h1{border-color:#333}.logo a:hover span{color:#555}table,th,td{border:1px solid #555}th{background:#333;color:#aaa;font-weight:400}tr:hover{background-color:#333;color:#aaa}input[type=url],input[type=password],input[type=text]{border:1px solid #555;background:#333;color:#ccc}input[type=url]:focus,input[type=password]:focus,input[type=text]:focus{color:#efefef;border-color:rgba(82,168,236,.8);box-shadow:0 0 8px rgba(82,168,236,.6)}.button-primary{border-color:#444;background:#333;color:#efefef}.button-primary:hover,.button-primary:focus{border-color:#888;background:#555}.alert,.alert-success,.alert-error,.alert-info,.alert-normal{color:#efefef;background-color:#333;border-color:#444}.panel{background:#333;border-color:#555;color:#9b9b9b}.unread-counter{color:#bbb}.category{color:#efefef;background-color:#333;border-color:#444}.category a{color:#999}.category a:hover,.category a:focus{color:#aaa}.pagination a{color:#aaa}.pagination-bottom{border-color:#333}.item{border-color:#666;padding:4px}.item.current-item{border-width:2px;border-color:rgba(82,168,236,.8);box-shadow:0 0 8px rgba(82,168,236,.6)}.item-title a{font-weight:400}.item-status-read .item-title a{color:#666}.item-status-read .item-title a:focus,.item-status-read .item-title a:hover{color:rgba(82,168,236,.6)}.item-meta a:hover,.item-meta a:focus{color:#aaa}.item-meta li:after{color:#ddd}.entry header{border-color:#333}.entry header h1 a{color:#bbb}.entry-content,.entry-content p,ul{color:#999}.entry-content pre,.entry-content code{color:#fff;background:#555;border-color:#888}.entry-enclosure{border-color:#333}`, + "common": `*{margin:0;padding:0;box-sizing:border-box}body{font-family:helvetica neue,Helvetica,Arial,sans-serif;text-rendering:optimizeLegibility}main{padding-left:5px;padding-right:5px}a{color:#36c}a:focus{outline:0;color:red;text-decoration:none;border:1px dotted #aaa}a:hover{color:#333;text-decoration:none}.header{margin-top:10px;margin-bottom:20px}.header nav ul{display:none}.header li{cursor:pointer;padding-left:10px;line-height:2.1em;font-size:1.2em;border-bottom:1px dotted #ddd}.header li:hover a{color:#888}.header a{font-size:.9em;color:#444;text-decoration:none;border:0}.header .active a{font-weight:600}.header a:hover,.header a:focus{color:#888}.page-header{margin-bottom:25px}.page-header h1{font-weight:500;border-bottom:1px dotted #ddd}.page-header ul{margin-left:25px}.page-header li{list-style-type:circle;line-height:1.8em}.logo{cursor:pointer;text-align:center}.logo a{color:#000;letter-spacing:1px}.logo a:hover{color:#396}.logo a span{color:#396}.logo a:hover span{color:#000}@media(min-width:600px){body{margin:auto;max-width:750px}.logo{text-align:left;float:left;margin-right:15px}.header nav ul{display:block}.header li{display:inline;padding:0;padding-right:15px;line-height:normal;border:0;font-size:1em}.page-header ul{margin-left:0}.page-header li{display:inline;padding-right:15px}}table{width:100%;border-collapse:collapse}table,th,td{border:1px solid #ddd}th,td{padding:5px;text-align:left}td{vertical-align:top}th{background:#fcfcfc}tr:hover{background-color:#f9f9f9}.column-40{width:40%}.column-25{width:25%}.column-20{width:20%}label{cursor:pointer;display:block}.radio-group{line-height:1.9em}div.radio-group label{display:inline-block}select{margin-bottom:15px}input[type=url],input[type=password],input[type=text]{border:1px solid #ccc;padding:3px;line-height:20px;width:250px;font-size:99%;margin-bottom:10px;margin-top:5px;-webkit-appearance:none}input[type=url]:focus,input[type=password]:focus,input[type=text]:focus{color:#000;border-color:rgba(82,168,236,.8);outline:0;box-shadow:0 0 8px rgba(82,168,236,.6)}input[type=checkbox]{margin-bottom:15px}::-moz-placeholder,::-ms-input-placeholder,::-webkit-input-placeholder{color:#ddd;padding-top:2px}.form-help{font-size:.9em;color:brown;margin-bottom:15px}.form-section{border-left:2px dotted #ddd;padding-left:20px;margin-left:10px}a.button{text-decoration:none}.button{display:inline-block;-webkit-appearance:none;-moz-appearance:none;font-size:1.1em;cursor:pointer;padding:3px 10px;border:1px solid;border-radius:unset}.button-primary{border-color:#3079ed;background:#4d90fe;color:#fff}.button-primary:hover,.button-primary:focus{border-color:#2f5bb7;background:#357ae8}.button-danger{border-color:#b0281a;background:#d14836;color:#fff}.button-danger:hover,.button-danger:focus{color:#fff;background:#c53727}.button:disabled{color:#ccc;background:#f7f7f7;border-color:#ccc}.buttons{margin-top:10px;margin-bottom:20px}.alert{padding:8px 35px 8px 14px;margin-bottom:20px;color:#c09853;background-color:#fcf8e3;border:1px solid #fbeed5;border-radius:4px;overflow:auto}.alert h3{margin-top:0;margin-bottom:15px}.alert-success{color:#468847;background-color:#dff0d8;border-color:#d6e9c6}.alert-error{color:#b94a48;background-color:#f2dede;border-color:#eed3d7}.alert-error a{color:#b94a48}.alert-info{color:#3a87ad;background-color:#d9edf7;border-color:#bce8f1}.panel{color:#333;background-color:#fcfcfc;border:1px solid #ddd;border-radius:5px;padding:10px;margin-bottom:15px}.panel h3{font-weight:500;margin-top:0;margin-bottom:20px}.panel ul{margin-left:30px}.login-form{margin:50px auto 0;max-width:280px}.unread-counter{font-size:.8em;font-weight:300;color:#666}.category{font-size:.75em;background-color:#fffcd7;border:1px solid #d5d458;border-radius:5px;margin-left:.25em;padding:1px .4em;white-space:nowrap}.category a{color:#555;text-decoration:none}.category a:hover,.category a:focus{color:#000}.pagination{font-size:1.1em;display:flex;align-items:center;padding-top:8px}.pagination-bottom{border-top:1px dotted #ddd;margin-bottom:15px;margin-top:50px}.pagination>div{flex:1}.pagination-next{text-align:right}.pagination-prev:before{content:"« "}.pagination-next:after{content:" »"}.pagination a{color:#333}.pagination a:hover,.pagination a:focus{text-decoration:none}.item{border:1px dotted #ddd;margin-bottom:20px;padding:5px;overflow:hidden}.item.current-item{border:3px solid #bce;padding:3px}.item-title a{text-decoration:none;font-weight:600}.item-status-read .item-title a{color:#777}.item-meta{color:#777;font-size:.8em}.item-meta a{color:#777;text-decoration:none}.item-meta a:hover,.item-meta a:focus{color:#333}.item-meta ul{margin-top:5px}.item-meta li{display:inline}.item-meta li:after{content:"|";color:#aaa}.item-meta li:last-child:after{content:""}.hide-read-items .item-status-read{display:none}.entry header{padding-bottom:5px;border-bottom:1px dotted #ddd}.entry header h1{font-size:2em;line-height:1.25em;margin:30px 0}.entry header h1 a{text-decoration:none;color:#333}.entry header h1 a:hover,.entry header h1 a:focus{color:#666}.entry-actions{margin-bottom:20px}.entry-meta{font-size:.95em;margin:0 0 20px;color:#666;overflow-wrap:break-word}.entry-website img{vertical-align:top}.entry-website a{color:#666;vertical-align:top;text-decoration:none}.entry-website a:hover,.entry-website a:focus{text-decoration:underline}.entry-date{font-size:.65em;font-style:italic;color:#555}.entry-content{padding-top:15px;font-size:1.2em;font-weight:300;font-family:Georgia,times new roman,Times,serif;color:#555;line-height:1.4em;overflow-wrap:break-word}.entry-content h1,h2,h3,h4,h5,h6{margin-top:15px;margin-bottom:10px}.entry-content iframe,.entry-content video,.entry-content img{max-width:100%}.entry-content figure img{border:1px solid #000}.entry-content figcaption{font-size:.75em;text-transform:uppercase;color:#777}.entry-content p{margin-top:10px;margin-bottom:15px}.entry-content a{overflow-wrap:break-word}.entry-content a:visited{color:purple}.entry-content dt{font-weight:500;margin-top:15px;color:#555}.entry-content dd{margin-left:15px;margin-top:5px;padding-left:20px;border-left:3px solid #ddd;color:#777;font-weight:300;line-height:1.4em}.entry-content blockquote{border-left:4px solid #ddd;padding-left:25px;margin-left:20px;margin-top:20px;margin-bottom:20px;color:#888;line-height:1.4em;font-family:Georgia,serif}.entry-content blockquote+p{color:#555;font-style:italic;font-weight:200}.entry-content q{color:purple;font-family:Georgia,serif;font-style:italic}.entry-content q:before{content:"“"}.entry-content q:after{content:"”"}.entry-content pre{padding:5px;background:#f0f0f0;border:1px solid #ddd;overflow:scroll;overflow-wrap:initial}.entry-content table{table-layout:fixed;max-width:100%}.entry-content ul,.entry-content ol{margin-left:30px}.entry-content ul{list-style-type:square}.entry-enclosures h3{font-weight:500}.entry-enclosure{border:1px dotted #ddd;padding:5px;margin-top:10px;max-width:100%}.entry-enclosure-download{font-size:.85em}.enclosure-video video,.enclosure-image img{max-width:100%}.confirm{font-weight:500;color:#ed2d04}.confirm a{color:#ed2d04}.loading{font-style:italic}.bookmarklet{border:1px dashed #ccc;border-radius:5px;padding:15px;margin:15px;text-align:center}.bookmarklet a{font-weight:600;text-decoration:none;font-size:1.2em}`, } var StylesheetsChecksums = map[string]string{ - "black": "38e7fee92187a036ce37f3c15fde2deff59a55c5ab693c7b8578af79d6a117d2", - "common": "af622cd4416dd93c3192a00c0123a37bd1880ef19d0e9f519e55c86533b10043", + "black": "a4d90d8c24bed43c38ebfa1054f7f5623423c16005843637bec59b3d98b0bcba", + "common": "4cdb7661cba3f85fbf85bac9062ee3852a131c7c176dbd7e5024640c6671e301", } diff --git a/server/static/css/black.css b/server/static/css/black.css index 793e51f..6ae0c6d 100644 --- a/server/static/css/black.css +++ b/server/static/css/black.css @@ -105,6 +105,7 @@ input[type="text"]:focus { .panel { background: #333; border-color: #555; + color: #9b9b9b; } /* Counter */ diff --git a/server/static/css/common.css b/server/static/css/common.css index b1b523d..7e0962e 100644 --- a/server/static/css/common.css +++ b/server/static/css/common.css @@ -223,7 +223,7 @@ input[type="text"]:focus { } input[type="checkbox"] { - margin-bottom: 10px; + margin-bottom: 15px; } ::-moz-placeholder, @@ -239,6 +239,12 @@ input[type="checkbox"] { margin-bottom: 15px; } +.form-section { + border-left: 2px dotted #ddd; + padding-left: 20px; + margin-left: 10px; +} + /* Buttons */ a.button { text-decoration: none; diff --git a/server/static/js.go b/server/static/js.go index a5a795f..f996746 100644 --- a/server/static/js.go +++ b/server/static/js.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2017-12-02 19:31:37.026479459 -0800 PST m=+0.011420585 +// 2017-12-02 21:11:24.018743922 -0800 PST m=+0.009917770 package static diff --git a/server/template/common.go b/server/template/common.go index e7fa6fc..586bf37 100644 --- a/server/template/common.go +++ b/server/template/common.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2017-12-02 19:31:37.041375649 -0800 PST m=+0.026316775 +// 2017-12-02 21:11:24.027142168 -0800 PST m=+0.018316016 package template diff --git a/server/template/html/integrations.html b/server/template/html/integrations.html index 8e3f872..5d33306 100644 --- a/server/template/html/integrations.html +++ b/server/template/html/integrations.html @@ -29,19 +29,34 @@ {{ end }}

Pinboard

- +
+ - - + + - - + + - + +
+ +

Instapaper

+
+ + + + + + + +
diff --git a/server/template/views.go b/server/template/views.go index 2f36c00..514c78e 100644 --- a/server/template/views.go +++ b/server/template/views.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2017-12-02 19:31:37.027317932 -0800 PST m=+0.012259058 +// 2017-12-02 21:11:24.019569008 -0800 PST m=+0.010742856 package template @@ -812,19 +812,34 @@ var templateViewsMap = map[string]string{ {{ end }}

Pinboard

- +
+ - - + + - - + + - + +
+ +

Instapaper

+
+ + + + + + + +
@@ -1145,7 +1160,7 @@ var templateViewsMapChecksums = map[string]string{ "feeds": "c22af39b42ba9ca69ea0914ca789303ec2c5b484abcd4eaa49016e365381257c", "history": "9a67599a5d8d67ef958e3f07da339b749f42892667547c9e60a54477e8d32a56", "import": "73b5112e20bfd232bf73334544186ea419505936bc237d481517a8622901878f", - "integrations": "e3cb653bf3d45fada18b64c53860fcae18a9a3f18162d42c56b290cd1aaa4e18", + "integrations": "4e51fabe73b4ee2c2268f77dbbf7987c2a176c5a5714ea29ac31986928f22b8a", "login": "04f3ce79bfa5753f69e0d956c2a8999c0da549c7925634a3e8134975da0b0e0f", "sessions": "878dbe8f8ea783b44130c495814179519fa5c3aa2666ac87508f94d58dd008bf", "settings": "ea2505b9d0a6d6bb594dba87a92079de19baa6d494f0651693a7685489fb7de9", diff --git a/server/ui/controller/integrations.go b/server/ui/controller/integrations.go index 12a7964..a3e545e 100644 --- a/server/ui/controller/integrations.go +++ b/server/ui/controller/integrations.go @@ -6,9 +6,8 @@ package controller import ( "errors" - "log" - "github.com/miniflux/miniflux2/integration/pinboard" + "github.com/miniflux/miniflux2/integration" "github.com/miniflux/miniflux2/model" "github.com/miniflux/miniflux2/server/core" "github.com/miniflux/miniflux2/server/ui/form" @@ -36,6 +35,9 @@ func (c *Controller) ShowIntegrations(ctx *core.Context, request *core.Request, PinboardToken: integration.PinboardToken, PinboardTags: integration.PinboardTags, PinboardMarkAsUnread: integration.PinboardMarkAsUnread, + InstapaperEnabled: integration.InstapaperEnabled, + InstapaperUsername: integration.InstapaperUsername, + InstapaperPassword: integration.InstapaperPassword, }, })) } @@ -85,20 +87,14 @@ func (c *Controller) SaveEntry(ctx *core.Context, request *core.Request, respons return } - integration, err := c.store.Integration(user.ID) + settings, err := c.store.Integration(user.ID) if err != nil { response.JSON().ServerError(err) return } go func() { - if integration.PinboardEnabled { - client := pinboard.NewClient(integration.PinboardToken) - err := client.AddBookmark(entry.URL, entry.Title, integration.PinboardTags, integration.PinboardMarkAsUnread) - if err != nil { - log.Println("[Pinboard]", err) - } - } + integration.SendEntry(entry, settings) }() response.JSON().Created(map[string]string{"message": "saved"}) diff --git a/server/ui/form/integration.go b/server/ui/form/integration.go index 566adae..be54e23 100644 --- a/server/ui/form/integration.go +++ b/server/ui/form/integration.go @@ -16,6 +16,9 @@ type IntegrationForm struct { PinboardToken string PinboardTags string PinboardMarkAsUnread bool + InstapaperEnabled bool + InstapaperUsername string + InstapaperPassword string } // Merge copy form values to the model. @@ -24,6 +27,9 @@ func (i IntegrationForm) Merge(integration *model.Integration) { integration.PinboardToken = i.PinboardToken integration.PinboardTags = i.PinboardTags integration.PinboardMarkAsUnread = i.PinboardMarkAsUnread + integration.InstapaperEnabled = i.InstapaperEnabled + integration.InstapaperUsername = i.InstapaperUsername + integration.InstapaperPassword = i.InstapaperPassword } // NewIntegrationForm returns a new AuthForm. @@ -33,5 +39,8 @@ func NewIntegrationForm(r *http.Request) *IntegrationForm { PinboardToken: r.FormValue("pinboard_token"), PinboardTags: r.FormValue("pinboard_tags"), PinboardMarkAsUnread: r.FormValue("pinboard_mark_as_unread") == "1", + InstapaperEnabled: r.FormValue("instapaper_enabled") == "1", + InstapaperUsername: r.FormValue("instapaper_username"), + InstapaperPassword: r.FormValue("instapaper_password"), } } diff --git a/sql/schema_version_5.sql b/sql/schema_version_5.sql index e4c597f..326562f 100644 --- a/sql/schema_version_5.sql +++ b/sql/schema_version_5.sql @@ -4,5 +4,8 @@ create table integrations ( pinboard_token text default '', pinboard_tags text default 'miniflux', pinboard_mark_as_unread bool default 'f', + instapaper_enabled bool default 'f', + instapaper_username text default '', + instapaper_password text default '', primary key(user_id) ) diff --git a/sql/sql.go b/sql/sql.go index 7ec60a5..e188131 100644 --- a/sql/sql.go +++ b/sql/sql.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2017-12-02 19:31:37.017577269 -0800 PST m=+0.002518395 +// 2017-12-02 21:11:24.01125036 -0800 PST m=+0.002424208 package sql @@ -127,6 +127,9 @@ alter table users add column entry_direction entry_sorting_direction default 'as pinboard_token text default '', pinboard_tags text default 'miniflux', pinboard_mark_as_unread bool default 'f', + instapaper_enabled bool default 'f', + instapaper_username text default '', + instapaper_password text default '', primary key(user_id) ) `, @@ -137,5 +140,5 @@ var SqlMapChecksums = map[string]string{ "schema_version_2": "e8e9ff32478df04fcddad10a34cba2e8bb1e67e7977b5bd6cdc4c31ec94282b4", "schema_version_3": "a54745dbc1c51c000f74d4e5068f1e2f43e83309f023415b1749a47d5c1e0f12", "schema_version_4": "216ea3a7d3e1704e40c797b5dc47456517c27dbb6ca98bf88812f4f63d74b5d9", - "schema_version_5": "69c0aff4d72f86a3f3c3cac33674a943d4f293dd88a8552706144814a85b5629", + "schema_version_5": "4e7958c01f15def3f8619fc5bee6f0d99e773353aeea08188f77ef089fc9d3e7", } diff --git a/storage/integration.go b/storage/integration.go index d21b618..07b67a8 100644 --- a/storage/integration.go +++ b/storage/integration.go @@ -18,7 +18,10 @@ func (s *Storage) Integration(userID int64) (*model.Integration, error) { pinboard_enabled, pinboard_token, pinboard_tags, - pinboard_mark_as_unread + pinboard_mark_as_unread, + instapaper_enabled, + instapaper_username, + instapaper_password FROM integrations WHERE user_id=$1 ` @@ -29,6 +32,9 @@ func (s *Storage) Integration(userID int64) (*model.Integration, error) { &integration.PinboardToken, &integration.PinboardTags, &integration.PinboardMarkAsUnread, + &integration.InstapaperEnabled, + &integration.InstapaperUsername, + &integration.InstapaperPassword, ) switch { case err == sql.ErrNoRows: @@ -47,8 +53,11 @@ func (s *Storage) UpdateIntegration(integration *model.Integration) error { pinboard_enabled=$1, pinboard_token=$2, pinboard_tags=$3, - pinboard_mark_as_unread=$4 - WHERE user_id=$5 + pinboard_mark_as_unread=$4, + instapaper_enabled=$5, + instapaper_username=$6, + instapaper_password=$7 + WHERE user_id=$8 ` _, err := s.db.Exec( query, @@ -56,6 +65,9 @@ func (s *Storage) UpdateIntegration(integration *model.Integration) error { integration.PinboardToken, integration.PinboardTags, integration.PinboardMarkAsUnread, + integration.InstapaperEnabled, + integration.InstapaperUsername, + integration.InstapaperPassword, integration.UserID, ) -- cgit v1.2.3