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 analytics.rb → Functions to add web analytics code
calendar.rb → Function show a date nicely in HTML calendar.rb → Function show a date nicely in HTML
gitmtime.rb gitmtime.rb → Show time using git last change log
graph.rb graph.rb → Use graphviz to draw graphs
helpers.rb helpers.rb → Some standard nanoc helpers are added
html.rb html.rb → Layout block helper
intenseDebate.rb intenseDebate.rb → IntenseDebate integration
macros.rb macros.rb → Macros system (%latex => LaTeX, etc...)
mail.rb mail.rb → My uniquely encoded personal email
multiMenu.rb multiMenu.rb → The machinery for the menu
multi.rb multi.rb → The machinery for helping to be multi-language
nanoc_item_conf.rb nanoc_item_conf.rb
repair_html.rb repair_html.rb
syntaxColorize.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 %> # <% content_for :summary do %>
# Sommaire que je veux ecrire # Sommaire que je veux ecrire
# <% end %> # <% end %>
#
# Pour remplir à la fois le texte et le sommaire # Pour remplir à la fois le texte et le sommaire
include Nanoc3::Helpers::Capturing include Nanoc3::Helpers::Capturing

View file

@ -1,14 +1,17 @@
# give item corresponding to the homepage of the current language
def homepage def homepage
@items.find do |i| @items.find do |i|
i.reps[0].path == %{#{@config[:webprefix]}/#{@conf.language}/} i.reps[0].path == %{#{@config[:webprefix]}/#{@conf.language}/}
end end
end end
# Explicit, give the children of a node in the menu, sorted by menu priority
def sortedChildrenByMenuPriority(item) def sortedChildrenByMenuPriority(item)
item.children.reject{|p| p[:isHidden]}. item.children.reject{|p| p[:isHidden]}.
sort!{|x,y| x[:menupriority] <=> y[:menupriority]} sort!{|x,y| x[:menupriority] <=> y[:menupriority]}
end end
# Generate the menu for the current item
def generateMenu def generateMenu
home=homepage home=homepage
if home.nil? if home.nil?
@ -22,6 +25,7 @@ def generateMenu
"<ul><li>"+liste.join("</li>\n<li>")+"</li></ul>" "<ul><li>"+liste.join("</li>\n<li>")+"</li></ul>"
end end
# get the depth of an item in the menu
def depthOf(item) def depthOf(item)
res=0 res=0
while item.parent != nil while item.parent != nil
@ -31,6 +35,8 @@ def depthOf(item)
return res return res
end end
# get the list of item children of a node sorted
# by menupriority or date depending of the kind fo page
def getSortedChildren(parent) def getSortedChildren(parent)
if parent[:kind] == "blog" if parent[:kind] == "blog"
return parent.children.reject{|p| p[:isHidden]}.sort!{|x,y| x[:created_at] <=> y[:created_at] } 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
end end
# For the page blog, the submenu is very specific
def generateBlogSubMenu(language) def generateBlogSubMenu(language)
year=0 year=0
res="" res=""
@ -63,6 +70,7 @@ def generateBlogSubMenu(language)
end end
end end
# Generate a submenu, not always needed
def generateSubMenu() def generateSubMenu()
if @item[:noSubMenu] if @item[:noSubMenu]
return return
@ -102,23 +110,6 @@ def generateSubMenu()
end 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) def lnkto(title,item)
language=@item_rep.path.sub(/#{@config[:webprefix]}\//,'').sub(/\/.*$/,'') language=@item_rep.path.sub(/#{@config[:webprefix]}\//,'').sub(/\/.*$/,'')
link_to(title, "#{@config[:webprefix]}/#{language}"+item) 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> <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Copyright ©, Yann Esposito</a>
</div> </div>
<div id="lastmod"> <div id="lastmod">
Modified: 09/12/2011 Modified: 09/13/2011
</div> </div>
<div> <div>
Entirely done with Entirely done with