summaryrefslogtreecommitdiff
path: root/GitTimeline_body.php
diff options
context:
space:
mode:
Diffstat (limited to 'GitTimeline_body.php')
-rw-r--r--GitTimeline_body.php52
1 files changed, 52 insertions, 0 deletions
diff --git a/GitTimeline_body.php b/GitTimeline_body.php
new file mode 100644
index 0000000..e1ea75b
--- /dev/null
+++ b/GitTimeline_body.php
@@ -0,0 +1,52 @@
+<?php
+
+class GitTimeline {
+
+ static function onParserInit( Parser $parser ) {
+
+ $parser->setHook( 'GitTimeline', array( __CLASS__, 'renderGitTimeline' ) );
+ return true;
+
+ }
+
+ static function onBeforePageDisplay( OutputPage &$out, Skin &$skin ) {
+
+ $out->addModuleStyles( array (
+ 'ext.gittimeline'
+ ) );
+
+ }
+
+ static function renderGitTimeline( $input, array $args, Parser $parser, PPFrame $frame ) {
+
+ global $wgRepositoriesDirectory;
+ global $wgCGitUrl;
+
+ if ( ! isset( $args['repo'] ) )
+ return '';
+
+ if ( ! isset( $args['keep'] ) )
+ return '';
+
+ $repo = $args['repo'];
+ $keep = $args['keep'];
+
+ $git_command = <<<EOT
+cd $wgRepositoriesDirectory/$repo
+for h in `git rev-list HEAD -$keep`; do
+ url="$wgCGitUrl/$repo/commit/?id=\$h"
+ revision=\$(( \$(git rev-list \$h | wc -l) + 4))
+ message=\$( git log -1 \$h --pretty=format:"%s <span class=\"gitdate\">(%ar)</span>" )
+ echo -e "\t<li><a href=\"\$url\">r\$revision</A> - \$message</li>"
+done
+EOT;
+
+ $output = shell_exec($git_command);
+
+ return array( "$output", 'noparse' => true, 'isHTML' => true );
+
+ }
+
+}
+
+?>