mirror of
https://github.com/mrusme/superhighway84.git
synced 2024-11-05 06:01:04 +00:00
Implemented readOnly for OpenArticle
This commit is contained in:
parent
0568fa3ec7
commit
62642f21f8
@ -17,7 +17,7 @@ func MillisecondsToDate(ms int64) (string) {
|
||||
return time.Unix(0, ms * int64(time.Millisecond)).Format("Mon Jan _2 15:04:05 2006")
|
||||
}
|
||||
|
||||
func (t *TUI) OpenArticle(article *models.Article) (models.Article, error) {
|
||||
func (t *TUI) OpenArticle(article *models.Article, readOnly bool) (models.Article, error) {
|
||||
if editor, exist := os.LookupEnv("EDITOR"); exist == false || editor == "" {
|
||||
return *article, errors.New("EDITOR environment variable not available, please export!")
|
||||
}
|
||||
@ -40,6 +40,10 @@ func (t *TUI) OpenArticle(article *models.Article) (models.Article, error) {
|
||||
return *article, err
|
||||
}
|
||||
|
||||
if readOnly == true {
|
||||
os.Chmod(tmpFile.Name(), 0400)
|
||||
}
|
||||
|
||||
wasSuspended := t.App.Suspend(func() {
|
||||
cmd := exec.Command(os.Getenv("EDITOR"), tmpFile.Name())
|
||||
cmd.Stdin = os.Stdin
|
||||
|
@ -267,7 +267,7 @@ func(mainscreen *Mainscreen) selectHandler(item string)(func(int, string, string
|
||||
case "group":
|
||||
mainscreen.Refresh()
|
||||
case "article":
|
||||
mainscreen.T.OpenArticle(mainscreen.ArticlesList[index])
|
||||
mainscreen.T.OpenArticle(mainscreen.ArticlesList[index], true)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -281,7 +281,7 @@ func(mainscreen *Mainscreen) submitNewArticle(group string) {
|
||||
newArticle.Organization = mainscreen.T.Config.Profile.Organization
|
||||
newArticle.Body = ""
|
||||
|
||||
updatedNewArticle, err := mainscreen.T.OpenArticle(newArticle)
|
||||
updatedNewArticle, err := mainscreen.T.OpenArticle(newArticle, false)
|
||||
if err != nil {
|
||||
mainscreen.T.ShowErrorModal(err.Error())
|
||||
return
|
||||
@ -319,7 +319,7 @@ func(mainscreen *Mainscreen) replyToArticle(article *models.Article) {
|
||||
newArticle.Organization = mainscreen.T.Config.Profile.Organization
|
||||
newArticle.Body = fmt.Sprintf("\nOn %s %s wrote:\n> %s", MillisecondsToDate(article.Date), article.From, strings.Replace(article.Body, "\n", "\n> ", -1))
|
||||
|
||||
updatedNewArticle, err := mainscreen.T.OpenArticle(newArticle)
|
||||
updatedNewArticle, err := mainscreen.T.OpenArticle(newArticle, false)
|
||||
if err != nil {
|
||||
mainscreen.T.ShowErrorModal(err.Error())
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user