<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
<document>
  <header>
    <title>How to use Apache Droids Hello crawler?</title>
  </header>
  <body>
    <section>
      <title>Hello crawler</title>
      <note>Please note that we do not crawl yet images, css and scripts linked in the pages,
        but this feature is on top of the TODO list (right next of the creation of a sample
        droid). We will try to implement it ASAP.</note>
      <p>Remember the build.properties from the build process? This file controlls the
        behaviour of the Hello crawler. This properties can be overriden via custom calls
        of the different methods in your custom java code.</p>
      <p>The HelloCrawler offers you a wget style robot. We will now describe the basic
        functionality. First it will open the initial webpage (with the
        <code>protocol plugin</code> corresponding to the uri) and tries to extract the
        outlinks (with the
        <code>parse plugin</code> for the corresponding content type). Then it will test
        the links found on the page with the regular expression defined in the regex file (via
        the
        <code>filter plugin</code>). If we find new links that are accepted by the filter we
        then merge them with the queue. The last step is to pass the input stream to the stack of .
        <code>handler plugins</code></p>
      <p>Like you can see the Hello droid crawler is build by various different type of
        plugin. At the moment we support the following types: </p>
      <ul>
        <li>protocol plugins</li>
        <li>parse plugins</li>
        <li>filter plugins</li>
        <li>handler plugins</li>
      </ul>
      <section>
        <title>Crawling</title>
        <p>If you have set the property "droids.initial.url" to your initial url and edited
          the regex file "droids.filter.regex" to exclude/include follow up links, the
          Hello Droid will save the crawl to "droids.filter.regex" after you invoke:</p>
        <source>ant droids.crawl</source>
        <p>If you have not changed anything the result will be stored in $DROIDS_HOME/export
          like:</p>
        <source>export/ 
`-- target-x.de 
  |-- about.html 
  |-- index.html 
  |-- open.html 
  `-- search.html</source>
      </section>
      <section>
        <title>Ant target</title>
        <p>To use this target in your ant based application you can add the following snippet
          to your build file and do not forget to implemented the
          <strong>PROPERTIES</strong> such as e.g. droids.name!</p>
        <source><![CDATA[<target name="droids.crawl" description="--> Will invoke the crawling.">
  <java classname="org.apache.droids.Cli" fork="true" dir="${build.dir}"
    maxmemory="${droids.maxmemory}" failonerror="true"
    resultproperty="buildResult">
    <arg value="${droids.name}"/>
    <arg value="${droids.spring.context}"/> 
    <classpath>
      <path refid="droids.classpath"/>
    </classpath>
  </java>
</target>]]>
        </source>
      </section>
      <section>
        <title>Java class</title>
        <p>You can directly use the class
          <code>org.apache.droids.Cli</code> by calling the
          <code>main</code> method. There are two input parameters that you can use. </p>
        <ol>
          <li>The droid name is obligatory. In the default configuration that is
            <code>Hello</code> </li>
          <li>The second one is the location of the spring configuration you want to use. In
            the default configuration that is
            <code>classpath:/org/apache/droids/droids-core-context.xml</code>.
            This parameter is not obligatory. and if it is not provided we fall back to the
            above location.</li>
        </ol>
      </section>
    </section>
  </body>
</document>
