diff --git a/app/controllers/public/api/v1/portals/base_controller.rb b/app/controllers/public/api/v1/portals/base_controller.rb index 323440304..7b592fbd8 100644 --- a/app/controllers/public/api/v1/portals/base_controller.rb +++ b/app/controllers/public/api/v1/portals/base_controller.rb @@ -24,7 +24,11 @@ class Public::Api::V1::Portals::BaseController < PublicController end def set_view_variant - request.variant = :documentation if @portal_layout == 'documentation' && !@is_plain_layout_enabled + request.variant = if @is_plain_layout_enabled + :plain + elsif @portal_layout == 'documentation' + :documentation + end end def portal @@ -65,6 +69,8 @@ class Public::Api::V1::Portals::BaseController < PublicController def render_404 portal + # set_locale can render_404 before the child's set_view_variant runs; set it here so plain 404s stay chrome-less + set_view_variant render 'public/api/v1/portals/error/404', status: :not_found end diff --git a/app/views/layouts/portal.html+documentation.erb b/app/views/layouts/portal.html+documentation.erb index aa26fce7e..45bf3dec9 100644 --- a/app/views/layouts/portal.html+documentation.erb +++ b/app/views/layouts/portal.html+documentation.erb @@ -3,9 +3,9 @@ <%= render 'layouts/portal_head' %> - +
-
+
<%= render 'public/api/v1/portals/documentation_layout/topbar', portal: @portal, locale: @locale, article: @article, category: @category %>
diff --git a/app/views/layouts/portal.html+plain.erb b/app/views/layouts/portal.html+plain.erb new file mode 100644 index 000000000..61f5257d5 --- /dev/null +++ b/app/views/layouts/portal.html+plain.erb @@ -0,0 +1,14 @@ + + + + <%= render 'layouts/portal_head' %> + + +
+
+ <%= yield %> +
+
+ <%= render 'layouts/portal_scripts' %> + + diff --git a/app/views/layouts/portal.html.erb b/app/views/layouts/portal.html.erb index 3085106dd..8b1fbfa7b 100644 --- a/app/views/layouts/portal.html.erb +++ b/app/views/layouts/portal.html.erb @@ -6,9 +6,9 @@
- <%= render 'public/api/v1/portals/header', portal: @portal unless @is_plain_layout_enabled %> + <%= render 'public/api/v1/portals/header', portal: @portal %> <%= yield %> - <%= render 'public/api/v1/portals/footer' unless @is_plain_layout_enabled || @portal.account.feature_enabled?('disable_branding') %> + <%= render 'public/api/v1/portals/footer' unless @portal.account.feature_enabled?('disable_branding') %>
<%= render 'layouts/portal_scripts' %> diff --git a/app/views/public/api/v1/portals/_category-block.html+plain.erb b/app/views/public/api/v1/portals/_category-block.html+plain.erb new file mode 100644 index 000000000..7e4ae0371 --- /dev/null +++ b/app/views/public/api/v1/portals/_category-block.html+plain.erb @@ -0,0 +1,61 @@ +<%# locals: (category:, portal:) %> +<% category_link_params = { + portal_slug: portal.slug, + category_locale: category.locale, + category_slug: category.slug, + theme: @theme_from_params, + is_plain_layout_enabled: true + } +%> + +
+
+
+
+
+ <% if category.icon.present? %> + <%= render_emoji_or_icon(category.icon, category.icon_color) %> + <% end %> +

+ + <%= category.name %> + +

+
+ <% if category.description.present? %> + <%= category.description %> + <% end %> +
+
+
+ <% if category.articles.published.size==0 %> +
+

<%= I18n.t('public_portal.common.no_articles') %>

