M card.go => card.go +2 -2
@@ 58,7 58,7 @@ func (card *Card) saveImage() func(image.Image) {
}
}
-func (card *Card) OpenArticle(articleChanged func(*readability.Article)) {
+func (card *Card) OpenArticle() {
if card == nil {
return
}
@@ 72,7 72,7 @@ func (card *Card) OpenArticle(articleChanged func(*readability.Article)) {
if len(card.Article.TextContent) < len(card.Item.Description) {
card.Article.TextContent = card.Item.Description
}
- articleChanged(article)
+ card.photon.cb.ArticleChanged(article)
}
card.photon.OpenedArticle.Article = card.Article
card.photon.OpenedArticle.Link = card.Item.Link
M card_lua.go => card_lua.go +6 -10
@@ 10,7 10,7 @@ const (
luaCardsTypeName = "photon.cards"
)
-func cardsLoader(L *lua.LState) int {
+func (p *Photon) cardsLoader(L *lua.LState) int {
var cardMethods = map[string]lua.LGFunction{
"link": cardItemLink,
"image": cardItemImage,
@@ 30,15 30,11 @@ func cardsLoader(L *lua.LState) int {
card.OpenBrowser()
return 0
},
- /*
- TODO
- "openArticle": func(L *lua.LState) int {
- card := checkCard(L, 1)
- someArticleOpener := checkArticleOpener(L, 1)
- card.OpenArticle(someArticleOpener)
- return 0
- },
- */
+ "openArticle": func(L *lua.LState) int {
+ card := checkCard(L, 1)
+ card.OpenArticle()
+ return 0
+ },
}
mt := L.NewTypeMetatable(luaCardTypeName)
L.SetField(mt, "__index", L.SetFuncs(L.NewTable(), cardMethods))
M libphoton.go => libphoton.go +2 -0
@@ 16,6 16,7 @@ import (
"git.sr.ht/~ghost08/libphoton/keybindings"
"git.sr.ht/~ghost08/libphoton/media"
"git.sr.ht/~ghost08/libphoton/states"
+ "github.com/cixtor/readability"
"github.com/mmcdole/gofeed"
)
@@ 43,6 44,7 @@ type Callbacks interface {
SelectedCardMoveUp()
SelectedCardMoveRight()
SelectedCardMoveLeft()
+ ArticleChanged(*readability.Article)
}
func New(cb Callbacks, paths []string, options ...Option) (*Photon, error) {
M plugins.go => plugins.go +1 -1
@@ 60,7 60,7 @@ func findPlugins() ([]string, error) {
func (p *Photon) initLuaState() {
luaState = lua.NewState()
media.Loader(luaState)
- cardsLoader(luaState)
+ p.cardsLoader(luaState)
luaState.PreloadModule("photon", p.photonLoader)
luaState.PreloadModule("photon.events", events.Loader)
luaState.PreloadModule("photon.feedInputs", inputs.Loader(&p.feedInputs))