do not link to insitu search
[sgn.git] / lib / SGN.pm
blob4e00436e0bceec7e92360de58da61ca9fca59b3e
2 =head1 NAME
4 SGN - Catalyst-based application to run the SGN website.
6 =head1 SYNOPSIS
8 script/sgn_server.pl
10 =head1 DESCRIPTION
12 This is the main class for the Sol Genomics Network main website.
14 =cut
16 package SGN;
17 use Moose;
18 use namespace::autoclean;
20 use SGN::Exception;
22 use Catalyst::Runtime 5.80;
24 =head1 ROLES
26 Does the roles L<SGN::Role::Site::Config>,
27 L<SGN::Role::Site::DBConnector>, L<SGN::Role::Site::DBIC>,
28 L<SGN::Role::Site::Exceptions>, L<SGN::Role::Site::Files>,
29 L<SGN::Role::Site::Mason>, L<SGN::Role::Site::SiteFeatures>,
30 L<SGN::Role::Site::TestMode>
32 =cut
34 use Catalyst qw/
35 ConfigLoader
36 Static::Simple
37 Authentication
38 +SGN::Authentication::Store
39 Authorization::Roles
40 +SGN::Role::Site::Config
41 +SGN::Role::Site::DBConnector
42 +SGN::Role::Site::DBIC
43 +SGN::Role::Site::Exceptions
44 +SGN::Role::Site::Files
45 +SGN::Role::Site::Mason
46 +SGN::Role::Site::SiteFeatures
47 +SGN::Role::Site::TestMode
50 extends 'Catalyst';
52 =head1 METHODS
54 =cut
56 # configure catalyst-related things. in general, things should not be
57 # added here. add them to SGN.conf, with comments.
58 __PACKAGE__->config(
60 name => 'SGN',
61 root => 'static',
63 disable_component_resolution_regex_fallback => 1,
65 default_view => 'Mason',
67 # Static::Simple configuration
68 static => {
69 dirs => [qw[ s static img documents static_content data ]],
72 'Plugin::ConfigLoader' => {
73 substitutions => {
74 UID => sub { $> },
75 USERNAME => sub { (getpwuid($>))[0] },
76 GID => sub { $) },
77 GROUPNAME => sub { (getgrgid($)))[0] },
81 # configure SGN::Role::Site::TestMode. These are the
82 # configuration keys that it will change so that they point into
83 # t/data
84 'Plugin::TestMode' => {
85 test_data_dir => __PACKAGE__->path_to('t','data'),
86 reroot_conf =>
87 [qw(
89 blast_db_path
90 cluster_shared_tempdir
91 ftpsite_root
92 image_path
93 genefamily_dir
94 homepage_files_dir
95 intron_finder_database
96 r_qtl_temp_path
97 static_content_path
98 static_datasets_path
99 trace_path
104 'Plugin::Authentication' => {
105 default_realm => 'default',
106 realms => {
107 default => {
108 credential => {
109 class => '+SGN::Authentication::Credentials',
112 store => {
113 class => "+SGN::Authentication::Store",
114 user_class => "+SGN::Authentication::User",
115 ### role_column => 'roles',
123 # on startup, do some dynamic configuration
124 after 'setup_finalize' => sub {
125 my $self = shift;
128 $ENV{PROJECT_NAME} = $self->config->{name};
129 $self->config->{basepath} = $self->config->{home};
131 # all files written by web server should be group-writable
132 umask 000002;
134 # update the symlinks used to serve static files
135 $self->_update_static_symlinks;
138 __PACKAGE__->setup;
140 sub _update_static_symlinks {
141 my $self = shift;
143 # symlink the static_datasets and
144 # static_content in the root dir so that
145 # Catalyst::Plugin::Static::Simple can serve them. in production,
146 # these will be served directly by Apache
148 # make symlinks for static_content and static_datasets
149 my @links =
150 map [ $self->config->{$_.'_path'} =>
151 $self->path_to( $self->config->{root}, $self->config->{$_.'_url'} )
153 qw( static_content static_datasets );
155 for my $link (@links) {
156 if( $self->debug ) {
157 my $l1_rel = $link->[1]->relative( $self->path_to );
158 $self->log->debug("symlinking static dir '$link->[0]' -> '$l1_rel'") if $self->debug;
160 unlink $link->[1];
161 symlink( $link->[0], $link->[1] )
162 or die "$! symlinking $link->[0] => $link->[1]";
166 =head1 SEE ALSO
168 L<SGN::Controller::Root>, L<Catalyst>
170 =head1 AUTHOR
172 The SGN team
174 =head1 LICENSE
176 This library is free software. You can redistribute it and/or modify
177 it under the same terms as Perl itself.
179 =cut