mirror of
https://github.com/urbit/shrub.git
synced 2024-12-14 20:02:51 +03:00
More cleanups.
This commit is contained in:
parent
966499980b
commit
c735a5a522
@ -1,23 +1,24 @@
|
|||||||
:: A simple Twitter proxy.
|
:: A simple Twitter servant.
|
||||||
::
|
::
|
||||||
:::: /hook/core/twit/app
|
:::: /hook/core/twit/app
|
||||||
::
|
::
|
||||||
/? 314 :: need urbit 314
|
/? 314 :: need urbit 314
|
||||||
/+ twitter :: use twitter library
|
/+ twitter :: use twitter library
|
||||||
/= resource :: resource tree
|
/= front /:/%%/front:/hymn/ :: load front page
|
||||||
/. /= urbit /:/===/lib/urb:/hymn/ :: urbit library (js)
|
|
||||||
/= style /:/%%/style:/hymn/ :: stylesheet (css)
|
|
||||||
/= application /:/%%/app:/hymn/ :: application (js)
|
|
||||||
== ::
|
|
||||||
::
|
::
|
||||||
:::: structures
|
:::: structures
|
||||||
::
|
::
|
||||||
|% :: structures
|
|% :: structures
|
||||||
++ axle :: application state
|
++ axle ,[%0 axle-a] :: application state
|
||||||
,@t
|
++ axle-a ::
|
||||||
:: $: %0 :: revision 0
|
%- unit ::
|
||||||
:: tul=(unit json) ::
|
$: las=@da :: update time
|
||||||
:: ==
|
txt=@t :: XX timeline text
|
||||||
|
jon=json :: timeline json
|
||||||
|
== ::
|
||||||
|
++ axle-old :: any historic state
|
||||||
|
$% [%0 axle-a] ::
|
||||||
|
== ::
|
||||||
++ gilt :: subscription frame
|
++ gilt :: subscription frame
|
||||||
$% [%json p=json] :: json data
|
$% [%json p=json] :: json data
|
||||||
[%html p=@t] :: html text
|
[%html p=@t] :: html text
|
||||||
@ -25,7 +26,6 @@
|
|||||||
== ::
|
== ::
|
||||||
++ gift :: output action
|
++ gift :: output action
|
||||||
$% [%rust gilt] :: total update
|
$% [%rust gilt] :: total update
|
||||||
[%mean (unit (pair term (list tank)))] :: terminate
|
|
||||||
[%nice ~] :: succeed
|
[%nice ~] :: succeed
|
||||||
== ::
|
== ::
|
||||||
++ move ,[p=bone q=(mold note gift)] :: output operation
|
++ move ,[p=bone q=(mold note gift)] :: output operation
|
||||||
@ -55,105 +55,63 @@
|
|||||||
|_ $: hid=hide :: standard state
|
|_ $: hid=hide :: standard state
|
||||||
vat=axle :: custom state
|
vat=axle :: custom state
|
||||||
==
|
==
|
||||||
++ me :: internals
|
++ it :: internals
|
||||||
|%
|
|%
|
||||||
++ post :: post request
|
++ line :: get timeline
|
||||||
|
=+ (twit `keys`hardcoded-key lat.hid `@`eny.hid)
|
||||||
|
(stat-home ~ ~)
|
||||||
|
::
|
||||||
|
++ lint :: publish timeline
|
||||||
|
^- (list move)
|
||||||
|
?~ +.vat ~
|
||||||
|
%+ turn
|
||||||
|
(skim (~(tap by sup.hid)) |=([* * pax=path] ?=([%line ~] pax)))
|
||||||
|
|=([ost=bone *] `move`[ost give/rust/json/[jon.u.vat]])
|
||||||
|
::
|
||||||
|
++ post :: post a tweet
|
||||||
|= txt=cord
|
|= txt=cord
|
||||||
^- hiss
|
^- hiss
|
||||||
=+ (twit `keys`hardcoded-key lat.hid `@`eny.hid)
|
=+ (twit `keys`hardcoded-key lat.hid `@`eny.hid)
|
||||||
(stat-upda ~[(st ~ txt)] ~)
|
(stat-upda ~[(st ~ txt)] ~)
|
||||||
::
|
|
||||||
++ line :: timeline request
|
|
||||||
~& %request-timeline
|
|
||||||
=+ (twit `keys`hardcoded-key lat.hid `@`eny.hid)
|
|
||||||
(stat-home ~ ~)
|
|
||||||
--
|
--
|
||||||
::
|
::
|
||||||
++ page :: build front page
|
++ page front :: build front page
|
||||||
^- manx
|
|
||||||
;html
|
|
||||||
;head
|
|
||||||
;title: Urbit - Twitter Test
|
|
||||||
;+ style.resource
|
|
||||||
;script
|
|
||||||
=type "text/javascript"
|
|
||||||
=src "//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"
|
|
||||||
;
|
|
||||||
==
|
|
||||||
==
|
|
||||||
;body
|
|
||||||
;div#c
|
|
||||||
;div#d
|
|
||||||
;div#twet
|
|
||||||
;div.author: @urbit_test
|
|
||||||
;div.date;
|
|
||||||
;textarea#tweetr(placeholder "What would you like to tweet?");
|
|
||||||
;input#submit(type "button", value "Send");
|
|
||||||
;input#length(type "button", value "0/140");
|
|
||||||
==
|
|
||||||
;div#time;
|
|
||||||
==
|
|
||||||
==
|
|
||||||
;+ urbit.resource
|
|
||||||
;+ application.resource
|
|
||||||
==
|
|
||||||
==
|
|
||||||
::
|
|
||||||
++ prep :: load old state
|
++ prep :: load old state
|
||||||
|= old=(unit)
|
|= old=(unit (unit axle-old))
|
||||||
~& %hose-state
|
|
||||||
[~ +>]
|
[~ +>]
|
||||||
::
|
::
|
||||||
++ peer :: accept subscriber
|
++ peer :: accept subscriber
|
||||||
|= [ost=bone you=ship pax=path]
|
|= [ost=bone you=ship pax=path]
|
||||||
^- [(list move) _+>]
|
^- [(list move) _+>]
|
||||||
:_ +>.$
|
:_ +>.$
|
||||||
~& [%peer ost pax]
|
?~ pax [ost %give %rust %hymn page]~
|
||||||
?~ pax
|
?> ?=([%line ~] pax)
|
||||||
[ost %give %rust %hymn page]~
|
?~ +.vat
|
||||||
?>(?=([%line ~] pax) ~)
|
[ost %pass /line %e [%them (some line:it)]]~
|
||||||
|
[ost %give %rust %json jon.u.vat]~
|
||||||
::
|
::
|
||||||
++ poke-json :: client message
|
++ poke-json :: browser message
|
||||||
|= [ost=bone his=ship jon=json]
|
|= [ost=bone his=ship jon=json]
|
||||||
^- [(list move) _+>]
|
^- [(list move) _+>]
|
||||||
:_ +>.$
|
:_ +>.$
|
||||||
~& [%poke-json jon]
|
|
||||||
=+ txt=+:(need ((of [%tweet so] ~):jo jon))
|
=+ txt=+:(need ((of [%tweet so] ~):jo jon))
|
||||||
~& [%poke-tweet txt]
|
:~ [ost %pass /tweet/(scot %ud ost) %e [%them (some (post:it txt))]]
|
||||||
:~ [ost %pass /tweet/(scot %ud ost) %e [%them (some (post:me txt))]]
|
|
||||||
[ost %give %nice ~]
|
[ost %give %nice ~]
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ pour :: API response
|
++ pour :: HTTP response
|
||||||
|= [pax=path sih=sign]
|
|= [pax=path sih=sign]
|
||||||
^- [(list move) _+>]
|
^- [(list move) _+>]
|
||||||
?: ?=([%line ~] pax)
|
?+ -.pax !!
|
||||||
(pour-line pax sih)
|
%line :: timeline response
|
||||||
?> ?=([%tweet *] pax)
|
=+ txt=`@t`q:(need r.p.sih)
|
||||||
(pour-tweet pax sih)
|
=+ jon=(rash txt apex:poja) :: XX check content!!!
|
||||||
|
=+ old=&(?=(^ +.vat) =(jon jon.u.vat))
|
||||||
|
=. +.vat `[lat.hid txt jon]
|
||||||
|
[?:(old ~ lint:it) +>.$]
|
||||||
::
|
::
|
||||||
++ pour-line :: timeline response
|
%tweet :: post response
|
||||||
|= [pax=path sih=sign]
|
|
||||||
^- [(list move) _+>]
|
|
||||||
:_ +>.$
|
|
||||||
=. vat `@t`q:(need r.p.sih)
|
|
||||||
%+ turn
|
|
||||||
%+ skim (~(tap by sup.hid))
|
|
||||||
|= [ost=bone his=ship pax=path]
|
|
||||||
?=([%line ~] pax)
|
|
||||||
|= [ost=bone his=ship pax=path]
|
|
||||||
^- move
|
|
||||||
~& [%pour-line-give ost his pax]
|
|
||||||
=- [ost give/rust/json/-]
|
|
||||||
(rash vat apex:poja)
|
|
||||||
::
|
|
||||||
++ pour-tweet :: tweet response
|
|
||||||
|= [pax=path sih=sign]
|
|
||||||
^- [(list move) _+>]
|
|
||||||
~& %pour-tweet
|
|
||||||
=+ ost=(slav %ud -.+.pax)
|
=+ ost=(slav %ud -.+.pax)
|
||||||
:_ +>.$
|
[[ost %pass /line %e [%them (some line:it)]]~ +>.$]
|
||||||
:~ [ost %give %nice ~]
|
|
||||||
[ost %pass /line %e [%them (some line:me)]]
|
|
||||||
==
|
==
|
||||||
--
|
--
|
||||||
|
39
main/app/twit/front/hymn.hook
Normal file
39
main/app/twit/front/hymn.hook
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
:: Front page of the twitter app.
|
||||||
|
::
|
||||||
|
:::: /hook/hymn/front/twit/app
|
||||||
|
::
|
||||||
|
/? 314 :: need urbit 314
|
||||||
|
/= urbit /:/===/lib/urb:/hymn/ :: urbit library (js)
|
||||||
|
/= style /:/%%%/style:/hymn/ :: stylesheet (css)
|
||||||
|
/= application /:/%%%/app:/hymn/ :: application (js)
|
||||||
|
!:
|
||||||
|
:::: content
|
||||||
|
::
|
||||||
|
^- manx
|
||||||
|
;html
|
||||||
|
;head
|
||||||
|
;title: Urbit - Twitter Test
|
||||||
|
;+ style
|
||||||
|
;script
|
||||||
|
=type "text/javascript"
|
||||||
|
=src "//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"
|
||||||
|
;
|
||||||
|
==
|
||||||
|
==
|
||||||
|
;body
|
||||||
|
;div#c
|
||||||
|
;div#d
|
||||||
|
;div#twet
|
||||||
|
;div.author: @urbit_test
|
||||||
|
;div.date;
|
||||||
|
;textarea#tweetr(placeholder "What would you like to tweet?");
|
||||||
|
;input#submit(type "button", value "Send");
|
||||||
|
;input#length(type "button", value "0/140");
|
||||||
|
==
|
||||||
|
;div#time;
|
||||||
|
==
|
||||||
|
==
|
||||||
|
;+ urbit
|
||||||
|
;+ application
|
||||||
|
==
|
||||||
|
==
|
Loading…
Reference in New Issue
Block a user