<commit_before># Shrimp #

Version: 1.0.0  
Author: [<NAME>](<EMAIL>)  
Build Date: 1st July 2009  
Requirements: Symphony 2.0.3

## Installation ##
 
1. *If you've already installed the [Email Template Filter](http://github.com/rowan-lewis/emailtemplatefilter/tree/master) extension you can skip this step.* Edit `symphony/lib/toolkit/class.frontendpage.php` and replace the function on line 416 with this:

		public function __processDatasources(, &,  = array())
		{
			if (trim() == '') return;
			
			$datasources = preg_split('/,\s*/i', $datasources, -1, PREG_SPLIT_NO_EMPTY);
			$datasources = array_map('trim', $datasources);
			
			if (!is_array($datasources) || empty($datasources)) return;
			
			$this->_env['pool'] = $params;
			$pool = $params;
			$dependencies = array();
			
			foreach ($datasources as $handle) {
				$this->_Parent->Profiler->seed();
				
				$pool[$handle] =& $this->DatasourceManager->create($handle, null, false);
				
				$dependencies[$handle] = $pool[$handle]->getDependencies();
				
				unset($ds);
			}
			
			$dsOrder = $this->__findDatasourceOrder($dependencies);
			
			foreach ($dsOrder as $handle) {
				$this->_Parent->Profiler->seed();
		
				$ds = $pool[$handle];
				$ds->processParameters(array('env' => $this->_env, 'param' => $this->_param));
		
				if ($xml = $ds->grab($this->_env['pool'])) {
					if (is_object($xml)) {
						$wrapper->appendChild($xml);
				
					} else {
						$wrapper->setValue($wrapper->getValue() . self::CRLF . "\t" . trim($xml));
					}
				}
		
				$this->_Parent->Profiler->sample($handle, PROFILE_LAP, 'Datasource');
		
				unset($ds);
			}
		}
	
2. Upload the 'shrimp' folder in this archive to your Symphony 'extensions' folder.

3. Enable it by selecting the "Shrimp", choose Enable from the with-selected menu, then click Apply.

4. Change the URL prefix under "System > Preferences", the default is "s".

5. Add your redirection rules under "System > Shrimp".

## Usage ##

Shrimp works by intercepting any requests, such as `http://blah.com/s/123/` to your preferred URL prefix and constructing a new URL based on any rules you've set up. As Shrimp automatically infers the section your entry ID belongs to, rules are limited to one per section.

If a matching rule is found, any attached datasources are passed the entry id as `$shrimp-entry-id` allowing you to resolve the new URL using XPATH in your redirect.

## Shout Outs ##

Large sections of this extension has been adapted from [Rowan Lewis'](http://rowanlewis.com) [Email Template Filter](http://github.com/rowan-lewis/emailtemplatefilter/tree/master) extension.


<commit_msg>`__processDatasources` function in README was borked. Should work now.<commit_after># Shrimp #

Version: 1.0.0  
Author: [<NAME>](<EMAIL>)  
Build Date: 1st July 2009  
Requirements: Symphony 2.0.3

## Installation ##
 
1. *If you've already installed the [Email Template Filter](http://github.com/rowan-lewis/emailtemplatefilter/tree/master) extension you can skip this step.* Edit `symphony/lib/toolkit/class.frontendpage.php` and replace the function on line 441 with this:

		public function __processDatasources($datasources, &$wrapper, $params = array()) {
			if (trim($datasources) == '') return;
			
			$datasources = preg_split('/,\s*/i', $datasources, -1, PREG_SPLIT_NO_EMPTY);
			$datasources = array_map('trim', $datasources);
			
			if (!is_array($datasources) || empty($datasources)) return;
			
			$this->_env['pool'] = $params;
			$pool = $params;
			$dependencies = array();
			
			foreach ($datasources as $handle) {
				$this->_Parent->Profiler->seed();
				
				$pool[$handle] =& $this->DatasourceManager->create($handle, null, false);
				
				$dependencies[$handle] = $pool[$handle]->getDependencies();
				
				unset($ds);
			}
			
			$dsOrder = $this->__findDatasourceOrder($dependencies);
			
			foreach ($dsOrder as $handle) {
				$this->_Parent->Profiler->seed();
				
				$ds = $pool[$handle];
				$ds->processParameters(array('env' => $this->_env, 'param' => $this->_param));
				
				if ($xml = $ds->grab($this->_env['pool'])) {
					if (is_object($xml)) {
						$wrapper->appendChild($xml);
						
					} else {
						$wrapper->setValue($wrapper->getValue() . self::CRLF . "\t" . trim($xml));
					}
				}
				
				$this->_Parent->Profiler->sample($handle, PROFILE_LAP, 'Datasource');
				
				unset($ds);
			}
		}
	
2. Upload the 'shrimp' folder in this archive to your Symphony 'extensions' folder.

3. Enable it by selecting the "Shrimp", choose Enable from the with-selected menu, then click Apply.

4. Change the URL prefix under "System > Preferences", the default is "s".

5. Add your redirection rules under "System > Shrimp".

## Usage ##

Shrimp works by intercepting any requests, such as `http://blah.com/s/123/` to your preferred URL prefix and constructing a new URL based on any rules you've set up. As Shrimp automatically infers the section your entry ID belongs to, rules are limited to one per section.

If a matching rule is found, any attached datasources are passed the entry id as `$shrimp-entry-id` allowing you to resolve the new URL using XPATH in your redirect.

## Shout Outs ##

Large sections of this extension has been adapted from [<NAME>'](http://rowanlewis.com) [Email Template Filter](http://github.com/rowan-lewis/emailtemplatefilter/tree/master) extension.



{'fraction_non_alphanumeric': 0.14603174603174604, 'fraction_numerical': 0.008590102707749767, 'mean_word_length': 3.7065026362038664, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '5782241', 'n_tokens_mistral': 1974, 'n_tokens_neox': 1623, 'n_words': 499}