<commit_before><?php
/**
 * Contains utilities and classes for generating an atom feed. Relies
 * on the postObj class for retrieving and outputting post data in the
 * feed. Requires existing instances of the config and session classes.
 * 
 * @author <NAME> <<EMAIL>>
 * Language: PHP
 * Filename: core_atom.php
 * 
 */

/**
 * Defines a data object to contain an atom feed as items
 * are added and the feed is updated then returned
 */
class atom_feed {
	
	/**
	 * @var $items - an array of postObj instances
	 * @var $feedMeta - the feed metadata - location, title, author, datestamps
	 */

	private $feedMeta, $items;
	
	/**
	 * Creates an empty atom feed object with metadata
	 * 
	 * @param $title (str): a title for the atom feed
	 * @param $link (str): the base url for the feed
	 * @param $description (str): a description or summary of the feed
	 * @param $feedstamp (str): a datestamp for the feed, in standard atom format
	 */
	public function __construct($title, $link, $description, $feedstamp) {

		$this->feedMeta['title'] = $title;
		$this->feedMeta['link'] = $link;
		$this->feedMeta['description'] = $description;
		$this->feedMeta['feedstamp'] = $feedstamp;
		$this->feedMeta['author'] = $config->site_author;
		$this->items = array();

	}

	/**
	 * Adds an item to the feed as an object in the object's
	 * items array
	 * 
	 * @param $postObject - a fully initialized instance of the postObj
	 *	class.
	 * 
	 */
	public function new_item($postObject) {

		array_push($this->items, $postObject);
	}
	
	/**
	 * Returns a displayable representation of the feed
	 * with appropriate code added.  Relies on the postObj 
	 * atom_output() function to generate code for individidual
	 * feed items.
	 * 
	 */
	public function output() {

		$r ='<feed xmlns="http://www.w3.org/2005/Atom"
xml:lang="en"
xml:base="'.getConfigOption('site_domain').'/">';
		$r .= "\n";
		$r .= '<subtitle type="html">' . $this->feedMeta['description'] . "</subtitle>\n";
		$r .= "";
		$r .= "<id>" . $this->feedMeta['link'] . "</id>\n";
		$r .= "<title>" . $this->feedMeta['title'] . "</title>\n";
		$r .= "<updated>". $this->feedMeta['feedstamp'] ."</updated>\n";
		$r .= "<author><name>".$this->feedMeta['author']."</name></author>\n";
		foreach ($this->items as $item) {
			$r .= $item->atom_output();
		}
		$r .= "</feed>";
		return $r;
	}
	
	private function rss() {
		
		$r ='<?xml version="1.0"?>';
		$r .= '<rss version = "2.0">\n';
		$r .= "<channel>";
		$r .= "<title>" . $this->feedMeta['title'] . "</title>";
		$r .= "<link>" . $this->feedMeta['link'] . "</link>";
		$r .= "<description>" . $this->feedMeta['description'] . "</description>";
		foreach ($this->items as $item){
			$r .= $item->rss_output();
		}
		
		$r .= "</channel>";
		$r .= "</rss>";		
		
		return $r;
	}

}

/**
 * Generates an atom feed and returns it
 * 
 * @return $atom (atom_feed): an instance of the atom_feed class
 * 
 */
function generateFeed(){
	
	$posts = getPostList();
	$atom = new atom_feed("The Philosophy of Nate", "http://blog.thenaterhood.com/", "It's the cyber age, stay in the know.", date(DATE_ATOM) );
	
	for ($i = 0; $i < count($posts); $i++){
		$newitem = new postObj(getConfigOption('post_directory').'/'.$posts[$i]);
		$atom->new_item($newitem);
	}
	return $atom;
}

