Skip to content

Commit 3f05dea

Browse files
authored
Merge branch 'develop' into 0valt/1941/community-assets-settings
2 parents e62f1bc + f86de01 commit 3f05dea

File tree

12 files changed

+212
-81
lines changed

12 files changed

+212
-81
lines changed

app/assets/stylesheets/application.scss

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,6 @@ a.header--site-name {
8484
}
8585
}
8686

87-
/* Copied from Co-Design for compatibility purposes */
88-
ul.pagination li.active {
89-
border-color:#293338;
90-
background-color:#3f4e56;
91-
box-shadow:2px 3px 2px -2px #344147;
92-
color:#fff;
93-
font-weight:600
94-
}
95-
96-
ul.pagination li.active a:hover {
97-
background-color:transparent
98-
}
99-
100-
ul.pagination li.disabled {
101-
box-shadow:none
102-
}
103-
/* *** */
104-
10587
.notice__dev-mode {
10688
font-size: 14px;
10789
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@import 'variables';
2+
3+
ul {
4+
&.pagination {
5+
li {
6+
&.active {
7+
border-color: #293338;
8+
background-color: #3f4e56;
9+
box-shadow: 2px 3px 2px -2px #344147;
10+
color: #fff;
11+
font-weight: 600;
12+
13+
a:hover {
14+
background-color: transparent;
15+
}
16+
}
17+
18+
&.disabled {
19+
box-shadow: none;
20+
filter: grayscale(1) opacity(0.7);
21+
cursor: not-allowed;
22+
}
23+
}
24+
}
25+
}

app/controllers/users/sessions_controller.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,17 @@ def post_sign_in(user, remember_me = false)
106106

107107
def handle_2fa_login(user, remember_me = false)
108108
sign_out user
109+
110+
# prevents premature sign in confirmation
111+
flash[:notice] = nil
112+
109113
case user.two_factor_method
110114
when 'app'
111115
id = user.id
112116
@@first_factor << id
113117
redirect_to login_verify_2fa_path(uid: id, remember_me: remember_me)
114118
when 'email'
115119
TwoFactorMailer.with(user: user, host: request.hostname).login_email.deliver_now
116-
flash[:notice] = nil
117120
flash[:info] = 'Please check your email inbox for a link to sign in.'
118121
redirect_to after_sign_in_path_for(user)
119122
end

app/helpers/tags_helper.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ def category_sort_tags(tags, required_ids, topic_ids, moderator_ids)
1515
end
1616
end
1717

18+
# Renders wiki for a given tag
19+
# @param tag [Tag] tag to render the wiki for
20+
# @return [ActiveSupport::SafeBuffer] rendered usage wiki
21+
def rendered_wiki(tag)
22+
sanitize(tag.wiki, scrubber: scrubber)
23+
end
24+
1825
##
1926
# Generate a list of classes to be applied to a tag.
2027
# @param tag [Tag]
@@ -38,4 +45,14 @@ def post_ids_for_tags(tag_ids)
3845
sql = "SELECT post_id FROM posts_tags WHERE tag_id IN #{ApplicationRecord.sanitize_sql_in(tag_ids)}"
3946
ActiveRecord::Base.connection.execute(sql).to_a.flatten
4047
end
48+
49+
class TagWikiScrubber < PostsHelper::PostScrubber
50+
def allowed_node?(node)
51+
super && !node.matches?("a[href=''], p:only-child:empty")
52+
end
53+
end
54+
55+
def scrubber
56+
TagsHelper::TagWikiScrubber.new
57+
end
4158
end

app/views/tags/show.html.erb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<% content_for :title, "Posts tagged #{@tag.name}" %>
22

3+
<%
4+
wiki = rendered_wiki(@tag)
5+
%>
6+
37
<h1 class="has-margin-0 has-margin-top-4">
48
Posts tagged <span class="<%= tag_classes(@tag, @category) %> is-large wrap-anywhere"><%= @tag.name %></span>
59
<% if at_least_moderator? %>
@@ -60,17 +64,17 @@
6064
<% end %>
6165
</div>
6266
<div class="widget--body">
63-
<% if @tag.wiki.present? %>
64-
<% if @tag.wiki.length < 600 %>
65-
<%= raw(sanitize(@tag.wiki, scrubber: scrubber)) %>
67+
<% if wiki.present? %>
68+
<% if wiki.length < 600 %>
69+
<%= wiki %>
6670
<% else %>
6771
<details>
6872
<summary>Tag Wiki</summary>
69-
<%= raw(sanitize(@tag.wiki, scrubber: scrubber)) %>
73+
<%= wiki %>
7074
</details>
7175
<% end %>
7276
<% end %>
73-
<% unless @tag.wiki.present? %>
77+
<% unless wiki.present? %>
7478
<p class="has-font-size-caption has-margin-0">
7579
<em>
7680
This tag doesn't have a detailed wiki yet.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<%#
2+
"Renders suspension notice for a given user
3+
4+
Variables:
5+
user: User to show the notice for
6+
"%>
7+
8+
<div class="notice is-danger h-m-b-4">
9+
<p>
10+
<% if user.community_user.suspension_public_comment.blank? %>
11+
This user has been <strong>temporarily suspended</strong>.
12+
<% else %>
13+
This user has been <strong>temporarily suspended</strong> <%= user.community_user.suspension_public_comment %>.
14+
<% end %>
15+
16+
The suspension ends <span title="<%= user.community_user.suspension_end.iso8601 %>">in <%= time_ago_in_words(user.community_user.suspension_end) %></span>.</p>
17+
</div>

app/views/users/show.html.erb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,7 @@
99
<h1><span dir="ltr"><%= rtl_safe_username(@user) %></span></h1>
1010

1111
<% if @user.community_user.suspended? %>
12-
<div class="notice is-danger h-m-b-4">
13-
<% if @user.community_user.suspension_public_comment.nil? %>
14-
<p>This user has been <strong>temporarily suspended</strong>.
15-
<% else %>
16-
<p>This user has been <strong>temporarily suspended</strong> <%= @user.community_user.suspension_public_comment %>.
17-
<% end %>
18-
19-
The suspension ends <span title="<%= @user.community_user.suspension_end.iso8601 %>">in <%= time_ago_in_words(@user.community_user.suspension_end) %></span>.</p>
20-
</div>
12+
<%= render 'users/notices/suspension', user: @user %>
2113
<% end %>
2214

2315
<% is_me = @user.same_as?(current_user) %>

0 commit comments

Comments
 (0)