summaryrefslogtreecommitdiff
path: root/desk/web/tv/router.hoon
blob: 6f4df215a8f831795228f1b4181fef6a933c1ee5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/-  boke, tp=trill-post, cnt=contact
/+  kaji, fetch-lib=fetch, plib=trill-utils, const=constants, sr=sortug, lib=boke
/=  index   /web/index
/=  tvp      /web/tv/tv
/=  subscribe   /web/subscribe
|_  [rl=req-line:kaji s=state:boke =bowl:gall]
+*  fetch  ~(. fetch-lib [s bowl])
    tv   ~(. tvp [s bowl])
++  eyre-bail   (error-response:kaji 404)
++  manx-bail   (error-page:kaji 404)
::
++  $  ^-  eyre-res:kaji
  =/  p  pat.rl  ::?.  mob.rl  pat.rl  [%m pat.rl]
  :: ?.  (is-subscribed:lib src.bowl)  nudge
  ?+  p  eyre-bail
    ~  main
    [%f *]  fragment
  ==
++  main
  :-  %page
  =/  ut  (~(get by here.tv.s) 'spandrell-tv')  
  ?~  ut  manx-bail
  =/  sta  (~(get by schedule.u.ut) started.current.u.ut)
  ?~  sta  manx-bail  :: TODO old station sorry
  =/  page  (main:tv ['spandrell-tv' %our 'Spandrell TV' ~docteg-mothep u.sta])
  (index ~[page] bowl)
  
++  nudge
  :-  %page
  =/  sub  ~(. subscribe src.bowl)
  =/  nudgep  (nudge:sub "TV")
  (index ~[nudgep] bowl)
++  fragment
  :-  %html
  ?+  pat.rl  manx-bail
  [%f %s ~]  ;div  ;*  tv-list:tv  ==
  [%f %u ~]  ;div  ;*  radio-list:tv   ==
  ==
--