apdm 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +1 -0
  4. data/Gemfile +4 -0
  5. data/README.md +223 -0
  6. data/Rakefile +1 -0
  7. data/apdm.gemspec +34 -0
  8. data/bin/apdm +6 -0
  9. data/features/ad_tech.feature +11 -0
  10. data/features/step_definitions/ad_tech_steps.rb +19 -0
  11. data/features/support/env.rb +5 -0
  12. data/fixtures/approvals/ad_tech_loader_scripts.approved.txt +42 -0
  13. data/fixtures/approvals/ad_tech_placeholders.approved.txt +6 -0
  14. data/lib/apdm.rb +24 -0
  15. data/lib/apdm/ad_tech.rb +96 -0
  16. data/lib/apdm/ad_tech/ad_loader.rb +67 -0
  17. data/lib/apdm/ad_tech/ads.csv +475 -0
  18. data/lib/apdm/ad_tech/data.rb +47 -0
  19. data/lib/apdm/channel.rb +87 -0
  20. data/lib/apdm/channels.rb +569 -0
  21. data/lib/apdm/credentials.rb +26 -0
  22. data/lib/apdm/design_elements.rb +60 -0
  23. data/lib/apdm/design_elements/api.rb +75 -0
  24. data/lib/apdm/feed.rb +65 -0
  25. data/lib/apdm/issues.rb +14 -0
  26. data/lib/apdm/issues/aasavis.rb +51 -0
  27. data/lib/apdm/issues/amta.rb +253 -0
  28. data/lib/apdm/issues/an.rb +302 -0
  29. data/lib/apdm/issues/auraavis.rb +154 -0
  30. data/lib/apdm/issues/austagderblad.rb +154 -0
  31. data/lib/apdm/issues/avisa-hordaland.rb +154 -0
  32. data/lib/apdm/issues/avisa-valdres.rb +177 -0
  33. data/lib/apdm/issues/ba.rb +352 -0
  34. data/lib/apdm/issues/bladet.rb +154 -0
  35. data/lib/apdm/issues/blv.rb +254 -0
  36. data/lib/apdm/issues/bygdeposten.rb +154 -0
  37. data/lib/apdm/issues/demokraten.rb +154 -0
  38. data/lib/apdm/issues/eikerbladet.rb +409 -0
  39. data/lib/apdm/issues/enebakkavis.rb +51 -0
  40. data/lib/apdm/issues/etl.rb +79 -0
  41. data/lib/apdm/issues/eub.rb +254 -0
  42. data/lib/apdm/issues/finnmarkdagblad.rb +302 -0
  43. data/lib/apdm/issues/finnmarken.rb +302 -0
  44. data/lib/apdm/issues/firda.rb +302 -0
  45. data/lib/apdm/issues/firdaposten.rb +153 -0
  46. data/lib/apdm/issues/fremover.rb +304 -0
  47. data/lib/apdm/issues/gd.rb +304 -0
  48. data/lib/apdm/issues/glomdalen.rb +302 -0
  49. data/lib/apdm/issues/ha-halden.rb +302 -0
  50. data/lib/apdm/issues/hadeland.rb +251 -0
  51. data/lib/apdm/issues/hardanger-folkeblad.rb +151 -0
  52. data/lib/apdm/issues/helgeland-arbeiderblad.rb +304 -0
  53. data/lib/apdm/issues/import.csv +12821 -0
  54. data/lib/apdm/issues/indre.rb +151 -0
  55. data/lib/apdm/issues/jarlsbergavis.rb +154 -0
  56. data/lib/apdm/issues/kvinnheringen.rb +202 -0
  57. data/lib/apdm/issues/lofot-tidende.rb +102 -0
  58. data/lib/apdm/issues/lofotposten.rb +304 -0
  59. data/lib/apdm/issues/mb.rb +103 -0
  60. data/lib/apdm/issues/namdalsavisa.rb +302 -0
  61. data/lib/apdm/issues/nordhordland.rb +103 -0
  62. data/lib/apdm/issues/nordlys.rb +304 -0
  63. data/lib/apdm/issues/oa.rb +302 -0
  64. data/lib/apdm/issues/op.rb +304 -0
  65. data/lib/apdm/issues/opdalingen.rb +150 -0
  66. data/lib/apdm/issues/oyene.rb +51 -0
  67. data/lib/apdm/issues/pd.rb +254 -0
  68. data/lib/apdm/issues/r-a.rb +152 -0
  69. data/lib/apdm/issues/ranablad.rb +304 -0
  70. data/lib/apdm/issues/rb.rb +302 -0
  71. data/lib/apdm/issues/retten.rb +151 -0
  72. data/lib/apdm/issues/ringblad.rb +304 -0
  73. data/lib/apdm/issues/rogalandsavis.rb +302 -0
  74. data/lib/apdm/issues/sa.rb +304 -0
  75. data/lib/apdm/issues/smaalenene.rb +304 -0
  76. data/lib/apdm/issues/sognavis.rb +254 -0
  77. data/lib/apdm/issues/ta.rb +304 -0
  78. data/lib/apdm/issues/tk.rb +304 -0
  79. data/lib/apdm/issues/tvedestrandsposten.rb +150 -0
  80. data/lib/apdm/issues/vestbyavis.rb +51 -0
  81. data/lib/apdm/local_paper_area.rb +21 -0
  82. data/lib/apdm/network.rb +49 -0
  83. data/lib/apdm/null_cache.rb +15 -0
  84. data/lib/apdm/origo.rb +46 -0
  85. data/lib/apdm/saxo.rb +58 -0
  86. data/lib/apdm/saxo/iptc.rb +69 -0
  87. data/lib/apdm/saxo/metadata.rb +36 -0
  88. data/lib/apdm/saxo/remote.rb +67 -0
  89. data/lib/apdm/sinatra.rb +85 -0
  90. data/lib/apdm/version.rb +3 -0
  91. data/lib/cli.rb +12 -0
  92. data/spec/ad_tech/ad_loader_spec.rb +27 -0
  93. data/spec/ad_tech/data_spec.rb +14 -0
  94. data/spec/ad_tech_spec.rb +70 -0
  95. data/spec/approvals_helper.rb +6 -0
  96. data/spec/channel_spec.rb +91 -0
  97. data/spec/channels_spec.rb +9 -0
  98. data/spec/credentials_integration_spec.rb +13 -0
  99. data/spec/credentials_spec.rb +34 -0
  100. data/spec/design_elements_spec.rb +132 -0
  101. data/spec/feed_spec.rb +49 -0
  102. data/spec/fixtures/ad_tech.csv +6 -0
  103. data/spec/fixtures/approvals/adtech/ad_loader.approved.txt +9 -0
  104. data/spec/fixtures/approvals/apdm_adtech/data/handles_artikkelboard.approved.txt +10 -0
  105. data/spec/fixtures/approvals/apdm_adtech/data/handles_bunnbanner.approved.txt +10 -0
  106. data/spec/fixtures/approvals/apdm_adtech/data/handles_skyskraper_1.approved.txt +10 -0
  107. data/spec/fixtures/approvals/apdm_adtech/data/handles_toppbanner.approved.txt +10 -0
  108. data/spec/fixtures/approvals/apdm_adtech/data/is_ok_with_new_bandwagon_data.approved.txt +10 -0
  109. data/spec/fixtures/approvals/apdm_adtech/data/loads_default_data.approved.txt +10 -0
  110. data/spec/fixtures/approvals/apdm_designelements/css/via_api.approved.txt +23 -0
  111. data/spec/fixtures/approvals/apdm_designelements/footer_html/via_api.approved.html +85 -0
  112. data/spec/fixtures/approvals/apdm_designelements/header_html/via_api.approved.html +40 -0
  113. data/spec/fixtures/approvals/apdm_designelements/tracking_scripts/api/keyword.approved.txt +54 -0
  114. data/spec/fixtures/approvals/apdm_designelements/tracking_scripts/api/placeholder.approved.txt +54 -0
  115. data/spec/fixtures/issues.csv +3 -0
  116. data/spec/fixtures/test.jpg +0 -0
  117. data/spec/fixtures/vcr_cassettes/apdm_credentials.yml +44 -0
  118. data/spec/fixtures/vcr_cassettes/css.yml +5588 -0
  119. data/spec/fixtures/vcr_cassettes/footer-html.yml +178 -0
  120. data/spec/fixtures/vcr_cassettes/header-html.yml +132 -0
  121. data/spec/fixtures/vcr_cassettes/origo_someone_credentials.yml +43 -0
  122. data/spec/fixtures/vcr_cassettes/origo_westerdal_credentials.yml +56 -0
  123. data/spec/fixtures/vcr_cassettes/site_stat.yml +172 -0
  124. data/spec/fixtures/vcr_cassettes/site_stat_custom_category.yml +172 -0
  125. data/spec/geo_spec.rb +10 -0
  126. data/spec/issues_etl_spec.rb +41 -0
  127. data/spec/mockcached.rb +36 -0
  128. data/spec/network_spec.rb +43 -0
  129. data/spec/null_cache_spec.rb +29 -0
  130. data/spec/origo_spec.rb +24 -0
  131. data/spec/saxo/iptc_spec.rb +105 -0
  132. data/spec/saxo/metadata_spec.rb +79 -0
  133. data/spec/saxo/remote_spec.rb +71 -0
  134. data/spec/saxo/saxo_spec.rb +82 -0
  135. data/spec/spec_helper.rb +22 -0
  136. data/spec/vcr_helper.rb +6 -0
  137. data/test/fixtures/config-example.yml +6 -0
  138. data/test/saxo/acceptance_spec.rb +109 -0
  139. metadata +427 -0
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ M2QzMjJlZGYzYTJkYzZjYTkyZmM2N2IwNGE4NzI3MGYwMGM4YWU1ZQ==
5
+ data.tar.gz: !binary |-
6
+ ZDYxMmJkOGE4MGNlMzg1ZTI5MWNmMWIyYjMxYmQ3MWQyMDUyMWU3ZA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MGQ5MDA4YjY4ODUwY2ZmMjZiYmJiM2EzYzVkN2M1MmI4N2U3NzRjNWZmNDM1
10
+ YzBlODk4MTVmNGZiODg2ZjMwNmZlMzQwYjQxMDBjYzRhMTNkMTQ4NzRmODk5
11
+ NDVlNTU2MDg2NmNkY2JjM2U2NjUwZGNiZDE4ZmRiOWI4NzQ4OTI=
12
+ data.tar.gz: !binary |-
13
+ NzQzNDA1MTFmZWUwOTM3NGNlZTEyZGRlMzNhMGUyMGQ0NDVmOGI1MGQ0MDAw
14
+ N2EwMmQ5N2MxMTQyMDMwZjBlYTkzMWJjMmEyZWEwMzAxNjVmMDdkMjlmZGU3
15
+ ODMwZThkOWZhNjUwNzgzOWJiNTRiOGEyNzQxZjM3YjI3NWFjM2I=
@@ -0,0 +1,9 @@
1
+ *.gem
2
+ .bundle
3
+ .idea
4
+ Gemfile.lock
5
+ pkg/*
6
+ test/fixtures/config.yml
7
+ log/
8
+ .approvals
9
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in apdm.gemspec
4
+ gemspec
@@ -0,0 +1,223 @@
1
+ # APDM
2
+
3
+ A-Pressens Digitale Medier
4
+
5
+ Bucket for APDM specific stuff.
6
+
7
+ Usage intended for the pebble _Pulp_ and the apps _Lifeloop_ and _Bandwagon_, _Strider_, should it expand to include multiple papers, as well as any apps that come out of the _Evergreen_ project.
8
+
9
+ ## Channels
10
+
11
+ channel = Channel.find('avisnavn')
12
+
13
+ channel.name
14
+ => 'Avisnavn'
15
+
16
+ channel.domain
17
+ => 'avisnavn.no'
18
+
19
+ channel.ad_tech
20
+ => 123
21
+
22
+ # ... and loads of other handy methods
23
+
24
+ ## Design Elements
25
+
26
+ The api key is just an identifier, and is not used for authorization. In other words, you can make them up as you go along.
27
+
28
+ api = APDM::DesignElements.new('avisnavn', :api_key => 'bandwagon')
29
+
30
+ ### Header/Footer
31
+
32
+ Each newspaper has a standard header and footer along with the css necessary to display it.
33
+ This header changes regularly. We cache these for a day by default.
34
+
35
+ api.header
36
+ api.footer
37
+ api.css
38
+
39
+ ### SiteStat
40
+
41
+ These are tracking scripts used for analytics. It is common to give each type of page within an application its own key.
42
+
43
+ api.site_stat('personalia.bursdag.hilsen.123456')
44
+
45
+ ## RSS Feeds
46
+
47
+ The newspapers each have an RSS feed:
48
+
49
+ channel = Channel.find 'avisnavn'
50
+ feed = APDM::Feed.new(channel)
51
+
52
+ feed.fetch
53
+
54
+ You can specify extra parameters for the number of entries it should return:
55
+
56
+ feed.fetch("amount" => 5)
57
+
58
+ Also, newspapers sometimes set up specific sections, like 'bandwagon', or 18368. These are specified as follows:
59
+
60
+ feed.fetch("sectionId" => 'bandwagon')
61
+
62
+ ## AdTech
63
+
64
+ AdTech ads are managed by Elisabeth Drange Tønnessen <elisabeth.tonnessen@apdm.no>. We receive a standardized .csv file with ad data, keyed off of a `website id`. The `website_id` in the .csv file corresponds to the `ad_tech_id` in the `Channels` list.
65
+
66
+ When APDM says that they just want to use the "default origo ads" this doesn't mean actual origo ads, it means the ads that we have stored with this gem.
67
+
68
+ It is important, if you create the snippets ahead of time, to make sure that all the ads on a single page are served with a uniq group id.
69
+ We use a large rand: "grp=12345678990". This identifies them as having been shown together, simultaneously.
70
+
71
+ ## Sinatra extensions and workarounds for evil APDM proxy
72
+
73
+ If you are writing a Sinatra app that is going to live behind the evil apdm proxy, there's a Sinatra extension for you.
74
+
75
+ Enable it with:
76
+
77
+ require 'apdm/sinatra'
78
+
79
+ and adding this line to your Sinatra App class:
80
+
81
+ register Sinatra::APDM
82
+
83
+ ### Sinatra helpers
84
+
85
+ The following helper methods will be registered:
86
+
87
+ * `current_channel` Returns the current channel (based on current domain name - avisnavn.no if in development)
88
+ * `design_elements` Returns the DesignElements instance for the current channel (see Design Elements above)
89
+ * `ad_tech` Returns the AdTech instance for current channel
90
+ * `design_elements_css_path` Returns the path (sinatra route) to where the css for current channel is published. Use in your templates to load css for channel, i.e. `%link{ :href => design_elements_css_path, :rel => "stylesheet", :type => "text/css" }`
91
+ * `ad_tech_api_js` Returns a JavaScript snippet that defines functionality (a global `window.api` object with several methods) needed by the ad_tech scripts. If you get a lot of `Uncaught ReferenceError: api is not defined` you probably want to include the following in your template:
92
+
93
+ ```haml
94
+ %script
95
+ = ad_tech_api_js
96
+ ```
97
+
98
+ In order to make design elements or ad tech work properly, you need set a couple of configuration options:
99
+
100
+ * `set_design_elements_api_key` The api key for design elements (see above)
101
+
102
+ * `set_ad_tech_context_prefix` The context_key/context_prefix of your application (i.e. `bandwagon`)
103
+
104
+ ### Workarounds
105
+
106
+ You probably want to enable workarounds and cache headers proven to work with the evil apdm proxy (see the following example)
107
+
108
+ ### Example (all options enabled):
109
+
110
+ ```rb
111
+ class MyApp < Sinatra::Base
112
+
113
+ register Sinatra::APDM
114
+ apdm_configure do
115
+ set_design_elements_api_key "kalender"
116
+ set_ad_tech_context_prefix "kalender"
117
+ enable_apdm_proxy_workarounds
118
+ enable_apdm_cache_headers
119
+ end
120
+ # (...)
121
+ ```
122
+
123
+ ### Usage
124
+
125
+ For each page request, you can instantiate an `ad_tech` ad repository for your current channel.
126
+ This needs to know what context (application, possibly which part of the application) the ads are being shown in.
127
+
128
+ ad_tech = AdTech.new(current_channel, :context_key => 'bandwagon') # e.g. 'bandwagon', or 'origo+profile'
129
+
130
+ ad_tech.slot(:toppbanner)
131
+ ad_tech.slot(:bunnbanner)
132
+
133
+ ad_tech.loader_scripts
134
+
135
+ It is possible to add local context in addition to the app context. For example, in Lifeloop, we specify `personalia+<greeting-kind>` on the greeting category pages as well as individual greeting pages.
136
+
137
+ ad_tech = AdTech.new(current_channel, :context_key => 'personalia')
138
+
139
+ ad_tech.slot(:toppbanner, :local_context => 'mothersday')
140
+
141
+ => 'personalia+mothersday'
142
+
143
+ ## Saxo
144
+
145
+ Origo/Apressen Web-to-Print module.
146
+
147
+ The local newspapers use Saxo to manage their images. This module writes metadata to jpg images for print, and transfers them to an FTP server, resulting in the images being pulled directly into the saxo system at the local papers.
148
+
149
+ ## Options
150
+
151
+ `APDM::Saxo` needs to be initialized with a hash containing the server connection details.
152
+ For convenience, these live in the Channel objects.
153
+
154
+ channel = Channel.find 'avisnavn'
155
+ channel.saxo_config
156
+ => { :server => 'ftp.example.com', :username => 'username', :password => 'password', :remote_dir => 'remote/dir' }
157
+
158
+ ## Metadata
159
+
160
+ The metadata is a hash with the following keys:
161
+
162
+ {
163
+ :keywords => 'some keywords',
164
+ :byline => 'the byline',
165
+ :headline => 'the headline',
166
+ :credit => 'the credits',
167
+ :source => 'the source',
168
+ :copyright => 'the copyright',
169
+ :caption => 'a caption'
170
+ }
171
+
172
+ ## Publication Dates (_Issues_)
173
+
174
+ Usually sometime before Christmas, someone realizes that we're running
175
+ out of publication dates for some of the newspapers.
176
+
177
+ The dates of each issue are delivered to us in a variety of formats, typically
178
+ an excel in an encoding which is not UTF-8, and with varying columns and date formats.
179
+
180
+ Til now, we have then massaged this in order to get a UTF-8 encoded .csv file
181
+ that has the following fields:
182
+
183
+ YYYY-MM-DD;Issue Number;Acronym;NEWSPAPER NAME IN ALL CAPS
184
+
185
+ We don't use the issue number or acronym for anything. Also the acronyms are not unique.
186
+
187
+ Ideally we would just get the date and the domain name:
188
+
189
+ YYYY-MM-DD;avisnavn.no
190
+
191
+ To import this, replace the `config/issues.csv` file with the newly massaged replacement,
192
+ and then run the command to import it:
193
+
194
+ ./bin/apdm import_issues
195
+
196
+
197
+ ## Usage
198
+
199
+ The default behavior is to take the image located at `./localname.jpg`, write the metadata to it, and transfer it to the remote destination.
200
+
201
+ saxo = APDM::Saxo.new(options)
202
+
203
+ photo = saxo.write(metadata).to('localname.jpg', '/some/path')
204
+ saxo.transfer(photo)
205
+
206
+ If a `:source` is provided, the image will be downloaded to `/some/path/localname.jpg` before proceeding.
207
+
208
+ saxo = APDM::Saxo.new(options)
209
+
210
+ photo = saxo.write(metadata).to('localname.jpg', '/some/path', :source => 'http://www.example.com/remote.jpg')
211
+ saxo.transfer(photo)
212
+
213
+ `saxo.transfer` returns true if it suceeded, otherwise false.
214
+
215
+ ## Acceptance Test
216
+
217
+ There is an acceptance test in `/test`. This test by itself covers 98.99% of the saxo module in the project.
218
+
219
+ To run it
220
+
221
+ * copy `test/config-example.yml` to `test/config.yml`
222
+ * edit to taste
223
+ * run `rspec test`
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require 'apdm/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "apdm"
7
+ s.version = APDM::VERSION
8
+ s.authors = ["Katrina Owen"]
9
+ s.email = ["katrina.owen@gmail.com"]
10
+ s.homepage = "https://github.com/bengler/apdm"
11
+ s.summary = %q{APDM local paper stuff.}
12
+ s.description = %q{A collection of APDM local paper-related things.}
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_development_dependency "rspec"
20
+ s.add_development_dependency "simplecov"
21
+ s.add_development_dependency "vcr"
22
+ s.add_development_dependency "approvals"
23
+ s.add_development_dependency "webmock"
24
+ s.add_development_dependency "cucumber"
25
+ s.add_development_dependency "timecop"
26
+ s.add_runtime_dependency "curb"
27
+ s.add_runtime_dependency "nokogiri"
28
+ s.add_runtime_dependency "feedzirra", "~>0.2.0.rc2"
29
+ s.add_runtime_dependency "rgeo"
30
+ s.add_runtime_dependency "rgeo-geojson"
31
+ s.add_runtime_dependency "queryparams"
32
+ s.add_runtime_dependency "unicode"
33
+
34
+ end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'thor'
4
+ require_relative '../lib/cli'
5
+
6
+ APDM::CLI.start
@@ -0,0 +1,11 @@
1
+ Feature: AdTech Ad Loaders
2
+
3
+ Display A-presse ads by inserting their old-school custom ad loaders
4
+ into the page.
5
+
6
+ Scenario: Render "toppbanner" and "bunnbanner" ad tech ads
7
+ Given an AdTech instance for Finnmark Dagblad
8
+ When toppbanner is slotted
9
+ And bunnbanner is slotted
10
+ Then the placeholders for toppbanner and bunnbanner are rendered
11
+ And loader scripts are included for both toppbanner and bunnbanner
@@ -0,0 +1,19 @@
1
+ Given /^an AdTech instance for Finnmark Dagblad$/ do
2
+ channel = APDM::Channel.find('finnmarkdagblad')
3
+ @ad_tech = APDM::AdTech.new(channel, :group_id => 3, :context_key => 'cucumber+features')
4
+ end
5
+
6
+ When /^(\w+) is slotted$/ do |ad_key|
7
+ @placeholders ||= ""
8
+ @placeholders << @ad_tech.slot(ad_key.to_sym)
9
+ end
10
+
11
+ Then /^the placeholders for toppbanner and bunnbanner are rendered$/ do
12
+ Approvals.verify(@placeholders, :name => "ad tech placeholders")
13
+ end
14
+
15
+ Then /^loader scripts are included for both toppbanner and bunnbanner$/ do
16
+ Approvals.verify(@ad_tech.loader_scripts, :name => "ad tech loader scripts")
17
+ end
18
+
19
+
@@ -0,0 +1,5 @@
1
+ $:.unshift "#{File.dirname(__FILE__)}/../../lib/"
2
+
3
+ require 'approvals'
4
+ require 'apdm'
5
+
@@ -0,0 +1,42 @@
1
+ <div id="adtech_loader_scripts" style="display:none;">
2
+ <div id="adtech_toppbanner_loader">
3
+ <!--AdTech Loader | Tag for network 838 : A-Pressen Multimedia Salg | Website: Origin - Finnmark Dagblad | Placement: Origo Toppbanner 980x150 (2984117) -->
4
+ <script>
5
+ document.write('<scr'+'ipt language="javascript1.1" src="http://adserver.adtech.de/addyn/3.0/838/2984117/0/1744/ADTECH;loc=100;target=_blank;key=cucumber+features;grp=3;misc='+new Date().getTime()+'"></scri'+'pt>');
6
+ </script>
7
+ <noscript>
8
+ <a href="http://adserver.adtech.de/adlink/3.0/838/2984117/0/1744/ADTECH;loc=300;key=cucumber+features;grp=3" target="_blank">
9
+ <img src="http://adserver.adtech.de/adserv/3.0/838/2984117/0/1744/ADTECH;loc=300;key=cucumber+features;grp=3" border="0" width="980" height="150">
10
+ </a>
11
+ </noscript>
12
+ </div>
13
+ <script>
14
+ (function() {
15
+ var loader = document.getElementById('adtech_toppbanner_loader');
16
+ var placeholder = document.getElementById('adtech_toppbanner_placeholder');
17
+ placeholder.innerHTML = loader.innerHTML;
18
+ loader.innerHTML = '';
19
+ }());
20
+ </script>
21
+
22
+ <div id="adtech_bunnbanner_loader">
23
+ <!--AdTech Loader | Tag for network 838 : A-Pressen Multimedia Salg | Website: Origin - Finnmark Dagblad | Placement: Origo Bunnbanner 980x150 (2984119) -->
24
+ <script>
25
+ document.write('<scr'+'ipt language="javascript1.1" src="http://adserver.adtech.de/addyn/3.0/838/2984119/0/1744/ADTECH;loc=100;target=_blank;key=cucumber+features;grp=3;misc='+new Date().getTime()+'"></scri'+'pt>');
26
+ </script>
27
+ <noscript>
28
+ <a href="http://adserver.adtech.de/adlink/3.0/838/2984119/0/1744/ADTECH;loc=300;key=cucumber+features;grp=3" target="_blank">
29
+ <img src="http://adserver.adtech.de/adserv/3.0/838/2984119/0/1744/ADTECH;loc=300;key=cucumber+features;grp=3" border="0" width="980" height="150">
30
+ </a>
31
+ </noscript>
32
+ </div>
33
+ <script>
34
+ (function() {
35
+ var loader = document.getElementById('adtech_bunnbanner_loader');
36
+ var placeholder = document.getElementById('adtech_bunnbanner_placeholder');
37
+ placeholder.innerHTML = loader.innerHTML;
38
+ loader.innerHTML = '';
39
+ }());
40
+ </script>
41
+
42
+ </div>
@@ -0,0 +1,6 @@
1
+ <div id="adtech_toppbanner_placeholder" style="height: 150px; width: 980px;">
2
+ Annonse
3
+ </div>
4
+ <div id="adtech_bunnbanner_placeholder" style="height: 150px; width: 980px;">
5
+ Annonse
6
+ </div>
@@ -0,0 +1,24 @@
1
+ require 'apdm/design_elements'
2
+ require 'apdm/channel'
3
+ require 'apdm/network'
4
+ require 'apdm/channels'
5
+ require 'apdm/saxo'
6
+ require 'apdm/null_cache'
7
+ require 'apdm/ad_tech'
8
+ require 'apdm/feed'
9
+ require 'apdm/local_paper_area'
10
+ require 'apdm/credentials'
11
+ require 'apdm/origo'
12
+ require 'apdm/issues'
13
+
14
+ module APDM
15
+
16
+ class << self
17
+ attr_writer :cache
18
+
19
+ def cache
20
+ @cache ||= NullCache.new
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,96 @@
1
+ require 'csv'
2
+ require 'apdm/ad_tech/data'
3
+ require 'apdm/ad_tech/ad_loader'
4
+ require 'securerandom'
5
+
6
+ module APDM
7
+ class AdTech
8
+
9
+ FORMATS = [:toppbanner, :bunnbanner, :skyskraper_1, :artikkelboard]
10
+
11
+ class << self
12
+ attr_writer :path_to_csv_file, :data
13
+ def path_to_csv_file
14
+ @path_to_csv_file ||= File.dirname(__FILE__) + '/ad_tech/ads.csv'
15
+ end
16
+
17
+ def load
18
+ @data = Data.new(path_to_csv_file)
19
+ end
20
+
21
+ def data
22
+ @data ||= Data.new(path_to_csv_file)
23
+ end
24
+ end
25
+
26
+ attr_reader :channel, :loaders, :data, :group_id
27
+ def initialize(channel, options = {})
28
+ @channel = channel
29
+ @context_key = options[:context_key]
30
+ @loaders = []
31
+ @data = options[:data] || AdTech.data.for(channel)
32
+ @group_id = options[:group_id] || rand(10**10)
33
+ end
34
+
35
+ def context_key(refinement = nil)
36
+ "#{@context_key}+#{refinement}".chomp('+')
37
+ end
38
+
39
+ def slot(key, options = {})
40
+ slotted = ad_loader(key, options)
41
+ loaders << slotted
42
+ placeholder_div slotted
43
+ end
44
+
45
+ def ad_loader(key, options = {})
46
+ AdLoader.new data_for(key, options)
47
+ end
48
+
49
+ def placeholder_div(loader)
50
+ s = <<-PLACEHOLDER.gsub(/^\s{8}/, '').chomp
51
+ <div id="#{loader.dom_prefix}_placeholder" style="width: #{loader.width}px;">
52
+ Annonse
53
+ </div>
54
+
55
+ PLACEHOLDER
56
+ end
57
+
58
+ def loader_scripts
59
+ html = "<div id=\"adtech_loader_scripts\" style=\"display:none;\">\n"
60
+
61
+ loaders.each do |loader|
62
+ html << wrap(loader)
63
+ end
64
+
65
+ html << '</div>'
66
+ end
67
+
68
+ def wrap(loader)
69
+ s = <<-HTML.gsub(/^\s{8}/, '')
70
+ <div id="#{loader.dom_prefix}_loader">
71
+ #{loader}
72
+ </div>
73
+ #{postloader(loader)}
74
+ HTML
75
+ s
76
+ end
77
+
78
+ def data_for(key, options = {})
79
+ data[key].merge(:group_id => group_id, :context_key => context_key(options[:local_context]))
80
+ end
81
+
82
+ def postloader(loader)
83
+ s = <<-SCRIPT
84
+ <script>
85
+ (function() {
86
+ var loader = document.getElementById('#{loader.dom_prefix}_loader');
87
+ var placeholder = document.getElementById('#{loader.dom_prefix}_placeholder');
88
+ placeholder.innerHTML = loader.innerHTML;
89
+ loader.innerHTML = '';
90
+ }());
91
+ </script>
92
+ SCRIPT
93
+ end
94
+
95
+ end
96
+ end