<commit_before><?php

namespace Augustus;

require_once('./src/markdown.php');
use \Michelf\Markdown;

class Augustus {
	private $options = ['forced' => false];

	public function new_post()
	{
		echo "Creating a new post\nTitle: ";
		$title = trim(fgets(STDIN));

		echo "Publish date [".date('Y-m-d')."]: ";
		$date = trim(fgets(STDIN));
		if(empty($date))
			$date = date('Y-m-d');

		echo "Category [Uncategorized]: ";
		$category = trim(fgets(STDIN));
		if(empty($category))
			$category = 'Uncategorized';

		echo "Tags (separate by commas): ";
		$tags = array_map('trim',(explode(',', fgets(STDIN))));

		$json = ['title'    => $title,
			 'category' => $category,
			 'tags'     => $tags,
			 'pubdate'  => $date,
			 'slug'     => $this->slug($title), 
			 'layout'   => 'post'];

		$md  = '#'.$title."\n\nPost goes here\n\n";
		$md .= "---EOF---\n";
		$md .= json_encode($json, JSON_PRETTY_PRINT);
		
		$filename = 'posts/'.$date.'_'.$json['slug'].'.md';
		file_put_contents($filename, $md);
		system('subl -w ./'.$filename);

		exit("Blog post saved as $filename.\n");
	}
	public function new_page()
	{
		echo "Creating a new static page\nTitle: ";
		$title = trim(fgets(STDIN));
		$slug = $this->slug($title);

		echo "Path [/$slug]: ";
		$path = trim(fgets(STDIN));
		if(empty($path))
			$path = '/'.$slug;

		$json = ['title'    => $title,
			 'slug'     => $slug, 
			 'layout'   => 'page',
			 'path'     => $path];

		$md  = '#'.$title."\n\nPost goes here\n\n";
		$md .= "---EOF---\n";
		$md .= json_encode($json, JSON_PRETTY_PRINT);
		
		$filename = 'pages/'.$json['slug'].'.md';
		file_put_contents($filename, $md);
		system('subl -w ./'.$filename);

		exit("Static page saved as $filename.\n");
	}
	public function build()
	{
		$this->copy_site_assets();
		
		$files = $this->write_index();
		$files = $this->checksum();
		var_dump($files);
		echo "Rendering pages ";
		foreach ($files as $file) {
			$this->render_page($file);<commit_msg>Added unescaped_slashes option to new_page()<commit_after><?php

namespace Augustus;

require_once('./src/markdown.php');
use \Michelf\Markdown;

class Augustus {
	private $options = ['forced' => false];

	public function new_post()
	{
		echo "Creating a new post\nTitle: ";
		$title = trim(fgets(STDIN));

		echo "Publish date [".date('Y-m-d')."]: ";
		$date = trim(fgets(STDIN));
		if(empty($date))
			$date = date('Y-m-d');

		echo "Category [Uncategorized]: ";
		$category = trim(fgets(STDIN));
		if(empty($category))
			$category = 'Uncategorized';

		echo "Tags (separate by commas): ";
		$tags = array_map('trim',(explode(',', fgets(STDIN))));

		$json = ['title'    => $title,
			 'category' => $category,
			 'tags'     => $tags,
			 'pubdate'  => $date,
			 'slug'     => $this->slug($title), 
			 'layout'   => 'post'];

		$md  = '#'.$title."\n\nPost goes here\n\n";
		$md .= "---EOF---\n";
		$md .= json_encode($json, JSON_PRETTY_PRINT);
		
		$filename = 'posts/'.$date.'_'.$json['slug'].'.md';
		file_put_contents($filename, $md);
		system('subl -w ./'.$filename);

		exit("Blog post saved as $filename.\n");
	}
	public function new_page()
	{
		echo "Creating a new static page\nTitle: ";
		$title = trim(fgets(STDIN));
		$slug = $this->slug($title);

		echo "Path [/$slug]: ";
		$path = trim(fgets(STDIN));
		if(empty($path))
			$path = '/'.$slug;

		$json = ['title'    => $title,
			 'slug'     => $slug, 
			 'layout'   => 'page',
			 'path'     => $path];

		$md  = '#'.$title."\n\nPost goes here\n\n";
		$md .= "---EOF---\n";
		$md .= json_encode($json, JSON_PRETTY_PRINT
					| JSON_UNESCAPED_SLASHES);
		
		$filename = 'pages/'.$json['slug'].'.md';
		file_put_contents($filename, $md);
		system('subl -w ./'.$filename);

		exit("Static page saved as $filename.\n");
	}
	public function build()
	{
		$this->copy_site_assets();
		
		$files = $this->write_index();
		$files = $this->checksum();
		var_dump($files);
		echo "Rendering pages ";
		foreach ($files as $file) {
			$this->render_page($file);
{'fraction_non_alphanumeric': 0.2305758109127483, 'fraction_numerical': 0.0, 'mean_word_length': 3.3239130434782607, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '3661144', 'n_tokens_mistral': 1685, 'n_tokens_neox': 1511, 'n_words': 302}