File: Root.pm

package info (click to toggle)
libcatalyst-view-csv-perl 1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 228 kB
  • sloc: perl: 1,622; sh: 14; makefile: 2
file content (76 lines) | stat: -rw-r--r-- 1,803 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package TestApp::Controller::Root;

use TestApp::Object;
use base qw ( Catalyst::Controller );
use strict;
use warnings;

__PACKAGE__->config->{namespace} = "";

sub literal :Local {
  ( my $self, my $c ) = @_;

  my $data = [
    [ "1", "first entry" ],
    [ "2", "second" ],
    [ "3", "third" ],
    { index => "4", entry => "fourth" },
    TestApp::Object->new ( index => 5, entry => "fifth" ),
  ];
  $c->stash ( data => $data,
	      columns => [ qw ( index entry ) ],
	      current_view => "CSV" );
}

sub db :Local {
  ( my $self, my $c ) = @_;

  my $resultset = $c->model ( "TestDB::Person" )->search ( undef, {
    select => [ qw ( name age ) ],
    order_by => [ qw ( name age ) ],
  } );
  $c->stash ( cursor => $resultset->cursor,
	      columns => [ qw ( Name Age ) ],
	      current_view => "CSV" );
}

sub noheader :Local {
  ( my $self, my $c ) = @_;

  my $resultset = $c->model ( "TestDB::Person" )->search ( undef, {
    select => [ qw ( name age ) ],
    order_by => [ qw ( name age ) ],
  } );
  $c->stash ( cursor => $resultset->cursor,
	      current_view => "CSV" );
}

sub tsv :Local {
  ( my $self, my $c ) = @_;

  my $resultset = $c->model ( "TestDB::Person" )->search ( undef, {
    select => [ qw ( name age ) ],
    order_by => [ qw ( age name ) ],
  } );
  $c->stash ( cursor => $resultset->cursor,
	      columns => [ qw ( Name Age ) ],
	      current_view => "TSV" );
}

sub filename :Local {
  ( my $self, my $c ) = @_;

  my $resultset = $c->model ( "TestDB::Person" )->search ( undef, {
    select => [ qw ( name age ) ],
    order_by => [ qw ( age name ) ],
  } );
  $c->stash ( cursor => $resultset->cursor,
	      columns => [ qw ( Name Age ) ],
	      filename => "explicit.txt",
	      current_view => "CSV" );
}

sub end :ActionClass("RenderView") {
}

1;