[LON-CAPA-cvs] cvs: loncom /publisher lonpublisher.pm
raeburn
raeburn at source.lon-capa.org
Thu Jun 3 23:06:15 EDT 2021
raeburn Fri Jun 4 03:06:15 2021 EDT
Modified files:
/loncom/publisher lonpublisher.pm
Log:
- Options for publishing a directory split into types.
- Options to exclude modified files and/or files with modified metadata
when publishing directory (e.g., to avoid unwanted changes when updating
copyright and/or source availability for an entire directory.
- For skipped files display reason file was skipped.
-------------- next part --------------
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.298 loncom/publisher/lonpublisher.pm:1.299
--- loncom/publisher/lonpublisher.pm:1.298 Thu Jun 3 13:59:44 2021
+++ loncom/publisher/lonpublisher.pm Fri Jun 4 03:06:15 2021
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Publication Handler
#
-# $Id: lonpublisher.pm,v 1.298 2021/06/03 13:59:44 raeburn Exp $
+# $Id: lonpublisher.pm,v 1.299 2021/06/04 03:06:15 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -367,7 +367,7 @@
sub checkbox {
my ($name,$text)=@_;
- return "\n<br /><label><input type='checkbox' name='$name' /> ".
+ return "\n<label><input type='checkbox' name='$name' /> ".
&mt($text)."</label>";
}
@@ -424,7 +424,6 @@
'sel' => 'Select',
);
my $output = <<"END";
-<br />
<span class="LC_nobreak">
<label>
<input type="checkbox" name="commonaccess" value="$name" id="$chkid"
@@ -2264,24 +2263,39 @@
.&Apache::lonhtmlcommon::row_title(&mt('Target'))
.'<span class="LC_filename">'.$thisdisresdir.'</span>'
);
+ my %reasons = &Apache::lonlocal::texthash(
+ mod => 'Authoring Space file postdates published file',
+ modmeta => 'Authoring Space metadata file postdates published file',
+ unpub => 'Resource is unpublished',
+ );
my $dirptr=16384; # Mask indicating a directory in stat.cmode.
unless ($env{'form.phase'} eq 'two') {
# ask user what they want
$r->print(&Apache::lonhtmlcommon::row_closure()
- .&Apache::lonhtmlcommon::row_title(&mt('Options'))
- );
+ .&Apache::lonhtmlcommon::row_title(&mt('Options')
+ .&Apache::loncommon::help_open_topic('Publishing_Directory_Options')));
$r->print(&hiddenfield('phase','two').
&hiddenfield('filename',$env{'form.filename'}).
- &checkbox('pubrec','include subdirectories').
- &checkbox('forcerepub','force republication of previously published files').
- &checkbox('obsolete','make file(s) obsolete').
- &checkbox('forceoverride','force directory level metadata over existing').
- &checkbox('excludeunpub','exclude currently unpublished files').
+ '<fieldset><legend>'.&mt('Recurse').'</legend>'.
+ &checkbox('pubrec','include subdirectories').
+ '</fieldset>'.
+ '<fieldset><legend>'.&mt('Force').'</legend>'.
+ &checkbox('forcerepub','force republication of previously published files').'<br />'.
+ &checkbox('forceoverride','force directory level metadata over existing').
+ '</fieldset>'.
+ '<fieldset><legend>'.&mt('Exclude').'</legend>'.
+ &checkbox('excludeunpub','exclude currently unpublished files').'<br />'.
+ &checkbox('excludemod','exclude modified files').'<br />'.
+ &checkbox('excludemodmeta','exclude files with modified metadata').
+ '</fieldset>'.
+ '<fieldset><legend>'.&mt('Actions').'</legend>'.
+ &checkbox('obsolete','make file(s) obsolete').'<br />'.
&common_access('dist',&mt('apply common copyright/distribution'),
- ['default','domain','custom']).
+ ['default','domain','custom']).'<br />'.
&common_access('source',&mt('apply common source availability'),
- ['closed','open'])
+ ['closed','open']).
+ '</fieldset>'
);
$r->print(&Apache::lonhtmlcommon::row_closure(1)
.&Apache::lonhtmlcommon::end_pick_box()
@@ -2292,6 +2306,8 @@
$r->print(&Apache::lonhtmlcommon::row_closure(1)
.&Apache::lonhtmlcommon::end_pick_box()
);
+ my %commonaccess;
+ map { $commonaccess{$_} = 1; } &Apache::loncommon::get_env_multiple('form.commonaccess');
unless ($lock) { $lock=&Apache::lonnet::set_lock(&mt('Publishing [_1]',$fn)); }
# actually publish things
opendir(DIR,$fn);
@@ -2312,6 +2328,7 @@
($filename!~/^[\#\.]/) && ($filename!~/\~$/)) {
# find out publication status and/or existing metadata
my $publishthis=0;
+ my $skipthis;
if (-e $resdir.'/'.$filename) {
my ($rdev,$rino,$rmode,$rnlink,
$ruid,$rgid,$rrdev,$rsize,
@@ -2319,24 +2336,72 @@
$rblksize,$rblocks)=stat($resdir.'/'.$filename);
if (($rmtime<$cmtime) || ($env{'form.forcerepub'})) {
# previously published, modified now
- $publishthis=1;
- }
- my $meta_cmtime = (stat($fn.'/'.$filename.'.meta'))[9];
- my $meta_rmtime = (stat($resdir.'/'.$filename.'.meta'))[9];
- if ( $meta_rmtime<$meta_cmtime ) {
- $publishthis=1;
+ if ($env{'form.excludemod'}) {
+ $skipthis='mod';
+ } else {
+ $publishthis=1;
+ }
}
+ unless ($skipthis) {
+ my $meta_cmtime = (stat($fn.'/'.$filename.'.meta'))[9];
+ my $meta_rmtime = (stat($resdir.'/'.$filename.'.meta'))[9];
+ if ( $meta_rmtime<$meta_cmtime ) {
+ if ($env{'form.excludemodmeta'}) {
+ $skipthis='modmeta';
+ $publishthis=0;
+ } else {
+ $publishthis=1;
+ }
+ } else {
+ unless (&Apache::loncommon::fileembstyle($extension) eq 'prv') {
+ if ($commonaccess{'dist'}) {
+ my ($currdist,$currdistfile,$currsourceavail);
+ my $currdist = &Apache::lonnet::metadata($thisdisresdir.'/'.$filename,'copyright');
+ if ($currdist eq 'custom') {
+ $currdistfile = &Apache::lonnet::metadata($thisdisresdir.'/'.$filename,'customdistributionfile');
+ }
+ if ($env{'form.commondistselect'} eq 'custom') {
+ if ($env{'form.commoncustomrights'} =~ m{^/res/.+\.rights$}) {
+ if ($currdist eq 'custom') {
+ unless ($env{'form.commoncustomrights'} eq $currdistfile) {
+ $publishthis=1;
+ }
+ } else {
+ $publishthis=1;
+ }
+ }
+ } elsif ($env{'form.commondistselect'} =~ /^default|domain|public$/) {
+ unless ($currdist eq $env{'form.commondistselect'}) {
+ $publishthis=1;
+ }
+ }
+ }
+ }
+ }
+ }
} else {
# never published
- unless ($env{'form.excludeunpub'}) {
- $publishthis=1;
- }
+ if ($env{'form.excludeunpub'}) {
+ $skipthis='unpub';
+ } else {
+ $publishthis=1;
+ }
}
if ($publishthis) {
&batchpublish($r,$fn.'/'.$filename,$resdir.'/'.$filename,$nokeyref);
} else {
- $r->print('<br />'.&mt('Skipping').' '.$filename.'<br />');
+ my $reason;
+ if ($skipthis) {
+ $reason = $reasons{$skipthis};
+ } else {
+ $reason = &mt('No changes needed to published resource or metadata');
+ }
+ $r->print('<br />'.&mt('Skipping').' '.$filename);
+ if ($reason) {
+ $r->print(' ('.$reason.')');
+ }
+ $r->print('<br />');
}
$r->rflush();
}
More information about the LON-CAPA-cvs
mailing list