<commit_before>/// <reference path="../../../typings/bundle.d.ts" />

import async = require('async');
import marked = require('marked');
import User = require('../../models/user');
import UserFollowing = require('../../models/user-following');
import Post = require('../../models/post');
import Timeline = require('../utils/timeline');
import conf = require('../../config');

export = render;

var render = (req: any, res: any, content: string = 'home'): void => {
	async.series([
		(callback: any) => {
			Post.getUserPostsCount(req.rootUser.id,(count: number) => {
				callback(null, count);
			});
		},
		(callback: any) => {
			UserFollowing.getFollowingsCount(req.rootUser.id,(count: number) => {
				callback(null, count);
			});
		},
		(callback: any) => {
			UserFollowing.getFollowersCount(req.rootUser.id,(count: number) => {
				callback(null, count);
			});
		},
		(callback: any) => {
			Post.findByUserId(req.rootUser.id, 30, null, null,(posts: Post[]) => {
				Timeline.generateHtml(posts,(timelineHtml: string) => {
					callback(null, timelineHtml);
				});
			});
		},
		(callback: any) => {
			if (req.login) {
				UserFollowing.isFollowing(req.me.id, req.rootUser.id,(isFollowing: boolean) => {
					callback(null, isFollowing);
				});
			} else {
				callback(null, null);
			}
		},
		(callback: any) => {
			if (req.login) {
				UserFollowing.isFollowing(req.rootUser.id, req.me.id,(isFollowMe: boolean) => {
					callback(null, isFollowMe);
				});
			} else {
				callback(null, null);
			}
		},
		(callback: any) => {
			switch (content) {
				case 'home':
					callback(null, marked(req.rootUser.bio));
					break;
				case 'followings':
					UserFollowing.getFollowings(req.rootUser.id, 50,(userFollowings: UserFollowing[]) => {
						if (userFollowings != null) {
							async.map(userFollowings,(userFollowing: UserFollowing, next: any) => {
								User.find(userFollowing.followeeId,(user: User) => {
									next(null, user);
								});
							},(err: any, results: User[]) => {
									callback(null, results);
								});
						} else {
							callback(null, null);
						}
					});
					break;
				case 'followers':
					UserFollowing.getFollowers(req.rootUser.id, 50,(userFollowings: UserFollowing[]) => {
						if (userFollowings != null) {
							async.map(userFollowings,(userFollowing: UserFollowing, next: any) => {
								User.find(userFollowing.followerId,(user: User) => {
									next(null, user);
								});
							},(err: any, results: User[]) => {
									callback(null, results);
								});
						} else {
							callback(null, null);
						}
					});
					break;
			}
		}],
		(err: any, results: any) => {
			res.display(req, res, 'user', {
				postsCount: results[0],
				followingsCount: results[1],
				followersCount: results[2],
				timelineHtml: results[3],
				isFollowing: results[4],
				isFollowMe: results[5],
				content: results[6],
				user: req.rootUser,
				tags: req.rootUser.tag != null ? req.rootUser.tag.split(',') : null,
				url: conf.publicConfig.url,
				page: content
			});
		});
};
<commit_msg>Set marked options<commit_after>/// <reference path="../../../typings/bundle.d.ts" />

import async = require('async');
import marked = require('marked');
import User = require('../../models/user');
import UserFollowing = require('../../models/user-following');
import Post = require('../../models/post');
import Timeline = require('../utils/timeline');
import conf = require('../../config');

marked.setOptions({
	gfm: true,
	breaks: true,
	sanitize: true
});

export = render;

var render = (req: any, res: any, content: string = 'home'): void => {
	async.series([
		(callback: any) => {
			Post.getUserPostsCount(req.rootUser.id,(count: number) => {
				callback(null, count);
			});
		},
		(callback: any) => {
			UserFollowing.getFollowingsCount(req.rootUser.id,(count: number) => {
				callback(null, count);
			});
		},
		(callback: any) => {
			UserFollowing.getFollowersCount(req.rootUser.id,(count: number) => {
				callback(null, count);
			});
		},
		(callback: any) => {
			Post.findByUserId(req.rootUser.id, 30, null, null,(posts: Post[]) => {
				Timeline.generateHtml(posts,(timelineHtml: string) => {
					callback(null, timelineHtml);
				});
			});
		},
		(callback: any) => {
			if (req.login) {
				UserFollowing.isFollowing(req.me.id, req.rootUser.id,(isFollowing: boolean) => {
					callback(null, isFollowing);
				});
			} else {
				callback(null, null);
			}
		},
		(callback: any) => {
			if (req.login) {
				UserFollowing.isFollowing(req.rootUser.id, req.me.id,(isFollowMe: boolean) => {
					callback(null, isFollowMe);
				});
			} else {
				callback(null, null);
			}
		},
		(callback: any) => {
			switch (content) {
				case 'home':
					callback(null, marked(req.rootUser.bio));
					break;
				case 'followings':
					UserFollowing.getFollowings(req.rootUser.id, 50,(userFollowings: UserFollowing[]) => {
						if (userFollowings != null) {
							async.map(userFollowings,(userFollowing: UserFollowing, next: any) => {
								User.find(userFollowing.followeeId,(user: User) => {
									next(null, user);
								});
							},(err: any, results: User[]) => {
									callback(null, results);
								});
						} else {
							callback(null, null);
						}
					});
					break;
				case 'followers':
					UserFollowing.getFollowers(req.rootUser.id, 50,(userFollowings: UserFollowing[]) => {
						if (userFollowings != null) {
							async.map(userFollowings,(userFollowing: UserFollowing, next: any) => {
								User.find(userFollowing.followerId,(user: User) => {
									next(null, user);
								});
							},(err: any, results: User[]) => {
									callback(null, results);
								});
						} else {
							callback(null, null);
						}
					});
					break;
			}
		}],
		(err: any, results: any) => {
			res.display(req, res, 'user', {
				postsCount: results[0],
				followingsCount: results[1],
				followersCount: results[2],
				timelineHtml: results[3],
				isFollowing: results[4],
				isFollowMe: results[5],
				content: results[6],
				user: req.rootUser,
				tags: req.rootUser.tag != null ? req.rootUser.tag.split(',') : null,
				url: conf.publicConfig.url,
				page: content
			});
		});
};

{'fraction_non_alphanumeric': 0.18781074578989576, 'fraction_numerical': 0.004170008019246191, 'mean_word_length': 2.892634207240949, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 53, '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': '2823328', 'n_tokens_mistral': 2701, 'n_tokens_neox': 2016, 'n_words': 375}