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
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'
@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
<%@election.candidates.length.times do |count|-%>
<% if (count%2)==0-%>
- <img src="/images/widget_dark.png"
- style="position:absolute;top:<%=(count+1)*53%>px;">
- <% else -%>
- <img src="/images/widget_light.png"
- style="position:absolute;top:<%=(count+1)*53%>px">
+ <img src=" <% if @bg1 -%>
+ <%= url_for @bg1.public_filename %>
+ <% else %>
+ /images/widget_dark.png
+ <% end -%> " style="position:absolute;top:<%=(count+1)*53%>px"/>
+ <% else -%>
+ <img src=" <% if @bg2 -%>
+ <%=url_for @bg2.public_filename %>
+ <% else %>
+ /images/widget_light.png
+ <% end -%>"
+ style="position:absolute;top:<%=(count+1)*53%>px">
<% end -%>
<p class="position" style="top:<%=(10+(count+1)*53)%>px;left:10px">
<%=count+1 -%>
+<head>
+<%javascript_include_tag :defaults %>
+<%if @top_bar %>
+<script type="text/javascript">
+
+document.getElementById("header").style.backgroundImage="<%=url_for @top_bar.public_filename%>"
+
+</script>
+<% end %>
+</head>
<div id="header">
<%= link_to '<img id="header_icon" src="/images/embed_header_icon.png" />',
{:controller => 'front'}, {:target => "_parent"} %><h2>Vote Now</h2>
<div id="voting-box" height="<%=(@election.candidates.length + 2)*53 %>px">
<%= render :partial => '/embed/backdrop' %>
-
<ul id="rankings-list">
<% @voter.vote.rankings.each do |ranking| %>
<li class="ranking" id="ranking_<%= ranking.candidate.id %>">
<img alt="<%= white_list ranking.candidate.name %>"
src="<% if ranking.candidate.picture -%>
<%= url_for ranking.candidate.picture.public_filename(:thumb) -%>
- <%- else -%>
+ <% elsif @default_image %>
+ <%= url_for @default_image.public_filename %>
+ <%- else -%>
/images/default_icon.png
<%- end %>" />
<p class="ranking-info">
<div style="clear:both;"></div>
<div id="voting-bottom" style="
- <% if @election.candidates.length%2 == 0 %>
+ <% if @bottom_bar %>
+ background-image:url(<%= url_for @bottom_bar.public_filename %>)
+ <% elsif @election.candidates.length%2 == 0 %>
background-image:url(/images/bottom_dark.png)
<%else%>
background-image:url(/images/bottom_light.png)