Permalink
Browse files

Extracted portions of PagesController#home view to their own partials.

  • Loading branch information...
1 parent 75cae20 commit f464a7d8e4f5b888d91b367c8f2b853c77e7a5cb @arttu arttu committed with ljuti Mar 5, 2012
View
15 app/views/pages/_drafts.html.haml
@@ -0,0 +1,15 @@
+.container_24.top_drafts
+ %h2 Luonnokset
+ - [["grid_8", "popular", "alpha"], ["grid_8", "popular"], ["grid_8", "popular", "omega"]][0, [3, @drafts.size].min].each_with_index do |klasses, i|
+ %div{:class => klasses}
+ - if recent_draft = @drafts[i]
+ %h3.title=link_to shorten(recent_draft.summary, 100, 20, "»"), idea_path(recent_draft)
+ %div{id: "draft_bar#{i}", class: "bar"}
+ - for_portion, for_, against_portion, against_ = @draft_counts[recent_draft.id]
+ - for_length = [35, (280-5-35)*for_portion].max
+ :javascript
+ var r = Raphael("draft_bar#{i}", 280, 20);
+ r.rect( 0, 0, #{for_length}, 20).attr({fill: "#8cc63f", stroke: "#fff", strokewidth: 5});
+ r.rect(#{for_length+5}, 0, #{280-5-for_length}, 20).attr({fill: "#a9003f", stroke: "#fff", strokewidth: 5});
+ r.text( 18,11, "#{for_}").attr({fill: "#fff", "font-size": 12});
+ r.text(261,11, "#{against_}").attr({fill: "#fff", "font-size": 12});
View
7 app/views/pages/_headline.html.haml
@@ -0,0 +1,7 @@
+.container_24.headline
+ %hgroup.grid_18
+ %h1 Tuulivoimalat pelastavat maailman?
+ %h2 Tee siitä laki
+ .actions.grid_6
+ = link_to "Listaa kaikki", ideas_path, class: "button"
+ %a.button{href: "/artikkelit/miten-palvelu-toimii"} Lisätietoa
View
19 app/views/pages/_ideas.html.haml
@@ -0,0 +1,19 @@
+.grid_16.top_ideas.alpha
+ %h2 Ajankohtaiset ideat
+ - @ideas.each do |idea|
+ .idea
+ .grid_16.info
+ %span.type
+ Idea/
+ %span.date
+ = finnishDate(idea.updated_at)
+ %h3=link_to shorten(idea.summary, 100, 20, "»"), idea_path(idea)
+ .grid_16.statistics
+ - for_, against, comments, total = @idea_counts[idea.id]
+ %span.total #{total} ääntä: 
+ %span.for #{for_}
+ |
+ %span.against #{against}
+ %span.comments= link_to "#{comments} kommenttia", idea_path(idea, anchor: "comments")
+
+ =link_to "Listaa kaikki»", ideas_path, class: "list_ideas"
View
12 app/views/pages/_news.html.haml
@@ -0,0 +1,12 @@
+.grid_8.news.omega
+ %h2 Ministeriössä tapahtuu
+ %iframe{width: "310", height: "192", src: "http://www.youtube.com/embed/R2wa2O0EBTg?rel=0", frameborder: "0", allowfullscreen: ""}
+ - if @blog_articles.any?
+ - @blog_articles.each do |article|
+ .news_item
+ - author_name = (article.author && article.author.profile.name) || "Tuntematon"
+ =link_to author_name, article_path(article)
+ #{finnishTime(article.updated_at)}
+ .content=link_to shorten(article.title, 100, 20, "»"), article_path(article)
+ - else
+ %p Ei kirjoituksia tällä hetkellä
View
10 app/views/pages/_newsletter.html.haml
@@ -0,0 +1,10 @@
+.grid_8.newsletter.omega
+ %h2 Tilaa uutiskirje
+
+ %div{:id => "mc_embed_signup"}
+ %form{ :action => "http://avoinministerio.us4.list-manage.com/subscribe/post?u=639187372f3d5221161f16dba&id=13448f1e4e", :method => "post", :id => "mc-embedded-subscribe-form", :name => "mc-embedded-subscribe-form", :class => "validate", :target => "_blank"}
+ %label{:for => "mce-EMAIL"} Pysy ajan tasalla Avoimen ministeriön toiminnasta tilaamalla uutiskirjeemme.
+ %br
+ %input{:type => "email", :name => "EMAIL", :class => "email", :id => "mce-EMAIL", :placeholder => "Sähköpostiosoitteesi", :required => true}
+ %br
+ %input{:type => "submit", :value => "Tilaa", :name => "subscribe", :id => "mc-embedded-subscribe", :class => "button"}
View
70 app/views/pages/home.html.haml
@@ -1,65 +1,5 @@
-.container_24.headline
- %hgroup.grid_18
- %h1 Tuulivoimalat pelastavat maailman?
- %h2 Tee siitä laki
- .actions.grid_6
- = link_to "Listaa kaikki", ideas_path, class: "button"
- %a.button{href: "/artikkelit/miten-palvelu-toimii"} Lisätietoa
-.container_24.top_drafts
- %h2 Luonnokset
- - [["grid_8", "popular", "alpha"], ["grid_8", "popular"], ["grid_8", "popular", "omega"]][0, [3, @drafts.size].min].each_with_index do |klasses, i|
- %div{:class => klasses}
- - if recent_draft = @drafts[i]
- %h3.title=link_to shorten(recent_draft.summary, 100, 20, "»"), idea_path(recent_draft)
- %div{id: "draft_bar#{i}", class: "bar"}
- - for_portion, for_, against_portion, against_ = @draft_counts[recent_draft.id]
- - for_length = [35, (280-5-35)*for_portion].max
- :javascript
- var r = Raphael("draft_bar#{i}", 280, 20);
- r.rect( 0, 0, #{for_length}, 20).attr({fill: "#8cc63f", stroke: "#fff", strokewidth: 5});
- r.rect(#{for_length+5}, 0, #{280-5-for_length}, 20).attr({fill: "#a9003f", stroke: "#fff", strokewidth: 5});
- r.text( 18,11, "#{for_}").attr({fill: "#fff", "font-size": 12});
- r.text(261,11, "#{against_}").attr({fill: "#fff", "font-size": 12});
-
-.grid_16.top_ideas.alpha
- %h2 Ajankohtaiset ideat
- - @ideas.each do |idea|
- .idea
- .grid_16.info
- %span.type
- Idea/
- %span.date
- = finnishDate(idea.updated_at)
- %h3=link_to shorten(idea.summary, 100, 20, "»"), idea_path(idea)
- .grid_16.statistics
- - for_, against, comments, total = @idea_counts[idea.id]
- %span.total #{total} ääntä: 
- %span.for #{for_}
- |
- %span.against #{against}
- %span.comments= link_to "#{comments} kommenttia", idea_path(idea, anchor: "comments")
-
- =link_to "Listaa kaikki»", ideas_path, class: "list_ideas"
-
-.grid_8.news.omega
- %h2 Ministeriössä tapahtuu
- %iframe{width: "310", height: "192", src: "http://www.youtube.com/embed/R2wa2O0EBTg?rel=0", frameborder: "0", allowfullscreen: ""}
- - if @blog_articles.any?
- - @blog_articles.each do |article|
- .news_item
- - author_name = (article.author && article.author.profile.name) || "Tuntematon"
- =link_to author_name, article_path(article)
- #{finnishTime(article.updated_at)}
- .content=link_to shorten(article.title, 100, 20, "»"), article_path(article)
- - else
- %p Ei kirjoituksia tällä hetkellä
-.grid_8.newsletter.omega
- %h2 Tilaa uutiskirje
-
- %div{:id => "mc_embed_signup"}
- %form{ :action => "http://avoinministerio.us4.list-manage.com/subscribe/post?u=639187372f3d5221161f16dba&id=13448f1e4e", :method => "post", :id => "mc-embedded-subscribe-form", :name => "mc-embedded-subscribe-form", :class => "validate", :target => "_blank"}
- %label{:for => "mce-EMAIL"} Pysy ajan tasalla Avoimen ministeriön toiminnasta tilaamalla uutiskirjeemme.
- %br
- %input{:type => "email", :name => "EMAIL", :class => "email", :id => "mce-EMAIL", :placeholder => "Sähköpostiosoitteesi", :required => true}
- %br
- %input{:type => "submit", :value => "Tilaa", :name => "subscribe", :id => "mc-embedded-subscribe", :class => "button"}
+= render partial: 'headline'
+= render partial: 'drafts'
+= render partial: 'ideas'
+= render partial: 'news'
+= render partial: 'newsletter'

0 comments on commit f464a7d

Please sign in to comment.