<commit_before>/*
 * CMS.js v1.0.0
 * Copyright 2015 <NAME>
 * www.cdmedia.github.io/cms.js
 * Free to use under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 */

var CMS = {

	settings: {
		siteName: 'CMS.js',
		siteTagline: 'Your site tagline',
		siteEmail: '<EMAIL>',
		siteAuthor: '<NAME>',
		siteUrl: '',
		siteNavItems: [
			{ name: 'Github', href: '#', newWindow: false},
			{ name: 'About' }
		],
		pagination: 3,
		postsFolder: 'posts',
		postSnippetLength: 120,
		pagesFolder: 'pages',
		fadeSpeed: 300,
		mainContainer: $('.cms_main'),
		footerContainer: $('.cms_footer'),
		footerText: '&copy; ' + new Date().getFullYear() + ' All Rights Reserved.',
		parseSeperator: '---',
		loader: '<div class="loader">Loading...</div>',
		get siteAttributes() {
			return [
				{ attr: 'title', value: CMS.settings.siteName },
				{ attr: '.cms_sitename', value: CMS.settings.siteName},
				{ attr: '.cms_tagline', value: CMS.settings.siteTagline},
				{ attr: '.cms_footer_text', value: CMS.settings.footerText}
			];
		},
		mode: 'Github',
		githubUserSettings: {
			username: 'yourusername',
			repo: 'yourrepo',
		},
		githubSettings: {
			branch: 'gh-pages',
			host: 'https://api.github.com'
		}
	},

	posts: [],
	pages: [],
	loaded: {},

	extend: function (target, opts, callback) {
		var next;
		if (typeof opts === "undefined") {
			opts = target;
			target = CMS;
		}
		for (next in opts) {
			if (Object.prototype.hasOwnProperty.call(opts, next)) {
				target[next] = opts[next];
			}
		}
		callback(); // check user config options
		return target;
	},

	render: function (url) {
		CMS.settings.mainContainer.html('').fadeOut(CMS.settings.fadeSpeed);
		CMS.settings.footerContainer.hide();

		var type = url.split('/')[0];
		var map = {

			// Main view
			'' : function () {
				CMS.renderPosts();
			},

			// Post view
			'#post' : function() {
				var id = url.split('#post/')[1].trim();
				CMS.renderPost(id);
			},

			// Post view
			'#page' : function() {
				var title = url.split('#page/')[1].trim();
				CMS.renderPage(title);
			}

		};

		if (map[type]) {
			map[type]();
		} else {
			var errorMsg = 'Error loading page.';
			CMS.renderError(errorMsg);
		}
	},

	renderPage: function(title) {
		CMS.pages.forEach(function(page){
			if(page.title == title) {

				var tpl = $('#page-template').html(),
					$tpl = $(tpl);

				$tpl.find('.page-title').html(page.title);
				$tpl.find('.page-content').html(page.contentData);

				CMS.settings.mainContainer.html($tpl).hide().fadeIn(CMS.settings.fadeSpeed);
			}
		});
		CMS.renderFooter();
	},

	renderPost: function(id) {
		CMS.posts.forEach(function(post){
			if(post.id == id) {

				var tpl = $('#post-template').html(),
					$tpl = $(tpl);

				$tpl.find('.post-title').html(post.title);
				$tpl.find('.post-date').html((post.date.getMonth() + 1) + '/' + post.date.getDate() + '/' +  post.date.getFullYear());
				$tpl.find('.post-content').html(post.contentData);

				CMS.settings.mainContainer.html($tpl).hide().fadeIn(CMS.settings.fadeSpeed);
			}
		});
		CMS.renderFooter();
	},

	renderPosts: function() {
		CMS.posts.forEach(function(post){
			var tpl = $('#post-template').html(),
				$tpl = $(tpl);

			var title = '<a href="#">' + post.title + '</a>',
				date = (post.date.getMonth() + 1) + '/' + post.date.getDate() + '/' +  post.date.getFullYear(),
				snippet = post.contentData.split('.')[0] + '.';

			var postLink = $tpl.find('.post-title'),
				postDate = $tpl.find('.post-date'),
				postSnippet = $tpl.find('.post-content');

			postLink.on('click', function (e) {
				e.preventDefault();
				window.location.hash = 'post/' + post.id;
			});

			postLink.html(title);
			postSnippet.html(snippet);
			postDate.html(date);
			CMS.settings.mainContainer.append($tpl).hide().fadeIn(CMS.settings.fadeSpeed);
		});
		CMS.renderFooter();
	},

	renderFooter: function() {
		// Load footer later so things dont look weird loading ajax stuff
		setTimeout(function () {
			CMS.settings.footerContainer.fadeIn(CMS.settings.fadeSpeed);<commit_msg>Fix order of posts and pages<commit_after>/*
 * CMS.js v1.0.0
 * Copyright 2015 <NAME>
 * www.cdmedia.github.io/cms.js
 * Free to use under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 */

var CMS = {

	settings: {
		siteName: 'CMS.js',
		siteTagline: 'Your site tagline',
		siteEmail: '<EMAIL>',
		siteAuthor: '<NAME>',
		siteUrl: '',
		siteNavItems: [
			{ name: 'Github', href: '#', newWindow: false},
			{ name: 'About' }
		],
		pagination: 3,
		postsFolder: 'posts',
		postSnippetLength: 120,
		pagesFolder: 'pages',
		fadeSpeed: 300,
		mainContainer: $('.cms_main'),
		footerContainer: $('.cms_footer'),
		footerText: '&copy; ' + new Date().getFullYear() + ' All Rights Reserved.',
		parseSeperator: '---',
		loader: '<div class="loader">Loading...</div>',
		get siteAttributes() {
			return [
				{ attr: 'title', value: CMS.settings.siteName },
				{ attr: '.cms_sitename', value: CMS.settings.siteName},
				{ attr: '.cms_tagline', value: CMS.settings.siteTagline},
				{ attr: '.cms_footer_text', value: CMS.settings.footerText}
			];
		},
		mode: 'Github',
		githubUserSettings: {
			username: 'yourusername',
			repo: 'yourrepo',
		},
		githubSettings: {
			branch: 'gh-pages',
			host: 'https://api.github.com'
		}
	},

	posts: [],
	pages: [],
	loaded: {},

	extend: function (target, opts, callback) {
		var next;
		if (typeof opts === "undefined") {
			opts = target;
			target = CMS;
		}
		for (next in opts) {
			if (Object.prototype.hasOwnProperty.call(opts, next)) {
				target[next] = opts[next];
			}
		}
		callback(); // check user config options
		return target;
	},

	render: function (url) {
		CMS.settings.mainContainer.html('').fadeOut(CMS.settings.fadeSpeed);
		CMS.settings.footerContainer.hide();

		var type = url.split('/')[0];
		var map = {

			// Main view
			'' : function () {
				CMS.renderPosts();
			},

			// Post view
			'#post' : function() {
				var id = url.split('#post/')[1].trim();
				CMS.renderPost(id);
			},

			// Post view
			'#page' : function() {
				var title = url.split('#page/')[1].trim();
				CMS.renderPage(title);
			}

		};

		if (map[type]) {
			map[type]();
		} else {
			var errorMsg = 'Error loading page.';
			CMS.renderError(errorMsg);
		}
	},

        renderPage: function(title) {
	        CMS.pages.sort(function(a,b) {return a.date - b.date});
		CMS.pages.forEach(function(page){
			if(page.title == title) {

				var tpl = $('#page-template').html(),
					$tpl = $(tpl);

				$tpl.find('.page-title').html(page.title);
				$tpl.find('.page-content').html(page.contentData);

				CMS.settings.mainContainer.html($tpl).hide().fadeIn(CMS.settings.fadeSpeed);
			}
		});
		CMS.renderFooter();
	},

	renderPost: function(id) {
		CMS.posts.forEach(function(post){
			if(post.id == id) {

				var tpl = $('#post-template').html(),
					$tpl = $(tpl);

				$tpl.find('.post-title').html(post.title);
				$tpl.find('.post-date').html((post.date.getMonth() + 1) + '/' + post.date.getDate() + '/' +  post.date.getFullYear());
				$tpl.find('.post-content').html(post.contentData);

				CMS.settings.mainContainer.html($tpl).hide().fadeIn(CMS.settings.fadeSpeed);
			}
		});
		CMS.renderFooter();
	},

        renderPosts: function() {
	        CMS.posts.sort(function(a,b) {return a.date - b.date});
		CMS.posts.forEach(function(post){
			var tpl = $('#post-template').html(),
				$tpl = $(tpl);

			var title = '<a href="#">' + post.title + '</a>',
				date = (post.date.getMonth() + 1) + '/' + post.date.getDate() + '/' +  post.date.getFullYear(),
				snippet = post.contentData.split('.')[0] + '.';

			var postLink = $tpl.find('.post-title'),
				postDate = $tpl.find('.post-date'),
				postSnippet = $tpl.find('.post-content');

			postLink.on('click', function (e) {
				e.preventDefault();
				window.location.hash = 'post/' + post.id;
			});

			postLink.html(title);
			postSnippet.html(snippet);
			postDate.html(date);
			CMS.settings.mainContainer.append($tpl).hide().fadeIn(CMS.settings.fadeSpeed);
		});
		CMS.renderFooter();
	},

	renderFooter: function() {
		// Load footer later so things dont look weird loading ajax stuff
		setTimeout(function () {
			CMS.settings.footerContainer.fadeIn(CMS.settings.fadeSpeed);
{'fraction_non_alphanumeric': 0.20354943860919958, 'fraction_numerical': 0.004829168175781722, 'mean_word_length': 3.230847803881512, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, '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': '3647477', 'n_tokens_mistral': 3474, 'n_tokens_neox': 2913, 'n_words': 520}