/** * Handle $data, and return the results. * * @param string data The data to handle. * @return string * @access public */ public function input($data, $options = array()) { $result = null; try { if (strpos($data, NL) === false && is_file($data)) { $data = file_get_contents($data); if ($data === false) { throw new \Exception('Could not load data: ' . $data); } } $data_array = explode("\n\n---\n\n", $data, 2); $header_handler = \Curator\Handler\Factory::getHandlerForMediaType(\Curator\Handler\YAML::getMediaType()); $header_data = $header_handler->input($data_array[0]); $body_format = $header_data['format']; $body_handler = \Curator\Handler\Factory::getHandlerForMediaType($body_format); $body_data = $body_handler->input($data_array[1]); $result = array(); $result['header'] = $header_data; $result['body'] = $body_data; $result['body_raw'] = $data_array[1]; } catch (\Exception $e) { \Curator\Console::stderr('** Could not handle curd data:'); \Curator\Console::stderr(' ' . $e->getMessage()); } return $result; }
/** * Handle $data, and return the results. * * @param string data The data to handle. * @return string * @access public */ public function input($data, $options = array()) { include_once CURATOR_APP_DIR . DS . 'Vendors' . DS . 'php-markdown' . DS . 'dist' . DS . 'markdown.php'; include_once CURATOR_APP_DIR . DS . 'Vendors' . DS . 'php-smartypants' . DS . 'dist' . DS . 'smartypants.php'; $result = null; try { if (strpos($data, NL) === false && is_file($data)) { $data = file_get_contents($data); if ($data === false) { throw new \Exception('Could not load file: ' . $data); } } $result = \SmartyPants(\Markdown($data)); } catch (\Exception $e) { \Curator\Console::stderr('** Could not handle Mardkwon data:'); \Curator\Console::stderr(' ' . $e->getMessage()); } return $result; }
/** * Handle $data, and return the results. * * @param string data The data to handle. * @return string * @access public */ public function input($data, $options = array()) { $default_options = array('minify' => true); $result = null; $options = array_merge($default_options, $options); try { if (strpos($data, NL) === false && is_file($data)) { $data = file_get_contents($data); if ($data === false) { throw new \Exception('Could not load CSS: ' . $data); } } require_once CURATOR_APP_DIR . DS . 'Vendors' . DS . 'css-compressor' . DS . 'dist' . DS . 'src' . DS . 'CSSCompression.php'; $result = \CSSCompression::express($data, 'sane'); } catch (\Exception $e) { \Curator\Console::stderr('** Could not handle CSS data:'); \Curator\Console::stderr(' ' . $e->getMessage()); } return $result; }
/** * Handle $data, and return the results. * * @param string data The data to handle. * @return string * @access public */ public function input($data, $options = array()) { $result = null; try { if (strpos($data, NL) === false && is_file($data)) { $data = file_get_contents($data); if ($data === false) { throw new \Exception('Could not load data: ' . $data); } } foreach ($options as $key => $value) { $needle = '%%__' . strtoupper($key) . '__%%'; $data = str_replace($needle, $value, $data); } $result = $data; } catch (\Exception $e) { \Curator\Console::stderr('** Could not handle basic template data:'); \Curator\Console::stderr(' ' . $e->getMessage()); } return $result; }
/** * Installs the skeleton project into the project directory. * * @returns boolean * @access public */ public function install() { $project_dir = $this->getProjectDirPath(); $skeleton_dir = $this->getSkeletonDirPath(); // remind us where we are dumping all this \Curator\Console::stdout('Project directory: ' . $project_dir); \Curator\Console::stdout(''); try { $this->installDirectory($skeleton_dir, $project_dir); } catch (\Exception $e) { \Curator\Console::stderr('** Could not install \'' . $skeleton_dir . '\' into \'' . $project_dir . '\''); \Curator\Console::stderr(' ' . $e->getMessage()); } }
/** * Convert $data (using $options) for writing as a string. * * @param string $data The data to convert. * @param array $options The options for converting data. * @return string * @access public */ public function output($data, $options = array()) { include_once CURATOR_APP_DIR . DS . 'Vendors' . DS . 'yaml' . DS . 'dist' . DS . 'lib' . DS . 'sfYamlDumper.php'; $yaml = new \sfYamlDumper(); $result = null; try { $result = $yaml->dump($data); } catch (\Exception $e) { \Curator\Console::stderr('** Unable to convert array to YAML:'); \Curator\Console::stderr(' ', $e->getMessage()); } return $result; }