Skip to content

Commit 0765032

Browse files
committed
Merge commit 'a11449523b164132e8063e1e7db21d6cc0e75902'
2 parents cde804d + a114495 commit 0765032

File tree

5 files changed

+47
-6
lines changed

5 files changed

+47
-6
lines changed

app/controllers/outlets_controller.rb

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
class OutletsController < ApplicationController
22
respond_to :html, :xml, :json
3+
respond_to :atom, :only => :list
34
before_filter :check_auth, :except => [:verify, :show, :list]
45

6+
def default_url_options
7+
{:host => ENV['RINGSAIL_API_HOST']}
8+
end
9+
510
def add
611
@outlet = Outlet.resolve(params[:service_url])
712

@@ -84,7 +89,7 @@ def update
8489
if request.format == :html
8590
flash[:shortnotice] = "Thank you!"
8691
flash[:notice] = "The entry for #{ @outlet.service_info.display_name} has been #{action_performed}. #{somebody_was_notified}"
87-
redirect_to :action => "verify", :service_url => @outlet.service_url, :auth_token => @current_token.token
92+
redirect_to :action => "verify", :service_url => @outlet.service_url, :auth_token => @current_token.token, :only_path => true
8893
else
8994
respond_with(XBoxer.new(:result, {:status => "success"}))
9095
end
@@ -157,7 +162,7 @@ def remove
157162
if request.format == :html
158163
flash[:shortnotice] = "Thank you!"
159164
flash[:notice] = "The entry for #{outlet_name} has been removed from the registry."
160-
redirect_to :action => "verify", :service_url => service_url, :auth_token => @current_token.token
165+
redirect_to :action => "verify", :service_url => service_url, :auth_token => @current_token.token, :only_path => true
161166
else
162167
respond_with(XBoxer.new(:result, {:status => "success"}))
163168
end
@@ -167,7 +172,14 @@ def list
167172
@page_title = "Accounts"
168173
# @keywords = params[:q] || params[:keywords]
169174

170-
@outlets = Outlet.includes(:agencies).order('account, service')
175+
@outlets = Outlet.includes(:agencies)
176+
177+
if request.format == :atom
178+
@outlets = @outlets.order('outlets.updated_at DESC')
179+
@per_page = 20
180+
else
181+
@outlets = @outlets.order('account, service')
182+
end
171183

172184
if params[:service_id] and !params[:service_id].empty?
173185
@outlets = @outlets.where(:service => params[:service_id])
@@ -179,7 +191,7 @@ def list
179191
@outlets = @outlets.tagged_with(params[:tag])
180192
end
181193

182-
@outlets = @outlets.page(params[:page_number])
194+
@outlets = @outlets.page(params[:page_number]).per(@per_page)
183195

184196
respond_with(XBoxer.new(:result, Boxer.ship(:outlets, @outlets) ))
185197
end

app/views/embed/verify.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
Many people now use tools like Twitter, Facebook and YouTube to receive news and information. This registry identifies social media accounts managed by the federal government, to help the public know which accounts they can trust to provide factual government information.
139139
</p>
140140
<p>
141-
If you work for the U.S. federal government and have a .gov or .mil email address, use this tool to register social media accounts managed by federal agencies (including accounts for elected officials, heads of agencies or Cabinet members). Any registered accounts should have been created under federal-compatible <a href="http://www.howto.gov/web-content/resources/tools/terms-of-service-agreements">Terms of Service (TOS)</a>. If they weren&rsquo;t, contact your agency <a href="http://www.howto.gov/web-content/resources/tools/terms-of-service-agreements/agency-points-of-contact">Point of Contact</a>, who can help you to bring these accounts into compliance with federal law.
141+
If you work for the U.S. federal government and have a .gov or .mil email address, use this tool to register social media accounts managed by federal agencies (including accounts for elected officials, heads of agencies or Cabinet members). Any registered accounts should have been created under federal-compatible <a href="http://www.howto.gov/web-content/resources/tools/terms-of-service-agreements" target="_top">Terms of Service (TOS)</a>. If they weren&rsquo;t, contact your agency <a href="http://www.howto.gov/web-content/resources/tools/terms-of-service-agreements/agency-points-of-contact" target="_top">Point of Contact</a>, who can help you to bring these accounts into compliance with federal law.
142142
</p>
143143
<p>
144144
To register an account, enter the account URL in the field below and click &ldquo;Look Up&rdquo;

app/views/outlets/list.atom.builder

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
atom_feed(:root_url => list_outlets_url) do |feed|
2+
feed.title "U.S. Government Social Media Registry Accounts"
3+
4+
last_account = @outlets.first
5+
feed.updated( last_account && last_account.updated_at )
6+
7+
@outlets.each do |outlet|
8+
feed.entry(outlet, :url => howto_find_outlet_url(:service_url => outlet.service_url, :host => ENV['RINGSAIL_HOST']) ) do |entry|
9+
if outlet.updated_at == outlet.created_at
10+
entry.title "New #{outlet.service} account: #{outlet.account} (#{outlet.agencies.join("/")})"
11+
else
12+
entry.title "Updated #{outlet.service} account: #{outlet.account} (#{outlet.agencies.join("/")})"
13+
end
14+
15+
entry.summary type: 'xhtml' do |xhtml|
16+
if outlet.updated_at == outlet.created_at
17+
xhtml.p "New account posted to the registry on: " + outlet.updated_at.to_s(:human)
18+
else
19+
xhtml.p "Account updated in the registry on: " + outlet.updated_at.to_s(:human)
20+
end
21+
xhtml.p "By: " + outlet.updated_by.gsub(/(\w)\w+@/, '\1*****@')
22+
end
23+
entry.author do |author|
24+
author.name outlet.updated_by.gsub(/(\w)\w+@/, '\1*****@')
25+
end
26+
end
27+
end
28+
end

config/too_many_secrets.example.rb

+1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
ENV['RAILS_COOKIE_TOKEN'] = 'at least 30 random hex digits'
66
ENV['EMAIL_BYPASS_USER'] = 'a developer email to use in development'
77
ENV['RINGSAIL_HOST'] = 'hostname where ringsail is installed'
8+
ENV['RINGSAIL_API_HOST'] = 'hostname where the API is accessed'
89
ENV['REGISTRY_DOCS_URL'] = 'redirect default requests to this URL'

lib/boxer/outlet_boxes.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
box.view(:brief, :extends => :base) do
1111
if outlet.verified?
1212
{
13-
:details_url => show_outlet_path(:service => outlet.service, :account => outlet.account),
13+
:details_url => show_outlet_url(:service => outlet.service, :account => outlet.account, :host => ENV['RINGSAIL_API_HOST']),
1414
:agencies => outlet.agencies.map { |agency| Boxer.ship(:agency, agency) },
1515
:organization => outlet.organization,
1616
}

0 commit comments

Comments
 (0)