Benjamin Renard commited on 2013-08-21 17:20:57
Showing 4 changed files, with 106 additions and 0 deletions.
... | ... |
@@ -0,0 +1,26 @@ |
1 |
+ShowReadme plugin for ViewGit |
|
2 |
+============================= |
|
3 |
+ |
|
4 |
+This plugin display README text file content on summary page of project. |
|
5 |
+README file(s) are detected at the root of the repository tree. File is |
|
6 |
+treat as README file if it's name is : |
|
7 |
+ |
|
8 |
+* README |
|
9 |
+* INSTALL |
|
10 |
+* README.txt |
|
11 |
+* README.md |
|
12 |
+* README.rst |
|
13 |
+ |
|
14 |
+This list could be override with configuration variable $conf['readme_filenames']. |
|
15 |
+ |
|
16 |
+Install |
|
17 |
+------- |
|
18 |
+ |
|
19 |
+* Put showreadme directory in plugins directory |
|
20 |
+* If you want to change README filenames, put this block in inc/localconfig.php file : |
|
21 |
+ |
|
22 |
+$conf['readme_filenames'] = array( |
|
23 |
+ 'REAME', |
|
24 |
+ 'INSTALL', |
|
25 |
+ ... |
|
26 |
+); |
... | ... |
@@ -0,0 +1,51 @@ |
1 |
+<?php |
|
2 |
+/** |
|
3 |
+ * Show readme plugin for ViewGit. |
|
4 |
+ * |
|
5 |
+ * This plugin display project README file content on summary page. |
|
6 |
+ * |
|
7 |
+ * @author Benjamin Renard <brenard@zionetrix.net> |
|
8 |
+ */ |
|
9 |
+class ShowReadmePlugin extends VGPlugin |
|
10 |
+{ |
|
11 |
+ var $readme_filenames=array( |
|
12 |
+ 'README', |
|
13 |
+ 'INSTALL', |
|
14 |
+ 'README.txt', |
|
15 |
+ 'README.md', |
|
16 |
+ 'README.rst' |
|
17 |
+ ); |
|
18 |
+ |
|
19 |
+ function __construct() { |
|
20 |
+ global $conf; |
|
21 |
+ if (isset($conf['readme_filenames']) && is_array($conf['readme_filenames'])) { |
|
22 |
+ $this -> readme_filenames = $conf['readme_filenames']; |
|
23 |
+ } |
|
24 |
+ $this->register_hook('header'); |
|
25 |
+ $this->register_hook('summary'); |
|
26 |
+ } |
|
27 |
+ |
|
28 |
+ function hook($type) { |
|
29 |
+ if ($type == 'header') { |
|
30 |
+ echo "\t<link rel='stylesheet' href='plugins/showreadme/style.css' type='text/css' />\n"; |
|
31 |
+ } |
|
32 |
+ elseif ($type == 'summary') { |
|
33 |
+ global $page; |
|
34 |
+ $tree=git_ls_tree($page['project'],'HEAD'); |
|
35 |
+ $readme=array(); |
|
36 |
+ foreach($tree as $file) { |
|
37 |
+ if ($file['type']!="blob") |
|
38 |
+ continue; |
|
39 |
+ if (in_array($file['name'],$this -> readme_filenames)) { |
|
40 |
+ $readme[$file['name']]=fix_encoding(join("\n", run_git($page['project'], "cat-file blob ".$file['hash']))); |
|
41 |
+ } |
|
42 |
+ } |
|
43 |
+ if (!empty($readme)) { |
|
44 |
+ $page['readme']=$readme; |
|
45 |
+ $this->display_plugin_template('summary', FALSE); |
|
46 |
+ } |
|
47 |
+ } |
|
48 |
+ } |
|
49 |
+ |
|
50 |
+} |
|
51 |
+ |
... | ... |
@@ -0,0 +1,20 @@ |
1 |
+fieldset.readme { |
|
2 |
+ border-top: 1px solid; |
|
3 |
+ background: #eee; |
|
4 |
+ margin-top: 2em; |
|
5 |
+ padding: 1.5em; |
|
6 |
+} |
|
7 |
+ |
|
8 |
+fieldset.readme pre { |
|
9 |
+ width: 90%; |
|
10 |
+ margin: auto; |
|
11 |
+ font-size: 1.2em; |
|
12 |
+} |
|
13 |
+ |
|
14 |
+fieldset.readme legend { |
|
15 |
+ background: url('../../images/silk/page_white_text.png') no-repeat 3px; |
|
16 |
+ padding: 0.3em; |
|
17 |
+ padding-left: 23px; |
|
18 |
+ border: 1px solid; |
|
19 |
+ font-weight: bold; |
|
20 |
+} |