This commit is contained in:
psyc://psyced.org/~lynX 2009-04-20 09:58:25 +02:00
commit 751a391dc3
5 changed files with 180 additions and 0 deletions

View File

@ -52,6 +52,10 @@ ________________________________________________________________________
_message_private
halo
.
- the linking blues...
tgX sagt: on reconnect i didn't get any _echo_place_enter_login's from this room, then no response for _request_do_enter, and after a _request_do_leave i get replies for enter/leave but instead of _echo_place_enter/leave i get _notice_place_enter/leave
________________________________________________________________________
== psyced 1.0 ==========================================================
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

View File

@ -1423,6 +1423,24 @@ _HTML_examine_friend_new
_HTML_examine_button_call
|&nbsp; &nbsp; <a id="Pebf" href="javascript:cmd('CALL [_nick]')">{_TEXT_button_call}</a>
_HTML_listing_head_twitter
|<title>twitter polly listing of available feeds</title>
|<link href="/static/twitter/listing.css" rel="stylesheet" type="text/css" />
|<body><div id="content">
|<ol class="listing" id="twitterlist">
_HTML_listing_tail_twitter
|</ol></div></body>
_HTML_listing_item_twitter
|<li>
|<span class="_photo"><a href="http://twitter.com/[_nick]" rel="nofollow"><img src="[_uniform_photo]" /></a></span>
|## <span class="_nick"><a href="http://twitter.com/[_nick]" rel="nofollow">[_nick]</a></span>
|<span class="_name"><a href="[_page]" rel="nofollow">[_name]</a></span><br/>
|<span class="_description">[_description]</span><br/>
|<span class="_uniform"><a href="[_uniform_context]">[_uniform_context]</a></span><br/>
|</li>
_HTML_call
|<object width="[_amount_width_object]" height="[_amount_height_object]">
|<param name="movie" value="[_path_object_local]"></param>

View File

@ -1790,6 +1790,7 @@ cmd(a, args, b, source, vars) {
return 1;
# endif
case "hc":
case "histclean": // in case you don't remember exactly.. it's ok
case "histclear": // wieso um alles in der welt soll das jeder dürfen?
// liest denn keiner die cvs kommentare? da stands
// drin.. ok wir sind realistisch und schreiben es

126
world/net/twitter/listing.c Normal file
View File

@ -0,0 +1,126 @@
// vim:foldmethod=marker:syntax=lpc:noexpandtab
//
// http://localhost:33333/net/twitter/listing shows a list of friends
#include <net.h>
#include <ht/http.h>
#include <text.h>
volatile object fetcha;
volatile mixed wurst;
parse(string body) {
if (!body || body == "") {
P1(("%O failed to get its listing.\n", ME))
return;
}
//#if DEBUG > 0
rm(DATA_PATH "twitter/friends.json");
write_file(DATA_PATH "twitter/friends.json", body);
P4((body))
//#endif
unless (pointerp(wurst = parse_json(body))) {
P1(("%O failed to parse its listing.\n", ME))
return;
}
#ifdef DEVELOPMENT
write_file(DATA_PATH "twitter/friends.parsed", sprintf("%O\n", wurst));
#endif
P1(("%O sorting %O subscription names ", ME, sizeof(wurst)))
wurst = sort_array(wurst, (:
unless (mappingp($1)) return 0;
unless (mappingp($2)) return 1;
// PT(("%O got %O vs %O\n", ME, $1, $2))
P1(("."))
return lower_case($2["screen_name"] || "") >
lower_case($1["screen_name"] || "");
:) );
P1((" done!\n"))
}
htget(prot, query, headers, qs, data, noprocess) {
string nick;
mapping d; //, s;
int i;
//sTextPath(query["layout"] || "twitter", query["lang"], "html");
localize(query["lang"], "html");
unless (pointerp(wurst)) {
hterror(R_TEMPOVERL,
"Haven't successfully retrieved data yet.");
return;
}
htok(prot); // outputs utf-8 header, but..
w("_HTML_listing_head_twitter");
for (i=sizeof(wurst)-1; i>=0; i--) {
d = wurst[i];
unless (mappingp(d)) {
P1(("%O got a broken entry: %O.\n", ME, d))
continue;
}
//
// user "foebud" has no updates ;)
//
// s = d["status"];
// unless (mappingp(s)) {
// P1(("%O got a statusless entry: %O.\n", ME, d))
// continue;
// }
unless (nick = d["screen_name"]) {
P1(("%O got a nickless tweeter.\n", ME))
continue;
}
w("_HTML_listing_item_twitter", 0, ([
// should i send text as _action?
"_nick": nick,
"_amount_updates": d["statuses_count"],
// _count_subscribers seems to be better for this
// or should it be _recipients? _targets?
"_amount_followers": d["followers_count"],
"_amount_sources": d["friends_count"],
// shows how old listing is.. hmm
//"_description_update": s["text"] || "",
"_color": "#"+ d["profile_sidebar_fill_color"],
"_description": d["description"] || "",
"_uniform_context": SERVER_UNIFORM +"@"+ nick,
"_page": d["url"] || "",
"_name": d["name"] || "",
// "_contact_twitter": d["id"],
"_reference_reply": d["in_reply_to_screen_name"],
// "_twit": d["id"],
"_uniform_photo": d["profile_image_url"] || "",
"_uniform_photo_background":
d["profile_background_image_url"] || ""
]));
}
w("_HTML_listing_tail_twitter");
return 1;
}
fetch() {
fetcha -> content( #'parse, 0, 1 );
fetcha -> fetch("http://twitter.com/statuses/friends.json?count=200");
}
create() {
mapping config;
object o = find_object(CONFIG_PATH "config");
if (o) config = o->qConfig();
if (!config) {
P1(("\nNo configuration for twitter gateway found in %O.\n", o))
//destruct(ME);
return 1;
}
string body = read_file(DATA_PATH "twitter/friends.json");
if (body) return parse(body);
// we could even choose to inherit this instead...
fetcha = clone_object(NET_PATH "http/fetch");
//fetcha -> sAgent(SERVER_VERSION " builtin Twitter to PSYC gateway");
fetcha -> sAuth(config["nickname"], config["password"]);
call_out( #'fetch, 14 );
}

View File

@ -0,0 +1,31 @@
* {
margin:0;padding:0;border-width:0;border-color:transparent;
}
a {
text-decoration:none;
color:#06a;
}
a:hover {
text-decoration:overline;
}
body{
font-family: 'Lucida Grande',helvetica,sans-serif;
color:#333;
background-color:#cc6;
margin:44px;
}
.listing {
background-color:#ddd;
border-left: 2px solid black;
border-right: 2px solid black;
}
.listing li:first-child{ border-top:1px dashed black; }
.listing li{position:relative;padding:7;border-bottom:1px dashed black;line-height:1.1em;}
.listing li:hover,ol.listing li.hover{background-color:white;}
._photo{display:block;width:50px;height:50px;position:absolute;right:7;margin:0 0 0 0;}
._photo img{width:48px;height:48px;}
._description{font-size:70%;}
._uniform{font-size:80%;}
._uniform a{color:#c30}