Commit 1a1df2a2 authored by IKEDA Soji's avatar IKEDA Soji
Browse files

Merge branch 'ikedas/issue-1091_imp1' into 'ikedas/issue-1091'

Conflicts:
	src/lib/Sympa/Archive.pm
parents 12fb608c d6b6feb1
......@@ -32,7 +32,7 @@ nobase_default_DATA = \
create_list.conf \
edit_list.conf \
ldap_alias_entry.tt2 \
mhonarc-ressources.tt2 \
mhonarc_rc.tt2 \
mime.types \
nrcpt_by_domain.conf \
sympa.wsdl \
......
......@@ -1873,7 +1873,7 @@ div.admin_cmd a {
}
[%~ END # IF 0 ~%]
/* Calendar in mhonarc-ressources.tt2 */
/* Calendar in mhonarc_rc.tt2 */
ul.calendar {
margin-left:0!important;
padding-left:0!important;
......@@ -1919,7 +1919,7 @@ ul li.calendarLinksInactive {
ul li.calendarYear {
border: 1px solid;
}
/* end calendar in mhonarc-ressources.tt2 */
/* end calendar in mhonarc_rc.tt2 */
abbr,
acronym,
......
......@@ -165,7 +165,7 @@ foreach my $tpl (@templates) {
if ($tpl =~ /mhonarc\-ressources$/) {
rename $tpl, "$tpl.incompatible";
printf STDERR
"File $tpl could not be translated to TT2 ; it has been renamed $tpl.incompatible. You should customize a standard mhonarc-ressourses.tt2 file\n";
"File $tpl could not be translated to TT2 ; it has been renamed $tpl.incompatible. You should customize a standard mhonarc_rc.tt2 file\n";
next;
}
......
......@@ -30,7 +30,6 @@ package Sympa::Archive;
use strict;
use warnings;
use Cwd qw();
use Digest::MD5 qw();
use Encode qw();
use English qw(-no_match_vars);
use File::Path qw();
......@@ -490,8 +489,7 @@ sub html_store {
return undef;
}
my $mhonarc_ressources =
Sympa::search_fullpath($list, 'mhonarc-ressources.tt2');
my $mhonarc_rc = Sympa::search_fullpath($list, 'mhonarc_rc.tt2');
$log->syslog(
'debug',
......@@ -499,18 +497,16 @@ sub html_store {
Conf::get_robot_conf($list->{'domain'}, 'mhonarc'), $list
);
my $tag = _get_tag($list);
# Call mhonarc on cleaned message source to make clean htlm view of
# message.
my @cmd = (
Conf::get_robot_conf($list->{'domain'}, 'mhonarc'),
'-add',
'-addressmodifycode' => '1', # w/a: Clear old cache in .mhonarc.db.
'-rcfile' => $mhonarc_ressources,
'-rcfile' => $mhonarc_rc,
'-outdir' => $self->{arc_directory},
'-definevars' => sprintf(
"listname='%s' hostname=%s yyyy=%s mois=%s yyyymm=%s-%s wdir=%s base=%s/arc tag=%s with_tslice=1 with_powered_by=1",
"listname='%s' hostname=%s yyyy=%s mois=%s yyyymm=%s-%s wdir=%s base=%s/arc with_tslice=1 with_powered_by=1",
$list->{'name'},
$list->{'domain'},
$yyyy,
......@@ -519,7 +515,6 @@ sub html_store {
$mm,
Conf::get_robot_conf($list->{'domain'}, 'arc_path'),
(Conf::get_robot_conf($list->{'domain'}, 'wwsympa_url') || ''),
$tag
),
'-umask' => $Conf::Conf{'umask'}
);
......@@ -645,9 +640,7 @@ sub html_rebuild {
my $robot_id = $list->{'domain'};
my $arc_directory = $self->{arc_directory};
my $tag = _get_tag($list);
my $mhonarc_ressources =
Sympa::search_fullpath($list, 'mhonarc-ressources.tt2');
my $mhonarc_rc = Sympa::search_fullpath($list, 'mhonarc_rc.tt2');
# Remove existing HTML files and .mhonarc.db.
my $dh;
......@@ -675,10 +668,10 @@ sub html_rebuild {
my @cmd = (
Conf::get_robot_conf($robot_id, 'mhonarc'),
'-addressmodifycode' => '1', # w/a: Clear old cache in .mhonarc.db.
'-rcfile' => $mhonarc_ressources,
'-rcfile' => $mhonarc_rc,
'-outdir' => $arc_directory,
'-definevars' => sprintf(
"listname='%s' hostname=%s yyyy=%s mois=%s yyyymm=%s-%s wdir=%s base=%s/arc tag=%s with_tslice=1 with_powered_by=1",
"listname='%s' hostname=%s yyyy=%s mois=%s yyyymm=%s-%s wdir=%s base=%s/arc with_tslice=1 with_powered_by=1",
$listname,
$robot_id,
$yyyy,
......@@ -687,7 +680,6 @@ sub html_rebuild {
$mm,
Conf::get_robot_conf($robot_id, 'arc_path'),
(Conf::get_robot_conf($robot_id, 'wwsympa_url') || ''),
$tag
),
'-umask' => $Conf::Conf{'umask'},
$dir_to_rebuild
......@@ -890,10 +882,9 @@ sub html_format {
map { Sympa::Tools::Text::encode_uri($_) } @$attachment_url;
}
my $mhonarc_ressources =
Sympa::search_fullpath($that, 'mhonarc-ressources.tt2');
unless ($mhonarc_ressources) {
$log->syslog('notice', 'Cannot find any MhOnArc ressource file');
my $mhonarc_rc = Sympa::search_fullpath($that, 'mhonarc_rc.tt2');
unless ($mhonarc_rc) {
$log->syslog('notice', 'Cannot find any MHonArc resource file');
return undef;
}
......@@ -923,21 +914,19 @@ sub html_format {
return undef;
}
my $tag = _get_tag($that);
my $exitcode = system(
Conf::get_robot_conf($robot, 'mhonarc'),
'-single',
'-rcfile' => $mhonarc_ressources,
'-rcfile' => $mhonarc_rc,
'-definevars' => sprintf(
"listname='%s' hostname=%s yyyy='' mois='' tag=%s with_tslice='' with_powered_by=''",
$listname, $domain, $tag
"listname='%s' hostname=%s yyyy='' mois='' with_tslice='' with_powered_by=''",
$listname, $domain
),
'-outdir' => $destination_dir,
'-attachmentdir' => $destination_dir,
'-attachmenturl' =>
sprintf('(%s%% path_cgi %%%s)/%s', $tag, $tag, $attachment_url),
'-umask' => $Conf::Conf{'umask'},
'-stdout' => "$destination_dir/msg00000.html",
'-attachmenturl' => sprintf('<%% path_cgi %%>/%s', $attachment_url),
'-umask' => $Conf::Conf{'umask'},
'-stdout' => "$destination_dir/msg00000.html",
'--',
$msg_file
) >> 8;
......@@ -957,21 +946,8 @@ sub html_format {
}
# Old name: Sympa::Archive::get_tag(), get_tag() in archived.pl.
sub _get_tag {
my $that = shift;
my $name;
if (ref $that eq 'Sympa::List') {
$name = $that->{'name'};
} elsif (!ref($that) and $that and $that ne '*') {
$name = $that;
} elsif (!ref($that)) {
$name = '*';
}
my $salt = rand; #FIXME: Unreproducible
return substr Digest::MD5::md5_hex(join '/', $salt, $name), -10;
}
# No longer used.
#sub _get_tag;
sub get_id {
my $self = shift;
......
......@@ -2070,6 +2070,46 @@ sub upgrade {
}
}
# Variable tags "($tag$% ... %$tag$)" no longer used in
# mhonarc_rc.tt2 (ex. mhonarc-ressources.tt2) and were replaced with
# "<% ... %>".
if (lower_version($previous_version, '6.2.61b.1')) {
$log->syslog('notice', 'Converting mhonarc-ressources.tt2...');
my $oldfile = 'mhonarc-ressources.tt2';
my $newfile = 'mhonarc_rc.tt2';
my @dirs;
push @dirs, $Conf::Conf{'etc'}
if -f $Conf::Conf{'etc'} . '/' . $oldfile;
foreach my $robot (Sympa::List::get_robots()) {
my $dir = sprintf '%s/%s', $Conf::Conf{'etc'}, $robot;
push @dirs, $dir
if -f $dir . '/' . $oldfile;
foreach my $list (@{Sympa::List::get_lists($robot) || []}) {
push @dirs, $list->{'dir'}
if -f $list->{'dir'} . '/' . $oldfile;
}
}
foreach my $dir (@dirs) {
open my $ifh, '<', $dir . '/' . $oldfile
or die sprintf '%s: %s', $oldfile, $ERRNO;
my $text = do { local $RS; <$ifh> };
close $ifh;
$text =~ s{[(]\$tag\$%}{<%}g;
$text =~ s{%\$tag\$[)]}{%>}g;
open my $ofh, '>', $dir . '/' . $newfile
or die sprintf '%s: %s', $newfile, $ERRNO;
print $ofh $text;
close $ofh;
}
$log->syslog('notice', '...Done. Use new file(s) mhonarc_rc.tt2.');
}
return 1;
}
......
......@@ -282,7 +282,16 @@ Print this help message.
F<$SPOOLDIR/outgoing/> outgoing Sympa directory.
F<$DEFAULTDIR/mhonarc-ressources.tt2> template of MHonArc resource file.
F<$DEFAULTDIR/mhonarc_rc.tt2> template of MHonArc resource file.
=over
=item *
F<mhonarc-ressources.tt2> was replaced with F<mhonarc_rc.tt2>
on Sympa 6.2.61b.1.
=back
F<--CONFIG--> Sympa configuration file.
......
......@@ -65,7 +65,7 @@ sub _do_test {
close $fh;
$tpl = "[% TAGS $tags %]$tpl";
$tpl = [split /(?<=\n)/, $tpl];
} elsif ($tpl eq 'mhonarc-ressources.tt2') {
} elsif ($tpl eq 'mhonarc_rc.tt2') {
open my $fh, '<', $dir . '/' . $tpl;
$tpl = do { local $RS; <$fh> };
close $fh;
......
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