wallabago

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2017 License: GPL-3.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

wallabago

Go wrapper for the Wallabag API

Project Status

Currently supported wallabag version

2.2.1 - 2.2.3

Travis CI

Build Status

Go Report Card

Go Report Card Badge

Status of the implementation of the API calls
GET
  • GET /api/annotations/{entry}.{_format}
  • GET /api/entries.{_format}
  • GET /api/entries/exists.{_format}
  • GET /api/entries/{entry}.{_format}
  • GET /api/entries/{entry}/export.{_format}
  • GET /api/entries/{entry}/tags.{_format}
  • GET /api/tags.{_format}
  • GET /api/version.{_format}
POST
  • POST /api/annotations/{entry}.{_format}
  • POST /api/entries.{_format}
  • POST /api/entries/{entry}/tags.{_format}
PUT
  • PUT /api/annotations/{annotation}.{_format}
DELETE
  • DELETE /api/annotations/{annotation}.{_format}
  • DELETE /api/entries/{entry}.{_format}
  • DELETE /api/entries/{entry}/tags/{tag}.{_format}
  • DELETE /api/tag/label.{_format}
  • DELETE /api/tags/label.{_format}
  • DELETE /api/tags/{tag}.{_format}
PATCH
  • PATCH /api/entries/{entry}.{_format}
  • PATCH /api/entries/{entry}/reload.{_format}

Documentation

Index

Constants

View Source
const WallabagTimeLayout = "2006-01-02T15:04:05-0700"

WallabagTimeLayout is a variation of RFC3339 but without colons in the timezone delimeter, breaking the RFC

Variables

This section is empty.

Functions

func APICall added in v1.0.0

func APICall(apiURL string, httpMethod string, postData []byte) []byte

APICall authenticates to wallabag instane before issuing the HTTP request

func GetAuthTokenHeader

func GetAuthTokenHeader() string

GetAuthTokenHeader will make sure there's a working token and return a valid string to be used as an Authentication: header

func GetEntriesExists added in v1.0.0

func GetEntriesExists(bodyByteGetterFunc BodyByteGetter, urls []string) map[string]bool

GetEntriesExists queries the API for articles according to the API request /entries/exists it checks if the urls in the given array exist returns a map with the URL as key and the result as value

func GetNumberOfArchivedArticles

func GetNumberOfArchivedArticles() int

GetNumberOfArchivedArticles returns the number of archived articles in wallabag

func GetNumberOfStarredArticles

func GetNumberOfStarredArticles() int

GetNumberOfStarredArticles returns the number of starred articles in wallabag (including unread and archived starred ones)

func GetNumberOfTotalArticles

func GetNumberOfTotalArticles() int

GetNumberOfTotalArticles returns the number of all articles saved in wallabag

func PostEntry

func PostEntry(url, title, tags string, starred, archive int)

PostEntry creates a new article in wallabag

func ReadConfig

func ReadConfig(configJSON string) (err error)

ReadConfig will read the configuration from the given configJSON file and set the global Config setting with the results of the parsing

func SetConfig added in v1.0.0

func SetConfig(wbgConfig WallabagConfig)

SetConfig sets global wallabago Config

func Version

func Version(bodyStringGetterFunc BodyStringGetter) string

Version returns the version of the configured wallabag instance

Types

type Annotation added in v1.0.0

type Annotation struct {
	AnnotatorSchemaVersion string       `json:"annotator_schema_version"`
	CreatedAt              WallabagTime `json:"created_at"`
	ID                     int          `json:"id"`
	Quote                  string       `json:"quote"`
	Ranges                 []Range      `json:"ranges"`
	Text                   string       `json:"text"`
	UpdatedAt              WallabagTime `json:"updated_at"`
}

Annotation represents one annotation made to an article

type Annotations added in v1.0.0

type Annotations struct {
	Rows  []Annotation `json:"rows"`
	Total int          `json:"total"`
}

Annotations represents an annotation result API call for an article

func GetAnnotations added in v1.0.0

func GetAnnotations(bodyByteGetterFunc BodyByteGetter, articleID int) Annotations

GetAnnotations queries the API for all annotations of an article according to /api/annotations/ID

type BodyByteGetter added in v1.0.0

