|
|
|
@ -14,7 +14,7 @@ class LeftPane(urwid.ListBox):
|
|
|
|
super().__init__(self)
|
|
|
|
super().__init__(self)
|
|
|
|
items = [urwid.AttrMap(urwid.Columns([
|
|
|
|
items = [urwid.AttrMap(urwid.Columns([
|
|
|
|
(16, urwid.Text(category["date"])), urwid.Text(category["name"]), (5, urwid.Text(str(category["count"])))]),
|
|
|
|
(16, urwid.Text(category["date"])), urwid.Text(category["name"]), (5, urwid.Text(str(category["count"])))]),
|
|
|
|
(category["id"], category["count"]), "reveal focus") for category in categories]
|
|
|
|
(category["id"], category["name"], category["count"]), "reveal focus") for category in categories]
|
|
|
|
walker = urwid.SimpleListWalker(items)
|
|
|
|
walker = urwid.SimpleListWalker(items)
|
|
|
|
self.body = walker
|
|
|
|
self.body = walker
|
|
|
|
self.categoryPosition = 0
|
|
|
|
self.categoryPosition = 0
|
|
|
|
@ -24,29 +24,35 @@ class LeftPane(urwid.ListBox):
|
|
|
|
if self.isCategoryView:
|
|
|
|
if self.isCategoryView:
|
|
|
|
self.currentCategory = focus_widget.attr_map[None][0]
|
|
|
|
self.currentCategory = focus_widget.attr_map[None][0]
|
|
|
|
|
|
|
|
|
|
|
|
def getArticlesFromCategory(self, category, number):
|
|
|
|
def setArticlesPaneTitle(self, text):
|
|
|
|
tui.fetcher.articlesFromCategory(category[13:], str(number))
|
|
|
|
tui.rightBox.set_title(text)
|
|
|
|
articles = tui.fetcher.articles[category[13:]]
|
|
|
|
|
|
|
|
|
|
|
|
def getArticlesFromCategory(self, category, number=0):
|
|
|
|
|
|
|
|
tui.fetcher.articlesFromCategory(category, str(number))
|
|
|
|
|
|
|
|
articles = tui.fetcher.articles[category]
|
|
|
|
return articles
|
|
|
|
return articles
|
|
|
|
|
|
|
|
|
|
|
|
def getArticlesFromFeed(self, feed):
|
|
|
|
def getArticlesFromFeed(self, feed):
|
|
|
|
return tui.fetcher.articlesFromFeed(feed, self.currentCategory[13:])
|
|
|
|
return tui.fetcher.articlesFromFeed(feed, self.currentCategory)
|
|
|
|
|
|
|
|
|
|
|
|
async def setCategoryArticles(self, attrMap):
|
|
|
|
async def setCategoryArticles(self, attrMap):
|
|
|
|
itemId = attrMap[0]
|
|
|
|
itemId = attrMap[0]
|
|
|
|
number = attrMap[1]
|
|
|
|
number = attrMap[2]
|
|
|
|
await tui.fetcher.articlesFromCategoryAsync(itemId[13:], str(number))
|
|
|
|
name = attrMap[1]
|
|
|
|
|
|
|
|
await tui.fetcher.articlesFromCategoryAsync(itemId, str(number))
|
|
|
|
focus_widget, idx = self.get_focus()
|
|
|
|
focus_widget, idx = self.get_focus()
|
|
|
|
currentCategory = focus_widget.attr_map[None][0]
|
|
|
|
currentCategory = focus_widget.attr_map[None][0]
|
|
|
|
if itemId == currentCategory:
|
|
|
|
if itemId == currentCategory:
|
|
|
|
tui.articles = tui.fetcher.articles[currentCategory[13:]]
|
|
|
|
tui.articles = tui.fetcher.articles[currentCategory]
|
|
|
|
tui.articleView.fill(tui.articles)
|
|
|
|
tui.articleView.fill(tui.articles)
|
|
|
|
|
|
|
|
self.setArticlesPaneTitle(name)
|
|
|
|
|
|
|
|
|
|
|
|
def setFeedArticles(self, attrMap):
|
|
|
|
def setFeedArticles(self, attrMap):
|
|
|
|
itemId = attrMap
|
|
|
|
itemId = attrMap[0]
|
|
|
|
tui.articles = tui.fetcher.articlesFromFeed(itemId, self.currentCategory[13:])
|
|
|
|
tui.articles = tui.fetcher.articlesFromFeed(itemId, self.currentCategory)
|
|
|
|
if tui.articles is not None:
|
|
|
|
if tui.articles is not None:
|
|
|
|
tui.articleView.fill(tui.articles)
|
|
|
|
tui.articleView.fill(tui.articles)
|
|
|
|
|
|
|
|
self.setArticlesPaneTitle(attrMap[1])
|
|
|
|
|
|
|
|
|
|
|
|
def keypress(self, size, key):
|
|
|
|
def keypress(self, size, key):
|
|
|
|
if key in ("j", "down"):
|
|
|
|
if key in ("j", "down"):
|
|
|
|
@ -75,36 +81,44 @@ class LeftPane(urwid.ListBox):
|
|
|
|
self.setFeedArticles(focus_widget.attr_map[None])
|
|
|
|
self.setFeedArticles(focus_widget.attr_map[None])
|
|
|
|
return
|
|
|
|
return
|
|
|
|
elif key in ("l", "right"):
|
|
|
|
elif key in ("l", "right"):
|
|
|
|
if self.isCategoryView and tui.fetcher.checkCategory(self.currentCategory[13:]):
|
|
|
|
if self.isCategoryView and tui.fetcher.checkCategory(self.currentCategory):
|
|
|
|
self.isCategoryView = False
|
|
|
|
self.isCategoryView = False
|
|
|
|
focus_widget, idx = self.get_focus()
|
|
|
|
focus_widget, idx = self.get_focus()
|
|
|
|
self.categoryPosition = idx
|
|
|
|
self.categoryPosition = idx
|
|
|
|
categoryId = focus_widget.attr_map[None][0]
|
|
|
|
categoryId = focus_widget.attr_map[None][0]
|
|
|
|
|
|
|
|
categoryName = focus_widget.attr_map[None][1]
|
|
|
|
feeds = tui.fetcher.feedsFromCategory(categoryId)
|
|
|
|
feeds = tui.fetcher.feedsFromCategory(categoryId)
|
|
|
|
feedItems = [urwid.AttrMap(urwid.Columns([(16, urwid.Text(tui.fetcher.unreadCounts[feed["id"]][2])),
|
|
|
|
feedItems = [urwid.AttrMap(urwid.Columns([(16, urwid.Text(tui.fetcher.unreadCounts[feed["id"]][2])),
|
|
|
|
urwid.Text(feed["title"]),
|
|
|
|
urwid.Text(feed["title"]),
|
|
|
|
(5, urwid.Text(str(tui.fetcher.unreadCounts[feed["id"]][0])))]),
|
|
|
|
(5, urwid.Text(str(tui.fetcher.unreadCounts[feed["id"]][0])))]),
|
|
|
|
feed["id"], "reveal focus") for feed in feeds]
|
|
|
|
(feed["id"], feed["title"]), "reveal focus") for feed in feeds]
|
|
|
|
walker = urwid.SimpleListWalker(feedItems)
|
|
|
|
walker = urwid.SimpleListWalker(feedItems)
|
|
|
|
self.body = walker
|
|
|
|
self.body = walker
|
|
|
|
tui.leftBox.set_title(categoryId[13:])
|
|
|
|
|
|
|
|
focus_widget, idx = self.get_focus()
|
|
|
|
focus_widget, idx = self.get_focus()
|
|
|
|
if self.isCategoryView:
|
|
|
|
|
|
|
|
self.currentCategory = focus_widget.attr_map[None][0]
|
|
|
|
|
|
|
|
self.setFeedArticles(focus_widget.attr_map[None])
|
|
|
|
self.setFeedArticles(focus_widget.attr_map[None])
|
|
|
|
|
|
|
|
tui.leftBox.set_title(categoryName)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
elif key in ("h", "left"):
|
|
|
|
elif key in ("h", "left"):
|
|
|
|
if not self.isCategoryView:
|
|
|
|
if not self.isCategoryView:
|
|
|
|
self.isCategoryView = True
|
|
|
|
self.isCategoryView = True
|
|
|
|
items = [urwid.AttrMap(urwid.Columns([
|
|
|
|
items = [
|
|
|
|
(16, urwid.Text(category["date"])), urwid.Text(category["name"]), (5, urwid.Text(str(category["count"])))]),
|
|
|
|
urwid.AttrMap(
|
|
|
|
(category["id"], category["count"]), "reveal focus") for category in tui.fetcher.categories]
|
|
|
|
urwid.Columns(
|
|
|
|
|
|
|
|
[(16, urwid.Text(category["date"])),
|
|
|
|
|
|
|
|
urwid.Text(category["name"]),
|
|
|
|
|
|
|
|
(5, urwid.Text(str(category["count"])))]),
|
|
|
|
|
|
|
|
(category["id"],
|
|
|
|
|
|
|
|
category["name"],
|
|
|
|
|
|
|
|
category["count"]),
|
|
|
|
|
|
|
|
"reveal focus") for category in tui.fetcher.categories]
|
|
|
|
walker = urwid.SimpleFocusListWalker(items)
|
|
|
|
walker = urwid.SimpleFocusListWalker(items)
|
|
|
|
self.body = walker
|
|
|
|
self.body = walker
|
|
|
|
tui.leftBox.set_title("Categories")
|
|
|
|
tui.leftBox.set_title("Categories")
|
|
|
|
self.set_focus(self.categoryPosition)
|
|
|
|
self.set_focus(self.categoryPosition)
|
|
|
|
focus_widget, idx = self.get_focus()
|
|
|
|
focus_widget, idx = self.get_focus()
|
|
|
|
tui.articles = self.setCategoryArticles(focus_widget.attr_map[None])
|
|
|
|
tui.articles = self.getArticlesFromCategory(focus_widget.attr_map[None][0])
|
|
|
|
|
|
|
|
tui.articleView.fill(tui.articles)
|
|
|
|
|
|
|
|
self.setArticlesPaneTitle(self.currentCategory[13:])
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
return super().keypress(size, key)
|
|
|
|
return super().keypress(size, key)
|
|
|
|
@ -133,7 +147,7 @@ class RightPane(urwid.ListBox):
|
|
|
|
self.body = walker
|
|
|
|
self.body = walker
|
|
|
|
|
|
|
|
|
|
|
|
def getArticle(self, articleId):
|
|
|
|
def getArticle(self, articleId):
|
|
|
|
article = [item for item in tui.fetcher.articles[tui.feedView.currentCategory[13:]] if item["id"] == articleId][0]
|
|
|
|
article = [item for item in tui.fetcher.articles[tui.feedView.currentCategory] if item["id"] == articleId][0]
|
|
|
|
return article
|
|
|
|
return article
|
|
|
|
|
|
|
|
|
|
|
|
def setArticleTitle(self):
|
|
|
|
def setArticleTitle(self):
|
|
|
|
@ -178,7 +192,8 @@ class RightPane(urwid.ListBox):
|
|
|
|
if self.isList is False:
|
|
|
|
if self.isList is False:
|
|
|
|
self.isList = True
|
|
|
|
self.isList = True
|
|
|
|
self.fill(tui.articles)
|
|
|
|
self.fill(tui.articles)
|
|
|
|
tui.rightBox.set_title("Articles")
|
|
|
|
focusFeed, idx = tui.feedView.get_focus()
|
|
|
|
|
|
|
|
tui.rightBox.set_title(focusFeed.attr_map[None][1])
|
|
|
|
self.set_focus(self.articlePosition)
|
|
|
|
self.set_focus(self.articlePosition)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
@ -240,10 +255,12 @@ class TUI(urwid.Frame):
|
|
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
def run(self):
|
|
|
|
focus_widget, idx = self.feedView.get_focus()
|
|
|
|
focus_widget, idx = self.feedView.get_focus()
|
|
|
|
item = focus_widget.attr_map[None][0][13:]
|
|
|
|
item = focus_widget.attr_map[None][0]
|
|
|
|
self.fetcher.articlesFromCategory(item, str(focus_widget.attr_map[None][1]))
|
|
|
|
name = focus_widget.attr_map[None][1]
|
|
|
|
|
|
|
|
self.fetcher.articlesFromCategory(item, str(focus_widget.attr_map[None][2]))
|
|
|
|
self.articles = tui.fetcher.articles[item]
|
|
|
|
self.articles = tui.fetcher.articles[item]
|
|
|
|
self.articleView.fill(self.articles)
|
|
|
|
self.articleView.fill(self.articles)
|
|
|
|
|
|
|
|
self.feedView.setArticlesPaneTitle(name)
|
|
|
|
self.loop.run()
|
|
|
|
self.loop.run()
|
|
|
|
self.executor.shutdown(wait=False)
|
|
|
|
self.executor.shutdown(wait=False)
|
|
|
|
|
|
|
|
|
|
|
|
@ -259,7 +276,7 @@ class TUI(urwid.Frame):
|
|
|
|
self.handle = self.loop.event_loop.alarm(0, self.fetchAll)
|
|
|
|
self.handle = self.loop.event_loop.alarm(0, self.fetchAll)
|
|
|
|
focus_widget, idx = self.feedView.get_focus()
|
|
|
|
focus_widget, idx = self.feedView.get_focus()
|
|
|
|
itemId = focus_widget.attr_map[None][0]
|
|
|
|
itemId = focus_widget.attr_map[None][0]
|
|
|
|
self.articles = tui.fetcher.articles[itemId[13:]]
|
|
|
|
self.articles = tui.fetcher.articles[itemId]
|
|
|
|
self.articleView.fill(self.articles)
|
|
|
|
self.articleView.fill(self.articles)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|