station 0.0.145 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nexmo_developer/Gemfile +6 -0
  3. data/lib/nexmo_developer/Gemfile.lock +8 -0
  4. data/lib/nexmo_developer/app/assets/stylesheets/{application.css → application.scss} +2 -0
  5. data/lib/nexmo_developer/app/assets/stylesheets/blog/badge.scss +245 -0
  6. data/lib/nexmo_developer/app/assets/stylesheets/blog/blog.scss +209 -0
  7. data/lib/nexmo_developer/app/controllers/blog/authors_controller.rb +8 -0
  8. data/lib/nexmo_developer/app/controllers/blog/blogpost_controller.rb +32 -0
  9. data/lib/nexmo_developer/app/controllers/blog/categories_controller.rb +8 -0
  10. data/lib/nexmo_developer/app/controllers/blog/main_controller.rb +9 -0
  11. data/lib/nexmo_developer/app/controllers/blog/tags_controller.rb +8 -0
  12. data/lib/nexmo_developer/app/helpers/blog_helper.rb +7 -0
  13. data/lib/nexmo_developer/app/models/blog/author.rb +59 -0
  14. data/lib/nexmo_developer/app/models/blog/blogpost.rb +68 -0
  15. data/lib/nexmo_developer/app/models/blog/category.rb +25 -0
  16. data/lib/nexmo_developer/app/services/author_parser.rb +61 -0
  17. data/lib/nexmo_developer/app/services/blogpost_parser.rb +57 -0
  18. data/lib/nexmo_developer/app/services/category_parser.rb +19 -0
  19. data/lib/nexmo_developer/app/services/tag_parser.rb +38 -0
  20. data/lib/nexmo_developer/app/views/blog/authors/_social_links.html.erb +67 -0
  21. data/lib/nexmo_developer/app/views/blog/authors/show.html.erb +46 -0
  22. data/lib/nexmo_developer/app/views/blog/blogpost/_blogpost.html.erb +74 -0
  23. data/lib/nexmo_developer/app/views/blog/blogpost/_blogpost_with_image.html.erb +59 -0
  24. data/lib/nexmo_developer/app/views/blog/blogpost/_tag_labels.html.erb +20 -0
  25. data/lib/nexmo_developer/app/views/blog/blogpost/index.html.erb +43 -0
  26. data/lib/nexmo_developer/app/views/blog/blogpost/show.html.erb +127 -0
  27. data/lib/nexmo_developer/app/views/blog/categories/show.html.erb +25 -0
  28. data/lib/nexmo_developer/app/views/blog/tags/show.html.erb +25 -0
  29. data/lib/nexmo_developer/app/views/layouts/application.html.erb +1 -1
  30. data/lib/nexmo_developer/app/views/layouts/partials/_header.html.erb +0 -3
  31. data/lib/nexmo_developer/config/application.rb +1 -0
  32. data/lib/nexmo_developer/config/routes.rb +9 -1
  33. data/lib/nexmo_developer/lib/tasks/blog.rake +12 -0
  34. data/lib/nexmo_developer/public/assets/.sprockets-manifest-3f3d4eafc3f8d9771fa4ba3f13084baf.json +1 -0
  35. data/lib/nexmo_developer/public/assets/application-aa88b3c7bd34ec529f43849541752fda7c9c202aa9fff905be578ef88d103b46.js.gz +0 -0
  36. data/lib/nexmo_developer/public/assets/{application-6e9186f7602070c57b5c60de9b45ad12f1fccdcf83e08ea28c809d7a5a42a232.css → application-d9ea3be5cba4feaa1cbe4f50a2d73a7cd19cbc1658778180d3cd3890a0dd6ed0.css} +1 -1
  37. data/lib/nexmo_developer/public/assets/application-d9ea3be5cba4feaa1cbe4f50a2d73a7cd19cbc1658778180d3cd3890a0dd6ed0.css.gz +0 -0
  38. data/lib/nexmo_developer/public/assets/manifest-b4bf6e57a53c2bdb55b8998cc94cd00883793c1c37c5e5aea3ef6749b4f6d92b.js.gz +0 -0
  39. data/lib/nexmo_developer/version.rb +1 -1
  40. metadata +31 -6
  41. data/lib/nexmo_developer/public/assets/.sprockets-manifest-cbc98735a38ce872d5ca075ef4d92ef7.json +0 -1
  42. data/lib/nexmo_developer/public/assets/application-6e9186f7602070c57b5c60de9b45ad12f1fccdcf83e08ea28c809d7a5a42a232.css.gz +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf19ece7e99c058c80d1e930a5ba8a764043085f80cbcc5cd5aa89e4fcb6121e
