Commit dc75d883 authored by Sacha's avatar Sacha
Browse files

adds optional name for credit for highlighting an article

parent dd7b58cc
......@@ -116,7 +116,7 @@ def update_doc():
col = get_articles_collection()
url = session['reading_url']
increment_reads(col, url, inds)
increment_reads(col, url, inds, request.args.get('author'))
toggle_being_read(col, url, False)
return success()
......@@ -149,7 +149,7 @@ def get_tweets_collection():
return get_db().tweets
def increment_reads(col, url, highlights):
def increment_reads(col, url, highlights, author):
return col.update_one({
'url': url
}, {
......@@ -158,6 +158,7 @@ def increment_reads(col, url, highlights):
}, '$inc': {
'n_reads': 1
}, '$push': {
'highlights_author': author,
'highlights': highlights
}
}).modified_count
......
@import url(bootstrap.min.css);body{font-family:'Verdana', sans-serif;border-top:10px solid #d9d9d9;padding-top:10px}blockquote{font-size:16px}blockquote.good{background-color:#dff0d8;border-left:5px solid #3c763d}blockquote.bad{background-color:#f2dede;border-left:5px solid #a94442}.col-md-3{color:#ddd;background-color:rgba(245,245,245,0.3)}div#full_article{font-size:16px}div#full_article span{cursor:pointer}div#full_article span.controversial{color:#bada55;background-color:#800}#copyright{margin-bottom:14em}.btn{font-weight:700}#full_article{text-align:justify}#bot_bar{position:fixed;z-index:1;bottom:0}#bot_bar .col-md-12{padding:8px;background-color:#eee;margin-top:8px;text-align:right;height:61px}#bot_bar .col-md-12 .pull-left{padding:8px}@media (max-height: 400px){#bot_bar{position:relative}}@media (min-width: 1200px){#bot_bar{width:1170px}}@media (min-width: 992px){#bot_bar{width:970}}@media (min-width: 768px){#bot_bar{width:750}}
@import url(bootstrap.min.css);body{font-family:'Verdana', sans-serif;border-top:10px solid #d9d9d9;padding-top:10px}blockquote{font-size:16px}blockquote.good{background-color:#dff0d8;border-left:5px solid #3c763d}blockquote.bad{background-color:#f2dede;border-left:5px solid #a94442}.col-md-3{color:#ddd;background-color:rgba(245,245,245,0.3)}div#full_article{font-size:16px}div#full_article span{cursor:pointer}div#full_article span.controversial{color:#bada55;background-color:#800}#copyright{margin-bottom:14em}.btn{font-weight:700}#full_article{text-align:justify}#bot_bar{position:fixed;z-index:1;bottom:0}#bot_bar .col-md-12{padding:8px;background-color:#eee;margin-top:8px;text-align:right;height:61px}#bot_bar .col-md-12 .pull-left{padding:8px}#bot_bar .col-md-12 .pull-left input[type='text']{width:230px;font-size:smaller;height:30px;vertical-align:middle}#error{display:none}@media (max-height: 400px){#bot_bar{position:relative}}@media (min-width: 1200px){#bot_bar{width:1170px}}@media (min-width: 992px){#bot_bar{width:970}}@media (min-width: 768px){#bot_bar{width:750}}
/*# sourceMappingURL=highlight.css.map */
......@@ -84,9 +84,10 @@ function updateCanSubmit() {
function showError(message) {
$("#error").text(message);
$("#error").show()
setTimeout(function() {
$("#error").text('');
}, 3000);
$("#error").hide()
}, 3000);
}
function disable(el) {
......@@ -114,18 +115,18 @@ function submitFailure(data) {
$("#submit").click(function() {
// these checks will be done server-side too. They are duplicated here to reduce strain on the server.
if (!pastMinTime()) {
showError("your reading speed is too high");
showError("Your reading speed is too high");
return;
}
var n_highlights = controversial.length;
if (n_highlights === 0) {
showError("no highlights");
showError("No highlights");
return;
}
if (n_highlights > n_sentences) {
showError('invalid # of highlights!');
showError('Invalid number of highlights!');
enable('#full_article');
return;
}
......@@ -133,24 +134,24 @@ $("#submit").click(function() {
for (var i = n_highlights - 1; i >= 0; i -= 1) {
var ei = controversial[i];
if (ei < 0 || ei > n_sentences) {
showError('invalid sentence indices!');
showError('Invalid sentence indices!');
return;
}
}
if (n_highlights > (0.8 * n_sentences)) {
showError("too many sentences highlighted");
showError("Too many sentences highlighted");
return;
}
if (n_highlights < (n_sentences * 0.05) && !CONFIRMED_HIGHLIGHTS) {
showError("are you sure you've highlighted all controversial sentences? Submit again to confirm.");
showError("Are you sure you've highlighted all controversial sentences? Submit again to confirm.");
CONFIRMED_HIGHLIGHTS = true;
return;
}
if (n_highlights > (0.5 * n_sentences) && !CONFIRMED_HIGHLIGHTS) {
showError("are you sure you've highlighted only controversial sentences? Submit again to confirm.");
showError("Are you sure you've highlighted only controversial sentences? Submit again to confirm.");
CONFIRMED_HIGHLIGHTS = true;
return
}
......@@ -158,6 +159,11 @@ $("#submit").click(function() {
controversial.sort();
var uri = 'submit?checked=' + controversial.join();
var name = $('#name').val();
if (name) {
uri += '&author=' + name;
}
console.log(uri);
$("#bot_bar img").show();
performRequest(uri, submitSuccess, submitFailure);
})
......@@ -40,7 +40,15 @@ div#full_article {
}
#bot_bar {
.col-md-12 {
.pull-left { padding: 8px; }
.pull-left {
padding: 8px;
input[type='text'] {
width: 230px;
font-size: smaller;
height: 30px;
vertical-align: middle;
}
}
padding: 8px;
background-color: #eee;
margin-top: 8px;
......@@ -50,6 +58,9 @@ div#full_article {
z-index: 1;
bottom: 0;
}
#error {
display: none;
}
@media (max-height: 400px) {
#bot_bar { position: relative; }
}
......
{% extends "highlighting_base.html" %}
{% extends 'highlighting_base.html' %}
{% block content %}
<!-- ``being_read``: {{ article.being_read }} -->
<!-- ``n_reads``: {{ article.n_reads }} -->
<div class="row">
<div class="col-md-9">
<p class="lead">Please click any sentences which you believe are controversial. We define controversial as expressing an opinon which could be debated by many people. When done, click <b><q>Submit</q></b>.</p>
<div class='row'>
<div class='col-md-9'>
<p class='lead'>Please click any sentences which you believe are controversial (as per our definition on the previous page). When done, click <b><q>Submit</q></b>.</p>
</div>
<div class="col-md-3">
<div class='col-md-3'>
<i>{{ article.title }}</i> <b>&middot;</b> {{ article.byline }} <b>&middot;</b> {{ article.published }} <b>&middot;</b> <q>{{ article.keyword }}</q> corpus.
</div>
<div class="col-md-12">
<div class='col-md-12'>
<hr>
</div>
<div class="col-md-12">
<div id="full_article">
<div class='col-md-12'>
<div id='full_article'>
{% for paragraph in paras %}
{% set _loop = loop %}
<p>
{% for sentence in paragraph %}
<span onclick="toggleControversial({{ sentence_lookup(sentence) }}, this)">{{ sentence }}</span>
<span onclick='toggleControversial({{ sentence_lookup(sentence) }}, this)'>{{ sentence }}</span>
{% endfor %}
</p>
{% endfor %}
</div>
</div>
<div class="col-md-6">
<div class="alert" id="time_left" role="alert">
<div class='col-md-6'>
<div class='alert' id='time_left' role='alert'>
<span></span>
</div>
<div class='alert alert-warning' id='error' role='alert'>
</div>
</div>
<div class="col-md-6" id="copyright">
<p class="text-muted">Study from the University of Illinois at Urbana&ndash;Champaign. Articles &copy; 2015, The New York Times Company <img width='17px' src="{{ url_for('static', filename='img/NYT.svg') }}" />. All rights reserved.</p>
<div class='col-md-6' id='copyright'>
<p class='text-muted'>If you supply your name or some moniker below, we will thank you in any publications that use the labor you've performed here.</p>
<p class='text-muted'>Study from the University of Illinois at Urbana&ndash;Champaign. Articles &copy; 2015, The New York Times Company <img width='17px' src='{{ url_for("static", filename="img/NYT.svg") }}' />. All rights reserved.</p>
</div>
<div class="row" id="bot_bar">
<div class="col-md-12">
<div class="pull-left">
<img src="{{ url_for('static', filename='img/small-loading.gif') }}" style="display: none" />
<b class="text-warning" id="error"></b>
</div>
<input type="button" class="btn btn-lg disabled" id="submit" value="Submit" />
<div class='row' id='bot_bar'>
<div class='col-md-12'>
<div class='pull-left'>
<img src='{{ url_for("static", filename="img/small-loading.gif") }}' style='display: none' />
<input autocomplete='words' id='name' name='name' placeholder='name for recognition (optional)' type='text' />
</div>
<input type='button' class='btn btn-lg disabled' id='submit' value='Submit' />
</div>
</div>
</div>
<script type="text/javascript" src="{{ url_for('static', filename='highlighting/jquery.min.js') }}"></script>
<script type="text/javascript">
<script type='text/javascript' src='{{ url_for("static", filename="highlighting/jquery.min.js") }}'></script>
<script type='text/javascript'>
<!-- Please don't you modify these variables via a console. -->
var controversial = [];
var minimum_time = {{ minimum_time }};
var n_sentences = {{ n_sentences }};
</script>
<script type="text/javascript" src="{{ js }}"></script>
<script type='text/javascript' src='{{ js }}'></script>
{% endblock %}
......@@ -5,7 +5,7 @@
<p class="lead"><b>You've completed this article &hellip; thanks!</b></p>
</div>
<div class='col-md-8'>
<p>Report feedback to us at <b><tt>gdyer2</tt>@<tt>illinois</tt>.<tt>edu</tt></b> or <a href='https://github.com/SXibolet/CONTROVERSY'>learn more about this project</a>.</p>
<p>Report feedback to us at <b><tt>gdyer2</tt>@<tt>illinois</tt>.<tt>edu</tt></b> or <a href='https://framagit.org/gdyer/CONTROVERSY'>learn more about this project</a>.</p>
</div>
</div>
{% endblock %}
Markdown is supported
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