Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
d41de41c49 | ||
|
9eb31f4e08 | ||
|
780f26245c | ||
|
c9ba058ae6 |
23
README.md
23
README.md
@@ -13,10 +13,7 @@ View RSS feeds from the terminal.
|
||||
### via releases
|
||||
|
||||
```shell
|
||||
VERSION='0.1.0'; \
|
||||
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
|
||||
curl -fsSL https://raw.githubusercontent.com/davegallant/srv/master/install.sh | bash
|
||||
```
|
||||
|
||||
### via go
|
||||
@@ -34,21 +31,19 @@ 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
|
||||
|
||||
Key mappings are statically defined for the time being.
|
||||
|
||||
- `TAB` switches between Feeds and Items.
|
||||
- `UP/DOWN` navigates feeds and items`
|
||||
- `ENTER` either selects a feed or opens a feed item in an external application.
|
||||
- `F5` refresh list of feeds
|
||||
- `CTRL+C` quit
|
||||
| Key | Description |
|
||||
|:---------:| --------------------------------------------------------------------- |
|
||||
| `TAB` | switches between Feeds and Items. |
|
||||
| `UP/DOWN` | navigates feeds and items` |
|
||||
| `ENTER` | either selects a feed or opens a feed item in an external application.|
|
||||
| `CTRL+R` | refresh list of feeds |
|
||||
| `CTRL+C` | quit |
|
||||
|
||||
|
||||
## build
|
||||
|
@@ -1,5 +0,0 @@
|
||||
feeds:
|
||||
- https://aws.amazon.com/blogs/security/feed/
|
||||
- https://www.phoronix.com/rss.php
|
||||
- https://www.zdnet.com/topic/security/rss.xml
|
||||
path: .config/srv/config.yml
|
@@ -1,9 +1,8 @@
|
||||
---
|
||||
feeds:
|
||||
- https://news.ycombinator.com/rss
|
||||
- https://www.reddit.com/r/linux/.rss
|
||||
- https://www.zdnet.com/topic/security/rss.xml
|
||||
- https://aws.amazon.com/blogs/security/feed/
|
||||
- https://www.phoronix.com/rss.php
|
||||
- https://www.zdnet.com/topic/security/rss.xml
|
||||
|
||||
# Optionally define an application to view the feeds
|
||||
#externalViewer: firefox
|
||||
|
@@ -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")
|
||||
}
|
||||
|
||||
|
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
// TestLoadConfiguration tests loading the example config
|
||||
func TestLoadConfiguration(t *testing.T) {
|
||||
exampleConfig, err := LoadConfiguration("../config-example.yaml")
|
||||
exampleConfig, err := LoadConfiguration("../config-example.yml")
|
||||
|
||||
assert.NoError(t, err)
|
||||
|
||||
|
@@ -25,7 +25,7 @@ func keybindings(g *gocui.Gui) error {
|
||||
if err := g.SetKeybinding("Items", gocui.KeyEnter, gocui.ModNone, openItem); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.SetKeybinding("", gocui.KeyF5, gocui.ModNone, refreshFeeds); err != nil {
|
||||
if err := g.SetKeybinding("", gocui.KeyCtrlR, gocui.ModNone, refreshFeeds); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
14
cui/main.go
14
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,14 +74,15 @@ 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
|
||||
}
|
||||
|
||||
func refreshFeeds(g *gocui.Gui, v *gocui.View) error {
|
||||
Controller.Rss.Update(Controller.Config.Feeds)
|
||||
g.Close()
|
||||
Start()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
2
go.mod
2
go.mod
@@ -13,7 +13,7 @@ require (
|
||||
github.com/mmcdole/gofeed v1.0.0
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
|
||||
github.com/nsf/termbox-go v0.0.0-20200204031403-4d2b513ad8be // indirect
|
||||
github.com/spf13/afero v1.3.1
|
||||
github.com/spf13/afero v1.3.2
|
||||
github.com/stretchr/testify v1.6.1
|
||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e // indirect
|
||||
golang.org/x/text v0.3.2 // indirect
|
||||
|
4
go.sum
4
go.sum
@@ -46,8 +46,8 @@ 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=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
|
6
install.sh
Executable file
6
install.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
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