Changeset 1231 for trunk/lib/OpenGuides/Template.pm
- Timestamp:
- 10/18/08 19:19:22 (3 months ago)
- Files:
-
- 1 modified
-
trunk/lib/OpenGuides/Template.pm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/OpenGuides/Template.pm
r1105 r1231 13 13 use Template; 14 14 use URI::Escape; 15 use Data::Validate::URI qw( is_web_uri ); 15 16 16 17 =head1 NAME … … 348 349 } @loclist; 349 350 350 # The 'website' attribute might contain a URL so we wiki-format it here351 # rather than just CGI::escapeHTMLing it all in the template.352 351 my $website = $args{metadata} ? $metadata{website}[0] 353 352 : $q->param("website"); 354 353 my $formatted_website_text = ""; 355 if ( $website && $website ne "http://" ) { 356 $formatted_website_text = $class->format_website_text( 357 formatter => $formatter, 358 text => $website 359 ); 354 if ( $website && $website ne "http://" && is_web_uri( $website ) ) { 355 my $trunc_website = substr( $website, 0, $config->website_link_max_chars ); 356 unless ($website eq $trunc_website ) { 357 $trunc_website .= '...'; 358 } 359 $formatted_website_text = '<a href="' . $website . '">' . $trunc_website . '</a>'; 360 360 } 361 361 … … 583 583 } 584 584 585 sub format_website_text {586 my ($class, %args) = @_;587 my ($formatter, $text) = @args{ qw( formatter text ) };588 my $formatted = $formatter->format($text);589 590 # Strip out paragraph markers put in by formatter since we want this591 # to be a single string to put in a <ul>.592 $formatted =~ s/<p>//g;593 $formatted =~ s/<\/p>//g;594 595 return $formatted;596 }597 598 599 585 =back 600 586 … … 605 591 =head1 COPYRIGHT 606 592 607 Copyright (C) 2003-200 7The OpenGuides Project. All Rights Reserved.593 Copyright (C) 2003-2008 The OpenGuides Project. All Rights Reserved. 608 594 609 595 This module is free software; you can redistribute it and/or modify it
