diff --git a/app/models/post.rb b/app/models/post.rb index 85c466d9cb5107d1d3d1f9a3c93f6da51c71fb94..c7c2df8759f631149eebc9f376882027d85a6210 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -30,7 +30,7 @@ class Post < ApplicationRecord validates :body, presence: true, length: { maximum: 30_000 } validates :doc_slug, uniqueness: { scope: [:community_id], case_sensitive: false }, if: -> { doc_slug.present? } - validates :title, presence: true + validates :title, presence: true, if: -> { post_type.is_top_level? } validates :tags_cache, presence: true, if: -> { post_type.has_tags } validate :category_allows_post_type, if: -> { category_id.present? } diff --git a/app/views/application/dashboard.html.erb b/app/views/application/dashboard.html.erb index f818dfaba71c5d2854b70a89687dd316a50da735..97eeadafb4c2cebfd8eb8c5ff743071b7a866036 100644 --- a/app/views/application/dashboard.html.erb +++ b/app/views/application/dashboard.html.erb @@ -19,7 +19,6 @@ <% end %> </div> </div> - <div class="widget--body h-fw-bold h-bg-tertiary-050"><i class="fa fa-file-alt"></i> Posts</div> <% categories.each do |cat| %> <% next if (cat.min_view_trust_level || -1) > (current_user&.trust_level || 0) %> <div class="widget--body"> diff --git a/app/views/posts/_form.html.erb b/app/views/posts/_form.html.erb index 2c6f5c9b8928d0baf82846b7165bb4703bc8a77b..47a8eaf77f229315a3119d90bbe9a8829456a68d 100644 --- a/app/views/posts/_form.html.erb +++ b/app/views/posts/_form.html.erb @@ -66,7 +66,8 @@ </div> <div> <span class="has-float-right has-font-size-caption js-character-count-post-title hide" - data-max="<%= max_title_length(category) %>" data-min="<%= min_title_length(category) %>" + data-min="<%= min_title_length(category) %>" + data-max="<%= max_title_length(category) %>" data-display-at="0.75"> <i class="fas fa-ellipsis-h js-character-count__icon"></i> <span class="js-character-count__count">0 / <%= max_title_length(category) %></span> diff --git a/app/views/posts/_mdhint.html.erb b/app/views/posts/_mdhint.html.erb index ee6f3898e7727499513ded59f208799891ab0342..b8e5ed06741ecdc6cb0858128fdcd3a0230a3082 100644 --- a/app/views/posts/_mdhint.html.erb +++ b/app/views/posts/_mdhint.html.erb @@ -17,7 +17,9 @@ We <a href="/help/formatting">support Markdown</a> for posts: <strong>**bold**</strong>, <em>*italics*</em>, <code>`code`</code>, two newlines for paragraphs <span class="has-float-right has-font-size-caption js-character-count-post-body hide" - data-max="<%= max_length %>" data-min="<%= min_length %>" data-display-at="0.75"> + data-min="<%= min_length %>" + data-max="<%= max_length %>" + data-display-at="0.75"> <i class="fas fa-ellipsis-h js-character-count__icon"></i> <span class="js-character-count__count">0 / <%= max_length %></span> </span> diff --git a/app/views/shared/_body_field.html.erb b/app/views/shared/_body_field.html.erb index de5c93f950a159618f3833e68900c7db9a6698a6..2ab596799399b4de70fee5d67b84adef1b1fbaac 100644 --- a/app/views/shared/_body_field.html.erb +++ b/app/views/shared/_body_field.html.erb @@ -13,6 +13,7 @@ min_length = defined?(min_length) ? min_length : nil max_length = defined?(max_length) ? max_length : nil %> + <div class="form-group"> <%= f.label field_name, field_label, class: "form-element" %> <% if block_given? %> diff --git a/test/fixtures/posts.yml b/test/fixtures/posts.yml index bd4c76383cb81d2101989a582feb4979711d253c..afbab5147a4926a388b3406737a43789e49e51fd 100644 --- a/test/fixtures/posts.yml +++ b/test/fixtures/posts.yml @@ -227,6 +227,7 @@ high_trust: answer_one: post_type: answer + title: A1 ABCDEF GHIJKL MNOPQR body: A1 ABCDEF GHIJKL MNOPQR STUVWX YZ ABCDEF GHIJKL MNOPQR STUVWX YZ body_markdown: ZY XWVUTS RQPONM LKJIHG FEDCBA ZY XWVUTS RQPONM LKJIHG FEDCBA score: 0.5 @@ -240,6 +241,7 @@ answer_one: answer_two: post_type: answer + title: A2 ABCDEF GHIJKL MNOPQR body: A2 ABCDEF GHIJKL MNOPQR STUVWX YZ ABCDEF GHIJKL MNOPQR STUVWX YZ body_markdown: ZY XWVUTS RQPONM LKJIHG FEDCBA ZY XWVUTS RQPONM LKJIHG FEDCBA score: 0.5 @@ -253,6 +255,7 @@ answer_two: comments_disabled: post_type: answer + title: A2 ABCDEF GHIJKL MNOPQR body: A2 ABCDEF GHIJKL MNOPQR STUVWX YZ ABCDEF GHIJKL MNOPQR STUVWX YZ body_markdown: ZY XWVUTS RQPONM LKJIHG FEDCBA ZY XWVUTS RQPONM LKJIHG FEDCBA score: 0.5 @@ -267,6 +270,7 @@ comments_disabled: bad_answer: post_type: answer + title: A2 ABCDEF GHIJKL MNOPQR body: A2 ABCDEF GHIJKL MNOPQR STUVWX YZ ABCDEF GHIJKL MNOPQR STUVWX YZ body_markdown: ZY XWVUTS RQPONM LKJIHG FEDCBA ZY XWVUTS RQPONM LKJIHG FEDCBA score: 0.4 @@ -280,6 +284,7 @@ bad_answer: really_old_answer: post_type: answer + title: A3RO ABCDEF GHIJKL MNOPQR body: A3RO ABCDEF GHIJKL MNOPQR STUVWX YZ ABCDEF GHIJKL MNOPQR STUVWX YZ body_markdown: ZY XWVUTS RQPONM LKJIHG FEDCBA ZY XWVUTS RQPONM LKJIHG FEDCBA score: 2 @@ -294,6 +299,7 @@ really_old_answer: deleted_answer: post_type: answer + title: A4D ABCDEF GHIJKL MNOPQR body: A4D ABCDEF GHIJKL MNOPQR STUVWX YZ ABCDEF GHIJKL MNOPQR STUVWX YZ body_markdown: ZY XWVUTS RQPONM LKJIHG FEDCBA ZY XWVUTS RQPONM LKJIHG FEDCBA score: 0.5