mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Create New Topic button on embed with params (#8280)
* FEATURE: Create New Topic button on embed with params
This commit is contained in:
committed by
GitHub
parent
0e2261c414
commit
66e0bdc053
@@ -3,6 +3,7 @@
|
|||||||
@import "./common/foundation/variables";
|
@import "./common/foundation/variables";
|
||||||
@import "./common/foundation/colors";
|
@import "./common/foundation/colors";
|
||||||
@import "./common/foundation/mixins";
|
@import "./common/foundation/mixins";
|
||||||
|
@import "./common/components/buttons";
|
||||||
|
|
||||||
article.post {
|
article.post {
|
||||||
border-bottom: 1px solid #ddd;
|
border-bottom: 1px solid #ddd;
|
||||||
@@ -176,6 +177,32 @@ div.lightbox-wrapper {
|
|||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.new-topic-btn {
|
||||||
|
margin: 0.5rem;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: #006da3;
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: middle;
|
||||||
|
padding-bottom: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-topic-btn__icon {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
margin-right: 2px;
|
||||||
|
background-image: svg-uri(
|
||||||
|
'<svg xmlns="http://www.w3.org/2000/svg" width="32px" height="32px" viewBox="0 0 448 512" fill="white"><path d="M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"></path></svg>'
|
||||||
|
);
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: 100%;
|
||||||
|
background-position: top center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.topics-list {
|
.topics-list {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,15 @@ class EmbedController < ApplicationController
|
|||||||
|
|
||||||
list_options = build_topic_list_options
|
list_options = build_topic_list_options
|
||||||
list_options[:per_page] = params[:per_page].to_i if params.has_key?(:per_page)
|
list_options[:per_page] = params[:per_page].to_i if params.has_key?(:per_page)
|
||||||
|
|
||||||
|
if params[:allow_create]
|
||||||
|
@allow_create = true
|
||||||
|
create_url_params = {}
|
||||||
|
create_url_params[:category_id] = params[:category] if params[:category].present?
|
||||||
|
create_url_params[:tags] = params[:tags] if params[:tags].present?
|
||||||
|
@create_url = "#{Discourse.base_url}/new-topic?#{create_url_params.to_query}"
|
||||||
|
end
|
||||||
|
|
||||||
topic_query = TopicQuery.new(current_user, list_options)
|
topic_query = TopicQuery.new(current_user, list_options)
|
||||||
@list = topic_query.list_latest
|
@list = topic_query.list_latest
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
<%- if @list && @list.topics.present? %>
|
<%- if @list && @list.topics.present? %>
|
||||||
|
<%- if @allow_create %>
|
||||||
|
<%= link_to @create_url, target: "_blank" do |link| %>
|
||||||
|
<button class="new-topic-btn btn btn-primary">
|
||||||
|
<span class="new-topic-btn__icon"></span>
|
||||||
|
<span class="new-topic-btn__text"><%= I18n.t('embed.new_topic') %></span>
|
||||||
|
</button>
|
||||||
|
<%- end %>
|
||||||
|
<%- end %>
|
||||||
<div class='topics-list' data-embed-state='loaded' <%- if @embed_id %>data-embed-id="<%= @embed_id %>"<%- end %>>
|
<div class='topics-list' data-embed-state='loaded' <%- if @embed_id %>data-embed-id="<%= @embed_id %>"<%- end %>>
|
||||||
<%- @list.topics.each do |t| %>
|
<%- @list.topics.each do |t| %>
|
||||||
<div class='topic-list-item'>
|
<div class='topic-list-item'>
|
||||||
|
|||||||
@@ -296,6 +296,7 @@ en:
|
|||||||
other: "%{count} likes"
|
other: "%{count} likes"
|
||||||
last_reply: "Last reply"
|
last_reply: "Last reply"
|
||||||
created: "Created"
|
created: "Created"
|
||||||
|
new_topic: "Create new topic"
|
||||||
|
|
||||||
no_mentions_allowed: "Sorry, you can't mention other users."
|
no_mentions_allowed: "Sorry, you can't mention other users."
|
||||||
too_many_mentions:
|
too_many_mentions:
|
||||||
|
|||||||
Reference in New Issue
Block a user