/[SVNBrowser]/trunk/lib/SVNBrowser/View.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

Contents of /trunk/lib/SVNBrowser/View.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 77 - (show annotations)
Wed Feb 6 12:46:50 2008 UTC (16 years, 2 months ago) by dpavlin
File size: 3551 byte(s)
Refactor show_revisions_actions into own sub
1 package SVNBrowser::View;
2
3 # Dobrica Pavlinusic, <dpavlin@rot13.org> 09/03/07 22:14:24 CEST
4
5 use strict;
6 use warnings;
7
8 use Jifty::View::Declare -base;
9
10 use Data::Dump qw/dump/;
11
12 template '/x-list' => page {
13 h1 { _("SVN Repository browser") };
14
15 form {
16
17 my $filter = Jifty->web->new_action(
18 class => 'Filter',
19 moniker => 'filter_list',
20 );
21
22 render_param( $filter => 'author' );
23 render_param( $filter => 'branch' );
24 render_param( $filter => 'rel_path', default => get('rel_path') );
25 render_param( $filter => 'path' );
26 render_param( $filter => 'search' );
27
28 div { attr { class => 'inline' }
29
30 render_param( $filter => 'from_date' );
31 render_param( $filter => 'to_date' );
32 render_param( $filter => 'per_page' );
33 render_param( $filter => 'show_actions' );
34
35 };
36
37 form_submit(
38 label => _("Filter commits")
39 );
40
41 #warn "####",dump( $filter->result->content );
42
43 my $revisions = $filter->result->content('revisions');
44 if ( $revisions ) {
45
46 sub pager {
47 my ( $action, $collection ) = @_;
48
49 return if $collection->pager->last_page == 1;
50
51 div {
52 attr { class => 'pager' };
53
54 if ( $collection->pager->previous_page ) {
55 outs_raw $action->button(
56 submit => $action,
57 label => _("previous page"),
58 arguments => { page => $collection->pager->previous_page },
59 );
60 }
61
62 if ($collection->pager->last_page > 1) {
63 span {
64 _("page"), ' ', $collection->pager->current_page, ' ',_("of"), ' ', $collection->pager->last_page
65 }
66 };
67
68 if ($collection->pager->next_page) {
69 outs_raw( $action->button(
70 submit => $action,
71 label => _("next page"),
72 arguments => { page => $collection->pager->next_page },
73 ) );
74 }
75 }
76 }
77
78 pager( $filter, $revisions );
79
80 my $show_actions = get('show_actions') || $filter->argument_value('show_actions');
81 my $rel_path = get('rel_path') || $filter->argument_value('rel_path');
82 warn "### show_actions = $show_actions";
83
84 show_revisions_actions( $filter, $revisions );
85
86 pager( $filter, $revisions );
87
88 }; #form
89
90 };
91
92 sub show_revisions_actions {
93 warn "### show_revisions_actions ",dump( @_ );
94 my ( $filter, $revisions ) = @_;
95
96 dl {
97 attr { class => 'results' };
98
99 while (my $r = $revisions->next ) {
100 dt {
101 attr { class => 'commit' }
102 tt { $r->revision }
103 span { attr { class => 'author' } $r->author }
104 span { attr { class => 'commit_date' } $r->commit_date }
105 }
106
107 dd {
108 pre { attr { class => 'commit_message' } $r->message };
109
110 warn "### rel_path ", $filter->argument_value('rel_path'), " path: ", $filter->argument_value('path');
111
112 my $actions = SVNBrowser::Model::ActionCollection->new();
113 $actions->unlimit;
114 $actions->limit( column => 'revision', value => $r->revision );
115 $actions->limit( column => 'rel_path', value => $filter->argument_value('rel_path'), operator => 'STARTSWITH' )
116 if $filter->argument_value('rel_path');
117 $actions->limit( column => 'rel_path', value => $filter->argument_value('path'), operator => 'MATCHES' )
118 if $filter->argument_value('path');
119
120 warn "### actions SQL query ", $actions->build_select_query;
121
122 ul { attr { class => 'actions' };
123 while (my $a = $actions->next) {
124 li {
125 tt { attr { class => 'action-' . $a->type }
126 outs (
127 $a->type, ' ',
128 $a->branch
129 );
130 hyperlink(
131 label => $a->rel_path,
132 parameters => {
133 rel_path => $a->rel_path,
134 }
135 );
136 }
137 }
138 }
139 }
140 }
141 }
142 }
143 }
144 };
145

  ViewVC Help
Powered by ViewVC 1.1.26