From 91a41242ef5309fdae0243251d0e0add75c51b99 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 30 Dec 2008 16:14:44 -0500 Subject: [PATCH] implement the api/laconica/config method darcs-hash:20081230211444-84dde-d36ece807afedfa6f918923ba9074f774cbcb5ec.gz --- _darcs/inventory | 4 +- ...36ece807afedfa6f918923ba9074f774cbcb5ec.gz | Bin 0 -> 725 bytes _darcs/pristine/actions/twitapilaconica.php | 40 +++++++++++++++- _darcs/tentative_pristine | 43 +++++++++++++++++- actions/twitapilaconica.php | 40 +++++++++++++++- 5 files changed, 122 insertions(+), 5 deletions(-) create mode 100644 _darcs/patches/20081230211444-84dde-d36ece807afedfa6f918923ba9074f774cbcb5ec.gz diff --git a/_darcs/inventory b/_darcs/inventory index da728be6f2..895091d014 100644 --- a/_darcs/inventory +++ b/_darcs/inventory @@ -106,4 +106,6 @@ Evan Prodromou **20081230203747] [implement api/laconica/version method Evan Prodromou **20081230205939] [add some breaks so that switch statement works -Evan Prodromou **20081230210114] \ No newline at end of file +Evan Prodromou **20081230210114] +[implement the api/laconica/config method +Evan Prodromou **20081230211444] \ No newline at end of file diff --git a/_darcs/patches/20081230211444-84dde-d36ece807afedfa6f918923ba9074f774cbcb5ec.gz b/_darcs/patches/20081230211444-84dde-d36ece807afedfa6f918923ba9074f774cbcb5ec.gz new file mode 100644 index 0000000000000000000000000000000000000000..3a9d1d17dd16306bbb1434c1e2f065fa693e6867 GIT binary patch literal 725 zcmV;`0xJCre&<)*B&39v5@1x?=vr+Ln>4ADs!5ZOP=!ol zh>K%K_Js~@{P&$h0tAAfnqT6JecyNAo$tmXNhMFXLco{+%iws2w%>`dsxCdqoTlt<9$UV4!C~YU!YlCOGS#slcl)TNalws_? zGp53o+eoJ78JpALj^(1|@q`KKAf`rV^BAYAijkT8FqGQz=HF}{GFuf3AkOYGunEs)?MTJqUY5cG;T_QP$!92lMU8{8>5Xs@x3ok--|Yb zOhw$#J!R2kIc$gGhTCp0C)_<$q6%a1o5U9}WMk5+kQ(L&S1I?NThw|xu_3eEsgvHY znt~?A!rnXxC2$hyFmsc@&o4T<{hL7mqtR#xVa&q?4GV_Aqy)=1+JUKv3`C*kWEc*T z&zXeLk4NB}31h2(Gi^A_CFIS0jI(Jqb4?kKTmgHj}s= ze}_>2Q@8?qTzWj8WT`T}scJ_g?!rV*Unl_U z7crl>U#)K~@=<{!K4XMf-|(Rn`Ae&rKuRMep61XyH+Y(%j`;ncJJ{!2H`a}R$*Tsb HItTy&29{z0 literal 0 HcmV?d00001 diff --git a/_darcs/pristine/actions/twitapilaconica.php b/_darcs/pristine/actions/twitapilaconica.php index 6d3490abdb..9d9fcef6f5 100644 --- a/_darcs/pristine/actions/twitapilaconica.php +++ b/_darcs/pristine/actions/twitapilaconica.php @@ -89,6 +89,8 @@ class TwitapilaconicaAction extends TwitterapiAction * Gives a full dump of configuration variables for this instance * of Laconica, minus variables that may be security-sensitive (like * passwords). + * URL: http://identi.ca/api/laconica/config.(xml|json) + * Formats: xml, json * * @param array $args Web arguments * @param array $apidata Twitter API data @@ -100,8 +102,44 @@ class TwitapilaconicaAction extends TwitterapiAction function config($args, $apidata) { + static $keys = array('site' => array('name', 'server', 'theme', 'path', 'fancy', 'language', + 'email', 'broughtby', 'broughtbyurl', 'closed', + 'inviteonly', 'private'), + 'license' => array('url', 'title', 'image'), + 'nickname' => array('featured'), + 'throttle' => array('enabled', 'count', 'timespan'), + 'xmpp' => array('enabled', 'server', 'user')); + parent::handle($args); - common_server_error(_('API method under construction.'), 501); + + switch ($apidata['content-type']) { + case 'xml': + $this->init_document('xml'); + // XXX: check that all sections and settings are legal XML elements + foreach ($keys as $section => $settings) { + common_element_start($section); + foreach ($settings as $setting) { + common_element($setting, null, common_config($section, $setting)); + } + common_element_end($section); + } + $this->end_document('xml'); + break; + case 'json': + $result = array(); + foreach ($keys as $section => $settings) { + $result[$section] = array(); + foreach ($settings as $setting) { + $result[$section][$setting] = common_config($section, $setting); + } + } + $this->init_document('json'); + $this->show_json_objects($result); + $this->end_document('json'); + break; + default: + $this->client_error(_('API method not found!'), $code=404); + } } /** diff --git a/_darcs/tentative_pristine b/_darcs/tentative_pristine index 8dfaf737ab..404e42f98d 100644 --- a/_darcs/tentative_pristine +++ b/_darcs/tentative_pristine @@ -1,4 +1,43 @@ -hunk ./actions/twitapilaconica.php 75 +hunk ./actions/twitapilaconica.php 92 ++ * URL: http://identi.ca/api/laconica/config.(xml|json) ++ * Formats: xml, json +hunk ./actions/twitapilaconica.php 105 ++ static $keys = array('site' => array('name', 'server', 'theme', 'path', 'fancy', 'language', ++ 'email', 'broughtby', 'broughtbyurl', 'closed', ++ 'inviteonly', 'private'), ++ 'license' => array('url', 'title', 'image'), ++ 'nickname' => array('featured'), ++ 'throttle' => array('enabled', 'count', 'timespan'), ++ 'xmpp' => array('enabled', 'server', 'user')); ++ +hunk ./actions/twitapilaconica.php 114 +- common_server_error(_('API method under construction.'), 501); ++ ++ switch ($apidata['content-type']) { ++ case 'xml': ++ $this->init_document('xml'); ++ // XXX: check that all sections and settings are legal XML elements ++ foreach ($keys as $section => $settings) { ++ common_element_start($section); ++ foreach ($settings as $setting) { ++ common_element($setting, null, common_config($section, $setting)); ++ } ++ common_element_end($section); ++ } ++ $this->end_document('xml'); + break; -hunk ./actions/twitapilaconica.php 80 ++ case 'json': ++ $result = array(); ++ foreach ($keys as $section => $settings) { ++ $result[$section] = array(); ++ foreach ($settings as $setting) { ++ $result[$section][$setting] = common_config($section, $setting); ++ } ++ } ++ $this->init_document('json'); ++ $this->show_json_objects($result); ++ $this->end_document('json'); + break; ++ default: ++ $this->client_error(_('API method not found!'), $code=404); ++ } diff --git a/actions/twitapilaconica.php b/actions/twitapilaconica.php index 6d3490abdb..9d9fcef6f5 100644 --- a/actions/twitapilaconica.php +++ b/actions/twitapilaconica.php @@ -89,6 +89,8 @@ class TwitapilaconicaAction extends TwitterapiAction * Gives a full dump of configuration variables for this instance * of Laconica, minus variables that may be security-sensitive (like * passwords). + * URL: http://identi.ca/api/laconica/config.(xml|json) + * Formats: xml, json * * @param array $args Web arguments * @param array $apidata Twitter API data @@ -100,8 +102,44 @@ class TwitapilaconicaAction extends TwitterapiAction function config($args, $apidata) { + static $keys = array('site' => array('name', 'server', 'theme', 'path', 'fancy', 'language', + 'email', 'broughtby', 'broughtbyurl', 'closed', + 'inviteonly', 'private'), + 'license' => array('url', 'title', 'image'), + 'nickname' => array('featured'), + 'throttle' => array('enabled', 'count', 'timespan'), + 'xmpp' => array('enabled', 'server', 'user')); + parent::handle($args); - common_server_error(_('API method under construction.'), 501); + + switch ($apidata['content-type']) { + case 'xml': + $this->init_document('xml'); + // XXX: check that all sections and settings are legal XML elements + foreach ($keys as $section => $settings) { + common_element_start($section); + foreach ($settings as $setting) { + common_element($setting, null, common_config($section, $setting)); + } + common_element_end($section); + } + $this->end_document('xml'); + break; + case 'json': + $result = array(); + foreach ($keys as $section => $settings) { + $result[$section] = array(); + foreach ($settings as $setting) { + $result[$section][$setting] = common_config($section, $setting); + } + } + $this->init_document('json'); + $this->show_json_objects($result); + $this->end_document('json'); + break; + default: + $this->client_error(_('API method not found!'), $code=404); + } } /** -- 2.39.5