<?xml version="1.0" encoding="UTF-8"?>
<service name="tinypic"
         version="$Id: tinypic.xml 2008-09-11 richard $"
         xmlns="http://www.flock.com/web-detective#">

  <strings>
    <string name="domains" value="tinypic.com" />
    <string name="homePageURL" locale="default"><![CDATA[http://tinypic.com/]]></string>
    <string name="loginURL" locale="default"><![CDATA[http://tinypic.com/]]></string>
    <string name="tpid" value="f1b45a574742097f" />
    <string name="tpkHash" value="2s280851o59spop15730p3659sq47965" />
    <string name="apiUrl" value="http://api.tinypic.com/api.php" />
    <string name="featuredPhotosUrl" value="http://tinypic.com/featuredimages.rss" />
    <string name="featuredVideosUrl" value="http://tinypic.com/featuredvideos.rss" />
  </strings>

  <sessioncookies>
    <cookie host=".tinypic.com" name="tpauth" path="/" />
  </sessioncookies>

  <detect type="loggedoutcookies">
    <cookie nomatch="true" host=".tinypic.com" name="tpauth" />
  </detect>

  <!--
    - FlockSvcUtils::getCredentialsFromForm() and ::ownsLoginForm() look for
    - webdetective rules named "login", "signup", and "changepassword".
   -->
  <detect type="signup">
    <url domain="tinypic.com">
      <path contains="/join.php" />
    </url>
    <form>
      <field tagname="input" fieldid="email" extractas="username" />
      <field tagname="input" fieldid="password" extractas="password" />
    </form>
  </detect>

  <detect type="login">
    <url domain="tinypic.com">
      <path notcontains="/join.php" />
    </url>
    <form>
      <field tagname="input" fieldid="email" extractas="username" />
      <field tagname="input" fieldid="password" extractas="password" />
    </form>
  </detect>

  <!--
    - FlockSvcUtils::docRepresentsSuccessfulLogin() looks for a webdetective
    - rule named "loggedin".
   -->

  <!-- TODO: can we make this better? -->
  <detect type="loggedin">
    <url domain="tinypic.com" />
    <xpath><![CDATA[//li[@id="your-home"]]]></xpath>
  </detect>

  <detect type="loggedout">
    <url domain="tinypic.com" />
    <xpath>
      <![CDATA[//input[@id="email"]]]>
    </xpath>
  </detect>

  <!--
    - FlockSvcUtils::getAccountIDFromDocument() looks for a webdetective rule
    - named "accountinfo".
   -->
  <detect type="accountinfo">
    <url domain="tinypic.com" />
    <xpath>
      <![CDATA[//li/a[@name="&lid=HeaderNav_MyProfile"]/@href]]>
       <regexp re1="accountid">
         <![CDATA[/\/friend\/profile\/displaySameProfile\.do\?userid=(\d+)/]]>
       </regexp>
    </xpath>
  </detect>

  <detect type="media">
    <conditions>
      <url><path contains="search.php"/></url>
    </conditions>
    <url>
      <regexp re1="tag">
        <![CDATA[/tag=([^&]+)/]]>
      </regexp>
    </url>
  </detect>

  <detect type="favorites">
    <conditions>
      <url><path contains="yourfavs.php"/></url>
    </conditions>
  </detect>

  <detect type="yourhome">
    <conditions>
      <url domain="tinypic.com"><path contains="yourhome.php"/></url>
    </conditions>
  </detect>

  <detect type="yourstuff">
    <conditions>
      <url domain="tinypic.com"><path contains="yourstuff.php"/></url>
    </conditions>
  </detect>
</service>
