Commit eccf11b9 authored by Sacha's avatar Sacha Committed by SXibolet@2PITAU
Browse files

ranked by sentence length

parent 66217bb2
......@@ -5,6 +5,7 @@
*.rdb
*.aux
*.log
dump.rdb
.DS_Store
config.py
venv
......
......@@ -26,10 +26,12 @@ def handle_error(error):
response.status_code = error.status_code
return response
@api.errorhandler(404)
def handle_404(error):
return justmime('not-found', status=404)
def loggedin():
return session.get('username') is not None
......
......@@ -10,7 +10,7 @@
:copyright: (c) 2015-2016 I Lourentzou, G Dyer, A Sharma, CX Zhai. Some rights reserved.
:license: CC BY-NC-SA 4.0, see LICENSE for more details.
"""
from flask import Flask, session, redirect, render_template, request, Blueprint, flash, abort
from flask import Flask, session, redirect, render_template, request, Blueprint, flash, abort, Response
from jinja2 import TemplateNotFound
from functools import wraps
from api import api
......@@ -30,21 +30,23 @@ application.register_blueprint(api, url_prefix='/api')
application.register_blueprint(mturk, url_prefix='/training')
application.secret_key = SECRET_KEY
application.config['RECAPTCHA_PUBLIC_KEY'] = CAPTCHA_PUBLIC
application.config['RECAPTCHA_PRIVATE_KEY'] = CAPTCHA_PRIVATE
application.config['version'] = '0.4'
application.config['testing'] = DEBUG
class AppConfig(object):
RECAPTCHA_PUBLIC_KEY = CAPTCHA_PUBLIC
RECAPTCHA_PRIVATE_KEY = CAPTCHA_PRIVATE
VERSION = '0.4'
testing = DEBUG
application.config.from_object(AppConfig)
def get_added_styles():
webkit = digest('webkit.css') if session.get('webkit') == 'webkit' else None
safari = digest('safari.css') if session.get('safari') == 'safari' else None
return webkit, safari
def plain_text_resp(message, code=200):
return Response(message,
mimetype='text/plain',
status=code)
@application.errorhandler(404)
def handle_404(e):
return render_template('404.html'), 404
def handle_404(error):
return plain_text_resp('not found', code=404)
@application.errorhandler(500)
......@@ -55,10 +57,20 @@ def handle_500(error):
from flask import jsonify
from error import UsageError
client = TwilioRestClient(TWILIO_SID, TWILIO_AUTH_TOKEN)
client.messages.create(body='problem on Linode: %s' % repr(error), to=ADMIN_PHONE, from_='+19089982913')
client.messages.create(body='problem on Linode: %s' % repr(error),
to=ADMIN_PHONE,
from_='+19089982913')
raise UsageError('our-fault', status_code=500)
def added_style(name):
return digest('%s.css' % name) if session.get(name) == name else None
def get_added_styles():
return added_style('webkit'), added_style('safari')
def loggedin():
return session.get('username') is not None
......@@ -99,16 +111,12 @@ def login(username):
username=username or '')
@application.route("/set_webkit")
def set_webkit():
session['webkit'] = 'webkit'
return 'yes'
@application.route("/set_safari")
def set_safari():
session['safari'] = 'safari'
return 'yes'
@application.route("/set/<name>")
def set_browser(name):
if name not in {'webkit', 'safari'}:
return plain_text_resp('no', code=400)
session[name] = name
return plain_text_resp('yes')
@application.route("/register", methods=['GET', 'POST'])
......@@ -218,4 +226,6 @@ def pretty_date(u):
if __name__ == '__main__':
application.run(host='0.0.0.0', port=4040, debug=DEBUG)
application.run(host='0.0.0.0',
port=4040,
debug=DEBUG)
#!/bin/bash
cd /home/www/controversy/controversy
python history_spider.py
......@@ -208,7 +208,8 @@ def get_next_doc():
'$lt': 3
}
}).sort([
('being_read', 1)
('being_read', 1),
('full', -1)
])
if poss is None:
......@@ -223,7 +224,7 @@ def get_next_doc():
def keyword_exists(kw):
"""Checks if ``kw`` has been saved already
"""Checks if ``kw`` has been saved already.
Forced collection update
"""
col = get_tweets_collection()
......@@ -234,8 +235,7 @@ def keyword_exists(kw):
def article_is_new(url, col=None):
"""Checks if article @ ``url``
has been saved already
"""Checks if article with ``url`` has been saved already
"""
if col is None:
col = get_articles_collection()
......
<!doctype html>
<html>
<title>404; not found</title>
<tt>404; not found &middot; <a href="{{ url_for('index') }}">homepage</a></tt>
</html>
......@@ -14,7 +14,7 @@
{% if messages %}
<div id=message>
{% for message in messages %}
{{ message }}
{{ message|safe }}
{% if not loop.last %}
&middot;
{% endif %}
......@@ -25,7 +25,7 @@
<div id=login>
<h1>Controversy</h1>
<span id=details>
Please login or <a href="register">create a free account</a>. <a href="training">Annotate articles</a> to help us build a dataset for future study!
Please login or <a href="register">create a free account</a>. <a href="training">Annotate articles</a>to help us build a dataset for future study!
<center>
<a class="github-button" href="https://github.com/gdyer/controversy" data-icon="octicon-star" data-style="mega" aria-label="Star gdyer/controversy on GitHub">Star</a>
<a class="github-button" href="https://github.com/gdyer/controversy/issues" data-icon="octicon-issue-opened" data-style="mega" data-count-api="/repos/gdyer/controversy#open_issues_count" data-count-aria-label="# issues on GitHub" aria-label="Issue gdyer/controversy on GitHub">Known bugs</a>
......@@ -56,12 +56,12 @@ if (!window.jQuery) {
} else {
var isWebKit = 'WebkitAppearance' in document.documentElement.style;
var isSafari = (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1);
console.log(isWebKit);
console.log(isSafari);
if (isWebKit)
$.ajax({url: '/set_webkit?webkit=' + 'webkit'});
if (isSafari)
$.ajax({url: '/set_safari?safari=' + 'safari'});
if (isWebKit) {
$.ajax({url: '/set/webkit'});
}
if (isSafari) {
$.ajax({url: '/set/safari'});
}
}
</script>
<script async defer id="github-bjs" src="//buttons.github.io/buttons.js"></script>
......
......@@ -16,7 +16,9 @@
Your information is for our reference only and will never be shared with a 3<sup>rd</sup> party. You can also <a href="bourbaki">use the demo anonymously</a> if you like.
</span>
{% if logged_in == true %}
You're already <a href="/">logged in</a>, but feel free to create another account.
<p>
<b>You're already <a href="/">logged in</a>, but feel free to create another account.</b>
</p>
{% endif %}
<form method=POST>
{{ form.hidden_tag() }}
......
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