4
- data.tar.gz: 9e9fc51a8579f6b77b2a112616c35547b8f12b4c75bed40aed71ce736dfef727
3
+ metadata.gz: 7026b61938f7c15334d21fba932497479059ee788f8929e6dff75fa5f6952644
4
+ data.tar.gz: 9fc137c36e9f86be4b77b0299136393043ec3f871e8dc44d2e0c0ce5dacf1431
5
5
  SHA512:
6
- metadata.gz: 76b4e6cfca0ece477ff5855ee40d8b21e9a5252927cfa9ef3a9218cda1a49d917fbb100293df679a288094b2baa4aef9c9c3873c06e7aab614140077dcd161bb
7
- data.tar.gz: 3badd1111779f92524c07921d20ce7d99cf6750441d31e220b974745c9e5d0920a04df19c52f8bb1bb204fdc5b55720ad1936cfdd582faecd781670813249e40
6
+ metadata.gz: ece3452d41faa4062cd7da89547c5f6d2d39155e062f041c68b2e5f94761cdf0a6f529a8df7a83dbbf4c37ac0989b4a0b30d2750dc0962a7363112bde20f0450
7
+ data.tar.gz: d7f55344de98ad0f64ad8e30f9b232e58a8648d7f9d35a1be10e7fbe5bc3a68a7b0438cf787cdf1085b33ab31f8e7eb56daee112030892d81c81de53773fd15e
@@ -95,6 +95,11 @@ gem 'bootsnap', require: false
95
95
  # Convenient diffing in ruby
96
96
  gem 'diffy', require: false
97
97
 
98
+ # Provides estimated reading times (for our Blog)
99
+ gem 'readingtime'
100
+
101
+ gem 'addressable', '~> 2.8', require: false
102
+
98
103
  # Automatic Ruby code style checking tool. Aims to enforce the community-driven Ruby Style Guide.
99
104
  gem 'rubocop', '~> 1.10.0', require: false
100
105
  gem 'rubocop-rails', '~> 2.9', require: false
@@ -146,6 +151,7 @@ group :development, :test do
146
151
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
147
152
  gem 'byebug', platform: :mri
148
153
  gem 'pry', require: false
154
+ gem 'rails-controller-testing'
149
155
  gem 'rawler', git: 'https://github.com/oscardelben/rawler.git', require: false
150
156
  gem 'rspec-collection_matchers'
151
157
  gem 'rspec-rails', '~> 5.0'
@@ -409,6 +409,10 @@ GEM
409
409
  bundler (>= 1.15.0)
410
410
  railties (= 6.1.4)
411
411
  sprockets-rails (>= 2.0.0)
412
+ rails-controller-testing (1.0.5)
413
+ actionpack (>= 5.0.1.rc1)
414
+ actionview (>= 5.0.1.rc1)
415
+ activesupport (>= 5.0.1.rc1)
412
416
  rails-dom-testing (2.0.3)
413
417
  activesupport (>= 4.2.0)
414
418
  nokogiri (>= 1.6)
@@ -429,6 +433,7 @@ GEM
429
433
  rb-fsevent (0.11.0)
