sako

package module
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

README

sako

Build status GoDoc

sako ("bag" in Esperanto) is a Wallabag-compatible set of tools for your local sako instance.

sako-logo

The sako logo is from Egon Elbre (under the under CC0 license.)

sako ships with a couple of commands:

  • sako-mgr to manage a local sako instance
  • sako-mgr import to import articles, tags, annotations and tagging rules from a Wallabag instance
  • sako-srv to serve a local sako instance (with a WIP Web UI and Wallabag-compatible REST API)

Example

Initialization
$> go install git.sr.ht/~sbinet/sako/cmd/sako-mgr@latest
$> export SAKO_ROOT=/path/to/sako/data-dir
$> sako-mgr init -pass SomeS3cr3t -root ${SAKO_ROOT}

## adding a local user
$> sako-mgr user-add -user bob -pass s3cr3t -email bob@example.org ${SAKO_ROOT}

## adding a sako-client (for use with the sako REST API)
$> sako-mgr client-add -user bob -client-name 'my sako client' ${SAKO_ROOT}
client for user "bob" created:
client-id=1_<somehash>
client-secret=<some-other-hash>

## importing data from a remote Wallabag instance
$> sako-mgr import \
    -src-uri https://wallabag.example.org     \
    -src-usr bob-on-wallabag                  \
    -src-pwd bob-pwd-on-wallabag              \
    -src-api-id ${WALLABAG_CLIENT_ID}         \
    -src-api-secret ${WALLABAG_CLIENT_SECRET} \
    -dst-uri ${SAKO_ROOT}                     \
    -dst-usr bob                              \
    -dst-pwd s3cr3t

## using sako:
$> go install git.sr.ht/~sbinet/sako/cmd/sako-srv@latest
$> sako-srv -addr :8080 -dir ${SAKO_ROOT}
Screenshots

sako-login sako-home sako-config-account sako-config-settings sako-config-rules sako-config-clients sako-all-articles sako-view-article

Commands

sako-mgr
$> sako-mgr help
sako-mgr - manages a sako server

Commands:

    client-add  creates a new client for an existing user of the sako system
    client-rm   removes an existing user's client from the sako system
    import      imports data from a wallabag account into a sako account
    init        initializes a sako server
    user-add    creates a new user for the sako system
    user-rm     removes a user from the sako system

Use "sako-mgr help <command>" for more information about a command.
sako-srv
$> Usage of sako-srv:
  -addr string
    	[host]:port to serve (default ":8080")
  -dir string
    	path to sako repository

License

Documentation

Overview

Package sako provides access to the Wallabag API

Index

Constants

View Source
const (
	AppName = "sako"
	Version = "0.1.0"

	WallabagAPI = "2.6.9"
)

Variables

View Source
var (
	// ErrNotAuthenticated is the error returned when a sako client is not
	// authenticated and a request that needed authentication was issued.
	ErrNotAuthenticated = errors.New("client not authenticated")

	// ErrUserNotExist is the error returned when operations for or about
	// a non-existing user are attempted.
	ErrUserNotExist = errors.New("user does not exist")

	ErrUserAlreadyExists = errors.New("user already exists")

	// ErrEntryNotExist is the error returned when a non existing entry
	// is requested.
	ErrEntryNotExist = errors.New("entry does not exist")

	// ErrTagNotExist is the error returned when a non existing tag
	// is requested.
	ErrTagNotExist = errors.New("tag does not exist")

	// ErrAnnotationNotExist is the error returned when a non existing
	// annotation is requested.
	ErrAnnotationNotExist = errors.New("annotation does not exist")

	// ErrEmptySearchTerm is the error returned when an empty search
	// is requested.
	ErrEmptySearchTerm = errors.New("empty search term")
)

Functions

func Hash

func Hash(v string) string

Types

type Annotation

type Annotation struct {
	ID            AnnotationID
	SchemaVersion string

	CreatedAt time.Time
	UpdatedAt time.Time

	Quote string
	Text  string

	Ranges []Range

	User string
}

Annotation represents one annotation made to an article.

type AnnotationID

type AnnotationID int64 // AnnotationID holds the unique ID for an annotation.

type ClientAuth

type ClientAuth struct {
	ID     string // ID is the oauth2 credentials identity
	Secret string // Secret is the oauth2 secret used for these credentials
	Name   string // Name describes the credentials
}

ClientAuth stores the user's OAuth2-like authentication credentials.

type Config

type Config struct {
	ID                int     `json:"id"`
	ItemsPerPage      int     `json:"items_per_page"`
	Language          string  `json:"language"`
	FeedToken         string  `json:"feed_token"`
	FeedLimit         int     `json:"feed_limit"`
	ReadingSpeed      float64 `json:"reading_speed"`
	ActionMarkAsRead  int     `json:"action_mark_as_read"`
	ListMode          int     `json:"list_mode"`
	DisplayThumbnails int     `json:"display_thumbnails"`
}

Config stores informations about a sako user account.

type Entry

type Entry struct {
	ID    EntryID
	UID   string
	Title string

	URL            string
	OriginURL      string
	GivenURL       string
	HashedGivenURL string
	HashedURL      string
	DomainName     string

	Tags        []Tag
	Annotations []Annotation

	Content    string
	IsArchived bool
	IsPublic   bool
	IsStarred  bool

	ArchivedAt  time.Time
	CreatedAt   time.Time
	UpdatedAt   time.Time
	StarredAt   time.Time
	PublishedAt time.Time
	PublishedBy []string

	Language       string
	Mimetype       string
	PreviewPicture string
	ReadingTime    int

	Status  string
	Headers map[string]string

	UserEmail string
	UserID    UserID
	UserName  string
}

Entry is an article in a sako user portfolio.

type EntryID

