Skip to content

Commit c366bbb

Browse files
committed
fix: homepage bio clamping
1 parent 205123c commit c366bbb

File tree

19 files changed

+116
-153
lines changed

19 files changed

+116
-153
lines changed

.eslintrc.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,18 @@
1616
"ecmaVersion": 2018,
1717
"sourceType": "module"
1818
},
19-
"plugins": [
20-
"react"
21-
],
19+
"plugins": ["react", "prettier"],
2220
"rules": {
2321
"indent": ["error", 4],
24-
"jsx-a11y/label-has-associated-control": ["error", {
25-
"labelAttributes": ["htmlFor"]
26-
}],
22+
"jsx-a11y/label-has-associated-control": [
23+
"error",
24+
{
25+
"labelAttributes": ["htmlFor"]
26+
}
27+
],
2728
"quotes": ["error", "double"],
2829
"react/jsx-indent": [2, 4],
2930
"react/jsx-indent-props": [2, 4],
3031
"react/jsx-props-no-spreading": [0]
3132
}
32-
}
33+
}

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"singleQuote": false,
3+
"trailingComma": "all",
4+
"printWidth": 120,
5+
"semi": true,
6+
"tabWidth": 4
7+
}

.rubocop.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ AllCops:
44
- 'config/**/*'
55
- 'script/**/*'
66
- 'bin/{rails,rake}'
7-
- !ruby/regexp /old_and_unused\.rb$/
87
Metrics/MethodLength:
98
Enabled: false
109
Metrics/AbcSize:
1110
Enabled: false
1211
Layout/LineLength:
13-
Max: 100
12+
Max: 100
13+
Style/ConditionalAssignment:
14+
Enabled: false

Gemfile.lock

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,14 @@ GEM
133133
ffi (1.15.4)
134134
globalid (1.0.0)
135135
activesupport (>= 5.0)
136+
google-protobuf (3.19.1)
136137
google-protobuf (3.19.1-x86_64-darwin)
137138
google-protobuf (3.19.1-x86_64-linux)
138139
googleapis-common-protos-types (1.3.0)
139140
google-protobuf (~> 3.14)
141+
grpc (1.42.0)
142+
google-protobuf (~> 3.18)
143+
googleapis-common-protos-types (~> 1.0)
140144
grpc (1.42.0-x86_64-darwin)
141145
google-protobuf (~> 3.18)
142146
googleapis-common-protos-types (~> 1.0)
@@ -160,6 +164,7 @@ GEM
160164
i18n (1.8.11)
161165
concurrent-ruby (~> 1.0)
162166
jmespath (1.4.0)
167+
libv8-node (16.10.0.0-arm64-darwin)
163168
libv8-node (16.10.0.0-x86_64-darwin)
164169
libv8-node (16.10.0.0-x86_64-linux)
165170
listen (3.0.8)
@@ -182,7 +187,7 @@ GEM
182187
libv8-node (~> 16.10.0.0)
183188
minitest (5.14.4)
184189
multipart-post (2.1.1)
185-
mysql2 (0.5.3)
190+
mysql2 (0.5.4)
186191
net-scp (3.0.0)
187192
net-ssh (>= 2.6.5, < 7.0.0)
188193
net-ssh (6.1.0)
@@ -191,6 +196,8 @@ GEM
191196
newrelic_rpm (= 8.2.0)
192197
newrelic_rpm (8.2.0)
193198
nio4r (2.5.8)
199+
nokogiri (1.12.5-arm64-darwin)
200+
racc (~> 1.4)
194201
nokogiri (1.12.5-x86_64-darwin)
195202
racc (~> 1.4)
196203
nokogiri (1.12.5-x86_64-linux)
@@ -316,6 +323,7 @@ GEM
316323
chronic (>= 0.6.3)
317324

318325
PLATFORMS
326+
arm64-darwin-21
319327
x86_64-darwin-18
320328
x86_64-darwin-20
321329
x86_64-linux
@@ -364,4 +372,4 @@ DEPENDENCIES
364372
whenever
365373

366374
BUNDLED WITH
367-
2.2.32
375+
2.3.15

app/controllers/authors_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def email_subscribe
150150

151151
def redirect_to_authenticated_usage(author, secret)
152152
@secret_url = CGI.escape("#{author.get_host}/authors/#{author.id}/extension/?secret=#{secret}&type=sn")
153-
redirect_to "#{ENV['HOST']}/new_author?secret_url=#{@secret_url}"
153+
redirect_to "#{ENV['HOST']}/new-author?secret_url=#{@secret_url}"
154154
end
155155

