ad_space 0.1.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/Gemfile +22 -0
- data/Gemfile.lock +240 -0
- data/MIT-LICENSE +20 -0
- data/README.md +92 -0
- data/Rakefile +8 -0
- data/ad_space.gemspec +25 -0
- data/app/assets/builds/application.js +7397 -0
- data/app/assets/builds/application.js.map +7 -0
- data/app/assets/config/ad_space_manifest.js +2 -0
- data/app/assets/javascript/ad_space/application.js +0 -0
- data/app/assets/stylesheets/ad_space/application.css +15 -0
- data/app/controllers/ad_space/advertisements_controller.rb +121 -0
- data/app/controllers/ad_space/api/v1/advertisements_controller.rb +36 -0
- data/app/controllers/ad_space/application_controller.rb +30 -0
- data/app/controllers/ad_space/dashboard_controller.rb +6 -0
- data/app/controllers/ad_space/slots_controller.rb +70 -0
- data/app/helpers/ad_space/advertisements_helper.rb +4 -0
- data/app/helpers/ad_space/application_helper.rb +15 -0
- data/app/helpers/ad_space/dashboard_helper.rb +4 -0
- data/app/helpers/ad_space/slots_helper.rb +4 -0
- data/app/javascript/application.js +3 -0
- data/app/javascript/controllers/application.js +9 -0
- data/app/javascript/controllers/hello_controller.js +153 -0
- data/app/javascript/controllers/image_upload_controller.js +46 -0
- data/app/javascript/controllers/index.js +11 -0
- data/app/jobs/ad_space/application_job.rb +4 -0
- data/app/mailers/ad_space/application_mailer.rb +6 -0
- data/app/models/ad_space/advertisement.rb +67 -0
- data/app/models/ad_space/application_record.rb +5 -0
- data/app/models/ad_space/breadcrumb.rb +14 -0
- data/app/models/ad_space/slot.rb +27 -0
- data/app/serializers/v1/advertisement_serializer.rb +30 -0
- data/app/validators/url_or_custom_scheme_validator.rb +20 -0
- data/app/views/ad_space/advertisements/_advertisement.html.erb +102 -0
- data/app/views/ad_space/advertisements/_form.html.erb +143 -0
- data/app/views/ad_space/advertisements/edit.html.erb +10 -0
- data/app/views/ad_space/advertisements/index.html.erb +15 -0
- data/app/views/ad_space/advertisements/new.html.erb +9 -0
- data/app/views/ad_space/advertisements/show.html.erb +13 -0
- data/app/views/ad_space/dashboard/index.html.erb +7 -0
- data/app/views/ad_space/slots/_form.html.erb +44 -0
- data/app/views/ad_space/slots/_slot.html.erb +30 -0
- data/app/views/ad_space/slots/edit.html.erb +10 -0
- data/app/views/ad_space/slots/index.html.erb +14 -0
- data/app/views/ad_space/slots/new.html.erb +9 -0
- data/app/views/ad_space/slots/show.html.erb +10 -0
- data/app/views/layouts/ad_space/application.html.erb +43 -0
- data/config/routes.rb +22 -0
- data/db/migrate/20231026152912_create_ad_space_slots.rb +11 -0
- data/db/migrate/20231026160758_create_ad_space_advertisements.rb +25 -0
- data/db/migrate/20231027070536_add_scheme_url_to_ad_space_advertisements.rb +10 -0
- data/db/migrate/20231027083935_add_target_version_code_to_ad_space_advertisements.rb +6 -0
- data/db/migrate/20231027115707_add_is_splash_to_ad_space_slots.rb +5 -0
- data/lib/ad_space/app.rb +16 -0
- data/lib/ad_space/configuration.rb +32 -0
- data/lib/ad_space/engine.rb +12 -0
- data/lib/ad_space/version.rb +3 -0
- data/lib/ad_space.rb +17 -0
- data/lib/tasks/ad_space_tasks.rake +4 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a12f9c56d13a27770794f6a45cbcfeab74b967ac816f80c64c71dff93a2bca1e
|
4
|
+
data.tar.gz: 4c2a6883b683c9ea101b18761c441bbfa03840d42ed30b5503f5167463e1b3a4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6f50e5b0cac4b17d987d2bc5e44dd2a685628cadeec7e280be3605f21e4bafc2020b8ce8d1d47e8af8d8e9cbe144c09a8c657c0dd1a5ce047fdec7b8a8e0d745
|
7
|
+
data.tar.gz: 30e0cb33ac32f287f6b8607d81c627736705ea177cdb0af138403cc63db09a1662bf6e9f7b56f09d601e894d1847616442bc12c7f4cb26a1d750635e7c7abaf1
|
data/Gemfile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
3
|
+
|
4
|
+
# Specify your gem's dependencies in ad_space.gemspec.
|
5
|
+
gemspec
|
6
|
+
|
7
|
+
gem "puma"
|
8
|
+
|
9
|
+
gem "sqlite3"
|
10
|
+
|
11
|
+
gem "sprockets-rails"
|
12
|
+
|
13
|
+
# Start debugger with binding.b [https://github.com/ruby/debug]
|
14
|
+
gem "debug", ">= 1.0.0"
|
15
|
+
|
16
|
+
gem 'jsbundling-rails'
|
17
|
+
gem 'cssbundling-rails'
|
18
|
+
gem 'stimulus-rails'
|
19
|
+
|
20
|
+
group :development do
|
21
|
+
gem "pg"
|
22
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,240 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ad_space (0.1.0)
|
5
|
+
active_model_serializers
|
6
|
+
dotenv-rails
|
7
|
+
rails (>= 7.1.1)
|
8
|
+
turbo-rails
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
actioncable (7.1.1)
|
14
|
+
actionpack (= 7.1.1)
|
15
|
+
activesupport (= 7.1.1)
|
16
|
+
nio4r (~> 2.0)
|
17
|
+
websocket-driver (>= 0.6.1)
|
18
|
+
zeitwerk (~> 2.6)
|
19
|
+
actionmailbox (7.1.1)
|
20
|
+
actionpack (= 7.1.1)
|
21
|
+
activejob (= 7.1.1)
|
22
|
+
activerecord (= 7.1.1)
|
23
|
+
activestorage (= 7.1.1)
|
24
|
+
activesupport (= 7.1.1)
|
25
|
+
mail (>= 2.7.1)
|
26
|
+
net-imap
|
27
|
+
net-pop
|
28
|
+
net-smtp
|
29
|
+
actionmailer (7.1.1)
|
30
|
+
actionpack (= 7.1.1)
|
31
|
+
actionview (= 7.1.1)
|
32
|
+
activejob (= 7.1.1)
|
33
|
+
activesupport (= 7.1.1)
|
34
|
+
mail (~> 2.5, >= 2.5.4)
|
35
|
+
net-imap
|
36
|
+
net-pop
|
37
|
+
net-smtp
|
38
|
+
rails-dom-testing (~> 2.2)
|
39
|
+
actionpack (7.1.1)
|
40
|
+
actionview (= 7.1.1)
|
41
|
+
activesupport (= 7.1.1)
|
42
|
+
nokogiri (>= 1.8.5)
|
43
|
+
rack (>= 2.2.4)
|
44
|
+
rack-session (>= 1.0.1)
|
45
|
+
rack-test (>= 0.6.3)
|
46
|
+
rails-dom-testing (~> 2.2)
|
47
|
+
rails-html-sanitizer (~> 1.6)
|
48
|
+
actiontext (7.1.1)
|
49
|
+
actionpack (= 7.1.1)
|
50
|
+
activerecord (= 7.1.1)
|
51
|
+
activestorage (= 7.1.1)
|
52
|
+
activesupport (= 7.1.1)
|
53
|
+
globalid (>= 0.6.0)
|
54
|
+
nokogiri (>= 1.8.5)
|
55
|
+
actionview (7.1.1)
|
56
|
+
activesupport (= 7.1.1)
|
57
|
+
builder (~> 3.1)
|
58
|
+
erubi (~> 1.11)
|
59
|
+
rails-dom-testing (~> 2.2)
|
60
|
+
rails-html-sanitizer (~> 1.6)
|
61
|
+
active_model_serializers (0.10.14)
|
62
|
+
actionpack (>= 4.1)
|
63
|
+
activemodel (>= 4.1)
|
64
|
+
case_transform (>= 0.2)
|
65
|
+
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
|
66
|
+
activejob (7.1.1)
|
67
|
+
activesupport (= 7.1.1)
|
68
|
+
globalid (>= 0.3.6)
|
69
|
+
activemodel (7.1.1)
|
70
|
+
activesupport (= 7.1.1)
|
71
|
+
activerecord (7.1.1)
|
72
|
+
activemodel (= 7.1.1)
|
73
|
+
activesupport (= 7.1.1)
|
74
|
+
timeout (>= 0.4.0)
|
75
|
+
activestorage (7.1.1)
|
76
|
+
actionpack (= 7.1.1)
|
77
|
+
activejob (= 7.1.1)
|
78
|
+
activerecord (= 7.1.1)
|
79
|
+
activesupport (= 7.1.1)
|
80
|
+
marcel (~> 1.0)
|
81
|
+
activesupport (7.1.1)
|
82
|
+
base64
|
83
|
+
bigdecimal
|
84
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
85
|
+
connection_pool (>= 2.2.5)
|
86
|
+
drb
|
87
|
+
i18n (>= 1.6, < 2)
|
88
|
+
minitest (>= 5.1)
|
89
|
+
mutex_m
|
90
|
+
tzinfo (~> 2.0)
|
91
|
+
base64 (0.1.1)
|
92
|
+
bigdecimal (3.1.4)
|
93
|
+
builder (3.2.4)
|
94
|
+
case_transform (0.2)
|
95
|
+
activesupport
|
96
|
+
concurrent-ruby (1.2.2)
|
97
|
+
connection_pool (2.4.1)
|
98
|
+
crass (1.0.6)
|
99
|
+
cssbundling-rails (1.3.3)
|
100
|
+
railties (>= 6.0.0)
|
101
|
+
date (3.3.3)
|
102
|
+
debug (1.8.0)
|
103
|
+
irb (>= 1.5.0)
|
104
|
+
reline (>= 0.3.1)
|
105
|
+
dotenv (2.8.1)
|
106
|
+
dotenv-rails (2.8.1)
|
107
|
+
dotenv (= 2.8.1)
|
108
|
+
railties (>= 3.2)
|
109
|
+
drb (2.1.1)
|
110
|
+
ruby2_keywords
|
111
|
+
erubi (1.12.0)
|
112
|
+
globalid (1.2.1)
|
113
|
+
activesupport (>= 6.1)
|
114
|
+
i18n (1.14.1)
|
115
|
+
concurrent-ruby (~> 1.0)
|
116
|
+
io-console (0.6.0)
|
117
|
+
irb (1.8.3)
|
118
|
+
rdoc
|
119
|
+
reline (>= 0.3.8)
|
120
|
+
jsbundling-rails (1.2.1)
|
121
|
+
railties (>= 6.0.0)
|
122
|
+
jsonapi-renderer (0.2.2)
|
123
|
+
loofah (2.21.4)
|
124
|
+
crass (~> 1.0.2)
|
125
|
+
nokogiri (>= 1.12.0)
|
126
|
+
mail (2.8.1)
|
127
|
+
mini_mime (>= 0.1.1)
|
128
|
+
net-imap
|
129
|
+
net-pop
|
130
|
+
net-smtp
|
131
|
+
marcel (1.0.2)
|
132
|
+
mini_mime (1.1.5)
|
133
|
+
minitest (5.20.0)
|
134
|
+
mutex_m (0.1.2)
|
135
|
+
net-imap (0.4.2)
|
136
|
+
date
|
137
|
+
net-protocol
|
138
|
+
net-pop (0.1.2)
|
139
|
+
net-protocol
|
140
|
+
net-protocol (0.2.1)
|
141
|
+
timeout
|
142
|
+
net-smtp (0.4.0)
|
143
|
+
net-protocol
|
144
|
+
nio4r (2.5.9)
|
145
|
+
nokogiri (1.15.4-x86_64-darwin)
|
146
|
+
racc (~> 1.4)
|
147
|
+
nokogiri (1.15.4-x86_64-linux)
|
148
|
+
racc (~> 1.4)
|
149
|
+
pg (1.5.4)
|
150
|
+
psych (5.1.1.1)
|
151
|
+
stringio
|
152
|
+
puma (6.4.0)
|
153
|
+
nio4r (~> 2.0)
|
154
|
+
racc (1.7.1)
|
155
|
+
rack (3.0.8)
|
156
|
+
rack-session (2.0.0)
|
157
|
+
rack (>= 3.0.0)
|
158
|
+
rack-test (2.1.0)
|
159
|
+
rack (>= 1.3)
|
160
|
+
rackup (2.1.0)
|
161
|
+
rack (>= 3)
|
162
|
+
webrick (~> 1.8)
|
163
|
+
rails (7.1.1)
|
164
|
+
actioncable (= 7.1.1)
|
165
|
+
actionmailbox (= 7.1.1)
|
166
|
+
actionmailer (= 7.1.1)
|
167
|
+
actionpack (= 7.1.1)
|
168
|
+
actiontext (= 7.1.1)
|
169
|
+
actionview (= 7.1.1)
|
170
|
+
activejob (= 7.1.1)
|
171
|
+
activemodel (= 7.1.1)
|
172
|
+
activerecord (= 7.1.1)
|
173
|
+
activestorage (= 7.1.1)
|
174
|
+
activesupport (= 7.1.1)
|
175
|
+
bundler (>= 1.15.0)
|
176
|
+
railties (= 7.1.1)
|
177
|
+
rails-dom-testing (2.2.0)
|
178
|
+
activesupport (>= 5.0.0)
|
179
|
+
minitest
|
180
|
+
nokogiri (>= 1.6)
|
181
|
+
rails-html-sanitizer (1.6.0)
|
182
|
+
loofah (~> 2.21)
|
183
|
+
nokogiri (~> 1.14)
|
184
|
+
railties (7.1.1)
|
185
|
+
actionpack (= 7.1.1)
|
186
|
+
activesupport (= 7.1.1)
|
187
|
+
irb
|
188
|
+
rackup (>= 1.0.0)
|
189
|
+
rake (>= 12.2)
|
190
|
+
thor (~> 1.0, >= 1.2.2)
|
191
|
+
zeitwerk (~> 2.6)
|
192
|
+
rake (13.0.6)
|
193
|
+
rdoc (6.5.0)
|
194
|
+
psych (>= 4.0.0)
|
195
|
+
reline (0.3.9)
|
196
|
+
io-console (~> 0.5)
|
197
|
+
ruby2_keywords (0.0.5)
|
198
|
+
sprockets (4.2.1)
|
199
|
+
concurrent-ruby (~> 1.0)
|
200
|
+
rack (>= 2.2.4, < 4)
|
201
|
+
sprockets-rails (3.4.2)
|
202
|
+
actionpack (>= 5.2)
|
203
|
+
activesupport (>= 5.2)
|
204
|
+
sprockets (>= 3.0.0)
|
205
|
+
sqlite3 (1.6.3-x86_64-darwin)
|
206
|
+
sqlite3 (1.6.3-x86_64-linux)
|
207
|
+
stimulus-rails (1.3.0)
|
208
|
+
railties (>= 6.0.0)
|
209
|
+
stringio (3.0.8)
|
210
|
+
thor (1.3.0)
|
211
|
+
timeout (0.4.0)
|
212
|
+
turbo-rails (1.5.0)
|
213
|
+
actionpack (>= 6.0.0)
|
214
|
+
activejob (>= 6.0.0)
|
215
|
+
railties (>= 6.0.0)
|
216
|
+
tzinfo (2.0.6)
|
217
|
+
concurrent-ruby (~> 1.0)
|
218
|
+
webrick (1.8.1)
|
219
|
+
websocket-driver (0.7.6)
|
220
|
+
websocket-extensions (>= 0.1.0)
|
221
|
+
websocket-extensions (0.1.5)
|
222
|
+
zeitwerk (2.6.12)
|
223
|
+
|
224
|
+
PLATFORMS
|
225
|
+
x86_64-darwin-20
|
226
|
+
x86_64-linux
|
227
|
+
|
228
|
+
DEPENDENCIES
|
229
|
+
ad_space!
|
230
|
+
cssbundling-rails
|
231
|
+
debug (>= 1.0.0)
|
232
|
+
jsbundling-rails
|
233
|
+
pg
|
234
|
+
puma
|
235
|
+
sprockets-rails
|
236
|
+
sqlite3
|
237
|
+
stimulus-rails
|
238
|
+
|
239
|
+
BUNDLED WITH
|
240
|
+
2.4.13
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 42up
|
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/README.md
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# AdSpace
|
2
|
+
|
3
|
+
## 使用前提
|
4
|
+
- 数据库类型 postgresql
|
5
|
+
- 开启了 active storage
|
6
|
+
|
7
|
+
## 参数说明
|
8
|
+
### weight
|
9
|
+
排序按照权重值逆序排列,越大显示位置约考前
|
10
|
+
|
11
|
+
### ad_type
|
12
|
+
ad_type 分为 custom(自定义), dsp(三方SDK广告)
|
13
|
+
|
14
|
+
#### custom
|
15
|
+
自定义类型,当广告位custom,则下面字段可以生效:
|
16
|
+
- cover_base
|
17
|
+
- cover_sm
|
18
|
+
- cover_md
|
19
|
+
- cover_lg
|
20
|
+
- scheme_url, 跳转路径
|
21
|
+
- splash_ui_type, 开屏样式,half, full
|
22
|
+
- splash_countdown 开屏倒计时
|
23
|
+
- visibility 广告可见性 all, premium_member, regular_user
|
24
|
+
|
25
|
+
#### dsp
|
26
|
+
第三方SDK广告,则dsp_type生效,其返回值为如下:
|
27
|
+
- gdt 广点通
|
28
|
+
- jrtt 今日头条 穿山甲
|
29
|
+
- google 谷歌 adsense
|
30
|
+
|
31
|
+
dsp也可以展示在开屏中,所以下面2个参数也应该有效,视情况而定。
|
32
|
+
- splash_ui_type, 开屏样式,half, full
|
33
|
+
- splash_countdown 开屏倒计时
|
34
|
+
|
35
|
+
|
36
|
+
## 接口
|
37
|
+
#### 请求
|
38
|
+
```sh
|
39
|
+
GET ad_space/api/v1/ads
|
40
|
+
```
|
41
|
+
|
42
|
+
# TODO: 添加个header鉴权
|
43
|
+
|
44
|
+
#### 参数
|
45
|
+
- screen_width 屏幕宽度
|
46
|
+
- screen_height 屏幕高度
|
47
|
+
- platform 平台 ios、android
|
48
|
+
- slot_ids 位置id,逗号分隔字符串
|
49
|
+
- version_code 当前App版本号
|
50
|
+
|
51
|
+
#### 返回
|
52
|
+
```json
|
53
|
+
[]
|
54
|
+
```
|
55
|
+
|
56
|
+
## 开发
|
57
|
+
```
|
58
|
+
yarn build:js --watch
|
59
|
+
```
|
60
|
+
|
61
|
+
## 发布
|
62
|
+
```
|
63
|
+
yarn prod:build:js
|
64
|
+
rake release
|
65
|
+
```
|
66
|
+
|
67
|
+
## 安装
|
68
|
+
|
69
|
+
```sh
|
70
|
+
# Gemfile
|
71
|
+
gem 'ad_space', path: '/path/to/ad_space'
|
72
|
+
|
73
|
+
bundle install
|
74
|
+
./bin/rails ad_space:install:migrations
|
75
|
+
rails db:migrate
|
76
|
+
|
77
|
+
mount AdSpace::Engine => "/ad_space"
|
78
|
+
|
79
|
+
# - `User.admin?` 方法要存在
|
80
|
+
# - 用户登录状态要存在 `session[:user_id]` 变量中
|
81
|
+
# - 没有权限会直接返回到 main_app.root_path
|
82
|
+
```
|
83
|
+
|
84
|
+
## TODO
|
85
|
+
- i18n-task i18n中文化
|
86
|
+
- 预览广告功能,支持参数可以直接在手机端拉取自定广告,展示在特定的位置
|
87
|
+
- 效果指标统计功能
|
88
|
+
- 调整UI
|
89
|
+
- 接口支持 缓存
|
90
|
+
- toast 消息
|
91
|
+
- https://simplecss.org/
|
92
|
+
- tailwindcss
|
data/Rakefile
ADDED
data/ad_space.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative "lib/ad_space/version"
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "ad_space"
|
5
|
+
spec.version = AdSpace::VERSION
|
6
|
+
spec.authors = ["42up"]
|
7
|
+
spec.email = ["foobar@v2up.com"]
|
8
|
+
spec.homepage = "https://github.com/42up/ad_space.git"
|
9
|
+
spec.summary = "AdSpace"
|
10
|
+
spec.description = "AdSpace"
|
11
|
+
spec.license = "MIT"
|
12
|
+
|
13
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
14
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
15
|
+
spec.metadata["changelog_uri"] = spec.homepage
|
16
|
+
|
17
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
18
|
+
Dir["{app,config,db,lib, public}/**/*", "MIT-LICENSE", "Rakefile", "README.md", "Gemfile", "Gemfile.lock", "ad_space.gemspec"]
|
19
|
+
end
|
20
|
+
|
21
|
+
spec.add_dependency "rails", ">= 7.1.1"
|
22
|
+
spec.add_dependency "active_model_serializers"
|
23
|
+
spec.add_dependency "turbo-rails"
|
24
|
+
spec.add_dependency "dotenv-rails"
|
25
|
+
end
|