+
+ <% else %> + <% category.articles.published.order(position: :asc).take(5).each do |article| %> + +
+ <%= article.title %> + + <%= render partial: 'icons/chevron-right' %> + +
+
+ <% end %> + <% end %> +
+
+
+ <%= render "public/api/v1/portals/authors", category: category, show_expanded: false %> + + <%= render 'public/api/v1/portals/article_count', article_count: category.articles.published.order(position: :asc).size %> +
+ +
+
+
diff --git a/app/views/public/api/v1/portals/_category-block.html.erb b/app/views/public/api/v1/portals/_category-block.html.erb index 715b20672..248b77a00 100644 --- a/app/views/public/api/v1/portals/_category-block.html.erb +++ b/app/views/public/api/v1/portals/_category-block.html.erb @@ -1,28 +1,29 @@ +<%# locals: (category:, portal:) %> <% category_link_params = { portal_slug: portal.slug, category_locale: category.locale, category_slug: category.slug, theme: @theme_from_params, - is_plain_layout_enabled: @is_plain_layout_enabled + is_plain_layout_enabled: false } %>
-
+
-
+
<% if category.icon.present? %> - <%= render_emoji_or_icon(category.icon, category.icon_color) %> + <%= render_emoji_or_icon(category.icon, category.icon_color) %> <% end %> -

+

<%= category.name %>

<% if category.description.present? %> - <%= category.description %> + <%= category.description %> <% end %>
@@ -33,8 +34,8 @@
<% else %> <% category.articles.published.order(position: :asc).take(5).each do |article| %> - -
-<% end %> diff --git a/app/views/public/api/v1/portals/_home_categories.html.erb b/app/views/public/api/v1/portals/_home_categories.html.erb new file mode 100644 index 000000000..116a94e8a --- /dev/null +++ b/app/views/public/api/v1/portals/_home_categories.html.erb @@ -0,0 +1,13 @@ +<%# locals: (portal:, locale:) %> +<%# Categories with articles %> +
+ <% portal.categories.where(locale: locale).joins(:articles).where(articles: { status: :published }).order(position: :asc).group('categories.id').each do |category| %> + <%= render "public/api/v1/portals/category-block", category: category, portal: portal %> + <% end %> +
+<%# Uncategorized articles %> +
+ <% if portal.articles.where(status: :published, category_id: nil, locale: locale).count > 0 %> + <%= render "public/api/v1/portals/uncategorized-block", portal: portal %> + <% end %> +
diff --git a/app/views/public/api/v1/portals/_uncategorized-block.html+plain.erb b/app/views/public/api/v1/portals/_uncategorized-block.html+plain.erb new file mode 100644 index 000000000..24729ef3e --- /dev/null +++ b/app/views/public/api/v1/portals/_uncategorized-block.html+plain.erb @@ -0,0 +1,28 @@ +<%# locals: (portal:) %> +
+ +
diff --git a/app/views/public/api/v1/portals/_uncategorized-block.html.erb b/app/views/public/api/v1/portals/_uncategorized-block.html.erb index fe28bca5f..3699826fb 100644 --- a/app/views/public/api/v1/portals/_uncategorized-block.html.erb +++ b/app/views/public/api/v1/portals/_uncategorized-block.html.erb @@ -1,7 +1,8 @@ +<%# locals: (portal:) %>
-
-
-

+
+
+

<%= I18n.t('public_portal.header.uncategorized') %>

