utils

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateExpectedReadTime

func CalculateExpectedReadTime(wordCount int) int

CalculateExpectedReadTime calculates approx. read time in minutes based on Medium's estimate https://help.medium.com/hc/en-us/articles/214991667-Read-time

func CheckURLMostRecentlyAdded

func CheckURLMostRecentlyAdded(clipboardManager ClipboardManager) bool

CheckURLMostRecentlyAdded checks to see if the text in clipboard is the same as the URL that was just added

func GetFromClipboard

func GetFromClipboard(clipboardManager ClipboardManager) (string, error)

GetFromClipboard gets clipboard text from the clipboard manager

func IsURL

func IsURL(urlStr string) bool

IsURL determines whether supplied string is a URL https://stackoverflow.com/a/55551215/9292680

func IsURLInClipboard

func IsURLInClipboard(clipboardManager ClipboardManager) bool

IsURLInClipboard checks to see if the clipboard text is actually a URL

func OpenAuthURL

func OpenAuthURL(code string, redirectURI string, browserOpenFunc func(string))

OpenAuthURL opens auth url

func UserHomeDir

func UserHomeDir() string

UserHomeDir gets the user's home directory based on OS https://stackoverflow.com/a/7922977/9292680

Types

type ClipboardManager

type ClipboardManager interface {
	GetFromClipboard() (string, error)
	GetMostRecentlyAddedURL() string
	SetMostRecentlyAddedURL(url string)
	CopyToClipboard(text string) error
}

ClipboardManager is an interface for actions with the clipboard

type ClipboardManagerImpl

type ClipboardManagerImpl struct {
	AddedURL string
}

ClipboardManagerImpl is an implementation of ClipboardManager that uses atotto's clipboard library

func (*ClipboardManagerImpl) CopyToClipboard

func (c *ClipboardManagerImpl) CopyToClipboard(text string) error

CopyToClipboard writes supplied text to the clipboard using atotto's clipboard library

func (*ClipboardManagerImpl) GetFromClipboard

func (c *ClipboardManagerImpl) GetFromClipboard() (string, error)

GetFromClipboard gets the clipboard text using atotto's clipboard library

func (*ClipboardManagerImpl) GetMostRecentlyAddedURL

func (c *ClipboardManagerImpl) GetMostRecentlyAddedURL() string

GetMostRecentlyAddedURL gets the URL that was most recently added

func (*ClipboardManagerImpl) SetMostRecentlyAddedURL

func (c *ClipboardManagerImpl) SetMostRecentlyAddedURL(url string)

SetMostRecentlyAddedURL sets the URL that was most recently added

Jump to

Keyboard shortcuts

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