Skip to content

Commit 6d08217

Browse files
committed
Merge branch 'develop' into 0valt/1699/erb_lint
2 parents 9763d01 + 1a59c4e commit 6d08217

File tree

11 files changed

+94
-54
lines changed

11 files changed

+94
-54
lines changed

app/assets/javascripts/comments.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ $(() => {
313313
ev.preventDefault();
314314
const $tgt = $(ev.target);
315315
const postId = $tgt.attr('data-post');
316-
const $reply = $(`#reply-to-thread-form-${postId}`);
316+
const threadId = $tgt.attr('data-thread');
317+
const $reply = $(`#reply-to-thread-form-${postId}-${threadId}`);
317318

318319
if ($reply.is(':hidden')) {
319320
$reply.show();

app/helpers/comments_helper.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def pinged_users(content)
4747
# @param content [String] content to convert ping-strings for
4848
# @param pingable [Array<Integer>, nil] A list of user IDs. Any user ID not present will be displayed as 'unpingable'.
4949
# @return [ActiveSupport::SafeBuffer]
50-
def render_pings(content, pingable: nil)
50+
def render_pings(content, pingable: nil, host: nil)
5151
users = pinged_users(content)
5252

5353
content.gsub(/@#(\d+)/) do |ping|
@@ -57,8 +57,10 @@ def render_pings(content, pingable: nil)
5757
else
5858
was_pung = pingable.present? && pingable.include?(user.id)
5959
classes = "ping #{'me' if user.same_as?(current_user)} #{'unpingable' unless was_pung}"
60-
user_link user, class: classes, dir: 'ltr',
61-
title: was_pung ? '' : I18n.t('comments.warnings.unrelated_user_not_pinged')
60+
user_link(user, { host: host },
61+
class: classes,
62+
dir: 'ltr',
63+
title: was_pung ? '' : I18n.t('comments.warnings.unrelated_user_not_pinged'))
6264
end
6365
end.html_safe
6466
end

app/models/pinned_link.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
class PinnedLink < ApplicationRecord
22
include MaybeCommunityRelated
33
belongs_to :post
4+
5+
# Is the link time-constrained?
6+
# @return [Boolean] check result
7+
def timed?
8+
shown_before.present? || shown_after.present?
9+
end
410
end

app/views/comments/_comment.html.erb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@
7777
</div>
7878
</div>
7979
<div class="comment--body" dir="ltr">
80-
<%= render_pings(raw(sanitize(render_comment_helpers(render_markdown(comment.content)), scrubber: CommentScrubber.new)),
81-
pingable: pingable) %>
80+
<% rendered = render_comment_helpers(render_markdown(comment.content)) %>
81+
<% sanitized = sanitize(rendered, scrubber: CommentScrubber.new) %>
82+
<%= render_pings(raw(sanitized), pingable: pingable, host: comment.community.host) %>
8283
</div>
8384
</div>

app/views/comments/_new_thread_modal.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
required: true,
3232
data: { post: post.id,
3333
thread: '-1',
34-
character_count: ".js-character-count-#{post.id}" } %>
35-
<%= render 'shared/char_count', type: post.id, min: min_chars, max: max_chars %>
34+
character_count: ".js-character-count-new-thread-#{post.id}" } %>
35+
<%= render 'shared/char_count', type: "new-thread-#{post.id}", min: min_chars, max: max_chars %>
3636

3737
<%= label_tag :title, 'Comment thread title (optional)', class: 'form-element' %>
3838
<span class="form-caption">

app/views/comments/_reply_to_thread.html.erb

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
%>
1111

1212
<%
13+
# TODO: make configurable
14+
min_chars = 15
15+
max_chars = 1000
16+
1317
can_comment = user.can_reply_to?(thread)
1418
is_rate_limited, rate_limit_message = comment_rate_limited?(user, post, create_audit_log: false)
1519
text ||= defined?(text) && text.present? ? text : t('comments.labels.reply_to_thread')
@@ -28,7 +32,7 @@
2832

2933
<div class="reply-to-thread-wrapper">
3034
<%= link_to 'javascript:void(0)', class: 'button is-outlined is-small js-reply-to-thread-link',
31-
data: { post: post.id },
35+
data: { post: post.id, thread: thread.id },
3236
disabled: !can_comment,
3337
role: 'button',
3438
title: is_exempt ? '' : title do %>
@@ -40,16 +44,20 @@
4044
</div>
4145

4246
<% if can_comment %>
43-
<%= form_tag create_comment_path(thread.id), class: 'reply-to-thread-form', id: "reply-to-thread-form-#{post.id}" do %>
47+
<%= form_tag create_comment_path(thread.id), class: 'reply-to-thread-form',
48+
id: "reply-to-thread-form-#{post.id}-#{thread.id}" do %>
4449
<%= hidden_field_tag :post_id, post.id %>
4550
<%= hidden_field_tag :inline, inline %>
4651
<%= label_tag :content, 'Your message', class: 'form-element' %>
4752
<%= text_area_tag :content, '',
4853
class: 'form-element js-comment-field',
54+
minlength: min_chars,
55+
maxlength: max_chars,
56+
required: true,
4957
data: { thread: thread.id,
5058
post: thread.post_id,
51-
character_count: ".js-character-count-#{post.id}" } %>
52-
<%= render 'shared/char_count', type: post.id, min: 15, max: 1000 %>
53-
<%= submit_tag 'Add reply', class: 'button is-muted is-filled', disabled: true %>
59+
character_count: ".js-character-count-thread-reply-#{post.id}-#{thread.id}" } %>
60+
<%= render 'shared/char_count', type: "thread-reply-#{post.id}-#{thread.id}", min: min_chars, max: max_chars %>
61+
<%= submit_tag 'Add reply', class: 'button is-muted is-filled', disabled:true %>
5462
<% end %>
5563
<% end %>

app/views/layouts/_sidebar.html.erb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
<% end %>
1313
<% end %>
1414

15-
1615
<% unless @community.is_fake %>
1716
<%# Featured widget %>
1817
<% if Rails.env.development? || @pinned_links.to_a.size > 0 %>
19-
<% cache @pinned_links do %>
18+
<% has_timed = @pinned_links.any?(&:timed?) %>
19+
<% cache_unless has_timed, @pinned_links do %>
2020
<div class="widget has-margin-4 is-teal">
2121
<% if Rails.env.development? || @pinned_links.to_a.size > 0 %>
2222
<div class="widget--header">Featured</div>
@@ -122,8 +122,8 @@
122122
<% if can_see_deleted_posts? && !at_least_moderator? %>
123123
<li><a href="/mod/deleted">Recent Deletions</a></li>
124124
<% end %>
125-
<%# this calls into application_helper, not the user model! %>
126-
<% if at_least_moderator? %>
125+
<%# this calls into application_helper, not the user model! %>
126+
<% if at_least_moderator? %>
127127
<li><%= link_to 'Moderator Tools', moderator_path %></li>
128128
<% end %>
129129
<% if admin? %>
Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,51 @@
11
<!DOCTYPE html>
22
<html lang="en" dir="ltr">
3-
<head>
4-
<%= render 'layouts/head' %>
5-
</head>
6-
<body class="<%= Rails.env.development? ? 'development' : '' %>"
3+
<head>
4+
<%= render 'layouts/head' %>
5+
</head>
6+
<body class="<%= Rails.env.development? ? 'development' : '' %>"
77
data-user-id="<%= user_signed_in? ? current_user.id : 'none' %>"
88
data-mathjax="<%= SiteSetting['MathJaxEnabled'] %>">
9-
<%= render 'layouts/header' %>
10-
11-
<main class="container">
12-
<div class="grid">
13-
<div class="grid--cell is-8-lg is-12">
14-
<div class="has-padding-4">
15-
<% {notice: :info, alert: :danger, danger: :danger, success: :success, info: :info, warning: :warning}.each do |mt, cc| %>
16-
<% if flash[mt].present? %>
17-
<div class="notice is-<%= cc.to_s %>">
18-
<%= flash[mt] %>
19-
</div>
9+
<%= render 'layouts/header' %>
10+
11+
<main class="container">
12+
<div class="grid">
13+
<div class="grid--cell is-8-lg is-12">
14+
<div class="has-padding-4">
15+
<% {notice: :info, alert: :danger, danger: :danger, success: :success, info: :info, warning: :warning}.each do |mt, cc| %>
16+
<% if flash[mt].present? %>
17+
<div class="notice is-<%= cc.to_s %>">
18+
<%= flash[mt] %>
19+
</div>
20+
<% end %>
2021
<% end %>
21-
<% end %>
22-
2322

24-
<% if @first_visit_notice %>
25-
<% notice = SiteSetting['FirstVisitGuidance'] %>
26-
<% if notice.present? %>
27-
<div class="notice js-first-visit-notice" id="fvn">
28-
<button type="button" class="button is-close-button" data-dismiss="#fvn" aria-label="Close" id="fvn-dismiss">
29-
<span aria-hidden="true">&times;</span>
30-
</button>
31-
<%= raw(sanitize(notice, scrubber: scrubber)) %>
32-
</div>
23+
<% if @first_visit_notice %>
24+
<% notice = SiteSetting['FirstVisitGuidance'] %>
25+
<% if notice.present? %>
26+
<div class="notice js-first-visit-notice" id="fvn">
27+
<button type="button" class="button is-close-button" data-dismiss="#fvn" aria-label="Close" id="fvn-dismiss">
28+
<span aria-hidden="true">&times;</span>
29+
</button>
30+
<%= raw(sanitize(notice, scrubber: scrubber)) %>
31+
</div>
32+
<% end %>
3333
<% end %>
34-
<% end %>
3534

36-
<%= yield %>
35+
<%= yield %>
36+
</div>
3737
</div>
38-
</div>
3938

40-
<%= render 'layouts/sidebar' %>
41-
</div>
42-
</main>
39+
<%= render 'layouts/sidebar' %>
40+
</div>
41+
</main>
4342

44-
<%= render 'layouts/footer' %>
43+
<%= render 'layouts/footer' %>
4544

46-
<%= render 'layouts/matomo' %>
45+
<%= render 'layouts/matomo' %>
4746

48-
<script src="https://7zb04r9ckbwg.statuspage.io/embed/script.js"></script>
49-
</body>
47+
<% if Rails.env.production? %>
48+
<script src="https://7zb04r9ckbwg.statuspage.io/embed/script.js"></script>
49+
<% end %>
50+
</body>
5051
</html>

config/environments/development.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414

1515
# Show full error reports and disable caching.
1616
config.consider_all_requests_local = true
17-
config.action_controller.perform_caching = false
17+
config.action_controller.perform_caching = ActiveRecord::Type::Boolean.new.cast(ENV['PERFORM_CACHING']) || false
1818

1919
# Enable server timing
2020
config.server_timing = true
2121

22+
config.log_level = ENV['LOG_LEVEL'] || :info
23+
2224
# Set the cache store to the redis that was configured in the database.yml
2325
processed = ERB.new(File.read(Rails.root.join('config', 'database.yml'))).result(binding)
2426
redis_config = YAML.safe_load(processed, permitted_classes: [], permitted_symbols: [], aliases: true)["redis_#{Rails.env}"]

lib/namespaced_env_cache.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def self.supports_cache_versioning?
8282
private
8383

8484
def construct_ns_key(key, include_community: true)
85+
key = expanded_key(key)
8586
c_id = RequestContext.community_id if include_community
8687
"#{Rails.env}://#{[c_id, key].compact.join('/')}"
8788
end

0 commit comments

Comments
 (0)