4 SGN - Catalyst-based application to run the SGN website.
12 This is the main class for the Sol Genomics Network main website.
18 use namespace
::autoclean
;
21 $ENV{WEB_PROJECT_NAME
} = $ENV{PROJECT_NAME
} = __PACKAGE__
;
26 use Catalyst
::Runtime
5.80;
30 Does the roles L<SGN::Role::Site::Config>,
31 L<SGN::Role::Site::DBConnector>, L<SGN::Role::Site::DBIC>,
32 L<SGN::Role::Site::Exceptions>, L<SGN::Role::Site::Files>,
33 L<SGN::Role::Site::Mason>, L<SGN::Role::Site::SiteFeatures>,
34 L<SGN::Role::Site::TestMode>
43 +SGN
::Authentication
::Store
45 +SGN
::Role
::Site
::Config
46 +SGN
::Role
::Site
::DBConnector
47 +SGN
::Role
::Site
::DBIC
48 +SGN
::Role
::Site
::Exceptions
49 +SGN
::Role
::Site
::Files
50 +SGN
::Role
::Site
::Mason
51 +SGN
::Role
::Site
::SiteFeatures
52 +SGN
::Role
::Site
::TestMode
61 # configure catalyst-related things. in general, things should not be
62 # added here. add them to SGN.conf, with comments.
68 disable_component_resolution_regex_fallback
=> 1,
70 default_view
=> 'Mason',
72 # Static::Simple configuration
73 'Plugin::Static::Simple' => {
74 dirs
=> [qw
[ css s static img documents static_content data
]],
77 'Plugin::ConfigLoader' => {
80 USERNAME
=> sub { (getpwuid($>))[0] },
82 GROUPNAME
=> sub { (getgrgid($)))[0] },
86 # configure SGN::Role::Site::TestMode. These are the
87 # configuration keys that it will change so that they point into
89 'Plugin::TestMode' => {
90 test_data_dir
=> __PACKAGE__
->path_to('t','data'),
95 cluster_shared_tempdir
100 intron_finder_database
117 'Plugin::Authentication' => {
118 default_realm
=> 'default',
122 class => '+SGN::Authentication::Credentials',
126 class => "+SGN::Authentication::Store",
127 user_class
=> "+SGN::Authentication::User",
128 ### role_column => 'roles',
134 ( $ENV{SGN_TEST_MODE
} ?
( test_mode
=> 1 ) : () ),
138 # on startup, do some dynamic configuration
139 after
'setup_finalize' => sub {
142 $self->config->{basepath
} = $self->config->{home
};
144 # all files written by web server should be group-writable
147 # update the symlinks used to serve static files
148 $self->_update_static_symlinks;
150 if(! $ENV{SGN_WEBPACK_WATCH
}){
151 my $uid = (lstat("js/package.json"))[4];
154 my $user_exists = `id $uid 2>&1`;
155 if ($user_exists =~ /no such user/) {
156 `useradd -u $uid -m devel`;
159 print STDERR
"\n\nUSING USER ID $uid FOR npm...\n\n\n";
160 system("cd js && sudo -u \\#$uid npm run build && cd -");
166 sub _update_static_symlinks
{
169 # symlink the static_datasets and
170 # static_content in the root dir so that
171 # Catalyst::Plugin::Static::Simple can serve them. in production,
172 # these will be served directly by Apache
174 # make symlinks for static_content and static_datasets
176 map [ $self->config->{$_.'_path'} =>
177 $self->path_to( $self->config->{root
}, $self->config->{$_.'_url'} )
179 qw( static_content static_datasets );
181 for my $link (@links) {
183 my $l1_rel = $link->[1]->relative( $self->path_to );
184 $self->log->debug("symlinking static dir '$link->[0]' -> '$l1_rel'") if $self->debug;
187 symlink( $link->[0], $link->[1] )
188 or die "$! symlinking $link->[0] => $link->[1]";
194 L<SGN::Controller::Root>, L<Catalyst>
202 This library is free software. You can redistribute it and/or modify
203 it under the same terms as Perl itself.