type EntryID int64 // EntryID holds the unique ID for an entry.

type Filter added in v0.3.0

type Filter struct {
	Archived Value[bool]      // filter by archived status. all entries by default.
	Starred  Value[bool]      // filter by starred status. all entries by default.
	Sort     Value[string]    // sort entries by date.
	Order    Value[string]    // order of sort.
	Page     Value[int64]     // page one wants.
	PerPage  Value[int64]     // number of results per page.
	Tags     Value[[]string]  // list of tags. Will returns entries that matches ALL tags.
	Since    Value[time.Time] // The timestamp since when you want entries updated.
	Public   Value[bool]      // filter by entries with a public link. all entries by default
	Detailed Value[bool]      // include content field if 'full'. 'full' by default for backward compatibility.
	Domain   Value[string]    // filter entries with the given domain name
}

func FilterFrom added in v0.3.0

func FilterFrom(opts ...FilterOptions) (*Filter, error)

func FilterFromQuery added in v0.3.0

func FilterFromQuery(qry url.Values) *Filter

func NewFilter added in v0.3.0

func NewFilter() *Filter

func (*Filter) Encode added in v0.3.0

func (f *Filter) Encode(q url.Values) string

func (*Filter) Filter added in v0.3.0

func (f *Filter) Filter() FilterOptions

type FilterOptions

type FilterOptions func(opt *Filter) error

func EntriesArchived

func EntriesArchived(v bool) FilterOptions

func EntriesPublic

func EntriesPublic(v bool) FilterOptions

func EntriesSince

func EntriesSince(v time.Time) FilterOptions

func EntriesStarred

func EntriesStarred(v bool) FilterOptions

func EntriesWithDomain

func EntriesWithDomain(name string) FilterOptions

func EntriesWithSortCriteria

func EntriesWithSortCriteria(v string) FilterOptions

criteria = created | updated | archived

func EntriesWithSortOrder

func EntriesWithSortOrder(v string) FilterOptions

order = desc | asc

func EntriesWithTags

func EntriesWithTags(tags ...string) FilterOptions

func WithDetailedEntries

func WithDetailedEntries(v bool) FilterOptions

type Info

type Info struct {
	Name    string `json:"appname"`
	Version string `json:"version"`

	AllowedRegistration bool `json:"allowed_registration"`
}

Info stores informations about a sako/wallabag server.

type Pos

type Pos struct {
	Cursor string
	Offset int
}

Pos models the position in a document.

type Range

type Range struct {
	Beg Pos
	End Pos
}

Range holds the [beginning, end) position of an annotation in a document.

type Search struct {
	Term    Value[string] // Query term.
	Page    Value[int64]  // page one wants.
	PerPage Value[int64]  // number of results per page.
}

func NewSearch added in v0.3.0

func NewSearch() *Search

func SearchFromFilter added in v0.3.0

func SearchFromFilter(opts ...SearchOptions) (*Search, error)

func SearchFromQuery added in v0.3.0

func SearchFromQuery(qry url.Values) *Search

func (*Search) Encode added in v0.3.0

func (s *Search) Encode(q url.Values) string

func (*Search) Filter added in v0.3.0

func (s *Search) Filter() SearchOptions

type SearchOptions added in v0.3.0

type SearchOptions func(opt *Search) error

func WithSearch added in v0.3.0

func WithSearch(term string) SearchOptions

type Tag

type Tag struct {
	ID    TagID
	Label string
	Slug  string
}

Tag is a user-defined tag. A tag can be associated with multiple articles.

type TagID

type TagID int64 // TagID holds the unique ID for a tag.

type TaggingRule

type TaggingRule struct {
	ID   TaggingRuleID `json:"-"`
	Rule string        `json:"rule"`
	Tags []string      `json:"tags"`
}

type TaggingRuleID

type TaggingRuleID int64 // TaggingRuleID holds the unique ID for a tagging rule.

type Token added in v0.2.0

type Token struct {
	AccessToken  string
	ExpiresAt    time.Time
	RefreshToken string
	Scope        string
	TokenType    string
}

Token holds authentication informations.

type User

type User struct {
	ID        UserID
	User      string
	Email     string
	Name      string
	CreatedAt time.Time
	UpdatedAt time.Time
	Client    ClientAuth
}

User represents a sako account.

type UserID

type UserID int64 // UserID holds the unique ID for a user.

type Value

type Value[T any] struct {
	V     T
	Valid bool
}

func NewValue

func NewValue[T any](v T) Value[T]

func (Value[T]) Get

func (v Value[T]) Get() (T, bool)

func (*Value[T]) Set

func (v *Value[T]) Set(o T)

Directories

Path Synopsis
cmd
sako-mgr
Command sako-import imports data from a wallabag endpoint.
Command sako-import imports data from a wallabag endpoint.
sako-srv
Command sako-srv provides a sako API endpoint and a sako web server.
Command sako-srv provides a sako API endpoint and a sako web server.
internal
assets
Package assets provides embedded resources.
Package assets provides embedded resources.
overlayfs
Package overlyafs provides a way to overlay multiple fs.FS.
Package overlyafs provides a way to overlay multiple fs.FS.
skcmd
Package skcmd gathers useful commands to manage a sako repository.
Package skcmd gathers useful commands to manage a sako repository.
walla
Package walla holds types for the on-wire data from Wallabag.
Package walla holds types for the on-wire data from Wallabag.
Package sksrv provides a sako server API, compatible with Wallabag's API.
Package sksrv provides a sako server API, compatible with Wallabag's API.
sqlite
Package sqlite implements a sako repository backed by a SQLite database.
Package sqlite implements a sako repository backed by a SQLite database.
Package skweb provides a web interface to a sako (API) server.
Package skweb provides a web interface to a sako (API) server.

Jump to

Keyboard shortcuts

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