From: Date: Fri, 30 May 2008 02:42:46 +0000 (-0400) Subject: Custom embeddable code works for png's except for top_bar X-Git-Url: https://projects.mako.cc/source/selectricity-live/commitdiff_plain/91c9d10ebdbdd37b03fd287a9923759f85561d20?ds=sidebyside Custom embeddable code works for png's except for top_bar --- diff --git a/app/controllers/election_controller.rb b/app/controllers/election_controller.rb index 2fe5e4b..072d439 100644 --- a/app/controllers/election_controller.rb +++ b/app/controllers/election_controller.rb @@ -89,27 +89,27 @@ class ElectionController < ApplicationController def add_theme(prefix) unless params[:top_bar][:uploaded_data].to_s.empty? top_bar = SkinPicture.new(params[:top_bar]) - top_bar.filename = prefix + "top_bar" + top_bar.filename = prefix + "top_bar." + params[:top_bar][:uploaded_data].content_type[6..-2] top_bar.save end unless params[:default_image][:uploaded_data].to_s.empty? default_image = SkinPicture.new(params[:default_image]) - default_image.filename = prefix + "default_image" + default_image.filename = prefix + "default_image." + params[:default_image][:uploaded_data].content_type[6..-2] default_image.save end unless params[:bg1][:uploaded_data].to_s.empty? - bg1 = SkinPicture.new(params[:bg1]) - bg1.filename = prefix + "bg1" + bg1 = SkinPicture.new(params[:bg1]) + bg1.filename = prefix + "bg1." + params[:bg1][:uploaded_data].content_type[6..-2] bg1.save end unless params[:bg2][:uploaded_data].to_s.empty? - bg2 = SkinPicture.new(params[:bg2]) - bg2.filename = prefix + "bg2" + bg2 = SkinPicture.new(params[:bg2]) + bg2.filename = prefix + "bg2." + params[:bg2][:uploaded_data].content_type[6..-2] bg2.save end unless params[:bottom_bar][:uploaded_data].to_s.empty? bottom_bar = SkinPicture.new(params[:bottom_bar]) - bottom_bar.filename = prefix + "bottom_bar" + bottom_bar.filename = prefix + "bottom_bar." + params[:bottom_bar][:uploaded_data].content_type[6..-2] bottom_bar.save end diff --git a/app/controllers/voter_controller.rb b/app/controllers/voter_controller.rb index cdc045d..9e88e9e 100644 --- a/app/controllers/voter_controller.rb +++ b/app/controllers/voter_controller.rb @@ -61,6 +61,19 @@ class VoterController < ApplicationController else @sidebar_content = render_to_string(:partial => 'vote_sidebar') if @election.embeddable? and params[:embed] == "true" + #look for custom theme, and assign to instance variabels for widget use + if @election.embed_custom_string + @top_bar = SkinPicture.find(:first, + :conditions => ["filename = ?", @election.embed_custom_string + "top_bar.png"]) + @default_image = SkinPicture.find(:first, + :conditions => ["filename = ?", @election.embed_custom_string + "default_image.png"]) + @bg1 = SkinPicture.find(:first, + :conditions => ["filename = ?", @election.embed_custom_string + "bg1.png"]) + @bg2 = SkinPicture.find(:first, + :conditions => ["filename = ?", @election.embed_custom_string + "bg2.png"]) + @bottom_bar = SkinPicture.find(:first, + :conditions => ["filename = ?", @election.embed_custom_string + "bottom_bar.png"]) + end render :template => 'embed/full_vote', :layout => 'embed' else render :action => 'full_vote' @@ -151,6 +164,19 @@ class VoterController < ApplicationController @names = @election.names_by_id @sidebar_content = render_to_string(:partial => 'results_sidebar') + #look for custom theme, and assign to instance variabels for widget use + if @election.embed_custom_string + @top_bar = SkinPicture.find(:first, + :conditions => ["filename = ?", @election.embed_custom_string + "top_bar.png"]) + @default_image = SkinPicture.find(:first, + :conditions => ["filename = ?", @election.embed_custom_string + "default_image.png"]) + @bg1 = SkinPicture.find(:first, + :conditions => ["filename = ?", @election.embed_custom_string + "bg1.png"]) + @bg2 = SkinPicture.find(:first, + :conditions => ["filename = ?", @election.embed_custom_string + "bg2.png"]) + @bottom_bar = SkinPicture.find(:first, + :conditions => ["filename = ?", @election.embed_custom_string + "bottom_bar.png"]) + end if @election.embeddable? and params[:embed] == "true" render :template => 'embed/results', :layout => 'embed' else diff --git a/app/views/embed/_backdrop.rhtml b/app/views/embed/_backdrop.rhtml index 847f9a3..bee6fdf 100644 --- a/app/views/embed/_backdrop.rhtml +++ b/app/views/embed/_backdrop.rhtml @@ -1,10 +1,17 @@ <%@election.candidates.length.times do |count|-%> <% if (count%2)==0-%> - - <% else -%> - + + <% else -%> + <% end -%>

<%=count+1 -%> diff --git a/app/views/embed/full_vote.rhtml b/app/views/embed/full_vote.rhtml index 56715eb..4eca8c4 100644 --- a/app/views/embed/full_vote.rhtml +++ b/app/views/embed/full_vote.rhtml @@ -1,3 +1,13 @@ + +<%javascript_include_tag :defaults %> +<%if @top_bar %> + +<% end %> +