Skip to content

Commit

Permalink
BibFormat: new reference forms
Browse files Browse the repository at this point in the history
* Adds extra forms after a user clicks the "Update References"
  button.

* Improves reference correction form layout

* Keeps the output format while searching for references to add
  • Loading branch information
jmartinm committed Jan 31, 2014
1 parent c54cd88 commit bda3693
Show file tree
Hide file tree
Showing 15 changed files with 658 additions and 14 deletions.
3 changes: 2 additions & 1 deletion Makefile
Expand Up @@ -21,7 +21,8 @@ SUBDIRS = bibconvert \
bibsort \
bibexport \
webaccess \
tests
tests \
www

all:
$(foreach SUBDIR, $(SUBDIRS), cd $(SUBDIR) && make all && cd .. ;)
Expand Down
48 changes: 48 additions & 0 deletions bibformat/format_elements/bfe_update_references_button.py
@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
##
## This file is part of Invenio.
## Copyright (C) 2014 CERN.
##
## Invenio is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## Invenio is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Invenio; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
"""BibFormat element - Creates update references button
"""


def format_element(bfo, position='top'):
out = """
<div id='referenceinp_link_box'>
<span id='referenceinp_link_span'>
"""
references = bfo.fields("999C5", escape=1, repeatable_subfields_p=True)
if references:
out += "<a id='referenceinp_link' href='/record/%s/export/hru'>Update these references</a>" % bfo.control_field("001")
else:
if position == "bottom":
out += "<a id='referenceinp_link' href='/record/%s/export/hra'>Add references</a>" % bfo.control_field("001")
else:
return ""
out += """
</span>
</div>
"""
return out


def escape_values(bfo):
"""
Called by BibFormat in order to check if output of this element
should be escaped.
"""
return 0
11 changes: 4 additions & 7 deletions bibformat/format_templates/Default_HTML_references.bft
Expand Up @@ -2,11 +2,8 @@
<description>Outputs the references of a record</description>

<div style="margin-left:30px;min-height:100px;">

<div id='referenceinp_link_box'>
<span id='referenceinp_link_span'>
<a id='referenceinp_link' href='/record/<BFE_FIELD tag="001" />/export/hrf'>Update these references</a>
</span>
</div>
<BFE_REFERENCES default="<h2>No references were found for that record.<h2>" prefix='' suffix='' reference_prefix='' reference_suffix=''/>
<BFE_UPDATE_REFERENCES_BUTTON position='top'/>
<BFE_REFERENCES default="<h2>No references were found for that record.</h2><br/>" prefix='' suffix='' reference_prefix='' reference_suffix=''/>
<BFE_UPDATE_REFERENCES_BUTTON position='bottom'/>
</div>

4 changes: 2 additions & 2 deletions bibformat/format_templates/cite_as.bft
Expand Up @@ -40,8 +40,8 @@ function valtoReferenceinp(recid) {
<p>
<div id="detailedrecordshortreminder">
<form action="" method="POST">
<input type="button" value="Select this reference" onClick="valtoReferenceinp(<BFE_RECORD_ID>); return(false);" >
<br>
<input type="button" class="formbutton" value="Select this reference" onClick="valtoReferenceinp(<BFE_RECORD_ID>); return(false);" >
<br><br>
<a class = "titlelink" href="<BFE_SERVER_INFO var="recurl">">
<BFE_INSPIRE_TITLE_BRIEF prefix="" suffix="" default="" escape="" highlight="no" brief="yes" />
</a><br />
Expand Down
95 changes: 95 additions & 0 deletions bibformat/format_templates/reference_correction_options.bft
@@ -0,0 +1,95 @@
<style>
.radio {
margin-top:10px;
}

.tiny {
font-size: 85%;
color: grey;
}

#ref-form {
font-size: 80%;
}

#email-required {
color: red;
font-style: italic;
}
</style>

<script>
$().ready(function() {
if ( !$('#arxiv').is(':checked') ) {
$("#ref-extra-comments").hide();
}

$( "input[type=radio]" ).change(function() {
if( $(this).is(':checked') && $(this).attr("value") != "arxiv"){
$("#ref-extra-comments").slideUp();
}
else {
$("#ref-extra-comments").slideDown();
}
});

$("#ref-form").on("submit", function(event) {
/* Snippet from http://stackoverflow.com/questions/4964691/super-simple-email-validation-with-javascript*/
var email = $("#email").val();
if ( !$('#arxiv').is(':checked') || /(.+)@(.+){2,}\.(.+){2,}/.test(email) ){
return;
} else {
$("#email-required").html("Please, input a valid email address");
event.preventDefault();
}
})
});
</script>

<h1>Reference correction</h1>

<div id="detailedrecordshortreminder">
<a class = "titlelink" href="<BFE_SERVER_INFO var="recurl">">
<BFE_INSPIRE_TITLE_BRIEF prefix="" suffix="" default="" escape="" highlight="no" brief="yes" />
</a>
<br />
<BFE_INSPIRE_AUTHORS prefix="" suffix="" extension=" et al." limit="3" print_links="yes" separator="; " print_affiliations="no" highlight="no" interactive="no" />
<BFE_INSPIRE_PUBLI_INFO prefix="<br />Published in <b>" suffix="</b>" /><br />
<BFE_INSPIRE_ARXIV prefix="<a href=http://www.arxiv.org/pdf/" suffix=" target=blank />PDF</a> from arXiv " default="" escape=""
category="yes" links="no" mirrors="no"/>
</div>
<br/>

