Merge branch 'master' of github.com:kylewm/woodwind

This commit is contained in:
Kyle Mahan 2016-06-05 20:51:48 +00:00
commit 26306bcf99
7 changed files with 23 additions and 1647 deletions

View file

@ -8,11 +8,11 @@ db = SQLAlchemy()
micropub = MicropubClient(client_id='https://woodwind.xyz/')
login_mgr = LoginManager()
login_mgr.login_view = 'views.index'
toolbar = DebugToolbarExtension()
#toolbar = DebugToolbarExtension()
def init_app(app):
db.init_app(app)
micropub.init_app(app)
login_mgr.init_app(app)
toolbar.init_app(app)
# toolbar.init_app(app)

File diff suppressed because one or more lines are too long

View file

@ -1,148 +0,0 @@
$(function(){
function updateTimestamps() {
$(".permalink time").each(function() {
var absolute = $(this).attr('datetime');
var formatted = moment.utc(absolute).fromNow();
$(this).text(formatted);
})
}
function clickOlderLink(evt) {
evt.preventDefault();
$.get(this.href, function(result) {
var $newElements = $("article,.pager", $(result));
$(".pager").replaceWith($newElements);
$newElements.each(function () {
twttr.widgets.load(this);
});
attachListeners();
});
}
function clickShowReplyForm(evt) {
var a = $(this);
evt.preventDefault();
$(".like-form", a.parent()).hide();
$(".reply-form", a.parent()).toggle();//css('display', 'inherit');
//a.css('display', 'none');
}
function clickShowLikeForm(evt) {
var a = $(this);
evt.preventDefault();
$(".reply-form", a.parent()).hide();
$(".like-form", a.parent()).toggle();
//a.css('display', 'none');
}
function submitMicropubForm(evt) {
evt.preventDefault();
var button = this;
var form = $(button).closest('form');
var replyArea = form.parent();
var endpoint = form.attr('action');
var responseArea = $('.micropub-response', replyArea);
var formData = form.serializeArray();
formData.push({name: button.name, value: button.value});
$.post(
endpoint,
formData,
function(result) {
if (Math.floor(result.code / 100) == 2) {
responseArea.html('<a target="_blank" href="' + result.location + '">Success!</a>');
$("textarea", form).val("");
if (button.value === 'rsvp-yes') {
$(".rsvps", form).html('✓ Going');
} else if (button.value === 'rsvp-maybe') {
$(".rsvps", form).html('? Interested');
} else if (button.value === 'rsvp-no') {
$(".rsvps", form).html('✗ Not Going');
}
} else {
responseArea.html('Failure');
}
},
'json'
);
responseArea.html('Posting…');
}
function attachListeners() {
$("#older-link").off('click').click(clickOlderLink);
$(".micropub-form button[type='submit']").off('click').click(submitMicropubForm);
// Post by ctrl/cmd + enter in the text area
$(".micropub-form textarea.content").keyup(function(e) {
if ((e.ctrlKey || e.metaKey) && (e.keyCode == 13 || e.keyCode == 10)) {
var button = $(e.target).closest('form').find('button[value=reply]');
button[0].click();
}
});
$(".micropub-form .content").focus(function () {
$(this).animate({ height: "4em" }, 200);
var $target = $(evt.target);
});
}
function clickUnfoldLink(evt) {
$('#fold').after($('#fold').children())
$('#unfold-link').hide();
}
function foldNewEntries(entries) {
$('#fold').prepend(entries.join('\n'));
attachListeners();
$('#unfold-link').text($('#fold>article:not(.reply-context)').length + " New Posts");
$('#unfold-link').off('click').click(clickUnfoldLink);
$('#unfold-link').show();
// load twitter embeds
twttr.widgets.load($('#fold').get(0));
}
// topic will be user:id or feed:id
function webSocketSubscribe(topic) {
if ('WebSocket' in window) {
var ws = new WebSocket(window.location.origin
.replace(/http:\/\//, 'ws://')
.replace(/https:\/\//, 'wss://')
+ '/_updates');
ws.onopen = function(event) {
// send the topic
console.log('subscribing to topic: ' + topic);
ws.send(topic);
};
ws.onmessage = function(event) {
var data = JSON.parse(event.data);
foldNewEntries(data.entries);
};
}
}
attachListeners();
$(document).on("keypress", function(e) {
if (e.which === 46) {
clickUnfoldLink();
}
});
if (WS_TOPIC) {
webSocketSubscribe(WS_TOPIC);
}
updateTimestamps();
window.setInterval(updateTimestamps, 60 * 1000);
});

File diff suppressed because one or more lines are too long

View file

@ -10,9 +10,11 @@
<link rel="stylesheet" href="{{ url_for('static', filename='style.css', version='2016-03-08') }}"/>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"/>
<script src="//code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="{{ url_for('static', filename='moment.min.js') }}"></script>
<script src="{{ url_for('static', filename='cassis.js') }}"></script>
<link rel="manifest" href="/manifest.json"/>
<script src="/node_modules/jquery/dist/jquery.js"></script>
<script src="/node_modules/moment/moment.js"></script>
{% block head %}{% endblock %}
</head>
@ -52,15 +54,18 @@
<div class="flash">{{ message }}</div>
{% endfor %}
{% if not current_user.is_authenticated %}
<form action="{{ url_for('.login') }}" method="POST">
<input type="url" name="me" placeholder="https://yourdomain.com" />
<input type="hidden" name="next" placeholder="{{ request.path }}" />
<button style="text-align: right;" type="submit">Login</button>
</form>
Your Woodwind account is tied to your personal domain name. Check out IndieWebCamp's <a href="http://indiewebcamp.com/Getting_Started" target="_blank">Getting Started</a> page for details.
{% block login %}
{% endif %}
{% if not current_user.is_authenticated %}
<form action="{{ url_for('.login') }}" method="POST">
<input type="url" name="me" placeholder="https://yourdomain.com" />
<input type="hidden" name="next" placeholder="{{ request.path }}" />
<button style="text-align: right;" type="submit">Login</button>
</form>
Your Woodwind account is tied to your personal domain name. Check out IndieWebCamp's <a href="http://indiewebcamp.com/Getting_Started" target="_blank">Getting Started</a> page for details.
{% endif %}
{% endblock login %}
{% block header %}{% endblock %}

View file

@ -4,7 +4,7 @@
{% if ws_topic %}
<script>var WS_TOPIC = "{{ ws_topic }}";</script>
{% endif %}
<script src="{{url_for('static', filename='feed.js', version='2016-05-21')}}"></script>
<script src="/feed.js"></script>
{% if current_user and current_user.settings
and current_user.settings.get('reply-method') == 'indie-config' %}

View file

@ -24,6 +24,10 @@ IMAGE_TAG_RE = re.compile(r'<img([^>]*) src="(https?://[^">]+)"')
views = flask.Blueprint('views', __name__)
@views.route('/offline')
def offline():
return flask.render_template('offline.jinja2')
@views.route('/')
def index():