?>
<commit_msg>remove php-like tags from rss xml<commit_after><?php
/**
 * Contains utilities and classes for generating an atom feed. Relies
 * on the postObj class for retrieving and outputting post data in the
 * feed. Requires existing instances of the config and session classes.
 * 
 * @author <NAME> <<EMAIL>>
 * Language: PHP
 * Filename: core_atom.php
 * 
 */

/**
 * Defines a data object to contain an atom feed as items
 * are added and the feed is updated then returned
 */
class atom_feed {
	
	/**
	 * @var $items - an array of postObj instances
	 * @var $feedMeta - the feed metadata - location, title, author, datestamps
	 */

	private $feedMeta, $items;
	
	/**
	 * Creates an empty atom feed object with metadata
	 * 
	 * @param $title (str): a title for the atom feed
	 * @param $link (str): the base url for the feed
	 * @param $description (str): a description or summary of the feed
	 * @param $feedstamp (str): a datestamp for the feed, in standard atom format
	 */
	public function __construct($title, $link, $description, $feedstamp) {

		$this->feedMeta['title'] = $title;
		$this->feedMeta['link'] = $link;
		$this->feedMeta['description'] = $description;
		$this->feedMeta['feedstamp'] = $feedstamp;
		$this->feedMeta['author'] = $config->site_author;
		$this->items = array();

	}

	/**
	 * Adds an item to the feed as an object in the object's
	 * items array
	 * 
	 * @param $postObject - a fully initialized instance of the postObj
	 *	class.
	 * 
	 */
	public function new_item($postObject) {

		array_push($this->items, $postObject);
	}
	
	/**
	 * Returns a displayable representation of the feed
	 * with appropriate code added.  Relies on the postObj 
	 * atom_output() function to generate code for individidual
	 * feed items.
	 * 
	 */
	public function output() {

		$r ='<feed xmlns="http://www.w3.org/2005/Atom"
xml:lang="en"
xml:base="'.getConfigOption('site_domain').'/">';
		$r .= "\n";
		$r .= '<subtitle type="html">' . $this->feedMeta['description'] . "</subtitle>\n";
		$r .= "";
		$r .= "<id>" . $this->feedMeta['link'] . "</id>\n";
		$r .= "<title>" . $this->feedMeta['title'] . "</title>\n";
		$r .= "<updated>". $this->feedMeta['feedstamp'] ."</updated>\n";
		$r .= "<author><name>".$this->feedMeta['author']."</name></author>\n";
		foreach ($this->items as $item) {
			$r .= $item->atom_output();
		}
		$r .= "</feed>";
		return $r;
	}
	
	private function rss() {
		
		$r ='<xml version="1.0">';
		$r .= '<rss version = "2.0">\n';
		$r .= "<channel>";
		$r .= "<title>" . $this->feedMeta['title'] . "</title>";
		$r .= "<link>" . $this->feedMeta['link'] . "</link>";
		$r .= "<description>" . $this->feedMeta['description'] . "</description>";
		foreach ($this->items as $item){
			$r .= $item->rss_output();
		}
		
		$r .= "</channel>";
		$r .= "</rss>";		
		
		return $r;
	}

}

/**
 * Generates an atom feed and returns it
 * 
 * @return $atom (atom_feed): an instance of the atom_feed class
 * 
 */
function generateFeed(){
	
	$posts = getPostList();
	$atom = new atom_feed("The Philosophy of Nate", "http://blog.thenaterhood.com/", "It's the cyber age, stay in the know.", date(DATE_ATOM) );
	
	for ($i = 0; $i < count($posts); $i++){
		$newitem = new postObj(getConfigOption('post_directory').'/'.$posts[$i]);
		$atom->new_item($newitem);
	}
	return $atom;
}

?>

{'fraction_non_alphanumeric': 0.194570821959357, 'fraction_numerical': 0.003033060357901122, 'mean_word_length': 3.399599733155437, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 2, '>': 103, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 9}, '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': '4584788', 'n_tokens_mistral': 2371, 'n_tokens_neox': 2158, 'n_words': 653}