2017-09-27 06:43:28 +00:00
|
|
|
{% extends 'bootstrap/base.html' %}
|
|
|
|
|
|
|
|
{% block title %}
|
2017-09-30 07:21:17 +00:00
|
|
|
{% if title %}{{ title }} - Microblog{% else %}{{ _('Welcome to Microblog') }}{% endif %}
|
2017-09-27 06:43:28 +00:00
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block navbar %}
|
|
|
|
<nav class="navbar navbar-default">
|
|
|
|
<div class="container">
|
|
|
|
<div class="navbar-header">
|
|
|
|
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
|
|
|
|
<span class="sr-only">Toggle navigation</span>
|
|
|
|
<span class="icon-bar"></span>
|
|
|
|
<span class="icon-bar"></span>
|
|
|
|
<span class="icon-bar"></span>
|
|
|
|
</button>
|
2017-10-09 07:09:22 +00:00
|
|
|
<a class="navbar-brand" href="{{ url_for('main.index') }}">Microblog</a>
|
2017-09-27 06:43:28 +00:00
|
|
|
</div>
|
|
|
|
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
|
|
|
<ul class="nav navbar-nav">
|
2017-10-09 07:09:22 +00:00
|
|
|
<li><a href="{{ url_for('main.index') }}">{{ _('Home') }}</a></li>
|
|
|
|
<li><a href="{{ url_for('main.explore') }}">{{ _('Explore') }}</a></li>
|
2017-09-27 06:43:28 +00:00
|
|
|
</ul>
|
2017-09-20 19:51:53 +00:00
|
|
|
{% if g.search_form %}
|
|
|
|
<form class="navbar-form navbar-left" method="get" action="{{ url_for('main.search') }}">
|
|
|
|
<div class="form-group">
|
|
|
|
{{ g.search_form.q(size=20, class='form-control', placeholder=g.search_form.q.label.text) }}
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
{% endif %}
|
2017-09-27 06:43:28 +00:00
|
|
|
<ul class="nav navbar-nav navbar-right">
|
|
|
|
{% if current_user.is_anonymous %}
|
2017-10-09 07:09:22 +00:00
|
|
|
<li><a href="{{ url_for('auth.login') }}">{{ _('Login') }}</a></li>
|
2017-09-27 06:43:28 +00:00
|
|
|
{% else %}
|
2017-11-13 07:53:18 +00:00
|
|
|
<li>
|
|
|
|
<a href="{{ url_for('main.messages') }}">{{ _('Messages') }}
|
|
|
|
{% set new_messages = current_user.new_messages() %}
|
|
|
|
<span id="message_count" class="badge"
|
|
|
|
style="visibility: {% if new_messages %}visible
|
|
|
|
{% else %}hidden{% endif %};">
|
|
|
|
{{ new_messages }}
|
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
</li>
|
2017-10-09 07:09:22 +00:00
|
|
|
<li><a href="{{ url_for('main.user', username=current_user.username) }}">{{ _('Profile') }}</a></li>
|
|
|
|
<li><a href="{{ url_for('auth.logout') }}">{{ _('Logout') }}</a></li>
|
2017-09-27 06:43:28 +00:00
|
|
|
{% endif %}
|
|
|
|
</ul>
|
|
|
|
</div>
|
2017-09-05 07:04:56 +00:00
|
|
|
</div>
|
2017-09-27 06:43:28 +00:00
|
|
|
</nav>
|
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block content %}
|
|
|
|
<div class="container">
|
2017-09-05 07:04:56 +00:00
|
|
|
{% with messages = get_flashed_messages() %}
|
|
|
|
{% if messages %}
|
|
|
|
{% for message in messages %}
|
2017-09-27 06:43:28 +00:00
|
|
|
<div class="alert alert-info" role="alert">{{ message }}</div>
|
2017-09-05 07:04:56 +00:00
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{% endwith %}
|
2017-09-27 06:43:28 +00:00
|
|
|
|
|
|
|
{# application content needs to be provided in the app_content block #}
|
|
|
|
{% block app_content %}{% endblock %}
|
|
|
|
</div>
|
|
|
|
{% endblock %}
|
2017-09-29 05:28:20 +00:00
|
|
|
|
|
|
|
{% block scripts %}
|
|
|
|
{{ super() }}
|
|
|
|
{{ moment.include_moment() }}
|
2017-09-30 07:21:17 +00:00
|
|
|
{{ moment.lang(g.locale) }}
|
2017-10-05 22:34:15 +00:00
|
|
|
<script>
|
|
|
|
function translate(sourceElem, destElem, sourceLang, destLang) {
|
|
|
|
$(destElem).html('<img src="{{ url_for('static', filename='loading.gif') }}">');
|
|
|
|
$.post('/translate', {
|
|
|
|
text: $(sourceElem).text(),
|
|
|
|
source_language: sourceLang,
|
|
|
|
dest_language: destLang
|
|
|
|
}).done(function(response) {
|
|
|
|
$(destElem).text(response['text'])
|
|
|
|
}).fail(function() {
|
|
|
|
$(destElem).text("{{ _('Error: Could not contact server.') }}");
|
|
|
|
});
|
|
|
|
}
|
2017-11-10 03:20:27 +00:00
|
|
|
$(function () {
|
|
|
|
var timer = null;
|
|
|
|
var xhr = null;
|
|
|
|
$('.user_popup').hover(
|
|
|
|
function(event) {
|
|
|
|
// mouse in event handler
|
|
|
|
var elem = $(event.currentTarget);
|
|
|
|
timer = setTimeout(function() {
|
|
|
|
timer = null;
|
|
|
|
xhr = $.ajax(
|
|
|
|
'/user/' + elem.first().text().trim() + '/popup').done(
|
|
|
|
function(data) {
|
|
|
|
xhr = null;
|
|
|
|
elem.popover({
|
|
|
|
trigger: 'manual',
|
|
|
|
html: true,
|
|
|
|
animation: false,
|
|
|
|
container: elem,
|
|
|
|
content: data
|
|
|
|
}).popover('show');
|
|
|
|
flask_moment_render_all();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}, 1000);
|
|
|
|
},
|
|
|
|
function(event) {
|
|
|
|
// mouse out event handler
|
|
|
|
var elem = $(event.currentTarget);
|
|
|
|
if (timer) {
|
|
|
|
clearTimeout(timer);
|
|
|
|
timer = null;
|
|
|
|
}
|
|
|
|
else if (xhr) {
|
|
|
|
xhr.abort();
|
|
|
|
xhr = null;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
elem.popover('destroy');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2017-11-13 07:53:18 +00:00
|
|
|
function set_message_count(n) {
|
|
|
|
$('#message_count').text(n);
|
|
|
|
$('#message_count').css('visibility', n ? 'visible' : 'hidden');
|
|
|
|
}
|
|
|
|
{% if current_user.is_authenticated %}
|
|
|
|
$(function() {
|
|
|
|
var since = 0;
|
|
|
|
setInterval(function() {
|
|
|
|
$.ajax('{{ url_for('main.notifications') }}?since=' + since).done(
|
|
|
|
function(notifications) {
|
|
|
|
for (var i = 0; i < notifications.length; i++) {
|
|
|
|
if (notifications[i].name == 'unread_message_count')
|
|
|
|
set_message_count(notifications[i].data);
|
|
|
|
since = notifications[i].timestamp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}, 10000);
|
|
|
|
});
|
|
|
|
{% endif %}
|
2017-10-05 22:34:15 +00:00
|
|
|
</script>
|
2017-09-29 05:28:20 +00:00
|
|
|
{% endblock %}
|