diff options
author | wei <> | 2006-05-11 11:35:35 +0000 |
---|---|---|
committer | wei <> | 2006-05-11 11:35:35 +0000 |
commit | cc61c2d74e151a7fb75303f8740edfe74cdd9eb8 (patch) | |
tree | 3d57f3db231469caaadf42eabe095cc6f17b9950 /buildscripts | |
parent | 90e706cda83d3b64a5508ed182956a1e3110ff26 (diff) |
Update api docs and add API search
Diffstat (limited to 'buildscripts')
-rw-r--r-- | buildscripts/index/api_index.php | 120 | ||||
-rw-r--r-- | buildscripts/index/build.php | 65 | ||||
-rw-r--r-- | buildscripts/index/quickstart_index.php (renamed from buildscripts/texbuilder/create_index.php) | 33 | ||||
-rw-r--r-- | buildscripts/texbuilder/build.php | 116 | ||||
-rw-r--r-- | buildscripts/texbuilder/pages.php | 100 |
5 files changed, 322 insertions, 112 deletions
diff --git a/buildscripts/index/api_index.php b/buildscripts/index/api_index.php new file mode 100644 index 00000000..ac2e37a7 --- /dev/null +++ b/buildscripts/index/api_index.php @@ -0,0 +1,120 @@ +<?php
+/*
+ * Created on 10/05/2006
+ */
+
+class api_index
+{
+ const API_URL = '';
+
+ private $_index;
+ private $_api;
+
+ public function __construct($index_file, $api)
+ {
+ $this->_api = $api;
+ $this->_index = new Zend_Search_Lucene($index_file, true);
+
+
+ }
+
+ function create_index()
+ {
+ echo "Building search index...\n";
+ $files = $this->get_file_list($this->_api);
+ $count = 0;
+ foreach($files as $file)
+ {
+ $content = $this->get_details($file, $this->_api);
+
+ $doc = new Zend_Search_Lucene_Document();
+
+ $title = $content['namespace'].'.'.$content['class'];
+
+ echo " Adding ".$title."\n";
+
+ //unsearchable text
+ $doc->addField(Zend_Search_Lucene_Field::UnIndexed('link', $content['link']));
+ $doc->addField(Zend_Search_Lucene_Field::UnIndexed('title', $title));
+ //$doc->addField(Zend_Search_Lucene_Field::UnIndexed('text', $content['content']));
+
+ //searchable
+ $body = strtolower($this->sanitize($content['content'])).' '.strtolower($title);
+ $doc->addField(Zend_Search_Lucene_Field::Keyword('page', strtolower(str_replace('.',' ',$title))));
+ $doc->addField(Zend_Search_Lucene_Field::Unstored('contents',$body));
+ $this->_index->addDocument($doc);
+ $count++;
+ }
+ $this->_index->commit();
+ echo "\n {$count} files indexed.\n";
+ }
+
+ function sanitize($input)
+ {
+ return htmlentities(strip_tags( $input ));
+ }
+
+
+ function get_file_list($path)
+ {
+
+ $d = dir($path);
+
+ $files = array();
+ while (false !== ($entry = $d->read()))
+ {
+ $filepath = $path.'/'.$entry;
+
+ if(is_dir($filepath) && is_int(strpos($entry, 'System')))
+ {
+ $files = array_merge($files, $this->get_files($filepath));
+ }
+ }
+
+ $d->close();
+ return $files;
+ }
+
+ function get_files($path)
+ {
+ $d = dir($path);
+
+ $files = array();
+ while (false !== ($entry = $d->read()))
+ {
+ $filepath = $path.'/'.$entry;
+ if(is_file($filepath) && $entry[0] !== '_')
+ $files[] = realpath($filepath);
+ }
+ return $files;
+ $d->close();
+ }
+
+ function get_doc_content($file)
+ {
+ $content = file_get_contents($file);
+ $html = preg_replace('/<h1>/','~~~', $content);
+ $html = preg_replace('/<![^~]+/m', '', $html);
+ $html = preg_replace('/<div class="credit">[\s\w\W\S]+/m', '', $html);
+ $html = preg_replace('/ |~+|\s{2,}/',' ',$html);
+ $html = preg_replace('/\s{2,}/',' ',$html);
+ $text = strip_tags($html);
+ $text = str_replace(' , ',', ',$text);
+ return $text;
+ }
+
+ function get_details($file, $base)
+ {
+ $result['content'] = $this->get_doc_content($file);
+ $find = array($base, '.html', '-');
+ $replace = array('', '', '.');
+ $path = preg_split('/\/|\\\/', str_replace($find, $replace, $file));
+ $result['namespace'] = $path[1];
+ $result['class'] = $path[2];
+ $result['link'] = self::API_URL.$path[1].'/'.$path[2].'.html';
+ return $result;
+ }
+}
+
+
+?>
\ No newline at end of file diff --git a/buildscripts/index/build.php b/buildscripts/index/build.php new file mode 100644 index 00000000..9ec0d659 --- /dev/null +++ b/buildscripts/index/build.php @@ -0,0 +1,65 @@ +<?php
+/*
+ * Created on 10/05/2006
+ */
+
+/**
+ * Building search index for quickstart tutorials and the API documentation.
+ */
+
+
+//quickstart source and the index data target directories.
+$quickstart_source = realpath(dirname(__FILE__).'/../texbuilder/pages.php');
+$quickstart_base = realpath(dirname(__FILE__).'/../../demos/quickstart/protected/pages/');
+$quickstart_target = realpath(dirname(__FILE__).'/../../demos/quickstart/protected/index/quickstart/');
+
+//API source and the index data target directories.
+$api_source = realpath(dirname(__FILE__).'/../../build/docs/manual/');
+$api_target = realpath(dirname(__FILE__).'/../../demos/quickstart/protected/index/api/');
+
+//get the ZEND framework
+$zend_path = realpath(dirname(__FILE__).'/../../demos/quickstart/protected/index');
+set_include_path(get_include_path().';'.$zend_path);
+require_once ('Zend/Search/Lucene.php');
+
+//get the indexers.
+include('quickstart_index.php');
+include('API_index.php');
+
+if(isset($argv[1]))
+{
+ if(strtolower($argv[1]) == "quickstart")
+ {
+ $quickstart = new quickstart_index($quickstart_target, $quickstart_base, $quickstart_source);
+ $quickstart->create_index();
+ }
+ else if(strtolower($argv[1]) == "api")
+ {
+ $api = new api_index($api_target, $api_source);
+ $api->create_index();
+ }
+ else
+ {
+ $q = new Zend_Search_Lucene($quickstart_target);
+ $query = $argv[1];
+ $hits = $q->find(strtolower($query));
+ echo "Found ".count($hits)." for ".$query." in quick start\n";
+ foreach($hits as $hit)
+ echo " ".$hit->title."\n";
+
+ $a = new Zend_Search_Lucene($api_target);
+ $query = $argv[1];
+ $hits = $a->find(strtolower($query));
+ echo "\nFound ".count($hits)." for ".$query." in API\n";
+ foreach($hits as $hit)
+ {
+ echo " ".$hit->link."\n";
+ }
+ }
+}
+else
+{
+ echo "Usage: 'php build.php quickstart' or 'php build.php api'\n";
+}
+
+?>
\ No newline at end of file diff --git a/buildscripts/texbuilder/create_index.php b/buildscripts/index/quickstart_index.php index b451473d..565734ef 100644 --- a/buildscripts/texbuilder/create_index.php +++ b/buildscripts/index/quickstart_index.php @@ -1,21 +1,40 @@ <?php
-// Create quickstart search index
-$zend_path = realpath(dirname(__FILE__).'/../../demos/quickstart/protected/index');
-set_include_path(get_include_path().';'.$zend_path);
-require_once ('Zend/Search/Lucene.php');
-
-
class quickstart_index
{
private $_index;
private $_dir;
- public function __construct($index_file)
+ private $_base;
+ private $_source;
+
+ public function __construct($index_file, $base, $source)
{
$this->_index = new Zend_Search_Lucene($index_file, true);
$this->_dir = $index_file;
+ $this->_base = $base;
+ $this->_source = $source;
+ }
+
+ public function create_index()
+ {
echo "Building search index...\n";
+ $pages = include($this->_source);
+ $count = 0;
+ foreach($pages as $chapter => $sections)
+ {
+ foreach($sections as $section)
+ {
+ echo " Adding $section\n";
+ $page = $this->_base.'/'.$section;
+ $file_content = file_get_contents($page);
+ $this->add($file_content,$section, filemtime($page));
+ $count++;
+ }
+ }
+
+ $this->_index->commit();
+ echo "\n {$count} files indexed.\n";
}
public function add($content, $section, $mtime)
diff --git a/buildscripts/texbuilder/build.php b/buildscripts/texbuilder/build.php index f0556e3f..cbea9859 100644 --- a/buildscripts/texbuilder/build.php +++ b/buildscripts/texbuilder/build.php @@ -10,102 +10,9 @@ $mainTexFile = dirname(__FILE__).'/prado3_quick_start.tex'; //page root location
$base = realpath(dirname(__FILE__).'/../../demos/quickstart/protected/pages/');
-//search index data directory
-$index_dir = realpath(dirname(__FILE__).'/../../demos/quickstart/protected/index/data/');
-
-
-//list page into chapters
-$pages['Getting Started'] = array(
- 'GettingStarted/Introduction.page',
- 'GettingStarted/AboutPrado.page',
- 'GettingStarted/Installation.page',
- 'GettingStarted/HelloWorld.page',
- 'GettingStarted/Upgrading.page'
- );
-
-$pages['Fundamentals'] = array(
- 'Fundamentals/Architecture.page',
- 'Fundamentals/Components.page',
- 'Fundamentals/Controls.page',
- 'Fundamentals/Pages.page',
- 'Fundamentals/Modules.page',
- 'Fundamentals/Services.page',
- 'Fundamentals/Applications.page',
- 'Fundamentals/Hangman.page');
-
-$pages['Configurations'] = array(
- 'Configurations/Overview.page',
- 'Configurations/Templates1.page',
- 'Configurations/Templates2.page',
- 'Configurations/Templates3.page',
- 'Configurations/AppConfig.page',
- 'Configurations/PageConfig.page');
-
-$pages['Control Reference : Standard Controls'] = array(
- 'Controls/Button.page',
- 'Controls/CheckBox.page',
- 'Controls/ColorPicker.page',
- 'Controls/DatePicker.page',
- 'Controls/Expression.page',
- 'Controls/FileUpload.page',
- 'Controls/Head.page',
- 'Controls/HiddenField.page',
- 'Controls/HtmlArea.page',
- 'Controls/HyperLink.page',
- 'Controls/ImageButton.page',
- 'Controls/ImageMap.page',
- 'Controls/Image.page',
- 'Controls/InlineFrame.page',
- 'Controls/JavascriptLogger.page',
- 'Controls/Label.page',
- 'Controls/LinkButton.page',
- 'Controls/Literal.page',
- 'Controls/MultiView.page',
- 'Controls/Panel.page',
- 'Controls/PlaceHolder.page',
- 'Controls/RadioButton.page',
- 'Controls/SafeHtml.page',
- 'Controls/Statements.page',
- 'Controls/Table.page',
- 'Controls/TextBox.page',
- 'Controls/TextHighlighter.page',
- 'Controls/Wizard.page');
-
-$pages['Control Reference : List Controls'] = array(
- 'Controls/List.page');
-
-$pages['Control Reference : Validation Controls'] = array(
- 'Controls/Validation.page');
-
-$pages['Control Reference : Data Controls'] = array(
- 'Controls/Data.page',
- 'Controls/DataList.page',
- 'Controls/DataGrid.page',
- 'Controls/Repeater.page');
-
-$pages['Write New Controls'] = array(
- 'Controls/NewControl.page');
-
-$pages['Advanced Topics'] = array(
- 'Advanced/Auth.page',
- 'Advanced/Security.page',
- 'Advanced/Assets.page',
- 'Advanced/MasterContent.page',
- 'Advanced/Themes.page',
- 'Advanced/State.page',
- 'Advanced/Logging.page',
- 'Advanced/I18N.page',
- 'Advanced/Error.page',
- 'Advanced/Performance.page');
-
-$pages['Client-side Scripting'] = array(
- 'Advanced/Scripts.page',
- 'Advanced/Scripts1.page',
- 'Advanced/Scripts2.page',
- 'Advanced/Scripts3.page');
-
//-------------- END CONFIG ------------------
+$pages = include('pages.php');
function escape_verbatim($matches)
{
@@ -259,9 +166,9 @@ function parse_html($page,$html) $html = preg_replace('/<\/li>/', '', $html);
//headings
- $html = preg_replace('/<h1>([^<]+)<\/h1>/', '\section{$1}', $html);
- $html = preg_replace('/<h2>([^<]+)<\/h2>/', '\subsection{$1}', $html);
- $html = preg_replace('/<h3>([^<]+)<\/h3>/', '\subsubsection{$1}', $html);
+ $html = preg_replace('/<h1\s+id="[^"]+">([^<]+)<\/h1>/', '\section{$1}', $html);
+ $html = preg_replace('/<h2\s+id="[^"]+">([^<]+)<\/h2>/', '\subsection{$1}', $html);
+ $html = preg_replace('/<h3\s+id="[^"]+">([^<]+)<\/h3>/', '\subsubsection{$1}', $html);
@@ -318,8 +225,8 @@ $header_count = 0; //--------------- Indexer -------------------
-require_once('create_index.php');
-$indexer = new quickstart_index($index_dir);
+//require_once('create_index.php');
+//$indexer = new quickstart_index($index_dir);
// ---------------- Create the Tex files ---------
$count = 1;
@@ -339,14 +246,13 @@ foreach($pages as $chapter => $sections) $current_path = $page;
//add id to <h1>, <h2>, <3>
- $content = set_header_id(file_get_contents($page),$j++);
- file_put_contents($page, $content);
+ $tmp_content = set_header_id(file_get_contents($page),$j++);
+ file_put_contents($page, $tmp_content);
$content .= get_section_label($section);
$file_content = file_get_contents($page);
- $tex = parse_html($page,$file_content);
- $content .= $tex;
- $indexer->add($file_content,$section, filemtime($page));
+ $tex =
+ $content .= parse_html($page,$file_content);
}
//var_dump($content);
@@ -355,7 +261,7 @@ foreach($pages as $chapter => $sections) echo "\n";
}
-$indexer->commit();
+//$indexer->commit();
if($argc <= 1 && $count > 1)
{
diff --git a/buildscripts/texbuilder/pages.php b/buildscripts/texbuilder/pages.php new file mode 100644 index 00000000..c55747c6 --- /dev/null +++ b/buildscripts/texbuilder/pages.php @@ -0,0 +1,100 @@ +<?php
+/*
+ * Created on 11/05/2006
+ */
+
+//list page into chapters
+$pages['Getting Started'] = array(
+ 'GettingStarted/Introduction.page',
+ 'GettingStarted/AboutPrado.page',
+ 'GettingStarted/Installation.page',
+ 'GettingStarted/HelloWorld.page',
+ 'GettingStarted/Upgrading.page'
+ );
+
+$pages['Fundamentals'] = array(
+ 'Fundamentals/Architecture.page',
+ 'Fundamentals/Components.page',
+ 'Fundamentals/Controls.page',
+ 'Fundamentals/Pages.page',
+ 'Fundamentals/Modules.page',
+ 'Fundamentals/Services.page',
+ 'Fundamentals/Applications.page',
+ 'Fundamentals/Hangman.page');
+
+$pages['Configurations'] = array(
+ 'Configurations/Overview.page',
+ 'Configurations/Templates1.page',
+ 'Configurations/Templates2.page',
+ 'Configurations/Templates3.page',
+ 'Configurations/AppConfig.page',
+ 'Configurations/PageConfig.page');
+
+$pages['Control Reference : Standard Controls'] = array(
+ 'Controls/Button.page',
+ 'Controls/CheckBox.page',
+ 'Controls/ColorPicker.page',
+ 'Controls/DatePicker.page',
+ 'Controls/Expression.page',
+ 'Controls/FileUpload.page',
+ 'Controls/Head.page',
+ 'Controls/HiddenField.page',
+ 'Controls/HtmlArea.page',
+ 'Controls/HyperLink.page',
+ 'Controls/ImageButton.page',
+ 'Controls/ImageMap.page',
+ 'Controls/Image.page',
+ 'Controls/InlineFrame.page',
+ 'Controls/JavascriptLogger.page',
+ 'Controls/Label.page',
+ 'Controls/LinkButton.page',
+ 'Controls/Literal.page',
+ 'Controls/MultiView.page',
+ 'Controls/Panel.page',
+ 'Controls/PlaceHolder.page',
+ 'Controls/RadioButton.page',
+ 'Controls/SafeHtml.page',
+ 'Controls/Statements.page',
+ 'Controls/Table.page',
+ 'Controls/TextBox.page',
+ 'Controls/TextHighlighter.page',
+ 'Controls/Wizard.page');
+
+$pages['Control Reference : List Controls'] = array(
+ 'Controls/List.page');
+
+$pages['Control Reference : Validation Controls'] = array(
+ 'Controls/Validation.page');
+
+$pages['Control Reference : Data Controls'] = array(
+ 'Controls/Data.page',
+ 'Controls/DataList.page',
+ 'Controls/DataGrid.page',
+ 'Controls/Repeater.page');
+
+$pages['Write New Controls'] = array(
+ 'Controls/NewControl.page');
+
+$pages['Advanced Topics'] = array(
+ 'Advanced/Auth.page',
+ 'Advanced/Security.page',
+ 'Advanced/Assets.page',
+ 'Advanced/MasterContent.page',
+ 'Advanced/Themes.page',
+ 'Advanced/State.page',
+ 'Advanced/Logging.page',
+ 'Advanced/I18N.page',
+ 'Advanced/Error.page',
+ 'Advanced/Performance.page');
+
+$pages['Client-side Scripting'] = array(
+ 'Advanced/Scripts.page',
+ 'Advanced/Scripts1.page',
+ 'Advanced/Scripts2.page',
+ 'Advanced/Scripts3.page');
+
+
+return $pages;
+//-------------- END CONFIG ----------------
+
+?>
\ No newline at end of file |