430
434
  rb-inotify (0.10.1)
431
435
  ffi (~> 1.0)
436
+ readingtime (0.4.0)
432
437
  recaptcha (5.8.1)
433
438
  json
434
439
  redcarpet (3.5.1)
@@ -617,6 +622,7 @@ PLATFORMS
617
622
  DEPENDENCIES
618
623
  actionpack-page_caching!
619
624
  activeadmin (~> 2.9)
625
+ addressable (~> 2.8)
620
626
  algoliasearch
621
627
  apparition
622
628
  awesome_print
@@ -659,7 +665,9 @@ DEPENDENCIES
659
665
  puma (>= 5.3.1)
660
666
  rack (>= 2.0.6)
661
667
  rails (~> 6.1.4)
668
+ rails-controller-testing
662
669
  rawler!
670
+ readingtime
663
671
  recaptcha
664
672
  redis
665
673
  rest-client
@@ -1,5 +1,7 @@
1
1
  //= require stylesheets/nexmo-oas-renderer
2
2
 
3
+ @import "blog/*";
4
+
3
5
  .Adp-use-cases__background {
4
6
  filter: blur(100px);
5
7
  }
@@ -0,0 +1,245 @@
1
+ .Vlt-badge--dispatch-api,
2
+ .Vlt-badge--messages-api,
3
+ .Vlt-badge--messages-api-sandbox,
4
+ .Vlt-badge--number-insight-api,
5
+ .Vlt-badge--number-api,
6
+ .Vlt-badge--reports-api,
7
+ .Vlt-badge--account-api,
8
+ .Vlt-badge--pricing-api,
9
+ .Vlt-badge--external-accounts-api,
10
+ .Vlt-badge--redact-api,
11
+ .Vlt-badge--audit-api,
12
+ .Vlt-badge--verify-api,
13
+ .Vlt-badge--media-api,
14
+ .Vlt-badge--voice-api,
15
+ .Vlt-badge--conversation-api,
16
+ .Vlt-badge--video-api,
17
+ .Vlt-badge--sms-api,
18
+ .Vlt-badge--station {
19
+ background: black;
20
+ color: white;
21
+ }
22
+
23
+ .Vlt-badge--spotlight {
24
+ background-color: rgba(135, 31, 255, 1);
25
+ color: white;
26
+ }
27
+
28
+ .Vlt-badge--voyagers {
29
+ background-color: rgba(135, 31, 255, 1);
30
+ color: white;
31
+ }
32
+
33
+ .Vlt-badge--slack {
34
+ background: rgba(74, 21, 75, 0.4);
35
+ color: black;
36
+ }
37
+
38
+ .Vlt-badge--faunadb {
39
+ background: rgba(50, 63, 203, 0.4);
40
+ color: black;
41
+ }
42
+
43
+ .Vlt-badge--vue {
44
+ background-color: rgba(65, 184, 131, 0.4);
45
+ color: rgba(53, 73, 94, 1);
46
+ }
47
+
48
+ .Vlt-badge--nuxt {
49
+ background-color: rgba(0, 197, 142, 0.4);
50
+ color: black;
51
+ }
52
+
53
+ .Vlt-badge--ruby-on-rails,
54
+ .Vlt-badge--ruby {
55
+ background-color: rgba(204, 52, 45, 0.4);
56
+ color: black;
57
+ }
58
+
59
+ .Vlt-badge--javascript {
60
+ background-color: rgba(247, 223, 30, 0.4);
61
+ color: black;
62
+ }
63
+
64
+ .Vlt-badge--typescript {
65
+ background-color: rgba(49, 120, 198, 0.4);
66
+ color: black;
67
+ }
68
+
69
+ .Vlt-badge--dotnet {
70
+ background-color: rgba(93, 37, 144, 0.4);
71
+ color: black;
72
+ }
73
+
74
+ .Vlt-badge--node {
75
+ background-color: rgba(61, 136, 54, 0.4);
76
+ color: black;
77
+ }
78
+
79
+ .Vlt-badge--deno {
80
+ background: rgba(22, 30, 46, 0.4);
81
+ color: black;
82
+ }
83
+
84
+ .Vlt-badge--node-red {
85
+ background-color: rgba(142, 1, 0, 0.4);
86
+ color: black;
87
+ }
88
+
89
+ .Vlt-badge--azure {
90
+ background-color: rgba(0, 127, 255, 0.4);
91
+ color: black;
92
+ }
93
+
94
+ .Vlt-badge--zapier {
95
+ background-color: rgba(255, 74, 0, 0.4);
96
+ color: black;
97
+ }
98
+
99
+ .Vlt-badge--go {
100
+ background-color: rgba(224, 235, 245, 0.4);
101
+ color: black;
102
+ }
103
+
104
+ .Vlt-badge--php {
105
+ background-color: rgba(35, 161, 170, 0.4);
106
+ color: black;
107
+ }
108
+
109
+ .Vlt-badge--aws {
110
+ background-color: rgba(33, 43, 58, 0.4);
111
+ color: black;
112
+ }
113
+
114
+ .Vlt-badge--firebase {
115
+ background-color: rgba(255, 202, 40, 0.4);
116
+ color: black;
117
+ }
118
+
119
+ .Vlt-badge--zendesk {
120
+ background-color: rgba(3, 54, 61, 0.4);
121
+ color: black;
122
+ }
123
+
124
+ .Vlt-badge--ibm-watson {
125
+ background-color: rgba(0, 98, 255, 0.4);
126
+ color: black;
127
+ }
128
+
129
+ .Vlt-badge--git {
130
+ background-color: rgba(241, 78, 50, 0.4);
131
+ color: black;
132
+ }
133
+
134
+ .Vlt-badge--github {
135
+ content: 'GitHub';
136
+ background-color: rgba(51, 51, 51, 0.4);
137
+ color: black;
138
+ }
139
+
140
+ .Vlt-badge--hacktoberfest {
141
+ background-color: rgba(7, 37, 64, 0.4);
142
+ color: black;
143
+ }
144
+
145
+ .Vlt-badge--digitalocean {
146
+ background-color: rgba(0, 105, 255, 0.4);
147
+ color: black;
148
+ }
149
+
150
+ .Vlt-badge--java {
151
+ background-color: rgba(1, 71, 110, 0.4);
152
+ color: black;
153
+ }
154
+
155
+ .Vlt-badge--python {
156
+ background-color: rgba(30, 56, 187, 0.4);
157
+ color: black;
158
+ }
159
+
160
+ .Vlt-badge--mongodb {
161
+ background-color: rgba(19, 170, 82, 0.4);
162
+ color: black;
163
+ }
164
+
165
+ .Vlt-badge--netlify {
166
+ background: linear-gradient(
167
+ to bottom,
168
+ rgba(35, 194, 184, 0.4),
169
+ rgba(55, 175, 188, 0.4)
170
+ );
171
+ color: black;
172
+ }
173
+
174
+ .Vlt-badge--postman {
175
+ background: rgba(255, 108, 55, 0.4);
176
+ color: black;
177
+ }
178
+
179
+ .Vlt-badge--opensource {
180
+ background: rgba(61, 166, 57, 0.4);
181
+ color: black;
182
+ }
183
+
184
+ .Vlt-badge--react-native,
185
+ .Vlt-badge--react {
186
+ background: rgba(97, 218, 251, 0.4);
187
+ color: black;
188
+ }
189
+
190
+ .Vlt-badge--open-api {
191
+ background: rgba(56, 184, 50, 0.4);
192
+ color: black;
193
+ }
194
+
195
+ .Vlt-badge--inclusion {
196
+ background: linear-gradient(
197
+ 90deg,
198
+ black,
199
+ black 12.5%,
200
+ rgba(117, 77, 21, 1) 12.5%,
201
+ rgba(117, 77, 21, 1) 25%,
202
+ rgba(240, 0, 0, 1) 25%,
203
+ rgba(240, 0, 0, 1) 37.5%,
204
+ rgba(255, 128, 0, 1) 37.5%,
205
+ rgba(255, 128, 0, 1) 50%,
206
+ rgba(255, 255, 0, 1) 50%,
207
+ rgba(255, 255, 0, 1) 62.5%,
208
+ rgba(0, 121, 64, 1) 62.5%,
209
+ rgba(0, 121, 64, 1) 75%,
210
+ rgba(64, 64, 255, 1) 75%,
211
+ rgba(64, 64, 255, 1) 87.5%,
212
+ rgba(160, 0, 192, 1) 87.5%,
213
+ rgba(160, 0, 192, 1)
214
+ );
215
+ color: white;
216
+ text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5), -1px -1px 2px rgba(0, 0, 0, 0.5),
217
+ -1px 1px 2px rgba(0, 0, 0, 0.5), 1px -1px 2px rgba(0, 0, 0, 0.5);
218
+ }
219
+
220
+ .Vlt-badge--diversity {
221
+ background: linear-gradient(
222
+ 90deg,
223
+ rgba(85, 205, 252, 1),
224
+ rgba(85, 205, 252, 1) 20%,
225
+ rgba(247, 168, 184, 1) 20%,
226
+ rgba(247, 168, 184, 1) 40%,
227
+ white 40%,
228
+ white 60%,
229
+ rgba(247, 168, 184, 1) 60%,
230
+ rgba(247, 168, 184, 1) 80%,
231
+ rgba(85, 205, 252, 1) 80%,
232
+ rgba(85, 205, 252, 1) 100%
233
+ );
234
+ color: black;
235
+ text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.5),
236
+ -1px -1px 2px rgba(255, 255, 255, 0.5),
237
+ -1px 1px 2px rgba(255, 255, 255, 0.5), 1px -1px 2px rgba(255, 255, 255, 0.5);
238
+ }
239
+
240
+ // HOVER effect for TAG labels
241
+ a small[class*="Vlt-badge--"] {
242
+ transition: all .2s ease-in-out;
243
+
244
+ &:hover { transform: scale(1.1); }
245
+ }
@@ -0,0 +1,209 @@
1
+ .max-w-screen-xl {
2
+ max-width: 1280px;
3
+ }
4
+ .mx-auto {
5
+ margin-left: auto;
6
+ margin-right: auto;
7
+ }
8
+
9
+
10
+ // Author info column
11
+ #author-column {
12
+ width: 25%;
13
+ display: flex;
14
+ align-items: center;
15
+ flex-direction: column;
16
+ }
17
+
18
+
19
+ // High opacity gradient BG
20
+ .gradient-bg {
21
+ // background: linear-gradient(to right, rgba(127, 198, 244, .1), rgba(213, 39, 155, .1));
22
+ background: linear-gradient(135deg, rgba(127, 198, 244, 0.3), rgba(213, 39, 155, 0.1));
23
+ background-attachment: fixed;
24
+ min-height: 100vh;
25
+ }
26
+
27
+
28
+ // border-top gradient for Author BIO
29
+ .gradient-border-left {
30
+ border-left: 2px solid;
31
+ padding-left: 4px;
32
+ border-image: linear-gradient(to bottom, rgba(127, 198, 244, .8), rgba(213, 39, 155, .8)) 5;
33
+ }
34
+
35
+
36
+ // Category titles separator
37
+ .Vlt-text-separator span::before,
38
+ .Vlt-text-separator span::after {
39
+ background: linear-gradient(to right, #7fc6f4, #d5279b) !important;
40
+ }
41
+
42
+
43
+ // Header IMG on blogpost_with_image card
44
+ .card-header-image {
45
+ width: 100%;
46
+ height: 26rem;
47
+ background-size: cover;
48
+ background-position: center;
49
+ }
50
+
51
+
52
+ // Border radius top for blogpost_with_image partial
53
+ .border-radius-top {
54
+ border-top-right-radius: 8px !important;
55
+ border-top-left-radius: 8px !important;
56
+ border-bottom-left-radius: 0 !important;
57
+ border-bottom-right-radius: 0 !important;
58
+ }
59
+
60
+
61
+ // Center Author name
62
+ .center-author-name {
63
+ display: flex;
64
+ justify-content: center;
65
+ }
66
+
67
+
68
+ // image_tag Author
69
+ .image-tag-author {
70
+ display: block;
71
+ width: 4.5rem;
72
+ height: 4.5rem;
73
+ border-radius: 50%;
74
+ }
75
+
76
+ // < CATEGORY /> tag on blogposts
77
+ .category-name {
78
+ display: block;
79
+
80
+ padding: 16px 16px 0 16px;
81
+
82
+ font-size: 1.5rem;
83
+ line-height: 3.25rem;
84
+ font-weight: bold;
85
+ text-transform: uppercase;
86
+
87
+ // HOVER effect for CATEGORY labels
88
+ position: relative;
89
+ left: 0;
90
+ transition: all .2s ease-in-out;
91
+
92
+ &:hover { left: 5px; }
93
+ }
94
+
95
+
96
+ // Centering orizontally V-icon with text
97
+ .fix-position-V-icon {
98
+ position: relative;
99
+ left: 2px;
100
+ }
101
+
102
+
103
+ // Centering orizontally V-icon with text
104
+ .social-links {
105
+ text-align: center;
106
+ }
107
+
108
+
109
+ // Raw blogpost content in SHOW
110
+ .raw_blopost_content {
111
+ margin-top: 3em;
112
+
113
+ p {
114
+ font-size: 1.8rem;
115
+ letter-spacing: 0.5px;
116
+ color: #374151;
117
+ margin: 1em 0;
118
+
119
+ strong {
120
+ display: inline-block;
121
+ margin: 1em 0;
122
+ }
123
+ }
124
+ }
125
+
126
+
127
+ // Blogpost card content
128
+ .blogpost_card_content {
129
+ display: flex;
130
+ justify-content: space-between;
131
+ flex-direction: column;
132
+ flex-grow: 1;
133
+ }
134
+
135
+
136
+ // Category header separator
137
+ .author-title {
138
+ margin-bottom:16px;
139
+ text-align: center;
140
+ }
141
+
142
+
143
+ // Category header separator
144
+ .header-separator {
145
+ opacity: .6;
146
+ letter-spacing: .1em;
147
+ }
148
+
149
+
150
+ // display flex for card content
151
+ .d-flex-column {
152
+ display: flex;
153
+ justify-content: space-between;
154
+ flex-direction: column;
155
+ }
156
+
157
+
158
+ // CUSTOM GRID
159
+ .my-2col-grid {
160
+ display: grid !important;
161
+ grid-template-columns: repeat(2, 1fr) !important;
162
+ grid-auto-rows: 1fr !important;
163
+ grid-column-gap: 10px !important;
164
+ grid-row-gap: 10px !important;
165
+
166
+ .Vlt-card:hover {
167
+ -webkit-transform: none;
168
+ transform: none;
169
+ -webkit-box-shadow: 0 10px 30px rgba(19, 20, 21, .1);
170
+ box-shadow: 0 10px 30px rgba(19, 20, 21, .1);
171
+ transform: none;
172
+ }
173
+
174
+ .Vlt-card {
175
+ -webkit-box-shadow: none;
176
+ box-shadow: none;
177
+ border: 1px solid #e6e6e6;
178
+ -webkit-transition: -webkit-box-shadow ease-in 0.25s;
179
+ transition: -webkit-box-shadow ease-in 0.25s;
180
+ transition: box-shadow ease-in 0.25s;
181
+ transition: box-shadow ease-in 0.25s, -webkit-box-shadow ease-in 0.25s;
182
+ }
183
+ }
184
+
185
+ .my-3col-grid {
186
+ display: grid !important;
187
+ grid-template-columns: repeat(3, 1fr) !important;
188
+ grid-auto-rows: 1fr !important;
189
+ grid-column-gap: 10px !important;
190
+ grid-row-gap: 10px !important;
191
+
192
+ .Vlt-card:hover {
193
+ -webkit-transform: none;
194
+ transform: none;
195
+ -webkit-box-shadow: 0 10px 30px rgba(19, 20, 21, .1);
196
+ box-shadow: 0 10px 30px rgba(19, 20, 21, .1);
197
+ transform: none;
198
+ }
199
+
200
+ .Vlt-card {
201
+ -webkit-box-shadow: none;
202
+ box-shadow: none;
203
+ border: 1px solid #e6e6e6;
204
+ -webkit-transition: -webkit-box-shadow ease-in 0.25s;
205
+ transition: -webkit-box-shadow ease-in 0.25s;
206
+ transition: box-shadow ease-in 0.25s;
207
+ transition: box-shadow ease-in 0.25s, -webkit-box-shadow ease-in 0.25s;
208
+ }
209
+ }
@@ -0,0 +1,8 @@
1
+ class Blog::AuthorsController < Blog::MainController
2
+ def show
3
+ data = BlogpostParser.fetch_all.select { |b| b['published'] && !b['outdated'] }
4
+ attributes = AuthorParser.fetch_author(params[:name]) || {}
5
+
6
+ @author = Blog::Author.new(attributes).build_all_blogposts_from_author(data)
7
+ end
8
+ end
@@ -0,0 +1,32 @@
1
+ class Blog::BlogpostController < Blog::MainController
2
+ LATEST_FOR_PREVIEW = 2
3
+ BLOGPOSTS_FOR_PREVIEW = 6
4
+ RELATED_FOR_PREVIEW = 3
5
+
6
+ def index
7
+ # Fetch data as Json
8
+ data = BlogpostParser.fetch_all
9
+ .select { |b| b['published'] && !b['outdated'] }
10
+
11
+ @authors = AuthorParser.fetch_all_authors
12
+ categories = CategoryParser.fetch_all_categories
13
+
14
+ # Build Blogposts by category
15
+ @categories_with_blogposts = categories.map do |category|
16
+ Blog::Category.new(category).build_n_blogposts_by_category(data, BLOGPOSTS_FOR_PREVIEW)
17
+ end
18
+
19
+ # Build latest Blogposts
20
+ @latest_blogposts = data.first(LATEST_FOR_PREVIEW)
21
+ .map { |attributes| Blog::Blogpost.new(attributes) }
22
+ end
23
+
24
+ def show
25
+ data = BlogpostParser.fetch_all
26
+ @blogpost = Blog::Blogpost.build_blogpost_from_path(params[:blog_path], 'en')
27
+ @related_blogposts = data.select { |b| b['category']['slug'] == @blogpost.category.slug && b['title'] != @blogpost.title && b['published'] && !b['outdated'] }
28
+ .first(RELATED_FOR_PREVIEW)
29
+ .sort_by { |b| b['updated_at'] }.reverse
30
+ .map { |attributes| Blog::Blogpost.new attributes }
31
+ end
32
+ end
@@ -0,0 +1,8 @@
1
+ class Blog::CategoriesController < Blog::MainController
2
+ def show
3
+ data = BlogpostParser.fetch_all.select { |b| b['published'] && !b['outdated'] }
4
+ attributes = CategoryParser.fetch_category(params[:slug])
5
+
6
+ @category_with_all_blogposts = Blog::Category.new(attributes).build_n_blogposts_by_category(data)
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ class Blog::MainController < ApplicationController
2
+ before_action :add_gradient_bg
3
+
4
+ private
5
+
6
+ def add_gradient_bg
7
+ @gradient_bg = true
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ class Blog::TagsController < Blog::MainController
2
+ def show
3
+ @tag = params['slug']
4
+
5
+ blogposts = TagParser.fetch_blogposts_with_tag(params[:slug])
6
+ @blogposts = blogposts.map { |attributes| Blog::Blogpost.new attributes }
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ module BlogHelper
2
+ def readind_time_without_code_tags(content)
3
+ regexp = Regexp.new(%r{<pre class=.*main-code(.*?)</code></pre>}m)
4
+
5
+ "#{content.gsub(regexp, '').reading_time format: :approx} read"
6
+ end
7
+ end
@@ -0,0 +1,59 @@
1
+ class Blog::Author
2
+ attr_reader :name, :title, :bio, :short_name, :email, :image_url,
3
+ :author, :alumni, :team, :hidden, :spotlight, :noteworthy,
4
+ :website_url, :twitter, :linkedin_url, :github_url, :youtube_url,
5
+ :facebook_url, :stackoverflow_url, :twitch_url, :blogposts, :url
6
+
7
+ DEFAULT_AVATAR = 'https://s3.eu-west-1.amazonaws.com/developer.vonage.com/vonage-logo-images/vonage-square-logo.png'.freeze
8
+
9
+ def initialize(attributes = {})
10
+ @name = attributes['name'] || 'Vonage Team Member'
11
+ @title = attributes['title'] || 'Vonage Team Member'
12
+ @bio = attributes['bio'] || ''
13
+ @short_name = attributes['short_name'] || 'vonage_team_member'
14
+ @email = attributes['email'] || ''
15
+ @image_url = attributes['image_url'] || ''
16
+
17
+ @author = attributes['author'] || ''
18
+ @alumni = attributes['alumni'] || false
19
+ @team = attributes['team'] || false
20
+ @hidden = attributes['hidden'] || false
21
+ @spotlight = attributes['spotlight'] || false
22
+ @noteworthy = attributes['noteworthy'] || ''
23
+
24
+ @website_url = attributes['website_url'] || ''
25
+ @twitter = attributes['twitter'] || ''
26
+ @linkedin_url = attributes['linkedin_url'] || ''
27
+ @github_url = attributes['github_url'] || ''
28
+ @youtube_url = attributes['youtube_url'] || ''
29
+ @facebook_url = attributes['facebook_url'] || ''
30
+ @twitch_url = attributes['twitch_url'] || ''
31
+ @stackoverflow_url = attributes['stackoverflow_url'] || ''
32
+
33
+ @blogposts = []
34
+ @url = build_avatar_url
35
+ end
36
+
37
+ def build_all_blogposts_from_author(blogposts_json)
38
+ # TODO: How to handle authors with no Json info? (assay-and-roy)
39
+ @blogposts = blogposts_json.select do |b|
40
+ if b['author'] && b['author']['short_name'].present?
41
+ b['author']['short_name'].downcase == @short_name.downcase
42
+ end
43
+ end
44
+
45
+ @blogposts = @blogposts.map { |b| Blog::Blogpost.new b }
46
+
47
+ self
48
+ end
49
+
50
+ def build_avatar_url
51
+ return DEFAULT_AVATAR if image_url.blank?
52
+
53
+ if image_url.include?('gravatar') || image_url.include?('https://github.com/') || image_url.include?('https://ca.slack-edge.com/')
54
+ image_url
55
+ else
56
+ "#{Blog::Blogpost::CLOUDFRONT_BLOG_URL}authors/#{image_url.gsub('/content/images/', '')}"
57
+ end
58
+ end
59
+ end