156156
def extension

app/controllers/usage_controller.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,5 @@ def index
2121

2222
def new_author
2323
@title = 'New Author | Listed'
24-
if params[:secret_url]
25-
@secret_url = Base64.encode64(params[:secret_url])
26-
else
27-
redirect_to '/'
28-
end
2924
end
3025
end

app/models/author.rb

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ class Author < ApplicationRecord
2424
update_homepage_status
2525
end
2626

27+
def string_has_restrictions(string, restrictions)
28+
return false if !string || string.empty?
29+
restrictions.any? { |word| string.downcase.include?(word.downcase) }
30+
end
31+
2732
def update_homepage_status(should_save = false)
2833
most_recent_post = listed_posts.where(
2934
'(posts.created_at >= ? AND posts.created_at <= ?)',
@@ -39,13 +44,20 @@ def update_homepage_status(should_save = false)
3944
!hide_from_homepage &&
4045
has_bio
4146

42-
if featured
43-
self.homepage_activity = DateTime.now
44-
elsif post_criteria
45-
self.homepage_activity = most_recent_post.created_at
46-
else
47+
if featured
48+
self.homepage_activity = DateTime.now
49+
elsif post_criteria
50+
restricted_words = (ENV['RESTRICTED_KEYWORDS'] || '').split(',')
51+
if string_has_restrictions(bio, restricted_words) ||
52+
string_has_restrictions(display_name, restricted_words) ||
53+
string_has_restrictions(personal_link, restricted_words)
4754
self.homepage_activity = nil
55+
else
56+
self.homepage_activity = most_recent_post.created_at
4857
end
58+
else
59+
self.homepage_activity = nil
60+
end
4961

5062
save if homepage_activity_changed? && should_save
5163
end

app/models/post.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def link_transformer
185185
elements: ['a', 'a img'],
186186
attributes: {'a' => ['href']},
187187
add_attributes: {
188-
'a' => {'rel' => "noopener", 'target' => "_blank"}
188+
'a' => {'rel' => "noopener nofollow", 'target' => "_blank"}
189189
}
190190
}
191191
) unless node_url.host.include? author_url.host

client/app/components/authors/header/AuthorInfo.jsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ const AuthorInfo = ({ author }) => {
1616
{author.header_image_url ? (
1717
<div style={{ backgroundImage: `url(${author.header_image_url})` }} className="header-image" />
1818
) : (
19-
<p className="header-author-capital">
20-
{author.title[0]}
21-
</p>
19+
<p className="header-author-capital">{author.title[0]}</p>
2220
)}
2321
</div>
2422
<div>
@@ -30,20 +28,19 @@ const AuthorInfo = ({ author }) => {
3028
<a
3129
href={`https://twitter.com/${author.twitter}`}
3230
target="_blank"
33-
rel="noopener noreferrer"
31+
rel="noopener nofollow"
3432
className="link author-twitter"
3533
>
3634
{`@${author.twitter}`}
3735
</a>
3836
</span>
39-
4037
)}
4138
{author.personal_link && (
4239
<span className="item">
4340
<a
4441
href={author.personal_link}
4542
target="_blank"
46-
rel="noopener noreferrer"
43+
rel="noopener nofollow"
4744
className="p2 link author-link"
4845
>
4946
{author.link}
@@ -55,9 +52,7 @@ const AuthorInfo = ({ author }) => {
5552
</div>
5653
<button className="button word-count__button" type="button" onClick={scrollToPosts}>
5754
<p className="p3 word-count" suppressHydrationWarning>
58-
{(author.last_word_count || 0).toLocaleString()}
59-
{" "}
60-
words
55+
{(author.last_word_count || 0).toLocaleString()} words
6156
</p>
6257
<SVG src={IcArrowLong} className="word-count__icon" />
6358
</button>

client/app/components/authors/header/menu/AuthorMenu.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const AuthorMenu = ({
3838
{authorHasPages(pages) && pages.map((page) => {
3939
const linkAttrs = page.page_link ? {
4040
target: "_blank",
41-
rel: "noreferrer",
41+
rel: "noreferrer nofollow",
4242
} : {};
4343
return (
4444
<a

0 commit comments

Comments
 (0)