urbit/main/app/twit/core.hook

153 lines
4.2 KiB
Plaintext
Raw Normal View History

2014-08-10 15:46:39 +04:00
/+ twitter
2014-08-08 11:41:54 +04:00
!:
=> |%
2014-08-11 07:49:56 +04:00
++ axle ,@t :: Just JSON
++ gilt :: subscriptions frames
2014-08-08 11:41:54 +04:00
$% [%json p=json] :: JSON format
[%html p=@t]
[%hymn p=manx] :: HTML format
==
++ gift :: Message data
$% [%rust gilt] :: Refresh webapp
[%rush gilt] :: Update webapp
[%mean (unit (pair term (list tank)))] :: Error, maybe w/ msg
[%nice ~] :: Response message
==
++ move ,[p=bone q=(mold note gift)] :: Arvo command
++ sign
$% $: %e
$% [%thou p=httr]
== == ==
++ note :: Arvo message
$% $: %e
$% [%them p=(unit hiss)]
== == ==
2014-08-11 07:49:56 +04:00
++ app-key :: hardcoded keys!
2014-08-10 15:46:39 +04:00
:- :- 'hDDOTPfGHGlsOUbhpy6qc6XbW'
'olCkea6wm3XG4pnVCHuPIozUF2ggH1sHjnBtuT4Ai6rCOeQGzO'
:- '2485712317-R77Lpdu5rAJadRVxTXPpnxvcwS0IfNG7QEzLPty'
'a41d83XId0P7QQbodkPYv3zxoEL0Cq9EsN2eXZBZAwAWA'
2014-08-08 11:41:54 +04:00
--
|_ [hid=hide vat=axle]
2014-08-11 07:49:56 +04:00
::
++ prep
|= old=(unit)
~& %hose-state
[~ +>]
2014-08-08 11:41:54 +04:00
::
2014-08-11 07:49:56 +04:00
++ root :: internal location
2014-08-08 11:41:54 +04:00
/(scot %p our.hid)/main/(scot %da lat.hid)/app/[app.hid]
::
2014-08-11 07:49:56 +04:00
++ incl :: include scripts
2014-08-08 11:41:54 +04:00
|= wal=wall
%+ turn wal
|= tape ;script(type "text/javascript", src +<);
2014-08-11 07:49:56 +04:00
::
++ peer :: accept subscriber
2014-08-08 11:41:54 +04:00
|= [ost=bone you=ship pax=path]
^- [(list move) _+>]
2014-08-11 07:49:56 +04:00
:_ +>.$
2014-08-08 11:41:54 +04:00
?~ pax
2014-08-11 07:49:56 +04:00
[ost %give %rust %hymn page]~
?>(?=([%time ~] pax) ~)
::
++ poke-json :: client message
2014-08-08 11:41:54 +04:00
|= [ost=bone his=ship jon=json]
^- [(list move) _+>]
2014-08-11 07:49:56 +04:00
~& [%got-json ost]
=+ jop=(need ((of [%tweet sa] [%time sa] ~):jo jon))
~& [%got-jop ost]
=+ key=-.jop
:_ +>.$
:_ ~
?: ?=(%tweet key)
~& [%tweet-pax /tweet/(scot %ud ost)]
[ost %pass /tweet/(scot %ud ost) %e [%them (some (posl jon))]]
?: ?=(%time key)
[ost %give %nice ~]
!!
2014-08-08 11:41:54 +04:00
::
++ page
^- manx
;html
;head
;style:"{(trip ;;(,@ .^(%cx (welp root /main/css))))}"
;* %- incl :~
"//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"
==
2014-08-09 08:00:44 +04:00
;title: Urbit - Twitter Test
2014-08-08 11:41:54 +04:00
==
;body
;div#c
;div#d
;div#twet
2014-08-09 08:00:44 +04:00
;div.author: @urbit_test
;div.date;
;textarea#tweetr(placeholder "What would you like to tweet?");
2014-08-08 11:41:54 +04:00
;input#submit(type "button", value "Send");
;input#length(type "button", value "0/140");
==
;div#time;
==
==
;script:"{(trip ;;(,@ .^(cx/(welp (scag 3 `path`root) /lib/urb/js))))}"
;script:"{(trip ;;(,@ .^(%cx (welp root /main/js))))}"
==
==
2014-08-11 07:49:56 +04:00
::
++ pour-time
|= [pax=path sih=sign]
2014-08-08 11:41:54 +04:00
^- [(list move) _+>]
2014-08-11 07:49:56 +04:00
~& %pour-time
2014-08-08 11:41:54 +04:00
:_ +>.$
2014-08-11 07:49:56 +04:00
=. vat `@t`q:(need r.p.sih)
:_ =. vat `@t`q:(need r.p.sih) +>.$
%+ turn
%+ skim (~(tap by sup.hid))
|= [ost=bone his=ship pax=path]
~& pax
?=([%time ~] pax)
|= [ost=bone his=ship pax=path]
~& [%pour-time-give
=- [ost give/rush/json/-]
(rash vat apex:poja)
::
++ pour-tweet
|= [pax=path sih=sign]
^- [(list move) _+>]
=+ ost=(slav %ud -.+.pax)
:_ +>.$
:~ [ost %give %nice ~]
[ost %pass /time %e [%them (some timl)]]
==
::
++ pour
|= [pax=path sih=sign]
^- [(list move) _+>]
~& [%pour pax]
?: ?=([%time ~] pax)
(pour-time pax sih)
?> ?=([%tweet ~] pax)
(pour-tweet pax sih)
::
2014-08-08 11:41:54 +04:00
++ testt
^- hiss
[(scan "http://www.example.com" auri:epur) %get ~ ~]
2014-08-11 07:49:56 +04:00
::
2014-08-08 11:41:54 +04:00
++ timl
^- hiss
2014-08-11 07:49:56 +04:00
~& %request-timeline
2014-08-10 15:46:39 +04:00
=+ (twit `keys`app-key lat.hid `@`eny.hid)
2014-08-08 11:41:54 +04:00
(stat-home ~ ~)
2014-08-11 07:49:56 +04:00
::
2014-08-08 11:41:54 +04:00
++ posl
|= jon=json
2014-08-11 07:49:56 +04:00
~& [%posl jon]
2014-08-08 11:41:54 +04:00
=+ txt=`(unit ,[%tweet p=cord])`((of:jo [%tweet so:jo] ~) jon)
2014-08-11 07:49:56 +04:00
~& [%posl-txt txt]
2014-08-08 11:41:54 +04:00
^- hiss
2014-08-10 15:46:39 +04:00
=+ (twit `keys`app-key lat.hid `@`eny.hid)
2014-08-08 11:41:54 +04:00
(stat-upda ~[(st ~ p:(need txt))] ~)
--