From 0654129e16e8f328e1048049923e7c2f73bf1d3c Mon Sep 17 00:00:00 2001 From: Dries Buytaert <dries@buytaert.net> Date: Tue, 6 Jul 2004 16:54:28 +0000 Subject: [PATCH] - Patch #8382 by jseng/junyor: allows autodiscovery of BloggerAPI via RSD. --- CHANGELOG.txt | 2 ++ modules/blogapi.module | 63 ++++++++++++++++++++++++++++++++++ modules/blogapi/blogapi.module | 63 ++++++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index e7828e4cc5c3..7ca96fc74d71 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -22,6 +22,8 @@ Drupal x.x.x, xxxx-xx-xx * added support for multiple database connections. - theme system: * changed all GIFs to PNGs. +- blogger API: + * added support for auto-discovery of blogger API via RSD. - accessibility: * improved the accessibility of the archive module's calendar. * improved form handling. diff --git a/modules/blogapi.module b/modules/blogapi.module index 44646e377b3d..7f38508ee77d 100644 --- a/modules/blogapi.module +++ b/modules/blogapi.module @@ -449,4 +449,67 @@ function blogapi_blogger_title(&$contents) { } return $title; } + +function blogapi_settings() { + $output = form_select(t('XML-RPC Engine'), 'blogapi_engine', variable_get('blogapi_engine', 0), array(0 => 'Blogger', 1 => 'MetaWeblog', 2 => 'Movabletype'), t('RSD or Really-Simple-Discovery is a mechanism which allows external blogger tools to discover the APIs they can use to interact with Drupal. The common XML-RPC engines are Blogger, MetaWeblog and Movabletype. If you are not sure which is the correct setting, choose Blogger.')); + return $output; +} + +function blogapi_menu() { + global $user; + $items = array(); + + if ($_GET['q'] == variable_get('site_frontpage', 'node')) { + drupal_set_html_head('<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . url('blogapi/rsd', NULL, NULL, TRUE) . '" />'); + } + + $items[] = array('path' => 'blogapi', 'title' => t('RSD'), 'callback' => 'blogapi_blogapi', 'access' => user_access('access_content'), 'type' => MENU_CALLBACK); + + return $items; +} + +function blogapi_blogapi() { + switch (arg(1)) { + case 'rsd': + blogapi_rsd(); + break; + default: + drupal_not_found(); + break; + } +} + +function blogapi_rsd() { + global $base_url; + + $xmlrpc = $base_url . FILE_SEPARATOR . 'xmlrpc.php'; + $base = url('', NULL, NULL, TRUE); + $blogid = 1; # until we figure out how to handle multiple bloggers + + $metaweblog = 'false'; $blogger = 'false'; $mt = 'false'; + if (variable_get('blogapi_engine', 0) == 0) { + $blogger = 'true'; + } else if (variable_get('blogapi_engine', 0) == 1) { + $metaweblog = 'true'; + } else if (variable_get('blogapi_engine', 0) == 2) { + $mt = 'true'; + } + + print <<<__RSD__ +<?xml version="1.0"?> +<rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd"> + <service> + <engineName>Drupal</engineName> + <engineLink>http://www.drupal.org/</engineLink> + <homePageLink>$base</homePageLink> + <apis> + <api name="MetaWeblog" preferred="$metaweblog" apiLink="$xmlrpc" blogID="$blogid" /> + <api name="Blogger" preferred="$blogger" apiLink="$xmlrpc" blogID="$blogid" /> + <api name="Movabletype" preferred="$mt" apiLink="$xmlrpc" blogID="$blogid" /> + </apis> + </service> +</rsd> +__RSD__; +} + ?> diff --git a/modules/blogapi/blogapi.module b/modules/blogapi/blogapi.module index 44646e377b3d..7f38508ee77d 100644 --- a/modules/blogapi/blogapi.module +++ b/modules/blogapi/blogapi.module @@ -449,4 +449,67 @@ function blogapi_blogger_title(&$contents) { } return $title; } + +function blogapi_settings() { + $output = form_select(t('XML-RPC Engine'), 'blogapi_engine', variable_get('blogapi_engine', 0), array(0 => 'Blogger', 1 => 'MetaWeblog', 2 => 'Movabletype'), t('RSD or Really-Simple-Discovery is a mechanism which allows external blogger tools to discover the APIs they can use to interact with Drupal. The common XML-RPC engines are Blogger, MetaWeblog and Movabletype. If you are not sure which is the correct setting, choose Blogger.')); + return $output; +} + +function blogapi_menu() { + global $user; + $items = array(); + + if ($_GET['q'] == variable_get('site_frontpage', 'node')) { + drupal_set_html_head('<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . url('blogapi/rsd', NULL, NULL, TRUE) . '" />'); + } + + $items[] = array('path' => 'blogapi', 'title' => t('RSD'), 'callback' => 'blogapi_blogapi', 'access' => user_access('access_content'), 'type' => MENU_CALLBACK); + + return $items; +} + +function blogapi_blogapi() { + switch (arg(1)) { + case 'rsd': + blogapi_rsd(); + break; + default: + drupal_not_found(); + break; + } +} + +function blogapi_rsd() { + global $base_url; + + $xmlrpc = $base_url . FILE_SEPARATOR . 'xmlrpc.php'; + $base = url('', NULL, NULL, TRUE); + $blogid = 1; # until we figure out how to handle multiple bloggers + + $metaweblog = 'false'; $blogger = 'false'; $mt = 'false'; + if (variable_get('blogapi_engine', 0) == 0) { + $blogger = 'true'; + } else if (variable_get('blogapi_engine', 0) == 1) { + $metaweblog = 'true'; + } else if (variable_get('blogapi_engine', 0) == 2) { + $mt = 'true'; + } + + print <<<__RSD__ +<?xml version="1.0"?> +<rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd"> + <service> + <engineName>Drupal</engineName> + <engineLink>http://www.drupal.org/</engineLink> + <homePageLink>$base</homePageLink> + <apis> + <api name="MetaWeblog" preferred="$metaweblog" apiLink="$xmlrpc" blogID="$blogid" /> + <api name="Blogger" preferred="$blogger" apiLink="$xmlrpc" blogID="$blogid" /> + <api name="Movabletype" preferred="$mt" apiLink="$xmlrpc" blogID="$blogid" /> + </apis> + </service> +</rsd> +__RSD__; +} + ?> -- GitLab