@@ -9,9 +10,9 @@ <% portal.articles.published.where(category_id: nil, locale: @locale).order(position: :asc).take(5).each do |article| %> -
+ -
+
<%= render 'public/api/v1/portals/article_count', article_count: portal.articles.published.where(category_id: nil, locale: @locale).size %>
diff --git a/app/views/public/api/v1/portals/articles/_article_body.html.erb b/app/views/public/api/v1/portals/articles/_article_body.html.erb new file mode 100644 index 000000000..1efda0012 --- /dev/null +++ b/app/views/public/api/v1/portals/articles/_article_body.html.erb @@ -0,0 +1,8 @@ +<%# locals: (parsed_content:, content_padding: 'pt-8 pb-12') %> +<%# Classic/Plain width wrapper. Body itself is the shared articles/content partial. %> +
+
+ <%= render 'public/api/v1/portals/articles/content', parsed_content: parsed_content %> +
+
+
diff --git a/app/views/public/api/v1/portals/articles/_article_header.html.erb b/app/views/public/api/v1/portals/articles/_article_header.html.erb index 9121b790a..aaf7d8c60 100644 --- a/app/views/public/api/v1/portals/articles/_article_header.html.erb +++ b/app/views/public/api/v1/portals/articles/_article_header.html.erb @@ -1,22 +1,23 @@ +<%# locals: (article:, plain: false) %> <% category_link_params = { portal_slug: @portal.slug, category_locale: @article.category&.locale, category_slug: @article.category&.slug, theme: @theme_from_params, - is_plain_layout_enabled: @is_plain_layout_enabled + is_plain_layout_enabled: plain } %>
<%= I18n.t('public_portal.common.home') %> <%= render partial: 'icons/chevron-right' %> <% if @article.category %> - + <%= @article.category&.name %> <%= render partial: 'icons/chevron-right' %> diff --git a/app/views/public/api/v1/portals/articles/_content.html.erb b/app/views/public/api/v1/portals/articles/_content.html.erb new file mode 100644 index 000000000..01116761b --- /dev/null +++ b/app/views/public/api/v1/portals/articles/_content.html.erb @@ -0,0 +1,19 @@ +<%# locals: (parsed_content:, link_class: 'prose-a:underline') %> +<%# Shared article body (id="cw-article-content"). Same rendering in all 3 layouts; + each layout controls its own width via the wrapping element. + link_class is layout-specific: classic/plain default to always-underlined default-color + links; documentation overrides with the portal-colored, underline-on-hover style. %> +
+ <%= parsed_content %> +
diff --git a/app/views/public/api/v1/portals/articles/_meta_head.html.erb b/app/views/public/api/v1/portals/articles/_meta_head.html.erb new file mode 100644 index 000000000..174eec2ba --- /dev/null +++ b/app/views/public/api/v1/portals/articles/_meta_head.html.erb @@ -0,0 +1,21 @@ +<%# locals: (article:, portal:, locale:, og_image_url: nil) %> +<%= article.title %> | <%= portal.display_title(locale) %> +<% if article.meta["title"].present? %> + "> + "> + "> +<% end %> +<% if article.meta["description"].present? %> + "> + "> + "> +<% end %> +<% if article.meta["tags"].present? %> + "> +<% end %> +<% if og_image_url.present? %> + + + + +<% end %> diff --git a/app/views/public/api/v1/portals/articles/index.html.erb b/app/views/public/api/v1/portals/articles/index.html.erb index e4dc9aa87..77832d4c3 100644 --- a/app/views/public/api/v1/portals/articles/index.html.erb +++ b/app/views/public/api/v1/portals/articles/index.html.erb @@ -1,36 +1,36 @@
-
-
- - <% @articles.each do |article| %> -

- <%= article.title %>

-
-
- -
-
<%= article.author.name %>
-

- <%= article.author.updated_at.strftime("%B %d %Y") %>

-
-
-
- <% end %> -
-
+
+
+ + <% @articles.each do |article| %> +

+ <%= article.title %>

+
+
+ +
+
<%= article.author.name %>
+

+ <%= article.author.updated_at.strftime("%B %d %Y") %>

+
+
+
+ <% end %> +
+
-
-
-
-
+
+
+
+
diff --git a/app/views/public/api/v1/portals/articles/show.html+documentation.erb b/app/views/public/api/v1/portals/articles/show.html+documentation.erb index 76aeb804e..1ce480311 100644 --- a/app/views/public/api/v1/portals/articles/show.html+documentation.erb +++ b/app/views/public/api/v1/portals/articles/show.html+documentation.erb @@ -11,20 +11,9 @@ <%= render 'public/api/v1/portals/documentation_layout/articles/header', portal: @portal, article: @article %> -
- <%= @parsed_content %> -
+ <%= render 'public/api/v1/portals/articles/content', + parsed_content: @parsed_content, + link_class: 'prose-a:text-n-portal prose-a:no-underline hover:prose-a:underline' %> <% if @article.category %>