Skip to content

Commit

Permalink
All changes for producing 3.4.1 release of EPrints, in preparation fo…
Browse files Browse the repository at this point in the history
…r pre-release testing.

Changes from 3.4.0

    Minor bug and typo fixes and addition of missing phrases.
    Ensure multi_param mthos is used if available.
    Improved default rendering of history tab
    Each part of the subjects hierarchy now a separate link
    Fixed rendering off logged in user link as part of the login menu.
    Added template field for DataObjs, so they can have a non-default display template.
    Better HTML class/ID labelling to faciltate CSS styling.
    Update CAPTCHA MetaFields to use ReCAPTCHAv2 by default.
    Better management of dependencies between ingredients.
    Allow searches to have their own titles defined directly rather than just constructed from the title phrase (e.g. Title matches 'test' AND Authors is 'Smith')
    Added Javascript variable definitions for user ID, name and type so these can be used client side.
    Enabled text indexing on set fields by default.
    Allow leaf nodes (i.e. pages rather than menus) of browse views to use a different template to other nodes.
    Added user role to give no (rather than all) editorial rights to an editor unless specified.
    Allow latest items feeds to only be displayed if specified rather than dependent on values set for the export plugin itself.
    Made configuration for side-wide HTTPS simpler.
    Prevent default export of issues field even for admin export, as this field can get exponentially quite large and is rarely useful as part of a general export.
    Fixed request processing so GET and HEAD requests get routed the same way.
    Added basic history search functionality.
    Colour space fix when generating thumbnails
    Fix to ensure EPMC screen plugins have the super class plugin pre-loaded
    Added registry line to /cgi/counter to list included paths for flavours, ingredients and otehr library directories.

Changes ported from 3.3

    Various typo fixes and additional documenting comments
    Fixed 'on behalf of' fuinctionality for SWORD deposits.
    Deal better with empty strings set for related_url_type.
    Improved name searching with apostrophes, accented characters and similar.
    Added ITF-8 compatibility for the DOI library
    Checkout URL for logout on logged_in_as phrase
    Added id attibute for ep_sr_compoment and ep_sr_none div elements to fix Prototype issue.
    Fixed bug with RDF triples generation for bibo.
    Simplified fallback logic for generated updated browse views.
    Added default phrase for enpty linbks in view menus.
    Fixed base URLs so https is used by default if ->{securehost} is set not if ->{host} is not.
    Remove leading and trailing white space from uploaded files, so they are consistent with the database.
    Added DOI library.
    Added mysql_enable_utf8 to MySQL DSN.
    Changed method for determining database index names to reduce the chances of them being too long for MySQL.
    Allow hyperlinks to be added to document icons.
    Add params to MetaField::render_search_value, so extended MetaField clases could make use of these.https://serviceswiki.eprints-hosting.org/index.php?title=3.4.1_Release&action=edit
    Created a citation for a logged in user (e.g. in menu bar) so this is more easily customisable.
    Allow for email black lists on request-a-copy.
    Added render_value_function to EPScript API
    Switched to using Perl JSON library to parse JSON / JavaScript strings.
    Fixed generic invalid XML revision file generation when metadata includes unrecognised (to XML) characters.
    Fixed issue with whitespace and buffer length when truncating the contents of a file for DataObj::File's characters method.
    Aesthetic improvements to the history tab layout.
    Hide full paths when running generate_static in quiet mode.
    Added required type to return value for run_doc_size.
    Ensured make_name_string can deal with single name people.
    Give 'email' field same type as 'requester_email' for Request DataObjs
    Added permanent redirect method to Apache::Rewrite
    Pre-emptively strip extra slashes from redirect
    Fixed bad regex in /cgi/search
    Fixed Apache rewrite match for sitemap.
    Captured error message in Event descriptions, so it can be displayed immediately and also set as the description value.
    Fixed output error element when a badVerb is request for OAI.
    Changed to using <tt> ratherthan <code> element on all default static pages.
  • Loading branch information
