From 88449331782da53fa6661e5f8ec80fe68d04cdbb Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 31 Mar 2016 16:15:10 -0700 Subject: [PATCH] render talk feed as %api speeches --- lib/twitter.hoon | 15 +++++++++++++++ mar/twit/cred.hoon | 9 ++++----- mar/twit/feed.hoon | 17 +++++++++++++++-- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/lib/twitter.hoon b/lib/twitter.hoon index 8bd3b3ecab..3938e80cde 100644 --- a/lib/twitter.hoon +++ b/lib/twitter.hoon @@ -47,6 +47,11 @@ ?. =(u p.i.b) ~|(mismatch+[u p.i.b] !!) [q.i.b $(a t.a, b t.b)] :: +++ interpolate-url :: XX friendlier url format #717 + |= {a/tape b/(list (pair term knot))} ^- purl + =+ url=`purl`(scan a auri:epur) + url(q.q (interpolate-path q.q.url b)) +:: ++ valve :: produce request |= {med/?($get $post) pax/path quy/quay} ^- hiss @@ -74,10 +79,20 @@ :: |% ++ render :: response printers + =+ args:reqs |% ++ mean |= {msg/@t num/@ud} ^- tank rose+[": " `~]^~[leaf+"Error {}" leaf+(trip msg)] + :: + ++ user-url + |= a/scr ^- purl + (interpolate-url "https://twitter.com/:scr" scr+a ~) + :: + ++ post-url + |= {a/scr b/tid} ^- purl + %+ interpolate-url "https://twitter.com/:scr/status/:tid" + ~[scr+a tid+(tid:print b)] -- ++ parse :: json reparsers |% diff --git a/mar/twit/cred.hoon b/mar/twit/cred.hoon index 655032620e..df90bc63bb 100644 --- a/mar/twit/cred.hoon +++ b/mar/twit/cred.hoon @@ -3,7 +3,7 @@ :::: /hoon/cred/twit/mar :: /- plan-acct -/+ httr-to-json +/+ httr-to-json, twitter |_ {acc/plan-acct raw/json} ++ grab |% @@ -12,12 +12,11 @@ ++ json |= jon/^json ^- {plan-acct ^json} =+ usr=(need ((ot 'screen_name'^so ~):jo jon)) - =+ url=(scan "https://twitter.com/FIXME" aurf:epur) - =. q.q.p.url /[usr] :: XX friendlier url format #717 - [[usr (some url)] jon] + =+ url=(user-url:render:twitter usr) + [[usr (some [url ~])] jon] -- ++ grow |% - ++ tank >[+<]< + ++ tank >[+<.+]< -- -- diff --git a/mar/twit/feed.hoon b/mar/twit/feed.hoon index 309afa688b..c7d637be49 100644 --- a/mar/twit/feed.hoon +++ b/mar/twit/feed.hoon @@ -2,8 +2,9 @@ :: :::: /hoon/feed/twit/mar :: +/- talk /+ twitter, httr-to-json -|_ (list post:twitter) +|_ fed/(list post:twitter) ++ grab |% ++ noun (list post:twitter) @@ -12,6 +13,18 @@ -- ++ grow |% - ++ tank >[+<]< + ++ tank >[fed]< + ++ talk-speeches + =+ r=render:twitter + %+ turn fed + |= a/post:twitter ^- speech:talk + :* %api %twitter + who.a + (user-url.r who.a) + txt.a + txt.a + (post-url.r who.a id.a) + (joba now+(jode now.a)) + == -- --