diff options
| -rw-r--r-- | GitTimeline_body.php | 52 | ||||
| -rw-r--r-- | extension.json | 34 | ||||
| -rw-r--r-- | gittimeline.css | 7 | 
3 files changed, 93 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 ); + +    } + +} + +?> diff --git a/extension.json b/extension.json new file mode 100644 index 0000000..b7220d8 --- /dev/null +++ b/extension.json @@ -0,0 +1,34 @@ +{ +    "name": "GitTimeline", +    "author": [ +        "Cyrille Bagard" +    ], +    "url": "https://www.mediawiki.org/wiki/Extension:Example", +    "description": "This extension allows to include an external file in a safe way.", +    "version": "1.0", +    "license-name": "GPL-2.0+", +    "type": "other", +    "AutoloadClasses": { +        "GitTimeline": "GitTimeline_body.php" +    }, +    "Hooks": { +        "ParserFirstCallInit": [ +            "GitTimeline::onParserInit" +        ], +        "BeforePageDisplay": [ +            "GitTimeline::onBeforePageDisplay" +        ] +    }, +    "ResourceModules": { +        "ext.gittimeline": { +            "styles": { +                "gittimeline.css": { +                    "media": "screen" +                } +            } +        } +    }, +    "ResourceFileModulePaths": { +        "localBasePath": "" +    } +} diff --git a/gittimeline.css b/gittimeline.css new file mode 100644 index 0000000..fb2c6fd --- /dev/null +++ b/gittimeline.css @@ -0,0 +1,7 @@ + +.gitdate { + +    font-size: 90%; +    color: #aaa; + +}  | 
