Merge remote-tracking branch 'origin/intercooler' into intercooler

This commit is contained in:
Jason McBrayer 2018-08-30 18:15:58 -04:00
commit fd5c2cfcbb
9 changed files with 256 additions and 195 deletions

View File

@ -47,7 +47,7 @@ MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
#'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',

2
brutaldon/static/js/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -27,8 +27,8 @@
<link rel="stylesheet"
href="{% static 'css/fork-awesome.min.css' %}">
{% block page_scripts %}
<script type="application/javascript" src="{% static 'js/zepto.min.js' %}"></script>
<script type="application/javascript" src="{% static 'js/intercooler.js' %}"></script>
<script type="text/javascript" src="{% static 'js/jquery.min.js' %}"></script>
<script type="text/javascript" src="{% static 'js/intercooler.js' %}"></script>
{% endblock %}
{% endif %}
{% endif %}
@ -184,6 +184,31 @@ document.addEventListener('DOMContentLoaded', function () {
}
});
$.ajaxSetup({
beforeSend: function(xhr, settings) {
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
// Only send the token to relative URLs i.e. locally.
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
}
}
});
</script>
{% block page_scripts_inline %}
{% endblock %}

View File

@ -0,0 +1,11 @@
{% if toot.visibility != 'private' and toot.visibility != 'direct' %}
{% if toot.reblogged %}
<span class="fa fa-retweet has-text-warning">
<strong class="is-hidden-mobile" >Boosted</strong>
{% else %}
<span class="fa fa-retweet" >
<span class="is-hidden-mobile" >Boost</span>
{% endif %}
</span>
</span>
{% endif %}

View File

@ -0,0 +1,9 @@
{% if toot.favourited %}
<span class="fa fa-heart has-text-warning">
<strong class="is-hidden-mobile" >Favorited</strong>
{% else %}
<span class="fa fa-heart">
<span class="is-hidden-mobile" >Favorite</span>
{% endif %}
</span>
</span>

View File

@ -34,9 +34,9 @@ def humane_time(arg):
else:
utc = ""
if diff < timedelta(hours=6):
return arg.strftime("%a, %b %d, %Y at %-I:%M %p") + utc
return arg.strftime("%a, %b %d, %Y at %I:%M %p") + utc
elif diff < timedelta(hours=12):
return arg.strftime("%a, %b %d, %Y around %-I %p") + utc
return arg.strftime("%a, %b %d, %Y around %I %p") + utc
elif diff < timedelta(hours=36):
return arg.strftime("%a, %b %d, %Y in the ") + time_of_day(arg.hour) + utc
elif diff < timedelta(days=6*28):

View File

@ -546,6 +546,13 @@ def fav(request, id):
mastodon.status_unfavourite(id)
else:
mastodon.status_favourite(id)
if request.POST.get('ic-request'):
toot['favourited'] = not toot['favourited']
return render(request, 'intercooler/fav.html',
{"toot": toot,
'own_acct': request.session['user'],
"preferences": account.preferences})
else:
return redirect(thread, id)
else:
return render(request, 'main/fav.html',
@ -565,6 +572,13 @@ def boost(request, id):
mastodon.status_unreblog(id)
else:
mastodon.status_reblog(id)
if request.POST.get('ic-request'):
toot['reblogged'] = not toot['reblogged']
return render(request, 'intercooler/boost.html',
{"toot": toot,
'own_acct': request.session['user'],
"preferences": account.preferences})
else:
return redirect(thread, id)
else:
return render(request, 'main/boost.html',

View File

@ -4,7 +4,7 @@
"bulmaswatch": "^0.6.2",
"fork-awesome": "^1.1.0",
"intercooler": "^1.2.1",
"mousetrap": "^1.6.2",
"zepto": "^1.2.0"
"jquery": "^3.3.1",
"mousetrap": "^1.6.2"
}
}

View File

@ -18,10 +18,10 @@ intercooler@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/intercooler/-/intercooler-1.2.1.tgz#50e9727ef2643ef7d5130c8e58f2af78098aa01f"
jquery@^3.3.1:
version "3.3.1"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.3.1.tgz#958ce29e81c9790f31be7792df5d4d95fc57fbca"
mousetrap@^1.6.2:
version "1.6.2"
resolved "https://registry.yarnpkg.com/mousetrap/-/mousetrap-1.6.2.tgz#caadd9cf886db0986fb2fee59a82f6bd37527587"
zepto@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/zepto/-/zepto-1.2.0.tgz#e127bd9e66fd846be5eab48c1394882f7c0e4f98"