Create a gist now

Instantly share code, notes, and snippets.

@alx /git.rb
Created Dec 6, 2010

What would you like to do?
Jekyll plugin to add Git activity inside a list
require 'git'
module Jekyll
class GitActivityTag < Liquid::Tag
def initialize(tag_name, text, tokens)
super
end
def render(context)
result = ""
g = Git.open(File.join(Dir.getwd, ".."))
index = 0
g.log.each do |log|
if(index < 10)
result << "<li>"
result << log.date.strftime("%d %b")
result << " - <a href='http://git.tetalab.org/index.php/p/jekyll/source/commit/"
result << log.sha
result << "/'>"
result << log.message
result << "</a></li>"
index += 1
end
end
"<ul>#{result}</ul>"
end
end
end
Liquid::Template.register_tag('gitactivity', Jekyll::GitActivityTag)
@christian-fei

This comment has been minimized.

Show comment Hide comment
@christian-fei

christian-fei Mar 28, 2013

Hey, I'm new to jekyll, ruby etc.
How do I use this?
I would be really grateful if you could take a minute :)

Hey, I'm new to jekyll, ruby etc.
How do I use this?
I would be really grateful if you could take a minute :)

@aledoroshenko

This comment has been minimized.

Show comment Hide comment
@aledoroshenko

aledoroshenko Apr 3, 2013

I'm new too, and eager to know, how to use it :) Alx, could you help us?

I'm new too, and eager to know, how to use it :) Alx, could you help us?

@heyLu

This comment has been minimized.

Show comment Hide comment
@heyLu

heyLu Apr 13, 2013

@christian-fei, @aledoroshenko: You would put it into your _plugins directory, as per the plugin page on the wiki.

After you did that you can use it just like other liquid tags, for example like this:

{% gitactivity %}

And it would generate an HTML list with the date, sha and commit message of the repo given in the code. If you'd like to play with it you could try to get it support other repos, for example with a syntax like this: {% awesomer_gitactivity /home/yournamehere/repos/jekyll %} (see the example on the wiki).

However, because the git (required at the top) module is not included in the standard ruby distribution you would have to install that first (with gem install git).

heyLu commented Apr 13, 2013

@christian-fei, @aledoroshenko: You would put it into your _plugins directory, as per the plugin page on the wiki.

After you did that you can use it just like other liquid tags, for example like this:

{% gitactivity %}

And it would generate an HTML list with the date, sha and commit message of the repo given in the code. If you'd like to play with it you could try to get it support other repos, for example with a syntax like this: {% awesomer_gitactivity /home/yournamehere/repos/jekyll %} (see the example on the wiki).

However, because the git (required at the top) module is not included in the standard ruby distribution you would have to install that first (with gem install git).

@aledoroshenko

This comment has been minimized.

Show comment Hide comment
@aledoroshenko

aledoroshenko Apr 20, 2013

@heyLu: I forgot to install git :) When installed it and set my path in Git.open, all works great. Thanks!

@heyLu: I forgot to install git :) When installed it and set my path in Git.open, all works great. Thanks!

@streambinder

This comment has been minimized.

Show comment Hide comment
@streambinder

streambinder Jan 13, 2015

I configured Jekyll on a Github Page.
Can I have a ultra-detailed how-to about how to include this plugins to make it work on my site, configured as written above?

I configured Jekyll on a Github Page.
Can I have a ultra-detailed how-to about how to include this plugins to make it work on my site, configured as written above?

@naiveaiguy

This comment has been minimized.

Show comment Hide comment
@naiveaiguy

naiveaiguy Dec 31, 2015

@streambinder You can still use plugins on gh-pages, but you have to push the static files instead of the Jekyll files.

@streambinder You can still use plugins on gh-pages, but you have to push the static files instead of the Jekyll files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment