foxynews 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +23 -0
- data/app/controllers/foxynews/presskits_controller.rb +10 -0
- data/app/controllers/foxynews/pressrooms_controller.rb +46 -0
- data/app/helpers/foxynews/foxynews_helper.rb +5 -0
- data/app/models/foxynews/featured_item.rb +4 -0
- data/app/services/foxynews/clipping.rb +14 -0
- data/app/services/foxynews/paging.rb +13 -0
- data/app/services/foxynews/parser.rb +28 -0
- data/app/services/foxynews/press_release.rb +22 -0
- data/app/services/foxynews/press_release_setter.rb +56 -0
- data/app/services/foxynews/presskit.rb +19 -0
- data/app/services/foxynews/presskit_setter.rb +48 -0
- data/app/services/foxynews/pressroom.rb +20 -0
- data/app/services/foxynews/pressroom_setter.rb +75 -0
- data/app/views/foxynews/partials/_contact_details.html.erb +18 -0
- data/app/views/foxynews/partials/_contact_panels.html.erb +28 -0
- data/app/views/foxynews/partials/_contact_social_media.html.erb +17 -0
- data/app/views/foxynews/partials/_featured_press_release.html.erb +12 -0
- data/app/views/foxynews/partials/_modal.html.erb +8 -0
- data/app/views/foxynews/partials/_presskits.html.erb +8 -0
- data/app/views/foxynews/partials/_pressroom_about.html.erb +6 -0
- data/app/views/foxynews/partials/_spokesman_details.html.erb +31 -0
- data/app/views/foxynews/partials/_thumbnails.html.erb +33 -0
- data/app/views/foxynews/partials/_timeline.html.erb +50 -0
- data/app/views/foxynews/presskits/show.html.erb +10 -0
- data/app/views/foxynews/pressrooms/index.html.erb +25 -0
- data/app/views/foxynews/pressrooms/show.html.erb +21 -0
- data/config/locales/en.yml +32 -0
- data/config/routes.rb +9 -0
- data/db/migrate/20150915120000_create_foxynews_featured_items.rb +13 -0
- data/db/migrate/20150921110000_change_article_to_article_id.rb +5 -0
- data/lib/foxynews.rb +10 -0
- data/lib/foxynews/engine.rb +13 -0
- data/lib/foxynews/version.rb +3 -0
- data/lib/generators/foxynews/initializer_generator.rb +12 -0
- data/lib/generators/foxynews/templates/foxynews_template.rb +3 -0
- data/lib/tasks/foxynews_tasks.rake +4 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +26 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/foxynews.rb +3 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +59 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20150921115208_create_foxynews_featured_items.foxynews.rb +14 -0
- data/test/dummy/db/migrate/20150921115209_change_article_to_article_id.foxynews.rb +6 -0
- data/test/dummy/db/schema.rb +27 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +351 -0
- data/test/dummy/log/test.log +9326 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/spec/features/pressroom_feature_spec.rb +101 -0
- data/test/dummy/spec/rails_helper.rb +52 -0
- data/test/dummy/spec/services/foxynews/press_release_setter_spec.rb +40 -0
- data/test/dummy/spec/services/foxynews/presskit_setter_spec.rb +40 -0
- data/test/dummy/spec/services/foxynews/pressroom_setter_spec.rb +50 -0
- data/test/dummy/spec/spec_helper.rb +92 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/0ieeKnMtadPClPcf7n4_-7f9dFAa5EKPn-nhh8g4E_I.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/3fB7XY5WyPu8FySUeyC372vbXJ2Ix4iB1QaNHXbk_BY.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +2 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/9dpacct--ty4g6t9ET48xr39Oa8KFJq67stokNMRBE0.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/CzzhnWANCyFkiMpG8MGAUus0oHH7jFGSjgKNQytoGB8.cache +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/EHcymtlGKlOMMf7gOs-X2_jpvcBTW92Qeaxu2B5-Wbg.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/LGn_lRMM4VGWV-tOkzVE711bHWh5XhMIHtLL-ydCc5s.cache +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +3 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/P6CzQLNPa_qmqh4oEs_FJcmJUu_RgN9rxL-u5eUX8a8.cache +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/SGxtd6iKmB2TMwH-VOx-jVYXh5m_09UjNEOkifPHLL0.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/ZF-VgWKVwd4l6mDAOWYmcWP44GkNpVapsSWxOVT_jXs.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/e_NLP8hWf6Ma_xNwWM6lWrQIYZIy62BM5mIpRIVEz24.cache +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/eyIVoTHtfeBUAG8zonwJLMFQsk7muavIqU6by75vy6E.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +3 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/hkb4T84XlBEogo6JU3t-W-8oWx1BbAVq7dqJ2DNHwt4.cache +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +2 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/1fnsGuWQsCAFit0Lhxi-NuDTrnuzg0MPZnEeYfoXT9Q.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +2 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/9dpacct--ty4g6t9ET48xr39Oa8KFJq67stokNMRBE0.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/9jPCqzZvmeFf31Rz8y3OEo8OQXEHVcwmLgkx0tXs-o8.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/CzzhnWANCyFkiMpG8MGAUus0oHH7jFGSjgKNQytoGB8.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/N-1CMS_rjg3LKA5Sh64XgIXIzy-4T-PQ8PIf4HY_R8s.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +3 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/WZy7M8vyOXLZi2NSRoODBS6edlqJTSpd1JoU8Aq03fY.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/ZF-VgWKVwd4l6mDAOWYmcWP44GkNpVapsSWxOVT_jXs.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/eyIVoTHtfeBUAG8zonwJLMFQsk7muavIqU6by75vy6E.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +3 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/o2kqwqoUQ3gkgncZO1IWdVRzFD0wCSQ-HyL62cINFOU.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +2 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/pQIgTfLmEPykNamzxdqBww21SMT7YlZlZGy6hgQ6eVE.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/tAO-KLuNv0f9gUG3lGwGw7ujopxtlyjAr83jAzLWyq0.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/td9wUl9SLRnSSgE2ZK_VqCzLxTkFiCW50KkOhE916Wo.cache +1 -0
- data/test/dummy_responses/pressrooms_id.json +1 -0
- data/test/dummy_responses/pressrooms_id_press_releases.json +45 -0
- data/test/dummy_responses/pressrooms_id_press_releases_109544.json +1 -0
- data/test/dummy_responses/pressrooms_id_presskits.json +1 -0
- data/test/dummy_responses/pressrooms_id_presskits_215958.json +1 -0
- data/test/dummy_responses/pressrooms_id_timeline.json +135 -0
- data/test/test_helper.rb +19 -0
- metadata +302 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 425da1ca87e5b176be475c38e7e7c5ffe535c4e2
|
|
4
|
+
data.tar.gz: ca53031bc9e497ace3ca12f71daa4b6e4751287a
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 02672d407354009eabbcdcf379824e1014002c7b9872dea61352e2f83815eb10a7baf08fbe6dce0a75938ee1bacc2f87898ab406c71ce80c2d30af402a7b0ebf
|
|
7
|
+
data.tar.gz: 3a6d7b6c70e0f9124209fc0621c1777bd88227883db368c82b7db92e84114c9b4014cc938e4a340802050084c4e6d481c4312047c08fc2210b0dfc51ce1d3296
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2015 Adam Bahlke
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
require 'rdoc/task'
|
|
8
|
+
|
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
11
|
+
rdoc.title = 'Foxynews'
|
|
12
|
+
rdoc.options << '--line-numbers'
|
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
Bundler::GemHelper.install_tasks
|
|
23
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
class Foxynews::PressroomsController < ApplicationController
|
|
2
|
+
helper Foxynews::FoxynewsHelper
|
|
3
|
+
|
|
4
|
+
helper_method :pressroom, :presskit
|
|
5
|
+
|
|
6
|
+
def index
|
|
7
|
+
|
|
8
|
+
feature_id = Foxynews::FeaturedItem.where(featured: true).pluck(:article_id).first
|
|
9
|
+
@press_release = feature_id ? Foxynews::PressReleaseSetter.find(feature_id, 'true') : nil
|
|
10
|
+
|
|
11
|
+
page = params[:page] || 1
|
|
12
|
+
@limit = params[:limit] || 30
|
|
13
|
+
@timeline, @next_timeline_page, @next_page = pagination_content(page, @limit)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def show
|
|
18
|
+
unless @press_release = Foxynews::PressReleaseSetter.find(params[:id], 'true')
|
|
19
|
+
redirect_to root_path, flash: { error: I18n.t('error')}
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def archive
|
|
24
|
+
page = params[:page] || 1
|
|
25
|
+
@limit = params[:limit] || 30
|
|
26
|
+
@timeline, @next_timeline_page, @next_page = pagination_content(page, @limit)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def pressroom
|
|
32
|
+
@pressroom ||= Foxynews::PressroomSetter.pressroom
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def presskit
|
|
36
|
+
@presskit ||= Foxynews::PresskitSetter.all
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def pagination_content(page, limit)
|
|
40
|
+
timeline = Foxynews::PressroomSetter.timeline({page: page, limit: limit})
|
|
41
|
+
next_page = page.to_i + 1
|
|
42
|
+
next_timeline_page = Foxynews::PressroomSetter.timeline({page: next_page, limit: limit})
|
|
43
|
+
|
|
44
|
+
[timeline, next_timeline_page, next_page]
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'httparty'
|
|
2
|
+
|
|
3
|
+
class Foxynews::Parser
|
|
4
|
+
include HTTParty
|
|
5
|
+
|
|
6
|
+
base_uri Foxynews.base_uri
|
|
7
|
+
|
|
8
|
+
class << self
|
|
9
|
+
def data(end_of_path = '', options = {})
|
|
10
|
+
if Rails.env.test?
|
|
11
|
+
|
|
12
|
+
end_of_path.gsub!('/', '_')
|
|
13
|
+
begin
|
|
14
|
+
file = File.read("../dummy_responses/pressrooms_id#{end_of_path}")
|
|
15
|
+
rescue
|
|
16
|
+
return {}
|
|
17
|
+
else
|
|
18
|
+
return JSON.parse file
|
|
19
|
+
end
|
|
20
|
+
else
|
|
21
|
+
http_obj = get(end_of_path, options)
|
|
22
|
+
return http_obj
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class Foxynews::PressRelease
|
|
2
|
+
|
|
3
|
+
def initialize(args)
|
|
4
|
+
if args.is_a? Hash
|
|
5
|
+
args.each do |name, value|
|
|
6
|
+
instance_variable_set("@#{name}", value)
|
|
7
|
+
self.class.send(:attr_accessor, name)
|
|
8
|
+
end
|
|
9
|
+
else
|
|
10
|
+
false
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def short_summary
|
|
15
|
+
summary.split(' ')[0..99].join(' ') + '...'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def parsed_content
|
|
19
|
+
json = JSON.parse(content_as_json)
|
|
20
|
+
return json['data']
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
class Foxynews::PressReleaseSetter
|
|
2
|
+
attr_accessor :data, :paging
|
|
3
|
+
|
|
4
|
+
def initialize(data = {}, paging = {})
|
|
5
|
+
@data = data
|
|
6
|
+
@paging = paging
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class << self
|
|
10
|
+
# maps to /v1/pressrooms/:pressroom_id/press_releases.json
|
|
11
|
+
# Note: all parameters must be strings
|
|
12
|
+
def all(includes = nil, order = nil, locales = nil)
|
|
13
|
+
options = {query: {includes: includes, order: order, locales: locales}}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
begin
|
|
17
|
+
press_releases = Foxynews::Parser.data('/press_releases.json', options)
|
|
18
|
+
rescue StandardError => error
|
|
19
|
+
raise GenericError(error.message)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
if press_releases.has_key?('data')
|
|
23
|
+
return Foxynews::PressReleaseSetter.new(
|
|
24
|
+
press_releases['data'].each_with_object(data = []) {|pr| data << Foxynews::PressRelease.new(pr) },
|
|
25
|
+
Foxynews::Paging.new(press_releases['paging'])
|
|
26
|
+
)
|
|
27
|
+
else
|
|
28
|
+
return false
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# maps to /v1/pressrooms/:pressroom_id/press_releases/:id.json
|
|
33
|
+
def find(id, includes = nil)
|
|
34
|
+
options = {query: {includes: includes}}
|
|
35
|
+
|
|
36
|
+
begin
|
|
37
|
+
press_release = Foxynews::Parser.data("/press_releases/#{id}.json", options)
|
|
38
|
+
rescue StandardError => error
|
|
39
|
+
raise GenericError(error.message)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
if press_release.has_key?('data')
|
|
43
|
+
# return the hash in open struct to allow for @press_release.body_html calls
|
|
44
|
+
return Foxynews::PressRelease.new(press_release['data'])
|
|
45
|
+
else
|
|
46
|
+
return false
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class Foxynews::Presskit
|
|
2
|
+
|
|
3
|
+
def initialize(args)
|
|
4
|
+
if args.is_a? Hash
|
|
5
|
+
args.each do |name, value|
|
|
6
|
+
value.map! {|m| OpenStruct.new(m) } if name == 'media' && value.present?
|
|
7
|
+
|
|
8
|
+
instance_variable_set("@#{name}", value)
|
|
9
|
+
self.class.send(:attr_accessor, name)
|
|
10
|
+
end
|
|
11
|
+
else
|
|
12
|
+
false
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def media_items(limit = 1)
|
|
17
|
+
media.take(limit)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
class Foxynews::PresskitSetter
|
|
2
|
+
attr_accessor :data, :paging
|
|
3
|
+
|
|
4
|
+
def initialize(data, paging)
|
|
5
|
+
@data = data
|
|
6
|
+
@paging = paging
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class << self
|
|
10
|
+
#maps to /v1/pressrooms/:pressroom_id/presskits.json
|
|
11
|
+
#pagination options take page and limit parameters
|
|
12
|
+
def all(pagination_options = {})
|
|
13
|
+
options = {query: pagination_options}
|
|
14
|
+
|
|
15
|
+
begin
|
|
16
|
+
presskits = Foxynews::Parser.data('/presskits.json', options)
|
|
17
|
+
rescue StandardError => error
|
|
18
|
+
raise GenericError(error.message)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
if presskits.has_key?('data')
|
|
22
|
+
return Foxynews::PresskitSetter.new(
|
|
23
|
+
presskits['data'].each_with_object(data = []) {|pk| data << Foxynews::Presskit.new(pk) },
|
|
24
|
+
Foxynews::Paging.new(presskits['paging'])
|
|
25
|
+
)
|
|
26
|
+
else
|
|
27
|
+
return false
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
#maps to /v1/pressrooms/:pressroom_id/presskits/:id.json
|
|
32
|
+
def find(id)
|
|
33
|
+
begin
|
|
34
|
+
presskit = Foxynews::Parser.data("/presskits/#{id}.json")
|
|
35
|
+
rescue StandardError => error
|
|
36
|
+
raise GenericError(error.message)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
if presskit.has_key?('data')
|
|
40
|
+
return Foxynews::Presskit.new(presskit['data'])
|
|
41
|
+
else
|
|
42
|
+
return false
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class Foxynews::Pressroom
|
|
2
|
+
|
|
3
|
+
def initialize(args)
|
|
4
|
+
if args.is_a?(Hash)
|
|
5
|
+
args.each do |name, value|
|
|
6
|
+
value = OpenStruct.new(value) if value.is_a?(Hash)
|
|
7
|
+
value.map! {|prc| OpenStruct.new(prc) } if name == 'pr_contacts' && value.present?
|
|
8
|
+
|
|
9
|
+
instance_variable_set("@#{name}", value)
|
|
10
|
+
self.class.send(:attr_accessor, name)
|
|
11
|
+
end
|
|
12
|
+
else
|
|
13
|
+
false
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
class Foxynews::PressroomSetter
|
|
2
|
+
attr_accessor :data, :paging
|
|
3
|
+
|
|
4
|
+
def initialize(data = [], paging = [])
|
|
5
|
+
@data = data
|
|
6
|
+
@paging = paging
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def filter_timeline_by_language!(language)
|
|
11
|
+
data.each_with_object(localized = {}) do |month|
|
|
12
|
+
month.last.each do |item|
|
|
13
|
+
if item.language.include? language
|
|
14
|
+
if localized.has_key? month.first
|
|
15
|
+
localized[month.first] << item
|
|
16
|
+
else
|
|
17
|
+
localized[month.first] = [item]
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
self.data = localized
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
class << self
|
|
27
|
+
# maps to /v1/pressrooms/:id.json
|
|
28
|
+
def pressroom
|
|
29
|
+
begin
|
|
30
|
+
pressroom = Foxynews::Parser.data('.json')
|
|
31
|
+
rescue StandardError => error
|
|
32
|
+
raise GenericError(error.message)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
return (pressroom.has_key?('data')) ? Foxynews::Pressroom.new(pressroom['data']) : false
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# maps to /v1/pressrooms/:id/timeline.json
|
|
40
|
+
def timeline(pagination_options = {})
|
|
41
|
+
options = {query: pagination_options}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
begin
|
|
45
|
+
timeline = Foxynews::Parser.data('/timeline.json', options)
|
|
46
|
+
rescue StandardError => error
|
|
47
|
+
raise GenericError(error.message)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
if timeline.has_key?('data')
|
|
51
|
+
grouped_by_month = timeline['data'].group_by { |t| Date.parse(t['release_date']).strftime('%B %Y') }
|
|
52
|
+
|
|
53
|
+
grouped_by_month.each do |month, content|
|
|
54
|
+
content.map! do |i|
|
|
55
|
+
if i['type'] == 'clipping'
|
|
56
|
+
Foxynews::Clipping.new(i)
|
|
57
|
+
else
|
|
58
|
+
Foxynews::PressRelease.new(i)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
return Foxynews::PressroomSetter.new(grouped_by_month, Foxynews::Paging.new(timeline['paging']))
|
|
64
|
+
else
|
|
65
|
+
return false
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# maps to /v1/pressrooms/:id/search.json
|
|
70
|
+
def search(query, locale = nil)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<div class="content" id="panel_details">
|
|
2
|
+
<p id="pressroom_name"><%= pressroom.name %></p>
|
|
3
|
+
<p id="pressroom_contact_info"><%= pressroom.contact_info %></p>
|
|
4
|
+
</div>
|
|
5
|
+
<ul id="pressroom_links">
|
|
6
|
+
<li>
|
|
7
|
+
<i class="ss-globe"/>
|
|
8
|
+
<a href=<%= pressroom.urls['homepage'] %>><%= t('pressroom.main_website') %></a>
|
|
9
|
+
</li>
|
|
10
|
+
<li>
|
|
11
|
+
<i class="ss-building"/>
|
|
12
|
+
<a href=<%= pressroom.urls['blog'] %>><%= t('pressroom.company_blog') %></a>
|
|
13
|
+
</li>
|
|
14
|
+
<li>
|
|
15
|
+
<i class="ss-mail"/>
|
|
16
|
+
<a href=<%= pressroom.urls['contact'] %>><%= t('pressroom.contact_us') %></a>
|
|
17
|
+
</li>
|
|
18
|
+
</ul>
|