Changeset 1593

Show
Ignore:
Timestamp:
01/19/05 02:05:07 (4 years ago)
Author:
whmoseley
Message:

Add inital code for indexing site and docs.

Meta name "section" is used to limit to a section. Search for "defaultcontents"

defaultcontents section=docs
defaultcontents section=devel ( only devel docs)
defaultcontents section=website ( only web site pages, excluding docs and devel_docs )

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/swish_website/Plugin/My/POD.pm

    r1587 r1593  
    77use vars '@pod_toc'; 
    88 
    9  
    10 my $mode = 'Pod::POM::View::HTML';  # The view module 
    11  
    12 # Much of this is based on (or copied from) Stas' DocSet 0.17 
     9my %split_by = map {"head".$_ => 1} 1..4; 
     10 
     11my $view_mode = 'Pod::POM::View::HTML';  # The view module 
     12 
     13# *Much* of this is based on (or copied from) Stas' DocSet 0.17 
    1314# I'm not sure why spaces need to be removed from links.  Pod::POM doesn't remove them. 
    1415 
     
    4243 
    4344    $data{sections} = \@sections; 
     45 
     46    $data{podparts} = [ slice_by_head(@sections) ]; 
    4447 
    4548    $data{toc} = fetch_toc( \@sections ); 
     
    6164} 
    6265 
     66sub slice_by_head { 
     67    my @sections = @_; 
     68    my @body = (); 
     69    for my $node (@sections) { 
     70        my @next = (); 
     71        # assumption, after the first 'headX' section, there can only 
     72        # be other 'headX' sections 
     73        my $count = scalar $node->content; 
     74        my $id = -1; 
     75        for ($node->content) { 
     76            $id++; 
     77            next unless exists $split_by{ $_->type }; 
     78            @next = splice @{$node->content}, $id; 
     79            last; 
     80        } 
     81        push @body, $node, slice_by_head(@next); 
     82    } 
     83    return @body; 
     84} 
     85 
    6386sub combine_verbatim_sections_hack { 
    6487    my $tree = shift; 
     
    88111        next unless $sections->[$_] && $sections->[$_]->title =~ /DESCRIPTION|OVERVIEW/; 
    89112 
    90         my $abstract = $sections->[$_]->content->present($mode); 
     113        my $abstract = $sections->[$_]->content->present($view_mode); 
    91114        $abstract =~ s|<p>(.*?)</p>.*|$1|s; 
    92115        return $abstract; 
     
    122145 
    123146    my %toc_entry = ( 
    124         title    => $title->present($mode), # run the formatting if any 
     147        title    => $title->present($view_mode), # run the formatting if any 
    125148        link     => "#$title", 
    126149    ); 
  • trunk/swish_website/README

    r1591 r1593  
    113113------------------------------ 
    114114 
    115 [todo] 
     115To index the site run from the top level directory: 
     116 
     117    $ SWISH_SITE=http://swish-e.org swish-e -c etc/swish.config -S prog 
     118 
     119SWISH_SITE is the top level URL. 
     120START_FILE is the starting file.  Default is index.html 
     121(SWISH_SITE=http://swish-e.org/docs START_FILE=readme.html to index just one file) 
     122 
     123That writes the index to public_html/search/ 
     124 
     125Or to run it quiet: 
     126 
     127$ SPIDER_QUIET=1 SWISH_SITE=http://localhost/apache/public_html \ 
     128    swish-e -c etc/swish.config -S prog -v0 
     129 
     130Capture output (for debugging) like this: 
     131 
     132  $ SWISH_SITE=http://localhost/apache/public_html \ 
     133        /usr/local/lib/swish-e/spider.pl etc/spider.config > out 
     134 
     135 
     136 
     137todo: add metaname selection and create build script that is built from 
    116138 
    117139 
     
    137159- enable template caching for the search script 
    138160 
     161- Probably should filter all hrefs= and name= through |uri|html.  Plus some 
     162are very large.  Maybe shorten or md5 them?  If so, then need to adjust link_to_page(). 
    139163 
    140164 
     165 
  • trunk/swish_website/bin/split.pl

    r1587 r1593  
    11#!/usr/bin/perl -w 
    22use strict; 
     3use warnings; 
    34use File::Find; 
    45 
    56my $dir = shift || die "failed to specify directory"; 
     7my $pat = qr!<h\d><a name="([^"]+)"></a>([^<]+)</h\d>!i; #" for vim 
     8 
     9 
     10if ( -f $dir ) { 
     11    warn "Indexing [$dir] as a single file\n"; 
     12    index_path( $dir ); 
     13    exit; 
     14} 
    615 
    716find( \&process_doc, $dir ); 
     
    1120 
    1221 
    13 my $pat = qr[<h\d><a name="([^"]+)">([^<]+)</a></h\d>]i; 
    1422 
    1523 
     
    3139    return if $dir =~ m!/graphics!; 
    3240 
     41    index_path( $path ); 
     42} 
     43 
     44sub index_path { 
     45    my ( $path ) = @_; 
    3346 
    3447    unless ( open( FH, "<$path" ) ) { 
    35         warn "Failed to open file [$path]\n"; 
     48        warn "Failed to open file - [$path]: $!\n"; 
    3649        return; 
    3750    } 
     
    4356sub index_doc { 
    4457    my ($name, $doc) = @_; 
     58 
    4559 
    4660 
     
    5569    $title ||= "Swish-e Documentation"; 
    5670 
    57     $title =~ s/^SWISH-Enhanced: //; 
     71    $title =~ s/^Swish-e :: //; 
    5872 
    5973 
  • trunk/swish_website/lib/page/podpage

    r1587 r1593  
    2020<hr> 
    2121 
    22 [% FOREACH section = pom.sections %] 
    23   [% section.present(view) %] 
     22[% FOREACH section = pom.podparts %] 
     23    <div class="sub-section"> 
     24        [% section.present(view) %] 
     25    </div> 
    2426[% END %] 
    2527 
  • trunk/swish_website/lib/page/search.html

    r1587 r1593  
    8686 
    8787    <div class="search-title"> 
    88         <a href="[% item.Property('swishdocpath') | uri | html %]"> 
     88        <a href="[% item.Property('swishdocpath') %]"> 
    8989            [%  item.Property('swishtitle') || 'missing title' | highlight('swishtitle', item ) %]</a> 
    9090 
     
    9797 
    9898    <div class="search-metadata"> 
    99         Path: <a href="[% item.Property('swishdocpath') | uri | html %]"> 
     99        Path: <a href="[% item.Property('swishdocpath') %]"> 
    100100            [% item.Property('swishdocpath') | highlight('swishdocpath', item ) %]</a> 
    101101            - [% item.Property('swishdocsize') %] bytes<br>