<commit_before>extends layout-nosidebar

block append trailers
	script(src='/js/bundle.js')
	script(src='/js/rivets.min.js')
	- var json = JSON.stringify(post)
	script(src='/js/app.js')
	script.
		var postjson = !{json};
		var app = require('./build/js/app.js');
		var Backbone = require('backbone');
		Backbone.$ = window.$;
		$(function()
		{
			var post = new app.PostModel();
			post.set(postjson);
			console.log(post);

			var controller = new app.Postmonger();
			Backbone.history.start({pushState: true});

			rivets.bind($('#preview'),
			{
				post: post,
				controller: controller
			});
		});

block content
	.container
		h2 New post
		.row
			.col-md-7
				form#postForm(method='POST', role='form')
					input#_csrf(name="_csrf", type='hidden', value="#{_csrf}")
					.form-group
						label.control-label Title
						- if (post.title)
							input.form-control(type="text", placeholder="title", name="title", value='#{post.title}')
						- else
							input.form-control(type="text", placeholder="title", name="title")
					.form-group
						label.control-label Tags
						- if (post.tags)
							input.form-control(type="text", placeholder="comma-separated list of tags", name="tags", value='#{post.tags}')
						- else
							input.form-control(type="text", placeholder="comma-separated list of tags", name="tags")
					.form-group
						label.control-label Your post
						textarea.form-control(rows='20', name='content')
							= post.content
						span.help-block You can use Markdown or limited html.
					.form-group
						.pull-right
							button.btn.btn-default(type='cancel') Cancel
							button.btn.btn-primary(type="submit") Post
			.col-md-5
				#preview
					h3 { post.attributes.title }
					#content { post.attributes.content }
					#tags { post.tags }<commit_msg>Now that's a preview. You need to click elsewhere to get the change event, but at least it's rendering.<commit_after>extends layout-nosidebar

block append trailers
	script(src='/js/bundle.js')
	script(src='/js/rivets.min.js')
	- var json = JSON.stringify(post)
	script(src='/js/app.js')
	script.
		var postjson = !{json};
		var 
			app = require('./build/js/app.js')
			Backbone = require('backbone'),
			marked = require('supermarked')
			;

		Backbone.$ = window.$;
		$(function()
		{
			var post = new app.PostModel();
			post.set(postjson);

			var controller = new app.Postmonger();
			Backbone.history.start({pushState: true});

			rivets.adapters[':'] =
			{
				subscribe: function(obj, keypath, callback) { obj.on('change:' + keypath, callback); },
				unsubscribe: function(obj, keypath, callback) { obj.off('change:' + keypath, callback); },
				read: function(obj, keypath) { return obj.get(keypath); },
				publish: function(obj, keypath, value) { obj.set(keypath, value); }
			}

			rivets.formatters.render = function(text)
			{
				return marked(text);
			}

			rivets.bind($('#preview'), { post: post });
			rivets.bind($('#postForm'), { post: post });
		});

block content
	.container
		h2 New post
		.row
			.col-md-7
				form#postForm(method='POST', role='form')
					input#_csrf(name="_csrf", type='hidden', value="#{_csrf}")
					.form-group
						label.control-label Title
						input.form-control(type="text", placeholder="title", name="title", rv-value="post:title")
					.form-group
						label.control-label Tags
						input.form-control(type="text", placeholder="comma-separated list of tags", name="tags", rv-value="post:tags")
					.form-group
						label.control-label Your post
						textarea.form-control(rows='20', name='content', rv-value="post:content")
						span.help-block You can use Markdown or limited html.
					.form-group
						.pull-right
							button.btn.btn-default(type='cancel') Cancel
							button.btn.btn-primary(type="submit") Post
			.col-md-5
				#preview
					h3 { post:title }
					#content(rv-html="post:content | render")
					#tags { post:tags }
{'fraction_non_alphanumeric': 0.16696542893725994, 'fraction_numerical': 0.0030729833546734955, 'mean_word_length': 3.209051724137931, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4195414', 'n_tokens_mistral': 1616, 'n_tokens_neox': 1276, 'n_words': 264}