type BodyByteGetter func(url string, httpMethod string, postData []byte) []byte

BodyByteGetter represents a function returning the body of an HTTP response as byte array

type BodyStringGetter added in v1.0.0

type BodyStringGetter func(url string, httpMethod string, postData []byte) string

BodyStringGetter represents a function returning the body of an HTTP response as string

type Embedded

type Embedded struct {
	Items []Item `json:"items"`
}

Embedded items in the API request

type Entries

type Entries struct {
	Page      int
	Limit     int
	Pages     int
	Total     int
	NaviLinks Links    `json:"_links"`
	Embedded  Embedded `json:"_embedded"`
}

Entries represents the object being returned from the API request /entries

func GetAllEntries

func GetAllEntries() Entries

GetAllEntries calls GetEntries with no parameters, thus using the default values of the API request /entries and returning all articles, of course not all at once, but limitted to page through

func GetEntries

func GetEntries(bodyByteGetterFunc BodyByteGetter, archive int, starred int, sort string, order string, page int, perPage int, tags string) Entries

GetEntries queries the API for articles according to the API request /entries

type Item

type Item struct {
	Links       Links        `json:"_links"`
	Annotations []Annotation `json:"annotations"`
	CreatedAt   WallabagTime `json:"created_at"`
	DomainName  string       `json:"domain_name"`
	ID          int          `json:"id"`
	IsArchived  int          `json:"is_archived"`
	IsStarred   int          `json:"is_starred"`
	Mimetype    string       `json:"mimetype"`
	ReadingTime int          `json:"reading_time"`
	Tags        []Tag        `json:"tags"`
	Title       string       `json:"title"`
	UpdatedAt   WallabagTime `json:"updated_at"`
	UserEmail   string       `json:"user_email"`
	UserID      int          `json:"user_id"`
	UserName    string       `json:"user_name"`
}

Item represents individual items in API responses

func GetEntry added in v1.0.0

func GetEntry(bodyByteGetterFunc BodyByteGetter, articleID int) Item

GetEntry queries the API for a specific article according to the API request /entries/ID

type Link struct {
	Href string
}

Link object consists of its URL

type Links struct {
	Self  *Link
	First *Link
	Last  *Link
	Next  *Link
}

Links contains four links (self, first, last, next), being part of the Entries object

type Range added in v1.0.0

type Range struct {
	End         string `json:"end"`
	EndOffset   int    `json:"endOffset"`
	Start       string `json:"start"`
	StartOffset int    `json:"startOffset"`
}

Range represents the text borders of an annotation

type Tag added in v1.0.0

type Tag struct {
	ID    int    `json:"id"`
	Label string `json:"label"`
	Slug  string `json:"slug"`
}

Tag represents one tag with its properties

func GetTags added in v1.0.0

func GetTags(bodyByteGetterFunc BodyByteGetter) []Tag

GetTags queries the API for all tags in wallabag /tags

func GetTagsOfEntry added in v1.0.0

func GetTagsOfEntry(bodyByteGetterFunc BodyByteGetter, articleID int) []Tag

GetTagsOfEntry queries the API for the tags of an article /entries/ID

type Token

type Token struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int    `json:"expires_in"`
	TokenType    string `json:"token_type"`
	Scope        string
	RefreshToken string `json:"refresh_token"`
}

Token represents the object being returned from the oauth process at the API containing the access token, expire time, type of token, scope and a refresh token

type WallabagConfig

type WallabagConfig struct {
	WallabagURL  string
	ClientID     string
	ClientSecret string
	UserName     string
	UserPassword string
}

WallabagConfig contains all data needed to connect to wallabag API like URL, id and secret of the API client and user name and according password

var Config WallabagConfig

Config containing all data to access wallabag API

func NewWallabagConfig added in v1.0.0

func NewWallabagConfig(wallabagURL, clientID, clientSecret, userName, userPassword string) WallabagConfig

NewWallabagConfig initializes a new WallabagConfig

type WallabagTime

type WallabagTime struct {
	time.Time
}

WallabagTime overrides builtin time to allow for custom time parsing

func (*WallabagTime) UnmarshalJSON

func (t *WallabagTime) UnmarshalJSON(buf []byte) (err error)

UnmarshalJSON parses the custom date format wallabag returns

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL