Created
March 26, 2013 12:24
-
-
Save taksatou/5244991 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def once(tag) | |
unless (@__once_executed__ ||= []).include? tag | |
yield | |
@__once_executed__ << tag | |
end | |
end | |
module Jekyll | |
class Post | |
def grid_position | |
pos = @site.posts.index(self) | |
siz = Math::sqrt(@site.posts.size).ceil | |
{ | |
"x" => 1000 * (pos % siz), | |
"y" => 1000 * (pos / siz), | |
} | |
end | |
once(:redefine_to_liquid) do | |
alias __old_to_liquid to_liquid | |
def to_liquid | |
dat = self.data["data"] | |
if dat.nil? | |
self.data["data"] = self.grid_position | |
end | |
__old_to_liquid | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment