*/ class ShowReadmePlugin extends VGPlugin { var $readme_filenames=array( 'README', 'INSTALL', 'README.txt', 'README.md', 'README.rst' ); function __construct() { global $conf; if (isset($conf['readme_filenames']) && is_array($conf['readme_filenames'])) { $this -> readme_filenames = $conf['readme_filenames']; } $this->register_hook('header'); $this->register_hook('summary'); } function hook($type) { if ($type == 'header') { echo "\t\n"; } elseif ($type == 'summary') { global $page; $tree=git_ls_tree($page['project'],'HEAD'); $readme=array(); foreach($tree as $file) { if ($file['type']!="blob") continue; if (in_array($file['name'],$this -> readme_filenames)) { $readme[$file['name']]=fix_encoding(join("\n", run_git($page['project'], "cat-file blob ".$file['hash']))); } } if (!empty($readme)) { $page['readme']=$readme; $this->display_plugin_template('summary', FALSE); } } } }