<commit_before>var Router = require('../../components/router').RegexRouter;
var Resource = require('../../components/resource').Resource;

module.exports = new Router({
	catch_all : /^\/posts/,
	routes : {
		public : [{ 
			match : /^\/posts$/,
			GET : function (uri_bundle, view) {
				var post_promise = null;
				if (uri_bundle.params.user_id) {
					post_promise = this.models.post.getForUser(uri_bundle.params.user_id);
					post_promise.preload((new Resource('User')).models.user);
				} else {
					post_promise = this.models.post.getAll();
					post_promise.preload('user_id', (new Resource('User')).models.user);
				}

				// this actually has to be assigned before the preload to work.
				// fix that
				post_promise.ready(function (posts) {
					view.set('posts', posts);
					view.render('many.html');
				});
			},
			POST : function (uri_bundle, view) {


			},
			keys : ['id'],
			options : {
				modes : ['text/html']
			}
		}, {
			match : /^\/posts\/(\d+)$/,
			GET : function (uri_bundle, view) {
				
				

				view.set('post', post);

				// should this view.child load templates from the blog folder? or from the user folder?
				this.getResource('user').request('/users/' + post.user_id, view.child('author'));
				view.render('one.html');<commit_msg>clean up code a tiny bit<commit_after>var Router = require('../../components/router').RegexRouter;
var Resource = require('../../components/resource').Resource;

module.exports = new Router({
	catch_all : /^\/posts/,
	routes : {
		public : [{ 
			match : /^\/posts$/,
			GET : function (uri_bundle, view) {
				var post_promise = null;
				if (uri_bundle.params.user_id) {
					post_promise = this.models.post.getForUser(uri_bundle.params.user_id);
				} else {
					post_promise = this.models.post.getAll();
				}

				post_promise.preload('user_id', (new Resource('User')).models.user);
				post_promise.ready(function (posts) {
					view.set('posts', posts);
					view.render('many.html');
				});
			},
			POST : function (uri_bundle, view) {


			},
			keys : ['id'],
			options : {
				modes : ['text/html']
			}
		}, {
			match : /^\/posts\/(\d+)$/,
			GET : function (uri_bundle, view) {
				
				

				view.set('post', post);

				// should this view.child load templates from the blog folder? or from the user folder?
				this.getResource('user').request('/users/' + post.user_id, view.child('author'));
				view.render('one.html');
{'fraction_non_alphanumeric': 0.17967781908302355, 'fraction_numerical': 0.0, 'mean_word_length': 2.8752, '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': '2620125', 'n_tokens_mistral': 973, 'n_tokens_neox': 792, 'n_words': 163}