Documentation
¶
Index ¶
- Constants
- Variables
- func Authorise(consumerKey string) (string, error)
- func CleanCRLF(inp string) string
- func CreatePDF(outputPath string, ad *ArticleDetails) (string, error)
- func FixForFileName(inp string) string
- func GenerateAuthURL(code string, redirect string) string
- func GenerateOutputFilename(outputPath string, source string) (string, error)
- func GetJSON(url string, origin string, headers map[string]string, res interface{}) error
- func LoadJSONFromFile(path string, v interface{}) error
- func PostJSON(url string, origin string, data, res interface{}) error
- func SaveJSONToFile(path string, v interface{}) error
- type AccessToken
- type ArticleDetails
- type Item
- type ItemStatus
- type Pocket2RM
- func (p *Pocket2RM) AddArticle(itemID string, pocketArticles map[string]Item)
- func (p *Pocket2RM) GeneratePDF(ad *ArticleDetails) (string, error)
- func (p *Pocket2RM) GetAccessToken()
- func (p *Pocket2RM) GetArticleDetails(articleURL string, details *ArticleDetails) error
- func (p *Pocket2RM) GetRequestToken()
- func (p *Pocket2RM) Init()
- func (p *Pocket2RM) ListFromRemarkable() (string, error)
- func (p *Pocket2RM) PullFromPocket(count int)
- type PocketCode
- type RMToken
- type RequestToken
- type RetrieveResult
Constants ¶
const APIOriginMercury = "mercury"
APIOriginMercury is the origin host for the Mercury API
const APIOriginPocket = "pocket"
APIOriginPocket contains the destination
const APIOriginRemarkable = "remarkable"
APIOriginRemarkable is the origin host for the reMarkable API
Variables ¶
var APIOrigin = map[string]string{ APIOriginPocket: "https://getpocket.com", APIOriginMercury: "https://mercury.postlight.com", APIOriginRemarkable: "", }
APIOrigin maps each origin host name
var ConfigFile = os.ExpandEnv("$HOME/.config/pocket2rm.yaml")
ConfigFile contains the default configuration file
var DatastoreFile = os.ExpandEnv("$HOME/.config/pocket2rm.db")
DatastoreFile contains the path to the SQLite3 database
var NullTime = time.Unix(0, 0)
NullTime is used to indicate an unset time.
var PocketAccessFile = os.ExpandEnv("$HOME/.config/pocket2rm.access.json")
AccessFile contains the access token file
var RMAccessFile = os.ExpandEnv("$HOME/.config/pocket2rm.access.rm.json")
AccessFile contains the access token file
Functions ¶
func CreatePDF ¶
func CreatePDF(outputPath string, ad *ArticleDetails) (string, error)
CreatePDF generates a simple PDF from the ArticleDetails
func FixForFileName ¶
FixForFileName replaces any illegal characters in the supplied string to allow it to be used as a filename.
func GenerateAuthURL ¶
GenerateAuthURL will return the URL to redirect the user to in order to authorise the app with Pocket
func GenerateOutputFilename ¶
GenerateOutputFilename returns a full output path
func LoadJSONFromFile ¶
LoadJSONFromFile loads the JSON file into the supplied interface{}
func PostJSON ¶
PostJSON creates a POST request with the supplied data, and sends it using sendJSON.
func SaveJSONToFile ¶
SaveJSONToFile dumps the supplied struct to the file in JSON format
Types ¶
type AccessToken ¶
AccessToken stores the returned access token and user name from an access call
func GetAccessToken ¶
func GetAccessToken(consumerKey string, requestToken *RequestToken) (*AccessToken, error)
GetAccessToken will retrieve an access token from Pocket
type ArticleDetails ¶
type ArticleDetails struct {
Title string `json:"title"`
Content string `json:"content"`
Author string `json:"author"`
DatePublished string `json:"date_published"`
LeadImageURL string `json:"lead_image_url"`
Dek string `json:"dek"`
URL string `json:"url"`
Domain string `json:"domain"`
Excerpt string `json:"excerpt"`
WordCount int `json:"word_count"`
Direction string `json:"direction"`
TotalPages int `json:"total_pages"`
RenderedPages int `json:"rendered_pages"`
}
ArticleDetails contains details about a URL, usually from the Mercury API
type Item ¶
type Item struct {
ItemID int `json:"item_id,string"`
ResolvedID int `json:"resolved_id,string"`
GivenURL string `json:"given_url"`
ResolvedURL string `json:"resolved_url"`
GivenTitle string `json:"given_title"`
ResolvedTitle string `json:"resolved_title"`
Favorite int `json:",string"`
Status ItemStatus `json:",string"`
Excerpt string
IsArticle int `json:"is_article,string"`
// HasImage ItemMediaAttachment `json:"has_image,string"`
// HasVideo ItemMediaAttachment `json:"has_video,string"`
WordCount int `json:"word_count,string"`
// Fields for detailed response
Tags map[string]map[string]interface{}
Authors map[string]map[string]interface{}
Images map[string]map[string]interface{}
Videos map[string]map[string]interface{}
}
Item contains all the data returned
type Pocket2RM ¶
type Pocket2RM struct {
Config *confer.Config
ConsumerKey string
RequestToken *RequestToken
AccessToken *AccessToken
RMToken *RMToken
// contains filtered or unexported fields
}
Pocket2RM contains the interface to the Pocket2RM API
func (*Pocket2RM) AddArticle ¶
AddArticle will retrieve the HTML, generate a PDF, and upload it to RM
func (*Pocket2RM) GeneratePDF ¶
func (p *Pocket2RM) GeneratePDF(ad *ArticleDetails) (string, error)
GeneratePDF creates a PDF from the supplied ArticleDetails
func (*Pocket2RM) GetAccessToken ¶
func (p *Pocket2RM) GetAccessToken()
GetAccessToken carries out an OAUTH call to Pocket to get a token
func (*Pocket2RM) GetArticleDetails ¶
func (p *Pocket2RM) GetArticleDetails(articleURL string, details *ArticleDetails) error
GetArticleDetails will use the Mercury API to retrieve details of the article, using the provided URL
func (*Pocket2RM) GetRequestToken ¶
func (p *Pocket2RM) GetRequestToken()
GetRequestToken calls into the API to get an initial request token
func (*Pocket2RM) Init ¶
func (p *Pocket2RM) Init()
Init performs any initialisation (such as loading API keys etc).
func (*Pocket2RM) ListFromRemarkable ¶
ListFromRemarkable will pull a list from the RM cloud
func (*Pocket2RM) PullFromPocket ¶
PullFromPocket retrieves a list of the articles from pocket and compares against local state.
type PocketCode ¶
type PocketCode struct {
Code string `json:"code"`
}
PocketCode contains the code returned from the first Pocket auth call.
type RMToken ¶
type RMToken struct {
Token string `json:"token"`
}
RMToken is a reMarkable access token
type RequestToken ¶
type RequestToken struct {
Code string `json:"code"`
}
RequestToken stores the initial request token
func GetRequestToken ¶
func GetRequestToken(consumerKey string) (*RequestToken, error)
GetRequestToken will retrieve a RequestToken from Pocket
type RetrieveResult ¶
RetrieveResult contains the response from a GET request
func PullArticles ¶
func PullArticles(consumerKey string, accessToken *AccessToken, count int) (*RetrieveResult, error)
PullArticles retrieves a list of articles