Display error in feed description if external viewer is not found (#19)
This commit is contained in:
@@ -31,11 +31,7 @@ If a configuration is not provided, a default configuration is generated.
|
||||
- `feeds` is a list of RSS/Atom feeds to be loaded in srv.
|
||||
- `externalViewer` defines an application to override the default web browser (optional).
|
||||
|
||||
An example config can be copied:
|
||||
|
||||
```shell
|
||||
cp ./config-example.yml ~/.config/srv/config.yml
|
||||
```
|
||||
An example config can be found [here](./config-example.yml).
|
||||
|
||||
## navigate
|
||||
|
||||
|
@@ -25,7 +25,6 @@ type Configuration struct {
|
||||
Feeds []string `yaml:"feeds"`
|
||||
ExternalViewer string `yaml:"externalViewer,omitempty"`
|
||||
ExternalViewerArgs []string `yaml:"externalViewerArgs,omitempty"`
|
||||
Path string
|
||||
}
|
||||
|
||||
// DefaultConfiguration can be used if a config is missing
|
||||
@@ -35,7 +34,6 @@ var DefaultConfiguration = Configuration{
|
||||
"https://www.phoronix.com/rss.php",
|
||||
"https://www.zdnet.com/topic/security/rss.xml",
|
||||
},
|
||||
Path: ConfigPath,
|
||||
}
|
||||
|
||||
// GetUGetUGetUserConfigPath returns the full configuration path for the current user
|
||||
@@ -58,7 +56,6 @@ func DetermineExternalViewer() (string, error) {
|
||||
case "darwin":
|
||||
return "open", nil
|
||||
}
|
||||
|
||||
return "", errors.New("Unable to determine a default external viewer")
|
||||
}
|
||||
|
||||
|
11
cui/main.go
11
cui/main.go
@@ -51,12 +51,17 @@ func getCurrentFeedItem(v *gocui.View) *gofeed.Item {
|
||||
|
||||
// displayDescription displays feed description if it exists
|
||||
func displayDescription(g *gocui.Gui, v *gocui.View) {
|
||||
item := getCurrentFeedItem(v)
|
||||
description := utils.StripHTMLTags(item.Description)
|
||||
setDescription(g, v, description)
|
||||
}
|
||||
|
||||
// setDescription displays text in the bottom panel
|
||||
func setDescription(g *gocui.Gui, v *gocui.View, description string) {
|
||||
|
||||
ov, _ := g.View("Description")
|
||||
ov.Clear()
|
||||
|
||||
item := getCurrentFeedItem(v)
|
||||
description := utils.StripHTMLTags(item.Description)
|
||||
fmt.Fprintln(ov, description)
|
||||
}
|
||||
|
||||
@@ -69,7 +74,7 @@ func openItem(g *gocui.Gui, v *gocui.View) error {
|
||||
append(Controller.Config.ExternalViewerArgs, item.Link)...).Start()
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
setDescription(g, v, err.Error())
|
||||
}
|
||||
|
||||
return nil
|
||||
|
2
go.sum
2
go.sum
@@ -46,8 +46,6 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
|
||||
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/spf13/afero v1.3.1 h1:GPTpEAuNr98px18yNQ66JllNil98wfRZ/5Ukny8FeQA=
|
||||
github.com/spf13/afero v1.3.1/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4=
|
||||
github.com/spf13/afero v1.3.2 h1:GDarE4TJQI52kYSbSAmLiId1Elfj+xgSDqrUZxFhxlU=
|
||||
github.com/spf13/afero v1.3.2/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4=
|
||||
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
|
||||
|
2
install.sh
Normal file → Executable file
2
install.sh
Normal file → Executable file
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
VERSION='0.1.1'; \
|
||||
VERSION='0.1.2'
|
||||
sudo curl --progress-bar \
|
||||
-L "https://github.com/davegallant/srv/releases/download/v${VERSION}/srv_${VERSION}_$(uname -s)_x86_64.tar.gz" | \
|
||||
sudo tar -C /usr/bin --overwrite -xvzf - srv
|
||||
|
Reference in New Issue
Block a user