melody
Version:
simple publishing platform
83 lines (61 loc) • 2.44 kB
text/jade
doctype html
html.no-js
head
meta(charset="utf-8")
meta(http-equiv="X-UA-Compatible", content="IE=edge")
title #{config.service.name}
meta(name="description", content="#{ (page) ? page.title || config.service.name + ': ' + config.service.mission : config.service.name + ': ' + config.service.mission }")
meta(name="viewport", content="width=device-width, initial-scale=1")
link(rel="stylesheet", href="/css/semantic.min.css")
link(rel="stylesheet", href="/css/highlight/maki.css")
link(rel="stylesheet", href="/css/maki.css")
link(rel="stylesheet", href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Open+Sans:300italic,400,300,700")
script(src="/js/jquery.js")
script(src="/js/semantic.min.js")
script(src="/js/lodash.min.js")
script(src="/js/highlight.pack.js")
script(src="/js/uuid.js")
script(src="/js/jsonrpc.js")
script(src="/js/maki.js")
base(href="/")
body
block page
.ui.page.grid
.row
block navbar
include ../partials/navbar
.row
.column.content(data-for="viewport")
include ../partials/flash
block content
.row
.ui.one.column.stackable.center.aligned
p
small powered by <a href="http://github.com/martindale/melody">melody</a>.
script.
$(document).on('click', '*[data-intent=edit]', function(e) {
e.preventDefault();
var $self = $(this);
$.getJSON('/posts/'+$self.data('id'), function(post) {
var editFunction = _.debounce(submitEdits, 250);
var $form = $('<form class="ui form"><div class="field"><textarea rows="20"></textarea></field></form>');
$form.find('textarea').val(post.content).on('keyup', editFunction);
$('*[data-bind='+$self.data('target')+'][data-id='+$self.data('id')+']').replaceWith($form);
function submitEdits() {
var content = $form.find('textarea').val();
$.ajax({
type: 'patch',
url: '/posts/'+$self.data('id'),
dataType: 'json',
headers: {
Accept: 'application/json'
},
data: {
content: content
}
});
}
});
return false;
});
block scripts