darjeelink 0.11.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +82 -0
  4. data/Rakefile +24 -0
  5. data/app/assets/config/darjeelink_manifest.js +2 -0
  6. data/app/assets/javascripts/darjeelink/application.js +15 -0
  7. data/app/assets/javascripts/darjeelink/sparkleh.js +248 -0
  8. data/app/assets/javascripts/darjeelink/tracking_link_generator.js +36 -0
  9. data/app/assets/stylesheets/darjeelink/application.css +15 -0
  10. data/app/controllers/darjeelink/application_controller.rb +31 -0
  11. data/app/controllers/darjeelink/sessions_controller.rb +31 -0
  12. data/app/controllers/darjeelink/short_links_controller.rb +111 -0
  13. data/app/controllers/darjeelink/tracking_links_controller.rb +8 -0
  14. data/app/helpers/darjeelink/application_helper.rb +6 -0
  15. data/app/importers/darjeelink/rebrandly_importer.rb +48 -0
  16. data/app/importers/darjeelink/short_link_importer.rb +32 -0
  17. data/app/jobs/darjeelink/application_job.rb +6 -0
  18. data/app/mailers/darjeelink/application_mailer.rb +8 -0
  19. data/app/models/darjeelink/application_record.rb +7 -0
  20. data/app/models/darjeelink/short_link.rb +58 -0
  21. data/app/views/darjeelink/short_links/_short_link_form.erb +24 -0
  22. data/app/views/darjeelink/short_links/edit.html.erb +29 -0
  23. data/app/views/darjeelink/short_links/index.html.erb +75 -0
  24. data/app/views/darjeelink/short_links/new.html.erb +12 -0
  25. data/app/views/darjeelink/tracking_links/new.erb +49 -0
  26. data/app/views/layouts/darjeelink/application.html.erb +39 -0
  27. data/config/initializers/darjeelink.rb +31 -0
  28. data/config/initializers/omniauth.rb +10 -0
  29. data/config/initializers/rebrandly.rb +5 -0
  30. data/config/routes.rb +11 -0
  31. data/db/migrate/20190103122918_create_portkey_short_links.rb +16 -0
  32. data/db/migrate/20190304094710_case_insensitive_index_short_link_shortened_path.rb +14 -0
  33. data/db/migrate/20200505220716_rename_portkey_short_links_to_darjeelink_short_links.rb +7 -0
  34. data/db/migrate/20200505221026_rename_portkey_short_link_index.rb +15 -0
  35. data/lib/darjeelink.rb +30 -0
  36. data/lib/darjeelink/configuration.rb +19 -0
  37. data/lib/darjeelink/engine.rb +23 -0
  38. data/lib/darjeelink/version.rb +5 -0
  39. data/lib/tasks/darjeelink.rake +6 -0
  40. metadata +250 -0
