<?xml version="1.0" encoding="utf-8"?>
<service name="wordpress"
         version="$Id: wordpress.xml 20110 2008-09-08 17:38:35Z chris $"
         xmlns="http://www.flock.com/web-detective#">

  <strings>
    <string name="dissectCookie" value="wordpressloggedin" />

    <string name="homePageURL" locale="default">
      <![CDATA[http://wordpress.com/]]>
    </string>

    <string name="homePageURL" locale="de">
      <![CDATA[http://de.wordpress.com/]]>
    </string>
  </strings>

  <sessioncookies>
    <cookie host=".wordpress.com" name="wordpress_logged_in" path="/" />
    <cookie host=".wordpress.com" name="wordpress" path="/wp-admin" />
    <cookie host=".wordpress.com" name="wordpress" path="/wp-content/plugins" />
  </sessioncookies>

  <detect type="signup">
    <url domain="wordpress.com" >
      <path contains="signup/" />
    </url>
    <form>
      <field name="user_name" extractas="username" />
      <field name="pass2" type="password" extractas="password" />
    </form>
  </detect>

  <detect type="login">
    <url domain="wordpress.com"/>
    <form>
      <field fieldid="user_login" extractas="username"/>
      <field fieldid="user_pass" type="password" extractas="password"/>
    </form>
  </detect>

  <detect type="loggedin">
    <url domain="wordpress.com" />
    <xpath>
      <![CDATA[//div[@id="user_info"]//a[contains(@href,"action=logout")]]]>
    </xpath>
  </detect>

  <detect type="loggedin">
    <url domain="wordpress.com"/>
    <xpath><![CDATA[//div[@id="wpcombar"]/div/ul/li/ul/li/strong/a/text()[contains(.,"Log Out")]]]></xpath>
  </detect>

  <detect type="loggedin">
    <url domain="wordpress.com"/>
    <xpath><![CDATA[//div[@id="wpcombar"]/div/ul/li/ul/li/a/text()[contains(.,"Log Out")]]]></xpath>
  </detect>

  <detect type="loggedin">
    <url domain="wordpress.com">
      <path contains="signup" />
    </url>
    <regexp><![CDATA[/Your account is now active!/]]></regexp>
  </detect>

  <detect type="loggedin">
    <url domain="wordpress.com">
      <path contains="activate/" />
    </url>
    <regexp><![CDATA[/Your account is now active!/]]></regexp>
  </detect>
  
  <detect type="loggedout">
    <url domain="wordpress.com" />
    <xpath><![CDATA[//form[@id="loginform"]]]></xpath>
  </detect>

  <detect type="loggedout">
    <url domain="wordpress.com" />
    <xpath><![CDATA[//a[contains(@href,"wordpress.com/wp-login.php")]]]></xpath>
  </detect>

  <detect type="blogURL">
    <url domain="wordpress.com"/>
    <xpath name="blogURL" extract="attribute:href">
      <![CDATA[/html/body/div[@id="wrapper"]/div[@id="block_2"]/div[@id="welcomeback"]/ul/li/a]]>
    </xpath>
  </detect>

  <detect type="accountinfo">
    <conditions>
      <url domain="wordpress.com"/>
      <xpath extract="attribute:class">
        <![CDATA[//div[@id="welcomeback"]//img[not(contains(@class,"avatar-unknown"))]]]>
        <regexp>
          <![CDATA[/avatar avatar-(.*) avatar-/]]>
        </regexp>
      </xpath>
    </conditions>
    <results>
      <xpath>
        <![CDATA[//div[@id="welcomeback"]//img[contains(@class,"avatar-")]/@class]]>
        <regexp re1="accountid">
          <![CDATA[/ avatar-(.*) /]]>
        </regexp>
      </xpath>
      <xpath name="avatarURL" extract="attribute:src">
        <![CDATA[//div[@id="welcomeback"]//div[@class="head"]/img]]>
      </xpath>
    </results>
  </detect>

  <detect type="accountinfo">
    <conditions>
      <url domain="wordpress.com"/>
      <xpath name="accountid">
        <![CDATA[/html/body/div[@id="wrapper"]/div[@id="block_2"]/div[@id="welcomeback"]/ul/li/strong/a/text()]]>
      </xpath>
    </conditions>
    <results>
      <xpath name="accountid">
        <![CDATA[/html/body/div[@id="wrapper"]/div[@id="block_2"]/div[@id="welcomeback"]/ul/li/strong/a/text()]]>
      </xpath>
      <xpath name="avatarURL" extract="attribute:src">
        <![CDATA[//div[@id="wrapper"]//div[@id="block_2"]//div[@id="welcomeback"]//div[@class="head"]/img]]>
      </xpath>
    </results>
  </detect>
 
  <detect type="accountinfo">
    <url domain="wordpress.com">
      <path contains="signup" />
    </url>
    <xpath name="accountid">
      <![CDATA[//p[contains(text(),"You are now logged in as")]/strong/text()]]>
    </xpath>
  </detect>

  <!-- login detection for accounts with no avatar set -->
  <detect type="accountinfo">
    <cookies>
      <cookie host=".wordpress.com" name="wordpress" re1="accountid">
        <![CDATA[/^([^%]+)%/]]>
      </cookie>
    </cookies>
  </detect>

  <detect type="changepassword">
    <url domain="wordpress.com">
      <path contains="/wp-admin/profile.php"/>
    </url>
    <document>
      <xpath name="username" extract="value">
        <![CDATA[//input[@name="user_login"]]]>
      </xpath>
    </document>
    <form>
      <xpath name="password" extract="value">
        <![CDATA[//input[@type="password"][@name="pass2"]]]>
      </xpath>
    </form>
  </detect>  

</service>
