]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
implement the api/laconica/config method
authorEvan Prodromou <evan@prodromou.name>
Tue, 30 Dec 2008 21:14:44 +0000 (16:14 -0500)
committerEvan Prodromou <evan@prodromou.name>
Tue, 30 Dec 2008 21:14:44 +0000 (16:14 -0500)
darcs-hash:20081230211444-84dde-d36ece807afedfa6f918923ba9074f774cbcb5ec.gz

_darcs/inventory
_darcs/patches/20081230211444-84dde-d36ece807afedfa6f918923ba9074f774cbcb5ec.gz [new file with mode: 0644]
_darcs/pristine/actions/twitapilaconica.php
_darcs/tentative_pristine
actions/twitapilaconica.php

index da728be6f2e08a561325fd536cb2756e2d4e4ddc..895091d0140b2a5a18f27036584a4d2a383fd829 100644 (file)
@@ -106,4 +106,6 @@ Evan Prodromou <evan@prodromou.name>**20081230203747]
 [implement api/laconica/version method
 Evan Prodromou <evan@prodromou.name>**20081230205939] 
 [add some breaks so that switch statement works
-Evan Prodromou <evan@prodromou.name>**20081230210114] 
\ No newline at end of file
+Evan Prodromou <evan@prodromou.name>**20081230210114] 
+[implement the api/laconica/config method
+Evan Prodromou <evan@prodromou.name>**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 (file)
index 0000000..3a9d1d1
Binary files /dev/null and b/_darcs/patches/20081230211444-84dde-d36ece807afedfa6f918923ba9074f774cbcb5ec.gz differ
index 6d3490abdb7026de0a8e59501ea8b48ddadf5b02..9d9fcef6f543ce079cdd1915a8ba2850438e5f9d 100644 (file)
@@ -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);
+        }
     }
 
     /**
index 8dfaf737ab5f3ad8915bbfdff0ccd63692fcd1d7..404e42f98d20d8dff12d97080f3cbe4056978733 100644 (file)
@@ -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);
++        }
index 6d3490abdb7026de0a8e59501ea8b48ddadf5b02..9d9fcef6f543ce079cdd1915a8ba2850438e5f9d 100644 (file)
@@ -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);
+        }
     }
 
     /**