EPrints Services committed Mar 4, 2019
1 parent aea81c5 commit d723a6e
Show file tree
Hide file tree
Showing 79 changed files with 1,800 additions and 687 deletions.
5 changes: 3 additions & 2 deletions bin/check_xapian
Expand Up @@ -49,7 +49,7 @@ Check all items list in the comma-separated list of IDs.
=item B<--facets>
Use matching for search results based on Xapian database being faceted.
Check search results using the facets matching protocol rather than the standard Xapian matching protocol.
=item B<--days=n>
Expand Down Expand Up @@ -360,6 +360,7 @@ for ( my $i = 0; $i < $listcount; $i++ )
{
$title = $title->[0]{'text'};
}
$title = "" unless defined $title;
my $sanitized_title = $title;
$sanitized_title =~ s/[^\w0-9,\;\:\.\?!%£\$&\(\)\[\]\@ -]/ /g;
my @results = ();
Expand Down Expand Up @@ -446,7 +447,7 @@ for ( my $i = 0; $i < $listcount; $i++ )
}
print "\n" if !$reindex && ( !$found || !$status_correct );
$unfound++ unless $found;
$status_wrong++ unless $status_correct;
$status_wrong++ unless $status_correct || !$found;
$counter++;
}
print "\n$unfound/$counter EPrints in the live archive were found not to be indexed by Xapian$period.\n" unless $quiet;
Expand Down
4 changes: 2 additions & 2 deletions bin/epadmin
Expand Up @@ -199,7 +199,7 @@ Remove the database entries for the given field, can not be undone!
=item B<epadmin> update I<repository_id>
This will add tables and columns to your SQL database to bring it in-line with your current configuration. It will not remove data. Use with caution on a live database. Database backup is recommended befire use on live systems.
This will add tables and columns to your SQL database to bring it in-line with your current configuration. It will not remove data. Use with caution on a live database. Database backup is recommended before use on live systems.
=item B<epadmin> update_dry_run I<repository_id>
Expand Down Expand Up @@ -381,7 +381,7 @@ sub create
pod2usage( 2 ) if( scalar @ARGV > 1 );

