Reorgarnization

This commit is contained in:
Yann Esposito (Yogsototh) 2011-09-14 09:51:52 +02:00
parent 94adfae3bf
commit 53717f4e96
5 changed files with 37 additions and 28 deletions

View file

@ -43,15 +43,15 @@ Here are features I added:
analytics.rb → Functions to add web analytics code
calendar.rb → Function show a date nicely in HTML
gitmtime.rb
graph.rb
helpers.rb
html.rb
intenseDebate.rb
macros.rb
mail.rb
multiMenu.rb
multi.rb
gitmtime.rb → Show time using git last change log
graph.rb → Use graphviz to draw graphs
helpers.rb → Some standard nanoc helpers are added
html.rb → Layout block helper
intenseDebate.rb → IntenseDebate integration
macros.rb → Macros system (%latex => LaTeX, etc...)
mail.rb → My uniquely encoded personal email
multiMenu.rb → The machinery for the menu
multi.rb → The machinery for helping to be multi-language
nanoc_item_conf.rb
repair_html.rb
syntaxColorize.rb

19
lib/blog.rb Normal file
View file

@ -0,0 +1,19 @@
# Helper to find an image corresponding to the current
# article
def blogimage(val,title="no name", divclass=nil)
if depthOf( @item ) == 4
imgpath=@item.parent.path
else
imgpath=@item.path
end
imgpath=imgpath.sub(%r{#{@config[:webprefix]}/../},@config[:webprefix]+'/img/')+val
if not divclass.nil?
cls=%{ class="#{divclass}"}
end
return %{<img alt="#{title}" src="#{imgpath}"#{cls}/>}
end
# Return a blog image with class left added
def leftblogimage(val,title="no name")
return blogimage(val, title, "left")
end

View file

@ -7,7 +7,6 @@
# <% content_for :summary do %>
# Sommaire que je veux ecrire
# <% end %>
#
# Pour remplir à la fois le texte et le sommaire
include Nanoc3::Helpers::Capturing

View file

@ -1,14 +1,17 @@
# give item corresponding to the homepage of the current language
def homepage
@items.find do |i|
i.reps[0].path == %{#{@config[:webprefix]}/#{@conf.language}/}
end
end
# Explicit, give the children of a node in the menu, sorted by menu priority
def sortedChildrenByMenuPriority(item)
item.children.reject{|p| p[:isHidden]}.
sort!{|x,y| x[:menupriority] <=> y[:menupriority]}
end
# Generate the menu for the current item
def generateMenu
home=homepage
if home.nil?
@ -22,6 +25,7 @@ def generateMenu
"<ul><li>"+liste.join("</li>\n<li>")+"</li></ul>"
end
# get the depth of an item in the menu
def depthOf(item)
res=0
while item.parent != nil
@ -31,6 +35,8 @@ def depthOf(item)
return res
end
# get the list of item children of a node sorted
# by menupriority or date depending of the kind fo page
def getSortedChildren(parent)
if parent[:kind] == "blog"
return parent.children.reject{|p| p[:isHidden]}.sort!{|x,y| x[:created_at] <=> y[:created_at] }
@ -39,6 +45,7 @@ def getSortedChildren(parent)
end
end
# For the page blog, the submenu is very specific
def generateBlogSubMenu(language)
year=0
res=""
@ -63,6 +70,7 @@ def generateBlogSubMenu(language)
end
end
# Generate a submenu, not always needed
def generateSubMenu()
if @item[:noSubMenu]
return
@ -102,23 +110,6 @@ def generateSubMenu()
end
# =======================
def blogimage(val,title="no name", divclass=nil)
if depthOf( @item ) == 4
imgpath=@item.parent.path
else
imgpath=@item.path
end
imgpath=imgpath.sub(%r{#{@config[:webprefix]}/../},@config[:webprefix]+'/img/')+val
if not divclass.nil?
cls=%{ class="#{divclass}"}
end
return %{<img alt="#{title}" src="#{imgpath}"#{cls}/>}
end
def leftblogimage(val,title="no name")
return blogimage(val, title, "left")
end
def lnkto(title,item)
language=@item_rep.path.sub(/#{@config[:webprefix]}\//,'').sub(/\/.*$/,'')
link_to(title, "#{@config[:webprefix]}/#{language}"+item)

View file

@ -188,7 +188,7 @@
<a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Copyright ©, Yann Esposito</a>
</div>
<div id="lastmod">
Modified: 09/12/2011
Modified: 09/13/2011
</div>
<div>
Entirely done with