mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:16:38 -06:00
FEATURE: allows to to style published page with themes/plugins (#9570)
This commit is contained in:
parent
b19dcac272
commit
a6f986b50f
@ -87,7 +87,7 @@
|
||||
{{/topic-title}}
|
||||
|
||||
{{#if model.publishedPage}}
|
||||
<div class="published-page">
|
||||
<div class="published-page-notice">
|
||||
<div class="details">
|
||||
{{i18n "topic.publish_page.topic_published"}}
|
||||
<div>
|
||||
|
@ -296,7 +296,7 @@ a.topic-featured-link {
|
||||
}
|
||||
}
|
||||
|
||||
.published-page {
|
||||
.published-page-notice {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding-bottom: 1em;
|
||||
|
@ -1,19 +1,20 @@
|
||||
@import "common";
|
||||
|
||||
body {
|
||||
.published-page-wrapper {
|
||||
margin: 2em auto;
|
||||
max-width: 800px;
|
||||
}
|
||||
|
||||
.published-page {
|
||||
background-color: $secondary;
|
||||
color: $primary;
|
||||
}
|
||||
|
||||
.published-page {
|
||||
margin: 2em auto;
|
||||
max-width: 800px;
|
||||
|
||||
h1 {
|
||||
.published-page-title {
|
||||
color: $header_primary;
|
||||
}
|
||||
}
|
||||
|
||||
.published-page-author {
|
||||
.published-page-author {
|
||||
margin-top: 1em;
|
||||
margin-bottom: 2em;
|
||||
display: flex;
|
||||
@ -24,9 +25,8 @@ body {
|
||||
.topic-created-at {
|
||||
color: $primary-medium;
|
||||
}
|
||||
}
|
||||
|
||||
.published-page-body {
|
||||
font-size: 1.25em;
|
||||
}
|
||||
}
|
||||
|
||||
.published-page-body {
|
||||
font-size: 1.25em;
|
||||
}
|
||||
|
@ -15,6 +15,18 @@ class PublishedPagesController < ApplicationController
|
||||
guardian.ensure_can_see!(pp.topic)
|
||||
@topic = pp.topic
|
||||
@canonical_url = @topic.url
|
||||
|
||||
@body_classes = Set.new([
|
||||
'published-page',
|
||||
params[:slug],
|
||||
"topic-#{@topic.id}",
|
||||
@topic.tags.pluck(:name)
|
||||
].flatten.compact)
|
||||
|
||||
if @topic.category
|
||||
@body_classes << @topic.category.slug
|
||||
end
|
||||
|
||||
render layout: 'publish'
|
||||
end
|
||||
|
||||
|
9
app/views/common/_discourse_publish_stylesheet.html.erb
Normal file
9
app/views/common/_discourse_publish_stylesheet.html.erb
Normal file
@ -0,0 +1,9 @@
|
||||
<%= discourse_stylesheet_link_tag 'publish', theme_ids: nil %>
|
||||
|
||||
<%- Discourse.find_plugin_css_assets(include_official: allow_plugins?, include_unofficial: allow_third_party_plugins?, mobile_view: mobile_view?, desktop_view: !mobile_view?, request: request).each do |file| %>
|
||||
<%= discourse_stylesheet_link_tag(file) %>
|
||||
<%- end %>
|
||||
|
||||
<%- if theme_ids.present? %>
|
||||
<%= discourse_stylesheet_link_tag(mobile_view? ? :mobile_theme : :desktop_theme) %>
|
||||
<%- end %>
|
@ -3,13 +3,14 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=yes, viewport-fit=cover">
|
||||
<%= discourse_stylesheet_link_tag 'publish', theme_ids: nil %>
|
||||
|
||||
<%= render partial: "common/discourse_publish_stylesheet" %>
|
||||
|
||||
<%- if @canonical_url -%>
|
||||
<link rel="canonical" href="<%= @canonical_url %>" />
|
||||
<%- end -%>
|
||||
</head>
|
||||
<body>
|
||||
<body class="<%= @body_classes.to_a.join(' ') %>">
|
||||
<%= yield %>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<div class="published-page">
|
||||
<div class="published-page-wrapper">
|
||||
<div class="published-page-header">
|
||||
<h1 class="published-page-title"><%= @topic.title %></h1>
|
||||
|
||||
|
@ -76,10 +76,22 @@ RSpec.describe PublishedPagesController do
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
|
||||
it "returns 200 for a valid article" do
|
||||
context "the article is valid" do
|
||||
before do
|
||||
SiteSetting.tagging_enabled = true
|
||||
published_page.topic.tags = [Fabricate(:tag, name: "recipes")]
|
||||
end
|
||||
|
||||
it "returns 200" do
|
||||
get published_page.path
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
it "defines correct css classes on body" do
|
||||
get published_page.path
|
||||
expect(response.body).to include("<body class=\"published-page published-page-test topic-#{published_page.topic_id} recipes uncategorized\">")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "publishing" do
|
||||
|
Loading…
Reference in New Issue
Block a user