summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ftplugin/hackernews.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/ftplugin/hackernews.py b/ftplugin/hackernews.py
index a055dba..4c84cb7 100644
--- a/ftplugin/hackernews.py
+++ b/ftplugin/hackernews.py
@@ -32,6 +32,8 @@ else:
API_URL = "http://node-hnapi.herokuapp.com"
MARKDOWN_URL = "http://fuckyeahmarkdown.com/go/?read=1&u="
+html = HTMLParser()
+
def bwrite(s):
b = vim.current.buffer
@@ -181,6 +183,15 @@ def link(external=False):
if 'content' in item:
bwrite("")
print_content(item['content'])
+ if 'poll' in item:
+ bwrite("")
+ max_score = max((c['points'] for c in item['poll']))
+ for c in item['poll']:
+ bwrite("%s (%d points)"
+ % (html.unescape(c['item']), c['points']))
+ bar = int(80.0 * c['points'] / max_score)
+ bwrite("#"*bar)
+ bwrite("")
bwrite("")
bwrite("")
if item['type'] == "comment":
@@ -232,9 +243,6 @@ def recall_pos():
vim.current.window.cursor = (int(mark[0]), int(mark[1]))
-html = HTMLParser()
-
-
def print_content(content):
for p in content.split("<p>"):
if not p: