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.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', #'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware', '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

@ -2,193 +2,218 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title> <title>
{% block title %} {% block title %}
{% if own_acct %} {% if own_acct %}
brutaldon ({{ own_acct.username }}) brutaldon ({{ own_acct.username }})
{% else %} {% else %}
brutaldon brutaldon
{% endif %} {% endif %}
{% endblock %}</title> {% endblock %}</title>
{% if not preferences %} {% if not preferences %}
<link rel="stylesheet" <link rel="stylesheet"
href="{% static 'css/bulma.min.css' %}"> href="{% static 'css/bulma.min.css' %}">
<link rel="stylesheet"
href="{% static 'css/fork-awesome.min.css' %}">
<link rel="stylesheet" href="{% static "css/brutaldon.css" %}">
{% else %}
<link rel="stylesheet"
href="{% static preferences.theme.main_css %}">
<link rel="stylesheet" href="{% static preferences.theme.tweaks_css %}">
{% if not preferences.theme.is_brutalist %}
<link rel="stylesheet" <link rel="stylesheet"
href="{% static 'css/fork-awesome.min.css' %}"> href="{% static 'css/fork-awesome.min.css' %}">
{% block page_scripts %} <link rel="stylesheet" href="{% static "css/brutaldon.css" %}">
<script type="application/javascript" src="{% static 'js/zepto.min.js' %}"></script> {% else %}
<script type="application/javascript" src="{% static 'js/intercooler.js' %}"></script> <link rel="stylesheet"
href="{% static preferences.theme.main_css %}">
<link rel="stylesheet" href="{% static preferences.theme.tweaks_css %}">
{% if not preferences.theme.is_brutalist %}
<link rel="stylesheet"
href="{% static 'css/fork-awesome.min.css' %}">
{% block page_scripts %}
<script type="text/javascript" src="{% static 'js/jquery.min.js' %}"></script>
<script type="text/javascript" src="{% static 'js/intercooler.js' %}"></script>
{% endblock %}
{% endif %}
{% endif %}
{% if own_acct %}
<link rel="icon" href="{{ own_acct.avatar_static }}">
{% else %}
<link rel="icon" href="{% static "images/brutaldon.png" %}" type="image/png">
{% endif %}
</head>
<body class="has-navbar-fixed-top">
{% block navbar %}
<nav class="navbar is-fixed-top" role="navigation"
aria-label="main navigation">
<div class="navbar-brand">
<a class="navbar-item" href="{% url "home" %}">
{% if own_acct %}
<img src="{{ own_acct.avatar_static }}"
class="image is-32x32 avatar"
alt="Brutaldon ({{ own_acct.username }})">
{% else %}
<img src="{% static "images/brutaldon.png" %}"
class="image is-32x32" alt="Brutaldon">
{% endif %}
</a>
</div>
{% if request.session.instance %}
{% if request.session.username or request.session.access_token %}
<div class="navbar-menu is-active" id="navMenu">
<!-- navbar start, navbar end -->
<div class="navbar-start">
<a href="{% url "home" %}" class="navbar-item">
<span class="fa fa-home"></span>
<span>&nbsp; Home</span>
</a>
<a class="navbar-item" href="{% url "note" %}">
<span class="fa fa-bell-o"></span>
<span >&nbsp; Notifications</span>
</a>
<a class="navbar-item" href="{% url "local" %}">
<span class="fa fa-community"></span>
<span >&nbsp; Local</span>
</a>
<a class="navbar-item" href="{% url "fed" %}">
<span class="fa fa-globe"></span>
<span >&nbsp;Federated</span>
</a>
<a class="navbar-item" href="{% url "toot" %}">
<span class="fa fa-edit"> </span>
<span >&nbsp; New Toot</span>
</a>
<a class="navbar-item" href="{% url "search" %}">
<span class="fa fa-search"> </span>
<span >&nbsp; Search</span>
</a>
</div>
<div class="navbar-end" >
<a class="navbar-item" href="{% url "settings" %}">
<span class="fa fa-gear"></span>
<span >&nbsp;Settings</span>
</a>
<a class="navbar-item" href="{% url "logout" %}">
<span class="fa fa-power-off"></span>
<span >&nbsp;Log out</span>
</a>
</div>
</div>
{% endif %}
{% endif %}
</nav>
{% endblock %}
<section class="section">
<div class="container">
{% block content %}
<h1 class="title">
Title
</h1>
<p class="subtitle">
Brutaldon is totally a thing.
</p>
{% endblock %} {% endblock %}
</div>
</section>
<footer class="footer">
<div class="level">
<div class="level-left">
<a class="level-item is-size-7" href="{% url "about" %}">
About
</a>
<a class="level-item is-size-7" href="https://github.com/jfmcbrayer/brutaldon">
Source
</a>
</div>
<div class="level-right">
{% if preferences.theme.is_brutalist %}
<img class="level-item" src="{% static '/images/lynx.gif' %}"
alt="Lynx Now!">
<img class="level-item" src="{% static '/images/now9.gif' %}"
alt="Netscape Now!">
{% endif %}
<a class="level-item is-size-7" href="{% url "privacy" %}">
Privacy
</a>
</div>
</div>
</footer>
{% if not preferences.theme.is_brutalist %}
<script type="application/javascript">
document.addEventListener('DOMContentLoaded', function () {
// Remove is-active from navbar menu
var menu = document.querySelector('#navMenu');
menu.classList.remove('is-active');
// Add the burger
var brand = document.querySelector('.navbar-brand');
var burger = document.createElement('a');
burger.classList.toggle('navbar-burger');
burger.setAttribute("aria-label", "menu");
burger.setAttribute("aria-expanded", "false");
burger.setAttribute("data-target", "navMenu");
for (var index = 0; index < 3; index++)
{
var span = document.createElement('span');
span.setAttribute('aria-hidden', "true");
burger.appendChild(span);
}
brand.appendChild(burger);
// Get all "navbar-burger" elements
var $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
// Check if there are any navbar burgers
if ($navbarBurgers.length > 0) {
// Add a click event on each of them
$navbarBurgers.forEach(function ($el) {
$el.addEventListener('click', function () {
// Get the target from the "data-target" attribute
var target = $el.dataset.target;
var $target = document.getElementById(target);
// Toggle the class on both the "navbar-burger" and the "navbar-menu"
$el.classList.toggle('is-active');
$target.classList.toggle('is-active');
});
});
}
});
$.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 %}
{% endif %} {% endif %}
{% endif %}
{% if own_acct %}
<link rel="icon" href="{{ own_acct.avatar_static }}">
{% else %}
<link rel="icon" href="{% static "images/brutaldon.png" %}" type="image/png">
{% endif %}
</head>
<body class="has-navbar-fixed-top">
{% block navbar %}
<nav class="navbar is-fixed-top" role="navigation"
aria-label="main navigation">
<div class="navbar-brand">
<a class="navbar-item" href="{% url "home" %}">
{% if own_acct %}
<img src="{{ own_acct.avatar_static }}"
class="image is-32x32 avatar"
alt="Brutaldon ({{ own_acct.username }})">
{% else %}
<img src="{% static "images/brutaldon.png" %}"
class="image is-32x32" alt="Brutaldon">
{% endif %}
</a>
</div>
{% if request.session.instance %}
{% if request.session.username or request.session.access_token %}
<div class="navbar-menu is-active" id="navMenu">
<!-- navbar start, navbar end -->
<div class="navbar-start">
<a href="{% url "home" %}" class="navbar-item">
<span class="fa fa-home"></span>
<span>&nbsp; Home</span>
</a>
<a class="navbar-item" href="{% url "note" %}">
<span class="fa fa-bell-o"></span>
<span >&nbsp; Notifications</span>
</a>
<a class="navbar-item" href="{% url "local" %}">
<span class="fa fa-community"></span>
<span >&nbsp; Local</span>
</a>
<a class="navbar-item" href="{% url "fed" %}">
<span class="fa fa-globe"></span>
<span >&nbsp;Federated</span>
</a>
<a class="navbar-item" href="{% url "toot" %}">
<span class="fa fa-edit"> </span>
<span >&nbsp; New Toot</span>
</a>
<a class="navbar-item" href="{% url "search" %}">
<span class="fa fa-search"> </span>
<span >&nbsp; Search</span>
</a>
</div>
<div class="navbar-end" >
<a class="navbar-item" href="{% url "settings" %}">
<span class="fa fa-gear"></span>
<span >&nbsp;Settings</span>
</a>
<a class="navbar-item" href="{% url "logout" %}">
<span class="fa fa-power-off"></span>
<span >&nbsp;Log out</span>
</a>
</div>
</div>
{% endif %}
{% endif %}
</nav>
{% endblock %}
<section class="section">
<div class="container">
{% block content %}
<h1 class="title">
Title
</h1>
<p class="subtitle">
Brutaldon is totally a thing.
</p>
{% endblock %}
</div>
</section>
<footer class="footer"> </body>
<div class="level">
<div class="level-left">
<a class="level-item is-size-7" href="{% url "about" %}">
About
</a>
<a class="level-item is-size-7" href="https://github.com/jfmcbrayer/brutaldon">
Source
</a>
</div>
<div class="level-right">
{% if preferences.theme.is_brutalist %}
<img class="level-item" src="{% static '/images/lynx.gif' %}"
alt="Lynx Now!">
<img class="level-item" src="{% static '/images/now9.gif' %}"
alt="Netscape Now!">
{% endif %}
<a class="level-item is-size-7" href="{% url "privacy" %}">
Privacy
</a>
</div>
</div>
</footer>
{% if not preferences.theme.is_brutalist %}
<script type="application/javascript">
document.addEventListener('DOMContentLoaded', function () {
// Remove is-active from navbar menu
var menu = document.querySelector('#navMenu');
menu.classList.remove('is-active');
// Add the burger
var brand = document.querySelector('.navbar-brand');
var burger = document.createElement('a');
burger.classList.toggle('navbar-burger');
burger.setAttribute("aria-label", "menu");
burger.setAttribute("aria-expanded", "false");
burger.setAttribute("data-target", "navMenu");
for (var index = 0; index < 3; index++)
{
var span = document.createElement('span');
span.setAttribute('aria-hidden', "true");
burger.appendChild(span);
}
brand.appendChild(burger);
// Get all "navbar-burger" elements
var $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
// Check if there are any navbar burgers
if ($navbarBurgers.length > 0) {
// Add a click event on each of them
$navbarBurgers.forEach(function ($el) {
$el.addEventListener('click', function () {
// Get the target from the "data-target" attribute
var target = $el.dataset.target;
var $target = document.getElementById(target);
// Toggle the class on both the "navbar-burger" and the "navbar-menu"
$el.classList.toggle('is-active');
$target.classList.toggle('is-active');
});
});
}
});
</script>
{% block page_scripts_inline %}
{% endblock %}
{% endif %}
</body>
</html> </html>

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: else:
utc = "" utc = ""
if diff < timedelta(hours=6): 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): 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): elif diff < timedelta(hours=36):
return arg.strftime("%a, %b %d, %Y in the ") + time_of_day(arg.hour) + utc return arg.strftime("%a, %b %d, %Y in the ") + time_of_day(arg.hour) + utc
elif diff < timedelta(days=6*28): elif diff < timedelta(days=6*28):

View File

@ -546,7 +546,14 @@ def fav(request, id):
mastodon.status_unfavourite(id) mastodon.status_unfavourite(id)
else: else:
mastodon.status_favourite(id) mastodon.status_favourite(id)
return redirect(thread, 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: else:
return render(request, 'main/fav.html', return render(request, 'main/fav.html',
{"toot": toot, {"toot": toot,
@ -565,7 +572,14 @@ def boost(request, id):
mastodon.status_unreblog(id) mastodon.status_unreblog(id)
else: else:
mastodon.status_reblog(id) mastodon.status_reblog(id)
return redirect(thread, 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: else:
return render(request, 'main/boost.html', return render(request, 'main/boost.html',
{"toot": toot, {"toot": toot,

View File

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

View File

@ -18,10 +18,10 @@ intercooler@^1.2.1:
version "1.2.1" version "1.2.1"
resolved "https://registry.yarnpkg.com/intercooler/-/intercooler-1.2.1.tgz#50e9727ef2643ef7d5130c8e58f2af78098aa01f" 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: mousetrap@^1.6.2:
version "1.6.2" version "1.6.2"
resolved "https://registry.yarnpkg.com/mousetrap/-/mousetrap-1.6.2.tgz#caadd9cf886db0986fb2fee59a82f6bd37527587" 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"