Changeset 509
- Timestamp:
- 09/20/04 21:05:10 (4 years ago)
- Location:
- trunk
- Files:
-
- 5 modified
-
Build.PL (modified) (1 diff)
-
Changes (modified) (1 diff)
-
PREREQUISITES (modified) (2 diffs)
-
lib/OpenGuides/Utils.pm (modified) (3 diffs)
-
t/12_macros.t (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Build.PL
r501 r509 233 233 'CGI::Cookie' => 0, 234 234 'CGI::Wiki' => '0.54', 235 'CGI::Wiki::Formatter::UseMod' => '0. 09',235 'CGI::Wiki::Formatter::UseMod' => '0.16', # macros 236 236 'CGI::Wiki::Plugin::Categoriser' => 0, 237 237 'CGI::Wiki::Plugin::Diff' => '0.07', # earlier buggy -
trunk/Changes
r507 r509 8 8 on edit form, banner at top of page (see CUSTOMISATION file 9 9 for details). 10 Added new macro - used as eg @INDEX_LIST [[Locale Fulham]] 10 11 11 12 0.40 18 September 2004 -
trunk/PREREQUISITES
r490 r509 1 Modules required by OpenGuides 0.4 01 Modules required by OpenGuides 0.41 2 2 =================================== 3 3 … … 7 7 CGI::Cookie 8 8 CGI::Wiki (version 0.54 or later) 9 CGI::Wiki::Formatter::UseMod (version 0. 09or later)9 CGI::Wiki::Formatter::UseMod (version 0.16 or later) 10 10 CGI::Wiki::Plugin::Categoriser 11 11 CGI::Wiki::Plugin::Diff (version 0.07 or later) -
trunk/lib/OpenGuides/Utils.pm
r469 r509 3 3 use strict; 4 4 use vars qw( $VERSION ); 5 $VERSION = '0.0 7';5 $VERSION = '0.08'; 6 6 7 7 use Carp qw( croak ); … … 120 120 qr/\@INDEX_LINK\s+\[\[(Category|Locale)\s+([^\]|]+)\|?([^\]]+)?\]\]/ => 121 121 sub { 122 my $wiki = shift; 122 123 my $link_title = $_[2] || "View all pages in $_[0] $_[1]"; 123 124 return qq(<a href="$script_name?action=index;index_type=) . uri_escape(lc($_[0])) . qq(;index_value=) . uri_escape($_[1]) . qq(">$link_title</a>); 124 125 }, 125 qr/\@RSS\s+\[(.*?)\]/ => sub { 126 qr/\@INDEX_LIST\s+\[\[(Category|Locale)\s+([^\]]+)]]/ => 127 sub { 128 my ($wiki, $type, $value) = @_; 129 my @nodes = $wiki->list_nodes_by_metadata( 130 metadata_type => $type, 131 metadata_value => $value, 132 ignore_case => 1, 133 ); 134 unless ( scalar @nodes ) { 135 return "\n* No pages currently in " 136 . lc($type) . " $value\n"; 137 } 138 my $return = "\n"; 139 foreach my $node ( @nodes ) { 140 $return .= "* " 141 . $wiki->formatter->format_link( 142 wiki => $wiki, 143 link => $node, 144 ) 145 . "\n"; 146 } 147 return $return; 148 }, 149 qr/\@RSS\s+\[(.*?)\]/ => sub { 150 my $wiki = shift; 126 151 # Get the URL. It's already been formatted into a 127 152 # hyperlink so we need to reverse that. … … 156 181 div code strike sub sup font)], 157 182 macros => \%macros, 183 pass_wiki_to_macros => 1, 158 184 node_prefix => "$script_name?", 159 185 edit_prefix => "$script_name?action=edit&id=", -
trunk/t/12_macros.t
r361 r509 1 1 use strict; 2 use CGI::Wiki::Setup::SQLite; 2 3 use Config::Tiny; 3 use OpenGuides ::Utils;4 use Test::More tests => 2;4 use OpenGuides; 5 use Test::More tests => 6; 5 6 6 7 eval { require DBD::SQLite; }; … … 8 9 9 10 SKIP: { 10 skip "DBD::SQLite not installed - no database to test with", 211 skip "DBD::SQLite not installed - no database to test with", 6 11 12 unless $have_sqlite; 13 14 # Clear out the database from any previous runs. 15 unlink "t/node.db"; 16 unlink <t/indexes/*>; 17 CGI::Wiki::Setup::SQLite::setup( { dbname => "t/node.db" } ); 12 18 13 19 my $config = Config::Tiny->new; … … 18 24 script_url => "", 19 25 script_name => "", 26 site_name => "Test", 27 template_path => "./templates", 28 home_name => "Home", 20 29 }; 21 30 22 my $ wiki = OpenGuides::Utils->make_wiki_object( config => $config );23 my $ formatter = $wiki->formatter;31 my $guide = OpenGuides->new( config => $config ); 32 my $wiki = $guide->wiki; 24 33 25 my $wikitext = <<WIKI; 34 # Test @INDEX_LINK 35 $wiki->write_node( "Test 1", "\@INDEX_LINK [[Category Foo]]" ) 36 or die "Can't write node"; 37 $wiki->write_node( "Test 2", "\@INDEX_LINK [[Category Bar|Bars]]" ) 38 or die "Can't write node"; 26 39 27 \@INDEX_LINK [[Category Foo]] 40 my $output; 41 $output = $guide->display_node( 42 return_output => 1, 43 id => "Test 1", 44 ); 45 like( $output, qr/View all pages in Category Foo/, 46 "\@INDEX_LINK has right default link text" ); 47 $output = $guide->display_node( 48 return_output => 1, 49 id => "Test 2", 50 ); 51 like( $output, qr/>Bars<\/a>/, "...and can be overridden" ); 28 52 29 \@INDEX_LINK [[Category Bar|Bars]] 30 31 WIKI 32 33 my $html = $formatter->format($wikitext); 34 like( $html, qr/View all pages in Category Foo/, 35 "\@INDEX_LINK has right default link text" ); 36 like( $html, qr/>Bars<\/a>/, "...and can be overridden" ); 53 # Test @INDEX_LIST 54 $wiki->write_node( "Test 3", "\@INDEX_LIST [[Category Foo]]" ) 55 or die "Can't write node"; 56 $wiki->write_node( "Test 4", "\@INDEX_LIST [[Locale Bar]]" ) 57 or die "Can't write node"; 58 $wiki->write_node( "Test 5", "\@INDEX_LIST [[Category Nonexistent]]" ) 59 or die "Can't write node"; 60 $wiki->write_node( "Test 6", "\@INDEX_LIST [[Locale Nonexistent]]" ) 61 or die "Can't write node"; 62 $wiki->write_node( "Wibble", "wibble", undef, 63 { 64 category => "foo", 65 locale => "bar", 66 } 67 ) 68 or die "Can't write node"; 69 $output = $guide->display_node( 70 return_output => 1, 71 id => "Test 3", 72 ); 73 like ( $output, qr|<a href=".*">Wibble</a>|, 74 '@INDEX_LIST works for categories' ); 75 $output = $guide->display_node( 76 return_output => 1, 77 id => "Test 5", 78 ); 79 like ( $output, qr|No pages currently in category|, 80 "...and fails nicely if no pages in category" ); 81 $output = $guide->display_node( 82 return_output => 1, 83 id => "Test 4", 84 ); 85 like ( $output, qr|<a href=".*">Wibble</a>|, 86 '@INDEX_LIST works for locales' ); 87 $output = $guide->display_node( 88 return_output => 1, 89 id => "Test 6", 90 ); 91 like ( $output, qr|No pages currently in locale|, 92 "...and fails nicely if no pages in locale" ); 37 93 }
