docbrown/app/models/settings/user_experience.rb
Daniel Uber 5678fb77f5
Remove unneeded checks for code tags when filtering articles from search indexing (#14801)
* Move logic to determine noindex from view to model

This brings attention to the code and allows for faster unit tests.

I expect we'll be modifying this soon to deemphasize the code tag as a
marker of quality.

* Replace "5" constant with home feed minimum score

* Remove check for "code" tags in low quality article check

This made sense for DEV and other devrel communities, but is no longer
necessary for Forems.

* Add UserExperience setting for minimum index score

- add setting, I used `index_minimum_score` to match the
`home_feed_minimum_score`, `minimum_index_score` feels natural but
breaks the pattern.

- use this to determine whether to include article in the sitemap

- use this to determine whether to add noindex meta to article show page

* Remove unneeded tests

Since there's no longer any check for <code> tags in the body, omit
those tests (which passed anyway).

* Add new setting to admin page
2021-09-28 13:44:35 -04:00

29 lines
1.3 KiB
Ruby

module Settings
# Basic UX settings that can be overriden by individual user preferences.
class UserExperience < Base
self.table_name = :settings_user_experiences
HEX_COLOR_REGEX = /\A#(\h{6}|\h{3})\z/
# The default font for all users that have not chosen a custom font yet
setting :default_font, type: :string, default: "sans_serif"
setting :feed_strategy, type: :string, default: "basic"
# basic (current default), rich (cover image on all posts), compact (more minimal)
setting :feed_style, type: :string, default: "basic"
setting :home_feed_minimum_score, type: :integer, default: 0
setting :index_minimum_score, type: :integer, default: 0
setting :primary_brand_color_hex, type: :string, default: "#3b49df", validates: {
format: {
with: HEX_COLOR_REGEX,
message: "must be be a 3 or 6 character hex (starting with #)"
},
color_contrast: true
}
# a non-public forem will redirect all unauthenticated pages to the registration page.
# a public forem could have more fine-grained authentication (listings ar private etc.) in future
setting :public, type: :boolean, default: 0
setting :tag_feed_minimum_score, type: :integer, default: 0
setting :default_locale, type: :string, default: "en"
setting :display_in_directory, type: :boolean, default: true
end
end