From 53717f4e9649c0e3182b01684df852365f390a3d Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Wed, 14 Sep 2011 09:51:52 +0200 Subject: [PATCH] Reorgarnization --- README.md | 18 +++++++++--------- lib/blog.rb | 19 +++++++++++++++++++ lib/helpers.rb | 1 - lib/multiMenu.rb | 25 ++++++++----------------- output/index.html | 2 +- 5 files changed, 37 insertions(+), 28 deletions(-) create mode 100644 lib/blog.rb diff --git a/README.md b/README.md index baa1cd04c..e560dd0a8 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/blog.rb b/lib/blog.rb new file mode 100644 index 000000000..4c0978998 --- /dev/null +++ b/lib/blog.rb @@ -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 %{#{title}} +end + +# Return a blog image with class left added +def leftblogimage(val,title="no name") + return blogimage(val, title, "left") +end diff --git a/lib/helpers.rb b/lib/helpers.rb index 4e0ded6a9..c68bad653 100644 --- a/lib/helpers.rb +++ b/lib/helpers.rb @@ -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 diff --git a/lib/multiMenu.rb b/lib/multiMenu.rb index 0537a03cf..3ef77eea8 100644 --- a/lib/multiMenu.rb +++ b/lib/multiMenu.rb @@ -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 "" 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 %{#{title}} -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) diff --git a/output/index.html b/output/index.html index 63c264881..37f9aa207 100644 --- a/output/index.html +++ b/output/index.html @@ -188,7 +188,7 @@ Copyright ©, Yann Esposito
- Modified: 09/12/2011 + Modified: 09/13/2011
Entirely done with