Browse Source

1.0.31 (#238)

* bump version

* respect xdg on more os

* add file extension

* update docs and man pages
pull/230/merge 1.0.31
Rasmus Lindroth 3 years ago committed by GitHub
parent
commit
a7651728e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      README.md
  2. 9
      config/config.go
  3. 8
      config/help.tmpl
  4. 11
      docs/man/tut.1
  5. 9
      docs/man/tut.1.md
  6. 12
      docs/man/tut.5
  7. 9
      docs/man/tut.5.md
  8. 2
      docs/man/tut.7
  9. 4
      docs/man/tut.7.md
  10. 5
      go.mod
  11. 12
      go.sum
  12. 2
      main.go
  13. 8
      ui/media.go
  14. 25
      util/util.go

7
README.md

@ -99,10 +99,15 @@ Tut is configurable, so you can change things like the colors, the default timel
what image viewer to use and some more. Check out the configuration file to see
all the options.
You find it in `XDG_CONFIG_HOME/tut/config.ini` which usually equals to `~/.config/tut/config.ini`.
You find it in `XDG_CONFIG_HOME/tut/config.ini` on Linux which usually equals to `~/.config/tut/config.ini`.
If you don't run Linux it will use the path of [os#UserConfigDir](https://github.com/golang/go/blob/7dc9fcb13de7bb20b11f6a526865545cc9142c2c/src/os/file.go#L455-L461).
But if you move the tut folder to `XDG_CONFIG_HOME/tut/` and have set the environment variable `XDG_CONFIG_HOME`
it will look there instead of the standard place.
You can find an updated configuration file in this repo named `config.example.ini`.
If there are any new configurations options you can copy them frome that file.
If you prefer a website you can read about all the options on [tut.anv.nu](https://tut.anv.nu/config) and
if man pages are your thing use `tut(5)`.
## Install instructions
### Binary releases

9
config/config.go

@ -12,6 +12,7 @@ import (
"strings"
"text/template"
"github.com/RasmusLindroth/tut/util"
"github.com/gdamore/tcell/v2"
"github.com/gobwas/glob"
"golang.org/x/exp/slices"
@ -1604,7 +1605,7 @@ func parseConfig(filepath string, cnfPath string, cnfDir string) (Config, error)
}
func createConfigDir() error {
cd, err := os.UserConfigDir()
cd, err := util.GetConfigDir()
if err != nil {
log.Fatalf("couldn't find config dir. Err %v", err)
}
@ -1631,7 +1632,7 @@ func checkConfig(filename string, cnfPath string, cnfDir string) (path string, e
}
return p, true, err
}
cd, err := os.UserConfigDir()
cd, err := util.GetConfigDir()
if err != nil {
log.Fatalf("couldn't find config dir. Err %v", err)
}
@ -1682,7 +1683,7 @@ func getThemes(cnfPath string, cnfDir string) (bundled []string, local []string,
if cnfDir != "" {
dir = filepath.Join(cnfDir, "themes")
} else {
cd, err := os.UserConfigDir()
cd, err := util.GetConfigDir()
if err != nil {
log.Fatalf("couldn't find config dir. Err %v", err)
}
@ -1710,7 +1711,7 @@ func getTheme(fname string, isLocal bool, cnfDir string) (*ini.File, error) {
if cnfDir != "" {
dir = filepath.Join(cnfDir, "themes")
} else {
cd, err := os.UserConfigDir()
cd, err := util.GetConfigDir()
if err != nil {
log.Fatalf("couldn't find config dir. Err %v", err)
}

8
config/help.tmpl

@ -139,9 +139,13 @@ Here's a list of supported commands.
{{ Color .Style.Text }}{{ Flags "b" }}Configuration{{ Flags "-" }}
tut searches for a config file in the following locations:
tut searches for a config file in the following locations on Linux:
1. $XDG_CONFIG_HOME/tut/config.ini
2. $HOME/.config/tut/config.ini
For information on the config file format go to <https://tut.anv.nu/config>.
If you don't run Linux it will use the path of the Go function {{ Flags "b" }}os.UserConfigDir(){{ Flags "-" }}.
But if you move the tut folder to {{ Flags "b" }}XDG_CONFIG_HOME/tut/{{ Flags "-" }} and have set the environment variable {{ Flags "b" }}XDG_CONFIG_HOME{{ Flags "-" }}
it will look there instead of the standard place.
For information on the config file format go to <https://tut.anv.nu/config> or use the man page {{ Flags "b" }}tut(5){{ Flags "-" }}.

11
docs/man/tut.1

@ -14,7 +14,7 @@
. ftr VB CB
. ftr VBI CBI
.\}
.TH "tut" "1" "2022-12-28" "tut 1.0.30" ""
.TH "tut" "1" "2022-12-29" "tut 1.0.31" ""
.hy
.SH NAME
.PP
@ -62,8 +62,13 @@ Tut is configurable, so you can change things like the colors, the
default timeline, what image viewer to use and some more.
Check out tut(5) or the configuration file to see all the options.
.PP
You find it in \f[I]$XDG_CONFIG_HOME/tut/config.ini\f[R] which usually
equals to \f[I]\[ti]/.config/tut/config.ini\f[R].
You find it in \f[I]$XDG_CONFIG_HOME/tut/config.ini\f[R] on Linux which
usually equals to \f[I]\[ti]/.config/tut/config.ini\f[R].
If you don\[cq]t run Linux it will use the path of the Go funcdtion
os.UserConfigDir().
But if you move the tut folder to \f[I]XDG_CONFIG_HOME/tut/\f[R] and
have set the environment variable \f[I]XDG_CONFIG_HOME\f[R] it will look
there instead of the standard place.
.PP
You can generate an example configuration file with \f[I]tut
example-config\f[R].

9
docs/man/tut.1.md

@ -1,6 +1,6 @@
% tut(1) tut 1.0.30
% tut(1) tut 1.0.31
% Rasmus Lindroth
% 2022-12-28
% 2022-12-29
# NAME
tut - a Mastodon TUI
@ -44,7 +44,10 @@ To see keys and commands you can use inside of tut check tut(7).
# CONFIGURATION
Tut is configurable, so you can change things like the colors, the default timeline, what image viewer to use and some more. Check out tut(5) or the configuration file to see all the options.
You find it in *$XDG_CONFIG_HOME/tut/config.ini* which usually equals to *~/.config/tut/config.ini*.
You find it in *$XDG_CONFIG_HOME/tut/config.ini* on Linux which usually equals to *~/.config/tut/config.ini*.
If you don't run Linux it will use the path of the Go funcdtion os.UserConfigDir().
But if you move the tut folder to *XDG_CONFIG_HOME/tut/* and have set the environment variable *XDG_CONFIG_HOME*
it will look there instead of the standard place.
You can generate an example configuration file with *tut example-config*. It will be updated with potential new features.

12
docs/man/tut.5

@ -14,7 +14,7 @@
. ftr VB CB
. ftr VBI CBI
.\}
.TH "tut" "5" "2022-12-28" "tut 1.0.30" ""
.TH "tut" "5" "2022-12-29" "tut 1.0.31" ""
.hy
.SH NAME
.PP
@ -23,9 +23,13 @@ tut - configuration for tut(1)
.PP
The configuration format for tut.
.PP
You find the configuration file in
\f[I]$XDG_CONFIG_HOME/tut/config.ini\f[R] which usually equals to
\f[I]\[ti]/.config/tut/config.ini\f[R].
You find it in \f[I]$XDG_CONFIG_HOME/tut/config.ini\f[R] on Linux which
usually equals to \f[I]\[ti]/.config/tut/config.ini\f[R].
If you don\[cq]t run Linux it will use the path of the Go funcdtion
os.UserConfigDir().
But if you move the tut folder to \f[I]XDG_CONFIG_HOME/tut/\f[R] and
have set the environment variable \f[I]XDG_CONFIG_HOME\f[R] it will look
there instead of the standard place.
.SH CONFIGURATION
.PP
The configuration file is divided in seven sections named general,

9
docs/man/tut.5.md

@ -1,6 +1,6 @@
% tut(5) tut 1.0.30
% tut(5) tut 1.0.31
% Rasmus Lindroth
% 2022-12-28
% 2022-12-29
# NAME
tut - configuration for tut(1)
@ -8,7 +8,10 @@ tut - configuration for tut(1)
# DESCRIPTION
The configuration format for tut.
You find the configuration file in *$XDG_CONFIG_HOME/tut/config.ini* which usually equals to *~/.config/tut/config.ini*.
You find it in *$XDG_CONFIG_HOME/tut/config.ini* on Linux which usually equals to *~/.config/tut/config.ini*.
If you don't run Linux it will use the path of the Go funcdtion os.UserConfigDir().
But if you move the tut folder to *XDG_CONFIG_HOME/tut/* and have set the environment variable *XDG_CONFIG_HOME*
it will look there instead of the standard place.
# CONFIGURATION
The configuration file is divided in seven sections named general, media, open-custom, open-pattern, desktop-notification, style and input.

2
docs/man/tut.7

@ -14,7 +14,7 @@
. ftr VB CB
. ftr VBI CBI
.\}
.TH "tut" "7" "2022-12-28" "tut 1.0.30" ""
.TH "tut" "7" "2022-12-29" "tut 1.0.31" ""
.hy
.SH NAME
.PP

4
docs/man/tut.7.md

@ -1,6 +1,6 @@
% tut(7) tut 1.0.30
% tut(7) tut 1.0.31
% Rasmus Lindroth
% 2022-12-28
% 2022-12-29
# NAME
tut - keys and commands inside of tut(1)

5
go.mod

@ -4,6 +4,7 @@ go 1.18
require (
github.com/RasmusLindroth/go-mastodon v0.0.17
github.com/adrg/xdg v0.4.0
github.com/atotto/clipboard v0.1.4
github.com/gdamore/tcell/v2 v2.5.3
github.com/gen2brain/beeep v0.0.0-20220909211152-5a9ec94374f6
@ -11,10 +12,10 @@ require (
github.com/icza/gox v0.0.0-20221026131554-a08a8cdc726a
github.com/microcosm-cc/bluemonday v1.0.21
github.com/pelletier/go-toml/v2 v2.0.6
github.com/rivo/tview v0.0.0-20221217182043-ccce554c3803
github.com/rivo/tview v0.0.0-20221221172820-02e38ea9604c
github.com/rivo/uniseg v0.4.3
github.com/spf13/pflag v1.0.5
golang.org/x/exp v0.0.0-20221217163422-3c43f8badb15
golang.org/x/exp v0.0.0-20221227203929-1b447090c38c
golang.org/x/net v0.4.0
gopkg.in/ini.v1 v1.67.0
)

12
go.sum

@ -1,5 +1,7 @@
github.com/RasmusLindroth/go-mastodon v0.0.17 h1:PUR4YS9ORe62ZSabvZVwxROZvrcMuNVC/8Y/D/d6dFQ=
github.com/RasmusLindroth/go-mastodon v0.0.17/go.mod h1:Lr6n8V1U2b+9P89YZKsICkNc+oNeJXkygY7raei9SXE=
github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls=
github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E=
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
@ -38,10 +40,10 @@ github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvI
github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
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/rivo/tview v0.0.0-20221212150847-19d943d59543 h1:qu4/1SXI23subKkH50FN7t6r0tPg7i7jI48M5kZ2qEE=
github.com/rivo/tview v0.0.0-20221212150847-19d943d59543/go.mod h1:YX2wUZOcJGOIycErz2s9KvDaP0jnWwRCirQMPLPpQ+Y=
github.com/rivo/tview v0.0.0-20221217182043-ccce554c3803 h1:gaknGRzW4g4I+5sGu4X81BZbROJ0j96ap9xnEbcZhXA=
github.com/rivo/tview v0.0.0-20221217182043-ccce554c3803/go.mod h1:YX2wUZOcJGOIycErz2s9KvDaP0jnWwRCirQMPLPpQ+Y=
github.com/rivo/tview v0.0.0-20221221172820-02e38ea9604c h1:Y4GSXEYKYAtguH10lmQmYb7hRkJ7U+m8GvnFHKU2jrk=
github.com/rivo/tview v0.0.0-20221221172820-02e38ea9604c/go.mod h1:lBUy/T5kyMudFzWUH/C2moN+NlU5qF505vzOyINXuUQ=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw=
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
@ -50,6 +52,7 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
@ -58,13 +61,14 @@ github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af h1:6yITBqGTE2lEeTPG0
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af/go.mod h1:4F09kP5F+am0jAwlQLddpoMDM+iewkxxt6nxUQ5nq5o=
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 h1:nrZ3ySNYwJbSpD6ce9duiP+QkD3JuLCcWkdaehUS/3Y=
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80/go.mod h1:iFyPdL66DjUD96XmzVL3ZntbzcflLnznH0fr99w5VqE=
golang.org/x/exp v0.0.0-20221212164502-fae10dda9338 h1:OvjRkcNHnf6/W5FZXSxODbxwD+X7fspczG7Jn/xQVD4=
golang.org/x/exp v0.0.0-20221212164502-fae10dda9338/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/exp v0.0.0-20221217163422-3c43f8badb15 h1:5oN1Pz/eDhCpbMbLstvIPa0b/BEQo6g6nwV3pLjfM6w=
golang.org/x/exp v0.0.0-20221217163422-3c43f8badb15/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/exp v0.0.0-20221227203929-1b447090c38c h1:Govq2W3bnHJimHT2ium65kXcI7ZzTniZHcFATnLJM0Q=
golang.org/x/exp v0.0.0-20221227203929-1b447090c38c/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU=
golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220318055525-2edf467146b5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=

2
main.go

@ -8,7 +8,7 @@ import (
"github.com/rivo/tview"
)
const version = "1.0.30"
const version = "1.0.31"
func main() {
util.SetTerminalTitle("tut")

8
ui/media.go

@ -6,13 +6,19 @@ import (
"net/http"
"os"
"os/exec"
"path/filepath"
"github.com/RasmusLindroth/go-mastodon"
"github.com/atotto/clipboard"
)
func downloadFile(url string) (string, error) {
f, err := os.CreateTemp("", "tutfile")
ext := filepath.Ext(url)
fname := "tutfile*"
if len(ext) > 0 {
fname = fmt.Sprintf("%s%s", fname, ext)
}
f, err := os.CreateTemp("", fname)
if err != nil {
return "", err
}

25
util/util.go

@ -9,10 +9,31 @@ import (
"strings"
"github.com/RasmusLindroth/go-mastodon"
"github.com/adrg/xdg"
"github.com/microcosm-cc/bluemonday"
"golang.org/x/net/html"
)
func GetConfigDir() (string, error) {
x, err := os.UserConfigDir()
if err != nil {
return "", err
}
y := xdg.ConfigHome
if x == y {
return x, nil
}
pathX := filepath.Join(x, "/tut")
if _, err := os.Stat(pathX); !os.IsNotExist(err) {
return x, nil
}
pathY := filepath.Join(y, "/tut")
if _, err := os.Stat(pathY); !os.IsNotExist(err) {
return y, nil
}
return x, nil
}
func GetAbsPath(path string) (string, error) {
if filepath.IsAbs(path) {
return path, nil
@ -88,7 +109,7 @@ func CmdToString(cmd string) (string, error) {
}
func MakeDirs() {
cd, err := os.UserConfigDir()
cd, err := GetConfigDir()
if err != nil {
log.Printf("couldn't find $HOME. Error: %v\n", err)
os.Exit(1)
@ -102,7 +123,7 @@ func MakeDirs() {
}
func CheckConfig(filename string) (path string, exists bool, err error) {
cd, err := os.UserConfigDir()
cd, err := GetConfigDir()
if err != nil {
log.Printf("couldn't find $HOME. Error: %v\n", err)
os.Exit(1)

Loading…
Cancel
Save