<form method="POST" action="/reference_update.py/reference_correction" id="ref-form">
<input type="hidden" name="record_id" id="record_id" value=<BFE_FIELD tag="001"/> />

<div id="ref-questions">
<label>What's wrong with the current reference list?</label>
<br/>
<input type = "radio" name="problem" id="arxiv" value="arxiv" class="radio" checked="checked" />
<label for="arxiv">A revised arXiv version exists with an updated reference list</label>
<br/>
<input type = "radio" name="problem" id="published" value="published" class="radio" />
<label for="published">The published version has an updated reference list</label>
<br/>
<input type = "radio" name="problem" id="wrong" value="wrong" class="radio" />
<label for="wrong">Some references have not been correctly identified</label>
<br/>
<br/>
</div>
<div id="ref-extra-comments">
<br/>
Your email address <span class="tiny">(we will notify you as soon as the references have been updated)</span><br/>
<input type="text" name="email" id="email" size="50" placeholder="youremail@example.com"><span><strong>&nbsp;Required</strong></span>
<div id="email-required">
</div>
<br/><br/>
Add extra comments to help us identifying the correct references:
<br/>
<textarea name="comments" cols="80" rows="5">
</textarea>
<br/>
<br/>
</div>
<input type="submit" class="formbutton" value="Next">
</form>
114 changes: 114 additions & 0 deletions bibformat/format_templates/reference_empty_add.bft
@@ -0,0 +1,114 @@
<style>
.tiny {
font-size: 85%;
color: grey;
}

#ref-form {
font-size: 80%;
}

#email-required {
color: red;
font-style: italic;
}

.tooltip {
display: inline;
position: relative;
}

.tooltip:hover:after{
background: #333;
background: rgba(0,0,0,.8);
border-radius: 5px;
bottom: 26px;
color: #fff;
left: 20%;
padding: 5px 15px;
position: absolute;
z-index: 98;
width: 220px;
}

.tooltip:hover:before{
border: solid;
border-color: #333 transparent;
border-width: 6px 6px 0 6px;
bottom: 20px;
content: "";
left: 50%;
position: absolute;
z-index: 99;
}

.tooltip_1:hover:after {
content: "Copy all the content present in the reference section as it appears in the original source";
}

.tooltip_2:hover:after {
content: "Accessible refers to not needing a subscription to access the content";
}

.aligned-image {
vertical-align: top;
}
</style>

<script>
$().ready(function() {
$("#ref-form").on("submit", function(event) {
/* Snippet from http://stackoverflow.com/questions/4964691/super-simple-email-validation-with-javascript*/
var email = $("#email").val();
if ( /(.+)@(.+){2,}\.(.+){2,}/.test(email) ){
return;
} else {
$("#email-required").html("Please, input a valid email address");
event.preventDefault();
}
})
});
</script>

<h1>Add references to record</h1>

<div id="detailedrecordshortreminder">
<a class = "titlelink" href="<BFE_SERVER_INFO var="recurl">">
<BFE_INSPIRE_TITLE_BRIEF prefix="" suffix="" default="" escape="" highlight="no" brief="yes" />
</a>
<br />
<BFE_INSPIRE_AUTHORS prefix="" suffix="" extension=" et al." limit="3" print_links="yes" separator="; " print_affiliations="no" highlight="no" interactive="no" />
<BFE_INSPIRE_PUBLI_INFO prefix="<br />Published in <b>" suffix="</b>" /><br />
<BFE_INSPIRE_ARXIV prefix="<a href=http://www.arxiv.org/pdf/" suffix=" target=blank />PDF</a> from arXiv " default="" escape=""
category="yes" links="no" mirrors="no"/>
</div>
<br/>

<form method="POST" action="/reference_update.py/reference_add" id="ref-form">
Please paste the reference list in the following text area:
<br />
<input type="hidden" name="record_id" id="record_id" value=<BFE_FIELD tag="001"/> />
<textarea name="references" cols="80" rows="15">
</textarea>

<br/><br/>
If available, please provide us with an accessible URL for the pdf:
<br />
<input type="text" name="url" size="50" placeholder="http://www.url.com/document.pdf">
<br/>
<br/>
<br/>
Your email address <span class="tiny">(we will notify you as soon as the references have been updated)</span><br/>
<input type="text" name="email" id="email" size="50" placeholder="youremail@example.com"><span><strong>&nbsp;Required</strong></span>
<div id="email-required">
</div>
<br/>
Add extra comments to help us identifying the correct references:
<br/>

<textarea name="comments" cols="80" rows="5"></textarea>
<br/>
<br/>
<input type="submit" value="Submit" class="formbutton">

</form>

0 comments on commit bda3693

Please sign in to comment.