my $conf = $EPrints::SystemSettings::conf;
my @flavours = keys %{$conf->{flavours}};
my @flavours = keys %{$conf->{flavours}};
my $repo_type = $ARGV[0]? $ARGV[0]:"";
if (not $repo_type ~~ @flavours)
{
Expand Down
2 changes: 1 addition & 1 deletion cgi/cal
Expand Up @@ -146,7 +146,7 @@ for my $_y ( @years )
{
$month_count++;
next if $month_count > $m;
print "</div><div class='month_row'>" if($col && $col%${r}==0);
print "</div><div class='month_row'>" if($r ne "flow" && $col && $col%${r}==0);
open(CAL, "cal $_mon $_y |");
print "<div class='month'>\n";
my $line_num = 1;
Expand Down
4 changes: 4 additions & 0 deletions cgi/counter
Expand Up @@ -93,4 +93,8 @@ if( $repo->dataset( 'epm' ) )
}
print "\n";


print "registry: " . join(", ",@{$repo->config("flavours")->{$repo->config("flavour")}}) . "\n";
# To check if a flavour has certain ingredient: $repo->flavour_has( "ingredients/eprints_lists" )

exit;
302 changes: 302 additions & 0 deletions cgi/history_search
@@ -0,0 +1,302 @@
##################
##History Search##
##################

use EPrints;
use Data::Dumper;
use Time::Piece;
use Time::Seconds;

use strict;

my $session = new EPrints::Session;
my $content = "text/html";
$session->send_http_header( content_type=>$content );

if( !( $session->current_user && $session->current_user->value("usertype") =~ /^(admin|local_admin)$/ ) )
{
print "<html><body>You must be logged in as an admin to view this page</body></html>\n";
$session->terminate;
exit( 0 );
}

#get field you want to watch
my $fname = $session->param( "fname" );

#get start date
my $start_date = $session->param( "start_date" );

#get end date
my $end_date = $session->param( "end_date" );

#title
my $title = $session->make_element( "h2" );
$title->appendChild( $session->make_text( "History Search" ) );

#page
my $page = $session->make_doc_fragment();

#render warning area
my $message_div = $session->make_element( "div", id=>"ep_messages", class=>"history_warning");
$page->appendChild( $message_div );

my $warning_div = $session->make_element( "div", class=>"ep_msg_warning" );
$message_div->appendChild( $warning_div );

my $content_div = $session->make_element( "div", id=>"warning_content", class=>"ep_msg_warning_content" );
$warning_div->appendChild( $content_div );

#render controls
my $controls = $session->make_element( "div", class=>"history_search controls");
my $form = $session->make_element( "form" );
$form->setAttribute( "onsubmit", "return validateHistorySearch()" );
$controls->appendChild( $form );

#print list of fields
my $fields = $session->make_element( "div", class=>"fields" );
my $dataset = "eprint";
my $eprint_ds = $session->dataset( $dataset );

my $field_label = $session->make_element( "label", for=>"fname" );
$field_label->appendChild( $session->make_text( "Field" ) );
$fields->appendChild( $field_label );

my $field_select = $session->make_element( "select", name=>"fname" );
my @fields = $eprint_ds->fields;
foreach my $field (@fields)
{
my $n = $field->name;
my $name = $field->render_name;
my $option = $session->make_element( "option", value=>$n );
if( $fname eq $n )
{
$option->setAttribute( "selected", "selected" );
}
$option->appendChild( $name );
$field_select->appendChild( $option );
}
$fields->appendChild( $field_select );
$form->appendChild( $fields );

#print start date
my $start_div = $session->make_element( "div", class=>"startdate" );
my $start_label = $session->make_element( "label", for=>"start_date" );
$start_label->appendChild( $session->make_text( "Start Date" ) );
$start_div->appendChild( $start_label );

my $start_input = $session->make_element( "input", type=>"text", id=>"start_date", name=>"start_date", value=>$start_date, placeholder=>"yyyy-mm-dd" );
$start_div->appendChild( $start_input );

$form->appendChild( $start_div );

#print end date
my $end_div = $session->make_element( "div", class=>"enddate" );
my $end_label = $session->make_element( "label", for=>"end_date" );
$end_label->appendChild( $session->make_text( "End Date" ) );
$end_div->appendChild( $end_label );

my $end_input = $session->make_element( "input", type=>"text", id=>"end_date", name=>"end_date", value=>$end_date, placeholder=>"yyyy-mm-dd" );
$end_div->appendChild( $end_input );

$form->appendChild( $end_div );

#print submit
my $submit_div = $session->make_element( "div", class=>"submit" );
my $submit = $session->make_element( "input", type=>"submit", value=>"Search" );
$submit_div->appendChild( $submit );
$form->appendChild( $submit_div );

#end controls
$page->appendChild( $controls );

#do the history search
my $hist_ds = $session->dataset( "history" );
my $search_string;
if(defined $fname)
{

my $field = $eprint_ds->field( $fname );
my $field_name = $field->render_name;

my $sql = "SELECT historyid, objectid, revision, timestamp_year, timestamp_month, timestamp_day FROM history WHERE datasetid = 'eprint' AND action = 'modify' AND (details LIKE '%|$fname|%' OR details LIKE '$fname|%' OR details LIKE '%|$fname' OR details LIKE '$fname')";

$search_string = $search_string . 'Changes to "'.$field_name.'" ';

my $using_dates = 0;
if( defined $start_date && $start_date =~ /(\d{4})-?(\d{1,2})?-?(\d{1,2})?/ )
{
$using_dates = 1;

my $y = $1;
my $m = sprintf( "%02d", $2 );
my $d = sprintf( "%02d", $3 );

my $s_date = "$y$m$d";
$sql = $sql . " AND CONCAT(timestamp_year,LPAD(timestamp_month,2,0),LPAD(timestamp_day,2,0)) > $s_date";

my $date_string = make_date_string( $d, $m, $y );
if( defined $end_date && $end_date =~ /(\d{4})-?(\d{1,2})?-?(\d{1,2})?/ )
{
$search_string = $search_string . "between $date_string and ";
}
else
{
$search_string = $search_string . "since $date_string";
}
}

if( defined $end_date && $end_date =~ /(\d{4})-?(\d{1,2})?-?(\d{1,2})?/ )
{
$using_dates = 1;

my $y = $1;
my $m = sprintf( "%02d", $2 );
my $d = sprintf( "%02d", $3 );

my $e_date = "$y$m$d";
$sql = $sql . " AND CONCAT(timestamp_year,LPAD(timestamp_month,2,0),LPAD(timestamp_day,2,0)) < $e_date";

my $date_string = make_date_string( $d, $m, $y );
if( defined $start_date && $start_date =~ /(\d{4})-?(\d{1,2})?-?(\d{1,2})?/ )
{
$search_string = $search_string . $date_string;
}
else
{
$search_string = $search_string . "before $date_string";
}

}

if( !$using_dates )
{
$sql = $sql . " ORDER BY historyid DESC";
$sql = $sql . " LIMIT 100";
$search_string = 'The last 100 changes to "'.$field_name.'"';
}
else
{
$sql = $sql . " ORDER BY historyid ASC";
}


my $sth = $session->get_database->prepare( $sql );
$session->get_database->execute( $sth , $sql );

my $search_title = $session->make_element( "h2" );
$search_title->appendChild( $session->make_text( $search_string ) );
$page->appendChild( $search_title );

my $table = $session->make_element( "table" );
my $tr = $session->make_element( "tr" );
my @headings = ("EPrint ID", "Timestamp", "Old Value", "New Value" );
foreach my $h (@headings)
{
my $th = $session->make_element( "th" );
$th->appendChild( $session->make_text( $h ) );
$tr->appendChild( $th );
}
$table->appendChild( $tr );
$page->appendChild( $table );

while( my( $historyid, $eprintid, $revision, $y, $m, $d ) = $sth->fetchrow_array )
{
#does the eprint exist???
my $eprint = $eprint_ds->dataobj( $eprintid );
if( defined $eprint )
{

#get the history object
my $hist = $hist_ds->dataobj( $historyid );

my $old_value = "Unknown";

#get previous state
my $previous = $hist->get_previous();
if( defined( $previous ) )
{
my $r_file = $previous->get_stored_file( "dataobj.xml" );
my $r_file_new = defined($r_file) ? $r_file->get_local_copy() : undef;
open(my $fh, "xmllint --recover $r_file_new |");
my $parser = XML::LibXML->new();
my $doc = XML::LibXML->load_xml( IO => $fh );
$old_value = get_content_value( $doc, $fname ) || "Unknown";
}

#get current state
my $r_file = $hist->get_stored_file( "dataobj.xml" );
my $r_file_new = defined($r_file) ? $r_file->get_local_copy() : undef;
open(my $fh, "xmllint --recover $r_file_new |");
my $parser = XML::LibXML->new();
my $doc = XML::LibXML->load_xml( IO => $fh );
my $new_value = get_content_value( $doc, $fname );

if( $d =~ /^\d{1}$/ )
{
$d = "0$d";
}
if( $m =~ /^\d{1}$/ )
{
$m = "0$m";
}

#render in a more human-readable way if appropriate
if( $field->isa( "EPrints::MetaField::Set" ) )
{
$old_value = $field->render_value( $session, $old_value ) . "\n" unless $old_value eq "Unknown";
$new_value = $field->render_value( $session, $new_value ) . "\n" unless $new_value eq "Unknown";
}

my $result_row = $session->make_element( "tr" );
$result_row->appendChild( make_td( $session, $eprintid ) );
$result_row->appendChild( make_td( $session, "$d/$m/$y" ) );
$result_row->appendChild( make_td( $session, $old_value ) );
$result_row->appendChild( make_td( $session, $new_value ) );
$table->appendChild( $result_row );
}
}

}

my $template = 'default';
$session->build_page( $title, $page, "history_search", undef, $template );
$session->send_page();

$session->terminate;
exit;

sub make_date_string{
my ( $d, $m, $y ) = @_;

my $string = $y;
if( $m != "00" )
{
$string = "$m/$y";
}
if( $d != "00" )
{
$string = "$d/$m/$y";
}
return $string;
}

sub make_td{
my( $session, $value ) = @_;
my $td = $session->make_element( "td" );
$td->appendChild( $session->make_text( $value ) );
return $td;
}

sub get_content_value{

my( $doc, $fname ) = @_;

my @possible_contents = ();
my @contents = $doc->getElementsByTagName( $fname );
foreach my $c (@contents)
{
push @possible_contents, $c->textContent;
}
return $possible_contents[0];
}

0 comments on commit d723a6e

Please sign in to comment.