Nice first page for my blog post.
This commit is contained in:
parent
34ac981698
commit
04eb99e057
4 changed files with 54 additions and 50 deletions
|
@ -509,3 +509,6 @@ hr
|
|||
#menuMessage
|
||||
+smallblock
|
||||
+downsmallround
|
||||
|
||||
#content > .date
|
||||
:color = !blanc_fonce
|
||||
|
|
|
@ -1,40 +1,27 @@
|
|||
-----
|
||||
# Built-in
|
||||
filters_pre:
|
||||
- erb
|
||||
- bluecloth
|
||||
|
||||
# Custom
|
||||
# menu
|
||||
title: Welcome
|
||||
multiTitle:
|
||||
fr: Bienvenue
|
||||
en: Welcome
|
||||
|
||||
noSubMenu: true
|
||||
-----
|
||||
Hello and welcome on my personnal website. This is mainly my blog.
|
||||
|
||||
Here are an exerpt of the last 5 articles
|
||||
|
||||
|
||||
|
||||
<%
|
||||
number_of_articles=5
|
||||
number_of_char_for_resume=800
|
||||
language=@item_rep.path.sub(/\/Scratch\//,'').sub(/\/.*$/,'')
|
||||
last_articles = articles.select do |a|
|
||||
a.reps[0].path =~ /\/#{language}\//
|
||||
end.sort { |x,y| x[:created_at] <=> y[:created_at] }[0..(number_of_articles-1)]
|
||||
end
|
||||
last_articles=last_articles.sort { |x,y| y[:created_at] <=> x[:created_at] }[0..(number_of_articles-1)]
|
||||
%>
|
||||
|
||||
<p>Welcome on my personnal website.</p>
|
||||
|
||||
<p>Here are my <%= number_of_articles %> last posts begining<sup>†</sup>.</p>
|
||||
|
||||
<hr/>
|
||||
<p class="small">† approximatively the <%= number_of_char_for_resume %> first characters.</p>
|
||||
|
||||
<% last_articles.each do |a| %>
|
||||
</div>
|
||||
<% puts @config[:dateFormat].to_s %>
|
||||
<% puts language %>
|
||||
<% puts @config[:dateFormat][language.intern] %>
|
||||
<h1><span class="date"><%= a[:created_at].strftime( @config[:dateFormat][language.intern] ) %></span> <%= link_to(a[:title], a) %></h1>
|
||||
|
||||
<div class="corps">
|
||||
<%= excerptize( a.reps[0].compiled_content, {:length => 500} ) %>
|
||||
</div>
|
||||
|
||||
<%= repair_html ( excerptize( a.reps[0].compiled_content, {:length => number_of_char_for_resume} ) ) %>
|
||||
<% end %>
|
||||
|
|
|
@ -1,39 +1,27 @@
|
|||
-----
|
||||
# Built-in
|
||||
filters_pre:
|
||||
- erb
|
||||
- bluecloth
|
||||
|
||||
# Custom
|
||||
# menu
|
||||
title: Welcome
|
||||
multiTitle:
|
||||
fr: Bienvenue
|
||||
en: Welcome
|
||||
|
||||
title: Bienvenue
|
||||
noSubMenu: true
|
||||
-----
|
||||
Bonjour et bienvenue sur mon site personnel. Je l'utilise principalement comme
|
||||
plateforme de blog.
|
||||
|
||||
Trouvez ici le résumé de mes cinq dernières entrées de blog.
|
||||
|
||||
<%
|
||||
number_of_articles=5
|
||||
number_of_char_for_resume=800
|
||||
language=@item_rep.path.sub(/\/Scratch\//,'').sub(/\/.*$/,'')
|
||||
last_articles = articles.select do |a|
|
||||
a.reps[0].path =~ /\/#{language}\//
|
||||
end.sort { |x,y| x[:created_at] <=> y[:created_at] }[0..(number_of_articles-1)]
|
||||
end
|
||||
last_articles=last_articles.sort { |x,y| y[:created_at] <=> x[:created_at] }[0..(number_of_articles-1)]
|
||||
%>
|
||||
|
||||
<p>Bonjour et bienvenue sur mon site personnel.</p>
|
||||
|
||||
<p>Voici un aperçu<sup>†</sup> de mes <%= number_of_articles %> derniers articles.</p>
|
||||
|
||||
<hr/>
|
||||
<p class="small">† approximativement les <%= number_of_char_for_resume %> premiers caractères.</p>
|
||||
|
||||
<% last_articles.each do |a| %>
|
||||
</div>
|
||||
<% puts @config[:dateFormat].to_s %>
|
||||
<% puts language %>
|
||||
<% puts @config[:dateFormat][language.intern] %>
|
||||
<h1><span class="date"><%= a[:created_at].strftime( @config[:dateFormat][language.intern] ) %></span> <%= link_to(a[:title], a) %></h1>
|
||||
|
||||
<div class="corps">
|
||||
<%= excerptize( a.reps[0].compiled_content, {:length => 500} ) %>
|
||||
</div>
|
||||
|
||||
<%= repair_html ( excerptize( a.reps[0].compiled_content, {:length => number_of_char_for_resume} ) ) %>
|
||||
<% end %>
|
||||
|
|
26
lib/repair_html.rb
Normal file
26
lib/repair_html.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
# All files in the 'lib' directory will be loaded
|
||||
# before nanoc starts compiling.
|
||||
|
||||
# repair cutted XML code by closing the tags
|
||||
# work even if the XML is cut into a tag.
|
||||
# example:
|
||||
# transform '<div> <code> toto </code> <p> hello <a href="http://tur'
|
||||
# into '<div> <code> toto </code> <p> hello </p></div>'
|
||||
def repair_html( html )
|
||||
parents=[]
|
||||
depth=0
|
||||
html.scan( %r{<(/?)(\w*)} ).each do |m|
|
||||
if m[0] == ""
|
||||
parents[depth]=m[1]
|
||||
depth+=1
|
||||
puts '<'+m[0]+m[1]+'> ' + depth.to_s
|
||||
puts 'parents='+parents.join('; ')
|
||||
else
|
||||
depth-=1
|
||||
puts '<'+m[0]+m[1]+'> ' + depth.to_s
|
||||
end
|
||||
end
|
||||
res=html.sub(/<[^>]*$/m,'')
|
||||
depth.downto(0).each { |x| res<<= %{</#{parents[x]}>} }
|
||||
res
|
||||
end
|
Loading…
Reference in a new issue