scratch/lib/blog.rb

34 lines
961 B
Ruby
Raw Normal View History

2011-09-14 07:51:52 +00:00
# Helper to find an image corresponding to the current
# article
2011-10-21 14:48:31 +00:00
def blogimage(filename,title="no name", divclass=nil)
imgpath=blogimagedir + filename
2011-09-14 07:51:52 +00:00
if not divclass.nil?
if divclass !~ /^\s*$/
cls=%{ class="#{divclass}"}
end
2011-09-14 07:51:52 +00:00
end
return %{<img alt="#{title}" src="#{imgpath}"#{cls}/>}
end
2012-04-05 11:47:30 +00:00
def blogfigure(filename,title="no name", divclass=nil)
imgpath=blogimagedir + filename
if not divclass.nil?
cls=%{ class="#{divclass}"}
end
return %{<figure><img alt="#{title}" src="#{imgpath}"#{cls}/><figcaption>#{title}</figcaption></figure>}
end
2011-09-14 07:51:52 +00:00
# Return a blog image with class left added
2011-10-21 14:48:31 +00:00
def leftblogimage(filename,title="no name")
return blogimage(filename, title, "left")
end
def blogimagedir
if depthOf( @item ) == 4
imgpath=@item.parent.path
else
imgpath=@item.path
end
imgpath=imgpath.sub(%r{#{@config[:webprefix]}/../},@config[:webprefix]+'/img/')
2011-09-14 07:51:52 +00:00
end