Changeset 1618
- Timestamp:
- 11/16/07 14:28:10 (6 years ago)
- Location:
- lang/perl/Jipotter/trunk
- Files:
-
- 1 added
- 7 modified
-
lib/Jipotter/Plugin/Timelines.pm (modified) (1 diff)
-
lib/Jipotter/Plugin/Timelines/Action/Post.pm (modified) (2 diffs)
-
lib/Jipotter/Plugin/Timelines/Action/Search.pm (added)
-
lib/Jipotter/Plugin/Timelines/Dispatcher.pm (modified) (1 diff)
-
lib/Jipotter/Plugin/Timelines/View.pm (modified) (5 diffs)
-
lib/Jipotter/Script/Aggregate.pm (modified) (1 diff)
-
lib/Jipotter/View.pm (modified) (1 diff)
-
share/web/static/css/jipotter.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Jipotter/trunk/lib/Jipotter/Plugin/Timelines.pm
r1563 r1618 58 58 sub items_per_page { shift->{items_per_page} || 20 } 59 59 60 sub search_phrase { 61 my $self = shift; 62 if ( @_ ) { 63 $self->{search_phrase} = shift; 64 } 65 $self->{search_phrase}; 66 } 60 67 61 68 1; -
lang/perl/Jipotter/trunk/lib/Jipotter/Plugin/Timelines/Action/Post.pm
r1595 r1618 40 40 }; 41 41 42 sub moniker { ' update' }42 sub moniker { 'timelines_post' } 43 43 44 44 sub sticky_on_failure { 0 } … … 57 57 if ( $self->argument_value( $service->name ) ) { 58 58 59 Jifty->log->info( $service->name .' is updatedat '. localtime );59 Jifty->log->info( 'Posted to '. $service->name .' at '. localtime ); 60 60 $service->update( $message ); 61 61 } -
lang/perl/Jipotter/trunk/lib/Jipotter/Plugin/Timelines/Dispatcher.pm
r1522 r1618 5 5 use Jifty::Dispatcher -base; 6 6 7 before qr{^/ update} => run {7 before qr{^/timelines/post} => run { 8 8 Jifty->web->new_action( 9 9 class => 'Jipotter::Plugin::Timelines::Action::Post', 10 moniker => 'update' 10 moniker => 'timelines_post' 11 )->run; 12 13 redirect '/'; 14 }; 15 16 before qr{^/timelines/search} => run { 17 Jifty->web->new_action( 18 class => 'Jipotter::Plugin::Timelines::Action::Search', 19 moniker => 'timelines_search' 11 20 )->run; 12 21 -
lang/perl/Jipotter/trunk/lib/Jipotter/Plugin/Timelines/View.pm
r1595 r1618 5 5 use Jifty::View::Declare -base; 6 6 use Jipotter::Model::StatusCollection; 7 use Time::Piece; 8 9 template 'timelines' => sub { 10 set region => Jifty::Web::PageRegion->new( 11 name => 'timelines_table', 12 path => '/timelines/region', 13 defaults => { page => get('page') || 1 }, 14 ); 15 16 show '/timelines/form'; 17 show '/timelines/search'; 18 show '/timelines/table'; 19 }; 7 20 8 21 private template 'timelines/form' => sub { 9 22 my $action = Jifty->web->new_action( 10 class => 'Jipotter::Plugin::Timelines::Action::Post',11 moniker => 'update',23 class => 'Jipotter::Plugin::Timelines::Action::Post', 24 moniker => 'timelines_post', 12 25 ); 13 26 27 my $plugin = Jifty->find_plugin('Jipotter::Plugin::Timelines'); 28 14 29 div { attr { class => 'PostBox' }; 15 Jifty->web->form->start( submit_to => '/ update' );30 Jifty->web->form->start( submit_to => '/timelines/post' ); 16 31 17 32 render_param( $action => 'message' ); … … 20 35 21 36 form_submit( label => 'Update', name => 'submit' ); 22 23 my $plugin = Jifty->find_plugin('Jipotter::Plugin::Timelines');24 37 25 38 foreach my $service ( $plugin->available_services ) { … … 34 47 }; 35 48 49 private template 'timelines/search' => sub { 50 my $action = Jifty->web->new_action( 51 class => 'Jipotter::Plugin::Timelines::Action::Search', 52 moniker => 'timelines_search', 53 ); 54 55 my $region = get('region'); 56 my $plugin = Jifty->find_plugin('Jipotter::Plugin::Timelines'); 57 58 div { attr { class => 'timelines_search' }; 59 Jifty->web->form->start( submit_to => 'timelines/search' ); 60 61 render_param( 62 $action => 'phrase', sticky_value => $plugin->search_phrase 63 ); 64 65 form_submit( 66 label => 'Search', 67 name => 'submit_search', 68 onclick => { 69 submit => $action, 70 refresh => $region->name, 71 args => { phrase => $plugin->search_phrase }, 72 } 73 ); 74 75 Jifty->web->form->end; 76 }; 77 }; 78 36 79 private template 'timelines/table' => sub { 37 render_region( 38 name => 'timelines_table', 39 path => '/timelines/region', 40 defaults => { page => get('page') || 1 }, 41 ); 80 my $region = get('region'); 81 82 $region->render; 42 83 }; 43 84 44 85 template 'timelines/region' => sub { 45 my $page = get('page') || 1;86 my $page = get('page') || 1; 46 87 my $message_id = get('message_id') || ''; 47 88 48 89 my $plugin = Jifty->find_plugin('Jipotter::Plugin::Timelines'); 90 my $phrase = $plugin->search_phrase; 49 91 50 92 my $entries = Jipotter::Model::StatusCollection->new; 51 $entries->unlimit; 52 $entries->order_by( column => 'epoch', order => 'DESC' ); 53 $entries->set_page_info( 54 current_page => $page, 55 per_page => $plugin->items_per_page, 56 ); 93 if ( defined $phrase ) { 94 95 # XXX: We need ESCAPE '\\' with them for SQLite actually... 96 $phrase =~ s/%/\\%/g; 97 $phrase =~ s/_/\\_/g; 98 99 $entries->limit( 100 column => 'text', 101 value => $phrase, 102 operator => 'MATCHES', 103 ); 104 } 105 else { 106 $entries->unlimit; 107 } 108 $entries->order_by( column => 'epoch', order => 'DESC' ); 109 $entries->set_page_info( 110 current_page => $page, 111 per_page => $plugin->items_per_page, 112 ); 57 113 set entries => $entries; 58 114 … … 60 116 61 117 table { attr { class => 'Statuses' }; 118 my $now = localtime; 119 caption { attr { class => 'timeline_caption' }; 120 'Last updated: '.$now->ymd.' '.$now->hms; 121 }; 122 62 123 while ( my $entry = $entries->next ) { 63 124 … … 125 186 } 126 187 else { 127 span { attr { class => 'current' }; strong { "$num " }};188 span { attr { class => 'current' }; "$num " }; 128 189 } 129 190 } -
lang/perl/Jipotter/trunk/lib/Jipotter/Script/Aggregate.pm
r1366 r1618 19 19 Jifty->log->debug( 'registering '.$service->name ); 20 20 21 my $ct = 0; 21 22 foreach my $status ( $service->timelines ) { 22 23 my $entry = Jipotter::Model::Status->new; 23 $entry->load_or_create( %{ $status } ); 24 $entry->load_by_cols( link => $status->link ); 25 unless ( $entry->id ) { 26 $entry->create( %{ $status } ); 27 $ct++; 28 } 24 29 } 30 Jifty->log->debug( "registered $ct entries" ) if $ct; 25 31 } 26 32 } -
lang/perl/Jipotter/trunk/lib/Jipotter/View.pm
r1595 r1618 13 13 body { 14 14 div { attr { class => 'BodyContainer' }; 15 # see Timelines plugin 16 show 'timelines/form'; 17 show 'timelines/table'; 15 show 'timelines'; # see Timelines plugin 18 16 } 19 17 } -
lang/perl/Jipotter/trunk/share/web/static/css/jipotter.css
r1563 r1618 74 74 } 75 75 76 .timeline_caption { 77 font-size: 90%; 78 margin-bottom: 20px; 79 } 80 81 .timelines_search { 82 background-color: #eeeeee; 83 width: 100%; 84 margin-bottom: 3px; 85 margin-top: 3px; 86 padding-top: 4px; 87 padding-bottom: 4px; 88 } 89 90 .timelines_search form { 91 margin-left: 10px; 92 } 93 94 .timelines_search div { 95 display: inline; 96 margin: auto; 97 } 98
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)