diff options
-rw-r--r-- | app/assets/images/widget-base.png | bin | 0 -> 7529 bytes | |||
-rw-r--r-- | app/assets/javascripts/general.js | 8 | ||||
-rw-r--r-- | app/assets/stylesheets/widget.css | 92 | ||||
-rw-r--r-- | app/controllers/request_controller.rb | 14 | ||||
-rw-r--r-- | app/views/request/create_widget.html.erb | 15 | ||||
-rw-r--r-- | app/views/request/widget.html.erb | 79 | ||||
-rw-r--r-- | config/application.rb | 1 | ||||
-rw-r--r-- | config/routes.rb | 2 |
8 files changed, 211 insertions, 0 deletions
diff --git a/app/assets/images/widget-base.png b/app/assets/images/widget-base.png Binary files differnew file mode 100644 index 000000000..c6d043817 --- /dev/null +++ b/app/assets/images/widget-base.png diff --git a/app/assets/javascripts/general.js b/app/assets/javascripts/general.js index 856f4c6d4..639a6917b 100644 --- a/app/assets/javascripts/general.js +++ b/app/assets/javascripts/general.js @@ -57,4 +57,12 @@ $(document).ready(function() { $('#everypage').hide(); } + // "Create widget" page + $("#widgetbox").select() + // Chrome workaround + $("widgetbox").mouseup(function() { + // Prevent further mouseup intervention + $this.unbind("mouseup"); + return false; + }); }) diff --git a/app/assets/stylesheets/widget.css b/app/assets/stylesheets/widget.css new file mode 100644 index 000000000..7d5a61bd5 --- /dev/null +++ b/app/assets/stylesheets/widget.css @@ -0,0 +1,92 @@ +body { + background: steelblue; +} +#alawidget-base { + width: 320px; + height: 215px; + background: url("widget-base.png") no-repeat; + font-family: 'Open Sans', sans-serif; + font-weight: 600; + font-size: 14px; + position: relative; +} +#alawidget-title { + position: absolute; + top: 24px; + left: 22px; + width: 123px; + height: 80px; + overflow: hidden; + color: #5a5a5a; +} +#alawidget-status { + position: absolute; + top: 113px; + left: 27px; + width: 1184x; + font-weight: 800; + font-size: 12px; +} +#alawidget-status.waiting_response, +#alawidget-status.waiting_response_overdue, +#alawidget-status.waiting_response_very_overdue { + color: #750096; +} +#alawidget-status.not_held { + color: #830016; +} +#alawidget-status.rejected { + color: #e62590; +} +#alawidget-status.successful { + color: #76b12c; +} +#alawidget-status.partially_successful { + color: #559798; +} +#alawidget-status.waiting_clarification { + color: #978f0b; +} +#alawidget-status.gone_postal { + color: #959191; +} +#alawidget-status.internal_review { + color: #7da49b; +} +#alawidget-status.error_message { + color: #e57f12; +} +#alawidget-status.user_withdrawn { + color: #5b8048; +} +#alawidget-left { + position: absolute; + width: 145px; +} +#alawidget-count { + position: absolute; + left: 176px; + top: 22px; + color: white; + font-weight: 800; + font-size: 55px; +} +#alawidget-bottom a { + text-decoration: none; +} +#alawidget-button { + position: absolute; + top: 173px; + left: 8px; + width: 151px; + height: 25px; + padding-top: 3px; + background: #009699; + color: white; + text-align: center; + box-shadow: 0 0 6px 1px #009699; +} +#alawidget-button.down { + background: #91b85d; + box-shadow: 0 0 6px 1px #91b85d; +} diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index e847cae1e..a1576beb7 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -161,6 +161,20 @@ class RequestController < ApplicationController @show_no_more_than = (@matches_estimated > MAX_RESULTS) ? MAX_RESULTS : @matches_estimated end + def widget + medium_cache + @info_request = InfoRequest.find(params[:id]) + @track_thing = TrackThing.create_track_for_request(@info_request) + @status = @info_request.calculate_status + render :template => 'request/widget', :layout => false + end + + def create_widget + long_cache + @info_request = InfoRequest.find(params[:id]) + render :template => 'request/create_widget' + end + def list medium_cache @view = params[:view] diff --git a/app/views/request/create_widget.html.erb b/app/views/request/create_widget.html.erb new file mode 100644 index 000000000..d6a71768a --- /dev/null +++ b/app/views/request/create_widget.html.erb @@ -0,0 +1,15 @@ +<h1>Add a widget</h1> + +<p> +To add a widget for <b><%= @info_request.title %></b>, copy and paste the +following code to your web page: +<textarea autofocus readonly rows='4' cols='60' id='widgetbox'> +<iframe src='<%= widget_url(@info_request) %>' width='320' height='215' frameborder='0' marginwidth='0' marginheight='0'> +</textarea> +</p> + +<p> +The widget will look like this: +<br> +<iframe src='<%= widget_url(@info_request) %>' width='320' height='215' frameborder='0' marginwidth='0' marginheight='0'> +</p> diff --git a/app/views/request/widget.html.erb b/app/views/request/widget.html.erb new file mode 100644 index 000000000..9a53b3a0e --- /dev/null +++ b/app/views/request/widget.html.erb @@ -0,0 +1,79 @@ +<head> + <%= stylesheet_link_tag "widget" %> + <link href='http://fonts.googleapis.com/css?family=Open+Sans:600,800' rel='stylesheet' type='text/css'> +</head> +<body> + <div id="alawidget-base"> + <div id="alawidget-top"> + <div id="alawidget-left"> + <div id="alawidget-title"> + <%= @info_request.title %> + </div> + <div id="alawidget-status" class="<%= @info_request.calculate_status %>"> + <% if @info_request.awaiting_description %> + <%= _('UNKNOWN STATUS') %> + <% elsif @status == 'waiting_response' %> + <%= _('WAITING RESPONSE') %> + <% elsif @status == 'waiting_response_overdue' %> + <%= _('WAITING RESPONSE') %> + <% elsif @status == 'waiting_response_very_overdue' %> + <%= _('WAITING RESPONSE') %> + <% elsif @status == 'not_held' %> + <%= _('NOT HELD') %> + <% elsif @status == 'rejected' %> + <%= _('REJECTED') %> + <% elsif @status == 'successful' %> + <%= _('SUCCESSFUL') %> + <% elsif @status == 'partially_successful' %> + <%= _('PARTIAL SUCCESS') %> + <% elsif @status == 'waiting_clarification' %> + <%= _('WAITING CLARIFICATION') %> + <% elsif @status == 'gone_postal' %> + <%= _('GONE POSTAL') %> + <% elsif @status == 'internal_review' %> + <%= _('INTERNAL REVIEW') %> + <% elsif @status == 'error_message' %> + <%= _('ERROR MESSAGE') %> + <% elsif @status == 'requires_admin' %> + <%= _('REQUIRES ADMIN') %> + <% elsif @status == 'user_withdrawn' %> + <%= _('USER WITHDRAWN') %> + <% elsif @status == 'attention_requested' %> + <%= _('ATTENTION REQUESTED') %> + <% elsif @status == 'vexatious' %> + <%= _('VEXATIOUS') %> + <% else %> + <%= render :partial => 'general/custom_state_descriptions', :locals => { :status => @status } %> + <% end %> + </div> + </div> + <div id="alawidget-count"> + <%= TrackThing.count(:all, :conditions => ["info_request_id = ?", @info_request.id]) + 1 %> + </div> + </div> + <% + if @user + existing_track = TrackThing.find_existing(@user, @track_thing) + end + %> + <div id="alawidget-bottom"> + <% if @info_request.user && @info_request.user == @user %> + <div id="alawidget-button" class="down"> + <%= _('This is your request') %> + </div> + <% elsif existing_track %> + <a href="<%= url_for :controller => 'track', :action => 'update', :track_id => existing_track.id, :track_medium => "delete", :r => request.fullpath %>"> + <div id="alawidget-button" class="down"> + <%= _('I also want to know!') %> + </div> + </a> + <% else %> + <a href="<%= url_for do_track_path(@track_thing) %>" target="_blank"> + <div id="alawidget-button"> + <%= _('I also want to know!') %> + </div> + </a> + <% end %> + </div> + </div> +</body> diff --git a/config/application.rb b/config/application.rb index 3c01e26c4..472077f06 100644 --- a/config/application.rb +++ b/config/application.rb @@ -116,6 +116,7 @@ module Alaveteli 'ie6.css', 'ie7.css', 'bootstrap-dropdown.js', + 'widget.css', 'responsive/print.css', 'responsive/application-lte-ie7.css', 'responsive/application-ie8.css'] diff --git a/config/routes.rb b/config/routes.rb index c975d6007..077dad002 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -54,6 +54,8 @@ Alaveteli::Application.routes.draw do match '/request/:id/response/:incoming_message_id' => 'request#show_response', :as => :show_response match '/request/:id/response/:incoming_message_id/attach/html/:part/*file_name' => 'request#get_attachment_as_html', :format => false, :as => :get_attachment_as_html match '/request/:id/response/:incoming_message_id/attach/:part(/*file_name)' => 'request#get_attachment', :format => false, :as => :get_attachment + match '/request/:id/widget' => 'request#widget', :as => :widget + match '/request/:id/widget/create' => 'request#create_widget', :as => :create_widget match '/request_event/:info_request_event_id' => 'request#show_request_event', :as => :info_request_event |