Commit 20078b24 authored by IKEDA Soji's avatar IKEDA Soji
Browse files

[bug] Values of css_url & css_path parameters by robot are broken.

[change] css_url & css_path are no longer may be per-robot parameters.  Because robot subdirectories under CSSDIR are assumed.
parent f2774e24
......@@ -1169,6 +1169,9 @@ while ($query = CGI::Fast->new) {
# Compat.: deprecated attributes of Robot.
$param->{'conf'}{'sympa'} = Sympa::get_address($robot);
$param->{'conf'}{'request'} = Sympa::get_address($robot, 'owner');
# Compat <= 6.2.16: CSS related.
$param->{'css_path'} = sprintf '%s/%s', $Conf::Conf{'css_path'}, $robot;
$param->{'css_url'} = sprintf '%s/%s', $Conf::Conf{'css_url'}, $robot;
 
foreach my $auth (keys %{$Conf::Conf{'cas_id'}{$robot}}) {
$log->syslog('debug2', 'CAS authentication service %s', $auth);
......@@ -1242,31 +1245,6 @@ while ($query = CGI::Fast->new) {
# Propagate plugins parameters
$param->{'plugin'} = $in{'plugin'};
 
# # Static content
# $param->{'static_content_url'} =
# Conf::get_robot_conf($robot, 'static_content_url');
## CSS related
$param->{'css_path'} = Conf::get_robot_conf($robot, 'css_path');
$param->{'css_url'} = Conf::get_robot_conf($robot, 'css_url');
## If CSS file not found, let Sympa do the job...
#unless ($param->{'css_path'} and -f $param->{'css_path'} . '/style.css') {
# wwslog(
# 'err',
# 'Could not find CSS file %s, using default CSS',
# $param->{'css_path'} . '/style.css'
# ) if $param->{'css_path'}; # Notice only if path was defined.
# $param->{'css_url'} =
# Sympa::get_url($robot, 'css', authority => 'omit');
#}
wwslog(
'info',
'Parameter css_url "%s" seems strange, it must be the url of a directory not a css file',
$param->{'css_url'}
) if $param->{'css_url'} =~ /\.css$/;
$session = Sympa::Session->new(
$robot,
{ 'cookie' =>
......
......@@ -2032,18 +2032,6 @@ sub _infer_robot_parameter_values {
$param->{'config_hash'}{'static_content_path'} ||=
$Conf{'static_content_path'};
## CSS
my $final_separator = '';
$final_separator = '/' if ($param->{'config_hash'}{'robot_name'});
$param->{'config_hash'}{'css_url'} ||=
$param->{'config_hash'}{'css_url'}
. $final_separator
. $param->{'config_hash'}{'robot_name'};
$param->{'config_hash'}{'css_path'} ||=
$param->{'config_hash'}{'css_path'}
. $final_separator
. $param->{'config_hash'}{'robot_name'};
unless ($param->{'config_hash'}{'email'}) {
$param->{'config_hash'}{'email'} = $Conf{'email'};
}
......
......@@ -1310,16 +1310,12 @@ our @params = (
'gettext_id' => 'Directory for static style sheets (CSS)',
'gettext_comment' =>
'After an upgrade, static CSS files are upgraded with the newly installed "css.tt2" template. Therefore, this is not a good place to store customized CSS files.',
'optional' => '1',
'vhost' => '1',
},
{ 'name' => 'css_url',
'default' => '/static-sympa/css',
'gettext_id' => 'URL for style sheets (CSS)',
'gettext_comment' =>
'To use auto-generated static CSS, HTTP server have to map it with "css_path".',
'optional' => '1',
'vhost' => '1',
},
{ 'name' => 'pictures_path',
'default_s' => '$PICTURESDIR',
......
......@@ -724,10 +724,8 @@ sub _get_css_url {
$template_path =
Sympa::search_fullpath($robot, 'css.tt2', subdir => 'web_tt2');
unless ($template_path) { # Impossible case.
my $url =
Sympa::Tools::Text::weburl(
Conf::get_robot_conf($robot, 'css_url'),
['style.css']);
my $url = Sympa::Tools::Text::weburl($Conf::Conf{'css_url'},
[$robot, 'style.css']);
return ($url);
}
}
......@@ -744,10 +742,7 @@ sub _get_css_url {
my ($dir, $path, $url);
if (%colors) {
$dir =
sprintf '%s/%s/%s',
Conf::get_robot_conf($robot, 'static_content_path'),
'css', $robot;
$dir = sprintf '%s/%s', $Conf::Conf{'css_path'}, $robot;
# Expire old files.
if (opendir my $dh, $dir) {
foreach my $file (readdir $dh) {
......@@ -761,33 +756,29 @@ sub _get_css_url {
closedir $dh;
}
$path = $dir . '/style.' . $hash . '.css';
$url = Sympa::Tools::Text::weburl(
Conf::get_robot_conf($robot, 'static_content_url'),
['css', $robot, 'style.' . $hash . '.css']
);
$path = sprintf '%s/style.%s.css', $dir, $hash;
$url = Sympa::Tools::Text::weburl($Conf::Conf{'css_url'},
[$robot, sprintf 'style.%s.css', $hash]);
} elsif ($lang) {
$dir =
sprintf '%s/%s/%s/%s',
Conf::get_robot_conf($robot, 'static_content_path'),
'css', $robot, $lang;
$dir = sprintf '%s/%s/%s', $Conf::Conf{'css_path'}, $robot, $lang;
$path = $dir . '/lang.css';
$url = Sympa::Tools::Text::weburl(
Conf::get_robot_conf($robot, 'static_content_url'),
['css', $robot, $lang, 'lang.css'],
$path = sprintf '%s/lang.css', $dir;
$url = Sympa::Tools::Text::weburl(
$Conf::Conf{'css_url'},
[$robot, $lang, 'lang.css'],
query => {h => $hash}
);
} else {
# Use css_path and css_url parameters so that the user may provide
# their own CSS.
$dir = Conf::get_robot_conf($robot, 'css_path');
$dir = sprintf '%s/%s', $Conf::Conf{'css_path'}, $robot;
$path = $dir . '/style.css';
$url =
Sympa::Tools::Text::weburl(
Conf::get_robot_conf($robot, 'css_url'),
['style.css'], query => {h => $hash});
$url = Sympa::Tools::Text::weburl(
$Conf::Conf{'css_url'},
[$robot, 'style.css'],
query => {h => $hash}
);
}
# Update the CSS if it is missing or if css.tt2 or configuration was
......
......@@ -1292,7 +1292,7 @@ sub upgrade {
}
# CSS would be regenerated...
my $dir = Conf::get_robot_conf($robot, 'css_path');
my $dir = $Conf::Conf{'css_path'} . '/' . $robot;
rename $dir . '/style.css', $dir . '/style.css.' . time
if -f $dir . '/style.css';
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment