/[Frey]/trunk/lib/Frey/Web.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Frey/Web.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 720 by dpavlin, Thu Dec 4 20:20:45 2008 UTC revision 796 by dpavlin, Wed Dec 10 18:47:14 2008 UTC
# Line 11  use Carp qw/confess cluck carp/; Line 11  use Carp qw/confess cluck carp/;
11  use File::Slurp;  use File::Slurp;
12    
13  use Frey::Bookmarklet;  use Frey::Bookmarklet;
14  use Frey::ClassBrowser;  use Frey::Class::Browser;
15  use Frey::INC;  use Frey::INC;
16    
17  use Frey::SVK;  use Frey::SVK;
# Line 93  sub html_dump { Line 93  sub html_dump {
93  sub popup    { my $self = shift; $self->popup_dropdown('popup',    @_); }  sub popup    { my $self = shift; $self->popup_dropdown('popup',    @_); }
94  sub dropdown { my $self = shift; $self->popup_dropdown('dropdown', @_); }  sub dropdown { my $self = shift; $self->popup_dropdown('dropdown', @_); }
95    
96  our $re_html = qr{<(?:!--.+?--|(\w+).+?/\1|[^>]+/)>}s; # relaxed html check for one semi-valid tag  our $re_html = qr{<(?:!--.+?--|(\w+).+?/\1|[^>]+/?)>}s; # relaxed html check for one semi-valid tag
97    
98  sub popup_dropdown {  sub popup_dropdown {
99          my ( $self, $type, $name, $content, $full ) = @_;          my ( $self, $type, $name, $content, $full ) = @_;
# Line 184  sub add_css { Line 184  sub add_css {
184          | );          | );
185  }  }
186    
187    sub add_js {
188            my ($self,$css) = @_;
189            my ( $package, $path, $line ) = caller;
190            $self->add_head( qq|
191            <script type="text/javascript">
192            /* via $package at $path line $line */
193            $css
194            </script>
195            | );
196    }
197    
198  our $reload_counter = 0;  our $reload_counter = 0;
199    
200    
# Line 408  sub clean_status { Line 419  sub clean_status {
419          my ($self) = shift;          my ($self) = shift;
420          @head = ( 'static/frey.css' );          @head = ( 'static/frey.css' );
421          @status = (          @status = (
422                  { 'ClassBrowser' => Frey::ClassBrowser->new( usage_on_top => 0 )->as_markup },                  { 'ClassBrowser' => Frey::Class::Browser->new( usage_sort => 1, usage_on_top => 0 )->as_markup },
423                  { 'Bookmarklets' => Frey::Bookmarklet->new->as_markup },                  { 'Bookmarklets' => Frey::Bookmarklet->new->as_markup },
424                  { 'INC' => Frey::INC->new->as_markup },                  { 'INC' => Frey::INC->new->as_markup },
425          );          );
# Line 446  sub DEMOLISH { Line 457  sub DEMOLISH {
457  sub icon_path {  sub icon_path {
458          my ($self,$class,$variant) = @_;          my ($self,$class,$variant) = @_;
459          my $icon = $class;          my $icon = $class;
460            $icon ||= $self->title;
461          $icon =~ s{::}{/}g;          $icon =~ s{::}{/}g;
462          $icon .= "/$variant" if $variant;          $icon .= "/$variant" if $variant;
463          my $path = 'static/icons/' . $icon . '.png';          my $path = 'static/icons/' . $icon . '.png';
# Line 659  Generate checkbox html markup from some Line 671  Generate checkbox html markup from some
671  sub checkbox {  sub checkbox {
672          my ($self,$name,$value) = @_;          my ($self,$name,$value) = @_;
673          my $checked = '';          my $checked = '';
674          my $all_checkboxes = $self->$name;          my $all_checkboxes = eval { $self->$name };
675            warn "ERROR tried to get checkbox value for '$name' which is unknown: $@" if $@;
676          $all_checkboxes = [ $all_checkboxes ] unless ref($all_checkboxes) eq 'ARRAY'; # sigh, too chatty          $all_checkboxes = [ $all_checkboxes ] unless ref($all_checkboxes) eq 'ARRAY'; # sigh, too chatty
677          $checked = ' checked' if grep { $_ eq $value } @$all_checkboxes;          $checked = ' checked' if grep { defined $_ && $_ eq $value } @$all_checkboxes;
678          warn "# checkbox $name $value $checked\t", $self->dump( $self->$name );          warn "# checkbox $name $value $checked\t", $self->dump( $self->$name );
679          qq|<input name="$name" value="$value" type="checkbox"$checked>|;          qq|<input name="$name" value="$value" type="checkbox"$checked>|;
680  }  }
681    
682    =head2 strip
683    
684    Strip whitespace around content
685    
686      my $stripped = strip('  no more whitespace around this   ');
687    
688    =cut
689    
690    sub strip {
691            my $t = shift;
692            $t =~ s{^\s+}{}gs;
693            $t =~ s{>\s+<}{><}gs;
694            $t =~ s{\s+$}{}gs;
695            return $t;
696    }
697    
698  1;  1;

Legend:
Removed from v.720  
changed lines
  Added in v.796

  ViewVC Help
Powered by ViewVC 1.1.26