~reesmichael1/roman

2486bf72656ab8187363501151a25064334f975e — Michael Rees 8 months ago b0b0bdc
Show authors when opening a post
2 files changed, 11 insertions(+), 1 deletions(-)

M src/romanpkg/posts.nim
M src/romanpkg/types.nim
M src/romanpkg/posts.nim => src/romanpkg/posts.nim +7 -1
@@ 1,3 1,4 @@
import options
import os
import strutils
import terminal


@@ 45,7 46,10 @@ proc isPostRead(itemGUID: string): bool {.raises: [RomanError].} =

proc displayPost*(p: Post) {.raises: [RomanError].} =
  try:
    page(p.title & "\n\n" & p.content)
    if p.author.isSome:
      page(p.title & "\n" & p.author.unsafeGet & "\n\n" & p.content)
    else:
      page(p.title & "\n\n" & p.content)
  except IOError, ValueError:
    let msg = getCurrentExceptionMsg()
    raise newException(RomanError, "could not write to the terminal: " & msg)


@@ 56,6 60,8 @@ proc postFromRSSItem*(item: RSSItem): Post {.raises: [RomanError].} =
  result.content = extractBody(item.description)
  result.guid = item.guid
  result.read = isPostRead(item.guid)
  if item.author.len > 0:
    result.author = some(item.author)


proc markAsRead*(p: Post) {.raises: [RomanError].} =

M src/romanpkg/types.nim => src/romanpkg/types.nim +4 -0
@@ 1,3 1,6 @@
import options


type
  RomanConfig* = object
    up*: char


@@ 18,6 21,7 @@ type
    content*: string
    guid*: string
    read*: bool
    author*: Option[string]

  Feed* = object
    posts*: seq[Post]