Updated the blog layout!

This commit is contained in:
Yann Esposito (Yogsototh) 2012-04-24 18:14:14 +02:00
parent 59da5a80bd
commit 7186435b9d
2 changed files with 28 additions and 20 deletions

View file

@ -49,3 +49,16 @@ def repair_html( html, debug=false )
depth.downto(0).each { |x| res<<= %{</#{parents[x]}>} } depth.downto(0).each { |x| res<<= %{</#{parents[x]}>} }
res res
end end
def showArticle( article, language )
if /<img [^>]*>/ =~ article.compiled_content
image=$&
else
image=%{<img src="/Scratch/img/presentation.png" alt="basic logo"/>}
end
presentation=%{<figure>#{image}
<figcaption>
#{article[:title]} <span class="nicer">»</span>
</figcaption></figure>}
%{<div class="popularblock">#{link_to(presentation, article)}</div>}
end

View file

@ -5,7 +5,7 @@ menupriority: 2
noSubMenu: true noSubMenu: true
----- -----
<% <%
number_of_articles=5 number_of_articles=18
number_of_char_for_resume=800 number_of_char_for_resume=800
language=@item_rep.path.sub(/\/Scratch\//,'').sub(/\/.*$/,'') language=@item_rep.path.sub(/\/Scratch\//,'').sub(/\/.*$/,'')
last_articles = @items.select do |a| last_articles = @items.select do |a|
@ -61,10 +61,10 @@ fr: Articles populaires
<div class="popularblock"> <div class="popularblock">
<a href="/Scratch/en/blog/Haskell-the-Hard-Way/"> <a href="/Scratch/en/blog/Haskell-the-Hard-Way/">
<figure> <figure>
<img src="/Scratch/img/blog/Haskell-the-Hard-Way/magritte_pleasure_principle.jpg" alt="Magritte pleasure principle"/> <img src="/Scratch/img/blog/Haskell-the-Hard-Way/magritte_pleasure_principle.jpg" alt="Magritte pleasure principle"/>
<figcaption> <figcaption>
Learn Haskell Fast and Hard <span class="nicer">»</span> Learn Haskell Fast and Hard <span class="nicer">»</span>
</figcaption> </figcaption>
</figure> </figure>
</a> </a>
</div> </div>
@ -72,28 +72,23 @@ fr: Articles populaires
<div class="flush"></div> <div class="flush"></div>
<h2 id="last-articles"> <h2 id="last-articles">
en: Last <%= number_of_articles %> Articles en: <%= number_of_articles %> lastest Articles
fr: Les <%= number_of_articles %> derniers articles fr: Les <%= number_of_articles %> derniers articles
</h2> </h2>
</div> </div>
<% last_articles.each do |a| %> <div class="corps">
<div class="resumearticle"> <%
<h1> <%= calendar_for( a[:created_at], language ) %> i=2
<%= link_to(a[:title]+%{ <span class="nicer">»</span>}, a) %> </h1> last_articles.each do |a|
<div class="corps"> i+=1 %>
<%= repair_html ( excerptize( a.reps[0].compiled_content, {:length => number_of_char_for_resume} ) ) %> <%= showArticle(a, language) %>
<% if i % 3 == 2 %>
<div class="flush"></div> <div class="flush"></div>
<div> <% end %>
<p>
fr: <%= link_to(%{en lire plus <span class="nicer">»</span>}, a) %>
en: <%= link_to(%{Read more <span class="nicer">»</span>}, a) %>
</p>
</div>
</div>
</div>
<% end %> <% end %>
</div>
<div class="corps"> <div class="corps">
<div> <div>