With this commit, we're only allowing users who can create articles to
enter RSS feed information for fetching of articles.
Note: I chose not to indent body of the if conditional to ease the code
review. I also chose to place the if statement in this partial instead
of in the [app/views/users/_extensions.html.erb][1] file; this helps
contain the logic around the policy.
For sleuthing this mirrors the approach of forem/forem#16735
Closes forem/forem#16788
Related to forem/forem#16766, forem/forem#16732, and forem/forem#16763
[1]:b87fd77992/app/views/users/_extensions.html.erb (L3)
53 lines
2.7 KiB
Text
53 lines
2.7 KiB
Text
<% if policy(Article).create? %>
|
|
<div class="crayons-card crayons-card--content-rows">
|
|
<div class="grid gap-4">
|
|
<h2 class="crayons-subtitle-1">
|
|
<%= t("views.settings.extensions.rss.heading", community: community_name) %>
|
|
</h2>
|
|
<% if @users_setting.feed_url.present? %>
|
|
<%= form_for @users_setting, url: users_settings_path do |f| %>
|
|
<%= f.hidden_field :feed_url, value: @users_setting.feed_url %>
|
|
<%= f.hidden_field :tab, value: @tab %>
|
|
<div class="flex items-center">
|
|
<button type="submit" class="crayons-btn crayons-btn--secondary"><%= t("views.settings.extensions.rss.fetch") %></button>
|
|
<p class="pl-2"><%= t("views.settings.extensions.rss.last_html", time: tag.time(id: "rss-fetch-time", datetime: @users_setting.user.feed_fetched_at.iso8601)) %></p>
|
|
</div>
|
|
<% end %>
|
|
<% end %>
|
|
<p>
|
|
<%= t("views.settings.extensions.rss.desc1_html", dashboard: link_to(t("views.settings.extensions.rss.dashboard"), "/dashboard")) %>
|
|
</p>
|
|
<p><%= t("views.settings.extensions.rss.desc2") %></p>
|
|
<p>
|
|
<%= t("views.settings.extensions.rss.desc3_html", guide: link_to(t("views.settings.extensions.rss.guide"), publishing_from_rss_guide_path)) %>
|
|
</p>
|
|
<p>
|
|
<%= t("views.settings.extensions.rss.desc4") %>
|
|
<%= t("contact_prompts.if_any_questions_html") %>
|
|
</p>
|
|
<p><%= t("views.settings.extensions.rss.desc5_html") %></p>
|
|
<p><em><%= t("views.settings.extensions.rss.desc6") %></em></p>
|
|
</div>
|
|
|
|
<%= form_for @users_setting, url: users_settings_path, html: { class: "grid gap-6" } do |f| %>
|
|
<div class="crayons-field">
|
|
<%= f.label :feed_url, "RSS Feed URL", class: "crayons-field__label" %>
|
|
<%= f.url_field :feed_url, placeholder: "https://yoursite.com/feed", class: "crayons-textfield" %>
|
|
</div>
|
|
|
|
<div class="crayons-field crayons-field--checkbox">
|
|
<%= f.check_box :feed_mark_canonical, class: "crayons-checkbox" %>
|
|
<%= f.label :feed_mark_canonical, t("views.settings.extensions.rss.mark_canonical_html"), class: "crayons-field__label" %>
|
|
</div>
|
|
|
|
<div class="crayons-field crayons-field--checkbox">
|
|
<%= f.check_box :feed_referential_link, class: "crayons-checkbox" %>
|
|
<%= f.label :feed_referential_link, t("views.settings.extensions.rss.referential_html", community: community_name), class: "crayons-field__label" %>
|
|
</div>
|
|
|
|
<%= f.hidden_field :tab, value: @tab, id: nil %>
|
|
<% button_text = @users_setting.feed_url.present? ? t("views.settings.extensions.rss.save") : t("views.settings.extensions.rss.submit") %>
|
|
<button class="crayons-btn w-max" type="submit"><%= button_text %></button>
|
|
<% end %>
|
|
</div>
|
|
<% end %>
|