@@ -0,0 +1,12 @@
1
+ <div class="row">
2
+ <div class="col-md-12">
3
+ <%= link_to "Back", darjeelink.short_links_path, class: "btn btn-default" %>
4
+ </div>
5
+ </div>
6
+
7
+ <div class="row">
8
+ <div class="col-md-12">
9
+ <h1>New Short Link</h1>
10
+ </div>
11
+ </div>
12
+ <%= render partial: 'short_link_form' %>
@@ -0,0 +1,49 @@
1
+ <% content_for :script_files do %>
2
+ <%= javascript_include_tag "darjeelink/tracking_link_generator" %>
3
+ <% end %>
4
+
5
+ <div class="row">
6
+ <div class="col-md-12">
7
+ <%= link_to "Back", darjeelink.short_links_path, class: "btn btn-default" %>
8
+ </div>
9
+ </div>
10
+
11
+ <div class="row">
12
+ <div class="col-md-12">
13
+ <h1>Tracking Link Generator!</h1>
14
+ </div>
15
+ </div>
16
+
17
+ <div class="row">
18
+ <div class="col-md-12">
19
+ <form id="tracking">
20
+ <div class="form-group">
21
+ <label for="url">URL</label>
22
+ <input type="text" class="form-control" id="url">
23
+ <label for="source">Source - Medium</label>
24
+ <select class="form-control" id="source-medium">
25
+ <% Darjeelink.source_mediums.each do |key, value| %>
26
+ <option value="<%= key %>"><%= value %></option>
27
+ <% end %>
28
+ </select>
29
+ <label for="campaign">ID / Identifier (lower-case, underscores only)</label>
30
+ <input type="text" class="form-control" id="campaign">
31
+ </div>
32
+ </form>
33
+ </div>
34
+ </div>
35
+
36
+ <div class="row">
37
+ <div class="col-md-12">
38
+ <h2>Your tracking link</h2>
39
+ <button id="copy-btn" class="btn btn-info btn-sm" data-clipboard-target="#long_url">
40
+ <span class="glyphicon glyphicon-copy"></span>
41
+ </button>
42
+ </div>
43
+ </div>
44
+
45
+ <%= render partial: 'darjeelink/short_links/short_link_form' %>
46
+
47
+ <script>
48
+ new ClipboardJS('#copy-btn');
49
+ </script>
@@ -0,0 +1,39 @@
1
+ <!doctype html>
2
+ <html class="no-js" lang="">
3
+
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <meta http-equiv="x-ua-compatible" content="ie=edge">
7
+ <title>Darjeelink</title>
8
+ <meta name="description" content="">
9
+ <meta name="viewport" content="width=device-width, initial-scale=1">
10
+ <%= csrf_meta_tag %>
11
+
12
+ <!-- External CSS -->
13
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
14
+
15
+ <!-- App CSS -->
16
+ <%= stylesheet_link_tag 'application', media: 'all' %>
17
+
18
+ <!-- External JS -->
19
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
20
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js"></script>
21
+
22
+ <!-- App JS -->
23
+ <%= javascript_include_tag "darjeelink/application" %>
24
+
25
+ <%= content_for :script_files %>
26
+
27
+ </head>
28
+
29
+ <body>
30
+
31
+ <div class="container-fluid <% if @wide_container %>wide-container<% end %>">
32
+ <%= yield %>
33
+ </div>
34
+
35
+ <%= content_for :render_async %>
36
+
37
+ </body>
38
+
39
+ </html>
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Do something smarter with these so that they can be overwritten an initializer?
4
+ Darjeelink.configure do |config|
5
+ config.domain = ENV['DOMAIN']
6
+
7
+ config.source_mediums = {
8
+ 'email-blast': 'Email blast',
9
+ 'email-thankyou': 'Email - Thank you',
10
+ 'facebook-post': 'Facebook post',
11
+ 'facebook-advert': 'Facebook advert',
12
+ 'twitter-tweet': 'Twitter tweet',
13
+ 'twitter-advert': 'Twitter advert',
14
+ 'sms-blast': 'SMS Blast',
15
+ 'google-advert': 'Google advert',
16
+ 'instagram-advert': 'Instagram Advert',
17
+ 'chatbot': 'Chatbot',
18
+ 'template': 'Template',
19
+ 'other': 'Other',
20
+ 'spotify': 'Spotify',
21
+ 'youtube': 'Youtube',
22
+ 'google-search': 'Google search',
23
+ 'google-display': 'Google display'
24
+ }
25
+
26
+ config.auth_domain = ENV['AUTH_DOMAIN']
27
+
28
+ config.rebrandly_api_key = ENV['REBRANDLY_API_KEY']
29
+
30
+ config.fallback_url = ENV['FALLBACK_URL']
31
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.config.middleware.use OmniAuth::Builder do
4
+ OmniAuth.config.allowed_request_methods = [:post]
5
+ provider(
6
+ :google_oauth2,
7
+ ENV['GOOGLE_API_CLIENT_ID'],
8
+ ENV['GOOGLE_API_CLIENT_SECRET']
9
+ )
10
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rebrandly.configure do |config|
4
+ config.api_key = Darjeelink.rebrandly_api_key
5
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ Darjeelink::Engine.routes.draw do
4
+ root 'short_links#index'
5
+
6
+ resources :short_links
7
+ resources :tracking_links, only: :new
8
+
9
+ # OmniAuth
10
+ get '/auth/:provider/callback', to: 'sessions#create'
11
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreatePortkeyShortLinks < ActiveRecord::Migration[5.2]
4
+ def change
5
+ create_table :portkey_short_links do |t|
6
+ t.string :url, null: false
7
+ t.string :shortened_path
8
+ t.integer :visits, null: false, default: 0
9
+
10
+ t.timestamps
11
+ end
12
+
13
+ add_index(:portkey_short_links, :url)
14
+ add_index(:portkey_short_links, :shortened_path, unique: true)
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CaseInsensitiveIndexShortLinkShortenedPath < ActiveRecord::Migration[5.2]
4
+ def up
5
+ remove_index(:portkey_short_links, :shortened_path)
6
+ execute 'CREATE UNIQUE INDEX index_portkey_short_links_on_lowercase_shortened_path
7
+ ON portkey_short_links USING btree (lower(shortened_path));'
8
+ end
9
+
10
+ def down
11
+ execute 'DROP INDEX index_portkey_short_links_on_lowercase_shortened_path;'
12
+ add_index(:portkey_short_links, :shortened_path, unique: true)
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RenamePortkeyShortLinksToDarjeelinkShortLinks < ActiveRecord::Migration[5.2]
4
+ def change
5
+ rename_table :portkey_short_links, :darjeelink_short_links
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RenamePortkeyShortLinkIndex < ActiveRecord::Migration[5.2]
4
+ def up
5
+ execute 'DROP INDEX index_portkey_short_links_on_lowercase_shortened_path;'
6
+ execute 'CREATE UNIQUE INDEX index_darjeelink_short_links_on_lowercase_shortened_path
7
+ ON darjeelink_short_links USING btree (lower(shortened_path));'
8
+ end
9
+
10
+ def down
11
+ execute 'DROP INDEX index_darjeelink_short_links_on_lowercase_shortened_path;'
12
+ execute 'CREATE UNIQUE INDEX index_portkey_short_links_on_lowercase_shortened_path
13
+ ON portkey_short_links USING btree (lower(shortened_path));'
14
+ end
15
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rebrandly'
4
+
5
+ require 'will_paginate'
6
+ require 'will_paginate/active_record'
7
+
8
+ require 'omniauth'
9
+ require 'omniauth-google-oauth2'
10
+
11
+ require 'darjeelink/engine'
12
+ require 'darjeelink/configuration'
13
+
14
+ module Darjeelink
15
+ class << self
16
+ delegate :domain, to: :configuration
17
+ delegate :source_mediums, to: :configuration
18
+ delegate :auth_domain, to: :configuration
19
+ delegate :rebrandly_api_key, to: :configuration
20
+ delegate :fallback_url, to: :configuration
21
+
22
+ def configuration
23
+ @configuration ||= Configuration.new
24
+ end
25
+
26
+ def configure
27
+ yield(configuration)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Darjeelink
4
+ class Configuration
5
+ attr_accessor :domain
6
+ attr_accessor :source_mediums
7
+ attr_accessor :auth_domain
8
+ attr_accessor :rebrandly_api_key
9
+ attr_accessor :fallback_url
10
+
11
+ def initialize
12
+ @domain = nil
13
+ @source_mediums = nil
14
+ @auth_domain = nil
15
+ @rebrandly_api_key = nil
16
+ @fallback_url = nil
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Darjeelink
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace Darjeelink
6
+
7
+ initializer :append_migrations do |app|
8
+ unless app.root.to_s.match? root.to_s
9
+ config.paths['db/migrate'].expanded.each do |expanded_path|
10
+ app.config.paths['db/migrate'] << expanded_path
11
+ end
12
+ end
13
+ end
14
+
15
+ config.generators do |g|
16
+ g.test_framework :rspec
17
+ end
18
+
19
+ initializer 'darjeelink.assets.precompile' do |app|
20
+ app.config.assets.precompile += %w[darjeelink/tracking_link_generator.js]
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Darjeelink
4
+ VERSION = '0.11.5'
5
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # desc "Explaining what the task does"
4
+ # task :darjeelink do
5
+ # # Task goes here
6
+ # end
metadata ADDED
@@ -0,0 +1,250 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: darjeelink
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.11.5
5
+ platform: ruby
6
+ authors:
7
+ - James Hulme
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-05-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bitly
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-google-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pg
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 5.2.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 5.2.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: rebrandly
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: repost
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: will_paginate
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: awesome_print
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: bundler-audit
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: dotenv-rails
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rspec-rails
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rubocop
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ description:
182
+ email:
183
+ - james@38degrees.org.uk
184
+ executables: []
185
+ extensions: []
186
+ extra_rdoc_files: []
187
+ files:
188
+ - MIT-LICENSE
189
+ - README.md
190
+ - Rakefile
191
+ - app/assets/config/darjeelink_manifest.js
192
+ - app/assets/javascripts/darjeelink/application.js
193
+ - app/assets/javascripts/darjeelink/sparkleh.js
194
+ - app/assets/javascripts/darjeelink/tracking_link_generator.js
195
+ - app/assets/stylesheets/darjeelink/application.css
196
+ - app/controllers/darjeelink/application_controller.rb
197
+ - app/controllers/darjeelink/sessions_controller.rb
198
+ - app/controllers/darjeelink/short_links_controller.rb
199
+ - app/controllers/darjeelink/tracking_links_controller.rb
200
+ - app/helpers/darjeelink/application_helper.rb
201
+ - app/importers/darjeelink/rebrandly_importer.rb
202
+ - app/importers/darjeelink/short_link_importer.rb
203
+ - app/jobs/darjeelink/application_job.rb
204
+ - app/mailers/darjeelink/application_mailer.rb
205
+ - app/models/darjeelink/application_record.rb
206
+ - app/models/darjeelink/short_link.rb
207
+ - app/views/darjeelink/short_links/_short_link_form.erb
208
+ - app/views/darjeelink/short_links/edit.html.erb
209
+ - app/views/darjeelink/short_links/index.html.erb
210
+ - app/views/darjeelink/short_links/new.html.erb
211
+ - app/views/darjeelink/tracking_links/new.erb
212
+ - app/views/layouts/darjeelink/application.html.erb
213
+ - config/initializers/darjeelink.rb
214
+ - config/initializers/omniauth.rb
215
+ - config/initializers/rebrandly.rb
216
+ - config/routes.rb
217
+ - db/migrate/20190103122918_create_portkey_short_links.rb
218
+ - db/migrate/20190304094710_case_insensitive_index_short_link_shortened_path.rb
219
+ - db/migrate/20200505220716_rename_portkey_short_links_to_darjeelink_short_links.rb
220
+ - db/migrate/20200505221026_rename_portkey_short_link_index.rb
221
+ - lib/darjeelink.rb
222
+ - lib/darjeelink/configuration.rb
223
+ - lib/darjeelink/engine.rb
224
+ - lib/darjeelink/version.rb
225
+ - lib/tasks/darjeelink.rake
226
+ homepage: https://www.github.com/the-open
227
+ licenses:
228
+ - MIT
229
+ metadata: {}
230
+ post_install_message:
231
+ rdoc_options: []
232
+ require_paths:
233
+ - lib
234
+ required_ruby_version: !ruby/object:Gem::Requirement
235
+ requirements:
236
+ - - ">="
237
+ - !ruby/object:Gem::Version
238
+ version: '0'
239
+ required_rubygems_version: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - ">="
242
+ - !ruby/object:Gem::Version
243
+ version: '0'
244
+ requirements: []
245
+ rubyforge_project:
246
+ rubygems_version: 2.7.8
247
+ signing_key:
248
+ specification_version: 4
249
+ summary: URL Shortener
250
+ test_files: []