Beispiel #1
0
    def format(trait, objs, *args, **kwargs) -> Htmlish:
        # TODO would be nice to have spinboard imported here for type checking..
        res = T.div(cls='pinboard')

        title = trait.title(objs)
        link = trait.link(objs)
        res.add(T.div(T.a(title, href=link)))

        with adhoc_html('pinboard', cb=lambda children: res.add(*children)):
            with T.table():
                for _, obj in objs:
                    if not isempty(obj.description):
                        with T.tr():
                            with T.td(colspan=3):
                                T.span(obj.description, cls='description')
                    with T.tr():
                        # TODO wtf is min??
                        with T.td(cls='min'):
                            T.a(f'{fdate(obj.when)}',
                                href=obj.blink,
                                cls='permalink timestamp')
                        with T.td(cls='min'):
                            text('by ')
                            trait.user_link(user=obj.user)
                        with T.td():
                            for t in obj.ntags:
                                trait.tag_link(tag=t, user=obj.user)
        # TODO userstats
        return res
Beispiel #2
0
 def format(trait, objs, *args, **kwargs) -> Htmlish:
     res = T.div(cls='github')
     res.add(T.div(T.a(trait.title(objs), href=trait.link(objs))))
     # TODO total stars?
     with adhoc_html('github', cb=lambda ch: res.add(*ch)):
         for _, obj in objs:
             if not isempty(obj.description):
                 T.div(obj.description)
             with T.div():
                 if obj.stars > 0:
                     sts = '' if obj.stars == 1 else str(obj.stars)
                     T.b(sts + '★')
                 T.a(f'{obj.when.strftime("%Y-%m-%d %H:%M")} by {obj.user}',
                     href=obj.link,
                     cls='permalink')
     return res
Beispiel #3
0
 def format(trait, objs) -> Htmlish:
     res = T.div(cls='twitter')
     # res.add(T.div(T.a(trait.title(objs), href=tw(trait.link(objs)))))
     with adhoc_html('twitter', cb=lambda ch: res.add(*ch)):
         for _, obj in objs:
             T.div(obj.text)
             with T.div():
                 if obj.likes + obj.retweets + obj.replies > 0:
                     ll = f'★{obj.likes} ♺{obj.retweets} 🗬{obj.replies}'
                     T.b(ll)
                 T.a(
                     f'{obj.when.strftime("%Y-%m-%d %H:%M")} by {obj.user}',
                     href=tw(obj.link),
                     cls='permalink',
                 )
                 T.a('X', user=obj.user, cls='blacklist')
     return res
Beispiel #4
0
 def format(trait, objs) -> Htmlish:
     res = T.div(cls='hackernews')
     with adhoc_html('hackernews', cb=lambda ch: res.add(*ch)):
         for _, obj in objs:
             if obj.url is not None:
                 T.div(T.a(obj.title, href=obj.url))
             T.div(raw(obj.text), cls='text')  # eh, it's html
             with T.div():
                 extra = []
                 if obj.points > 0:
                     extra.append(f'🠅{obj.points}')
                 if obj.comments > 0:
                     extra.append(f'🗬{obj.comments}')
                 T.b(' '.join(extra))
                 T.a(
                     obj.when.strftime('%Y-%m-%d %H:%M'),
                     href=obj.link,
                     cls=
                     'permalink',  # TODO FIXME not sure if should use 'timestamp' class??
                 )
                 text(' by ')
                 trait.user_link(user=obj.user)
     return res
Beispiel #5
0
    def format(trait, objs, *args, **kwargs) -> Htmlish:
        res = T.div(cls='reddit')

        title = trait.title(objs)
        link = trait.link(objs)

        ll = reddit(link)

        res.add(T.div(T.a(title, href=ll)))
        with adhoc_html('reddit', cb=lambda ch: res.add(*ch)):
            for _, obj in objs:
                if not isempty(obj.description):
                    T.div(obj.description)
                T.div(trait.subreddit_link(obj.subreddit))
                with T.div():
                    ud = f'{obj.ups}⇅{obj.downs}'  # TODO sum all ups and downs??
                    T.b(ud)
                    T.a(f'{obj.when.strftime("%Y-%m-%d %H:%M")}',
                        href=ll,
                        cls='permalink')
                    text(' by ')
                    trait.user_link(user=obj.user)
        return res