~chrisppy/beagles

51286e960efb7666ee481ffce0093ca26e62b18c — Chris Palmer a month ago b985f54
Man page fixes and start of gemini support
5 files changed, 70 insertions(+), 34 deletions(-)

M config/config.go
M doc/beagles-config.5.scd
M doc/beagles.1.scd
M ui/helpContent.go
M util/util.go
M config/config.go => config/config.go +39 -17
@@ 72,7 72,7 @@ const (
	list           = "list"
	markFavorite   = "mark-favorite"
	markRead       = "mark-read"
	markUnfavorite = "mark-unfavorite"
	markUnfavorite = "unmark-favorite"
	markUnread     = "mark-unread"
	openURL        = "open-url"
	pageDown       = "page-down"


@@ 178,7 178,14 @@ type ExternalPlayer struct {

// Browser config
type Browser struct {
	HTTP *HTTPBrowser
	HTTP   *HTTPBrowser
	Gemini *GeminiBrowser
}

// GeminiBrowser config
type GeminiBrowser struct {
	Bin  string
	Args []string
}

// HTTPBrowser config


@@ 347,29 354,44 @@ func processBrowser(cfg scfg.Block) (*Browser, map[error]bool) {
			continue
		}

		if p == "http" {
			e := &HTTPBrowser{
				Args: make([]string, len(v)-1),
		var found bool
		var bin string
		args := make([]string, len(v)-1)

		for i, a := range v {
			if i == 0 {
				bin = a
				continue
			}

			found := false
			for i, a := range v {
				if i == 0 {
					e.Bin = a
					continue
				}
			args[i-1] = a
			if a == "[URL]" {
				found = true
			}
		}

				e.Args[i-1] = a
				if a == "[URL]" {
					found = true
		switch p {
		case "http":
			if !found {
				errors[fmt.Errorf(`[URL] must be one of the args provided for %s "http"`, browser)] = false
			} else {
				b.HTTP = &HTTPBrowser{
					Bin:  bin,
					Args: args,
				}
			}

		case "gemini":
			if !found {
				errors[fmt.Errorf("[URL] must be one of the args provided for %s", browser)] = false
				errors[fmt.Errorf(`[URL] must be one of the args provided for %s "gemini"`, browser)] = false
			} else {
				b.HTTP = e
				b.Gemini = &GeminiBrowser{
					Bin:  bin,
					Args: args,
				}
			}

		default:
			errors[fmt.Errorf("unsupported protocol provided for %s", browser)] = false
		}
	}


M doc/beagles-config.5.scd => doc/beagles-config.5.scd +15 -14
@@ 22,7 22,7 @@ numbers with suffixes to denote the units, e.g. "90m",++

Theme is defined within a _theme_ _{_ _}_ block.  Colors must be specified++
either as W3C color names or RGB hexadecimal strings(e.g. #88c0d0).++
Also Note that if the object colors are not defined it will, inherit++
Also Note that if the object colors are not defined, it will inherit++
the colors from *background-color* and *foreground-color*.  Note this++
is a required block.



@@ 122,16 122,16 @@ the tcell library (e.g. PgUp).  Note this is a required block.
	Key used to switch the favorite page.

*mark-read* "<key>"
	Key used to make a post as read.
	Key used to mark a post as read.

*mark-unread* "<key>"
	Key used to make a post as unread.
	Key used to mark a post as unread.

*mark-favorite* "<key>"
	Key used to make a post as favorite.
	Key used to mark a post as favorite.

*mark-unfavorite* "<key>"
	Key used to make a post as unfavorite.
*unmark-favorite* "<key>"
	Key used to unmark a post as favorite.

*open-url* "<key>"
	Key used to open the url of the post.


@@ 168,12 168,13 @@ section.

## BROWSER

Browser is defined within a _browser_ _"http"_ _{_ _}_ block.
Browser is defined within _browser_ "http"|"gemini" _{_ _}_ blocks.

*navigate* "<command>"
	The command to pass to the program, must have [URL]++
	The command to open the browser, must have [URL]++
as one of the arguments as that will substitute the++
url to open.
url to open.++
Example: navigate "xdg-open [URL]"

## PODCAST



@@ 183,11 184,11 @@ Podcast is defined within a _podcast_ _{_ _}_ block.
	New podcasts that are found during an update will++
be downloaded.

*external_player* "<command>"
	The command to pass to the program, must have [FILE]++
as one of the arguments as that will substitute the++
podcast file to play.

*external-player* "<command>"
	The command to open the podcast with the media player,++
must have [FILE] as one of the arguments as that will++
substitute the podcast file to play.++
Example: external-player "ffplay [FILE]"

# SEE ALSO
	*beagles*(1)

M doc/beagles.1.scd => doc/beagles.1.scd +1 -1
@@ 83,7 83,7 @@ or even play the podcasts available on the feed.
SUBSCRIPTIONS

*c*
	mark current post as unfavorite when in LIST, CONTENT,++
	unmark current post as favorite when in LIST, CONTENT,++
SUBSCRIPTIONS, or FAVORITES

*n*

M ui/helpContent.go => ui/helpContent.go +1 -1
@@ 71,7 71,7 @@ KEYS:
		SUBSCRIPTIONS

	%s
		mark current post as unfavorite when in LIST, CONTENT,
		unmark current post as favorite when in LIST, CONTENT,
		SUBSCRIPTIONS, or FAVORITES

	%s

M util/util.go => util/util.go +14 -1
@@ 102,7 102,7 @@ func OpenBrowser(url string, cfg *config.Browser) error {
	}

	if cfg != nil {
		if cfg.HTTP != nil {
		if cfg.HTTP != nil && strings.HasPrefix(url, "http") {
			nargs := make([]string, len(cfg.HTTP.Args))
			for i, arg := range cfg.HTTP.Args {
				if arg == "[URL]" {


@@ 115,6 115,19 @@ func OpenBrowser(url string, cfg *config.Browser) error {
			cmd := exec.Command(cfg.HTTP.Bin, nargs...)

			return cmd.Run()
		} else if cfg.Gemini != nil && strings.HasPrefix(url, "gemini") {
			nargs := make([]string, len(cfg.Gemini.Args))
			for i, arg := range cfg.Gemini.Args {
				if arg == "[URL]" {
					nargs[i] = url
					continue
				}
				nargs[i] = arg
			}

			cmd := exec.Command(cfg.Gemini.Bin, nargs...)

			return cmd.Run()
		}
	}