From 0a53ca444a4bd4b28eddf2064133c38a65d41f2c Mon Sep 17 00:00:00 2001 From: "Akihiko Odaki (@fn_aki@pawoo.net)" Date: Thu, 29 Jun 2017 08:43:10 +0900 Subject: Cover Admin::AccountsController more (#3327) --- spec/controllers/admin/accounts_controller_spec.rb | 55 +++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) (limited to 'spec/controllers') diff --git a/spec/controllers/admin/accounts_controller_spec.rb b/spec/controllers/admin/accounts_controller_spec.rb index 305260475..8be27d866 100644 --- a/spec/controllers/admin/accounts_controller_spec.rb +++ b/spec/controllers/admin/accounts_controller_spec.rb @@ -3,11 +3,64 @@ require 'rails_helper' RSpec.describe Admin::AccountsController, type: :controller do render_views + let(:user) { Fabricate(:user, admin: true) } + before do - sign_in Fabricate(:user, admin: true), scope: :user + sign_in user, scope: :user end describe 'GET #index' do + around do |example| + default_per_page = Account.default_per_page + Account.paginates_per 1 + example.run + Account.paginates_per default_per_page + end + + it 'filters with parameters' do + new = AccountFilter.method(:new) + + expect(AccountFilter).to receive(:new) do |params| + h = params.to_h + + expect(h[:local]).to eq '1' + expect(h[:remote]).to eq '1' + expect(h[:by_domain]).to eq 'domain' + expect(h[:silenced]).to eq '1' + expect(h[:recent]).to eq '1' + expect(h[:suspended]).to eq '1' + expect(h[:username]).to eq 'username' + expect(h[:display_name]).to eq 'display name' + expect(h[:email]).to eq 'local-part@domain' + expect(h[:ip]).to eq '0.0.0.42' + + new.call({}) + end + + get :index, params: { + local: '1', + remote: '1', + by_domain: 'domain', + silenced: '1', + recent: '1', + suspended: '1', + username: 'username', + display_name: 'display name', + email: 'local-part@domain', + ip: '0.0.0.42' + } + end + + it 'paginates accounts' do + Fabricate(:account) + + get :index, params: { page: 2 } + + accounts = assigns(:accounts) + expect(accounts.count).to eq 1 + expect(accounts.klass).to be Account + end + it 'returns http success' do get :index expect(response).to have_http_status(:success) -- cgit From 6dd5eac7fc81f2283525f954db812d937153bcfc Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 30 Jun 2017 07:43:34 -0400 Subject: Add controller spec for manifests controller (#4003) --- spec/controllers/manifests_controller_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 spec/controllers/manifests_controller_spec.rb (limited to 'spec/controllers') diff --git a/spec/controllers/manifests_controller_spec.rb b/spec/controllers/manifests_controller_spec.rb new file mode 100644 index 000000000..6f188fa35 --- /dev/null +++ b/spec/controllers/manifests_controller_spec.rb @@ -0,0 +1,19 @@ +require 'rails_helper' + +describe ManifestsController do + render_views + + describe 'GET #show' do + before do + get :show, format: :json + end + + it 'assigns @instance_presenter' do + expect(assigns(:instance_presenter)).to be_kind_of InstancePresenter + end + + it 'returns http success' do + expect(response).to have_http_status(:success) + end + end +end -- cgit From 864e3f8d9ca652e10a28bddbb0d0df629d2849d4 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 8 Jul 2017 14:51:05 +0200 Subject: Replace OEmbed and initial state Rabl templates with serializers (#4110) * Replace OEmbed Rabl template with serializer * Replace initial state rabl with serializer --- app/controllers/api/oembed_controller.rb | 3 +- app/controllers/home_controller.rb | 17 ++++++--- app/presenters/initial_state_presenter.rb | 5 +++ app/serializers/initial_state_serializer.rb | 39 ++++++++++++++++++++ app/serializers/oembed_serializer.rb | 56 +++++++++++++++++++++++++++++ app/views/api/oembed/show.json.rabl | 14 -------- app/views/home/index.html.haml | 2 +- app/views/home/initial_state.json.rabl | 38 -------------------- spec/controllers/home_controller_spec.rb | 41 ++++----------------- 9 files changed, 121 insertions(+), 94 deletions(-) create mode 100644 app/presenters/initial_state_presenter.rb create mode 100644 app/serializers/initial_state_serializer.rb create mode 100644 app/serializers/oembed_serializer.rb delete mode 100644 app/views/api/oembed/show.json.rabl delete mode 100644 app/views/home/initial_state.json.rabl (limited to 'spec/controllers') diff --git a/app/controllers/api/oembed_controller.rb b/app/controllers/api/oembed_controller.rb index 6e3e34d96..f8c87dd16 100644 --- a/app/controllers/api/oembed_controller.rb +++ b/app/controllers/api/oembed_controller.rb @@ -5,8 +5,7 @@ class Api::OEmbedController < Api::BaseController def show @stream_entry = find_stream_entry.stream_entry - @width = maxwidth_or_default - @height = maxheight_or_default + render json: @stream_entry, serializer: OEmbedSerializer, width: maxwidth_or_default, height: maxheight_or_default end private diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 6209a3ae9..218da6906 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -2,13 +2,10 @@ class HomeController < ApplicationController before_action :authenticate_user! + before_action :set_initial_state_json def index - @body_classes = 'app-body' - @token = current_session.token - @web_settings = Web::Setting.find_by(user: current_user)&.data || {} - @admin = Account.find_local(Setting.site_contact_username) - @streaming_api_base_url = Rails.configuration.x.streaming_api_base_url + @body_classes = 'app-body' end private @@ -16,4 +13,14 @@ class HomeController < ApplicationController def authenticate_user! redirect_to(single_user_mode? ? account_path(Account.first) : about_path) unless user_signed_in? end + + def set_initial_state_json + state = InitialStatePresenter.new(settings: Web::Setting.find_by(user: current_user)&.data || {}, + current_account: current_account, + token: current_session.token, + admin: Account.find_local(Setting.site_contact_username)) + + serializable_resource = ActiveModelSerializers::SerializableResource.new(state, serializer: InitialStateSerializer) + @initial_state_json = serializable_resource.to_json + end end diff --git a/app/presenters/initial_state_presenter.rb b/app/presenters/initial_state_presenter.rb new file mode 100644 index 000000000..75fef28a8 --- /dev/null +++ b/app/presenters/initial_state_presenter.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +class InitialStatePresenter < ActiveModelSerializers::Model + attributes :settings, :token, :current_account, :admin +end diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb new file mode 100644 index 000000000..84f9e23a6 --- /dev/null +++ b/app/serializers/initial_state_serializer.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +class InitialStateSerializer < ActiveModel::Serializer + attributes :meta, :compose, :accounts, + :media_attachments, :settings + + def meta + { + streaming_api_base_url: Rails.configuration.x.streaming_api_base_url, + access_token: object.token, + locale: I18n.locale, + domain: Rails.configuration.x.local_domain, + me: object.current_account.id, + admin: object.admin&.id, + boost_modal: object.current_account.user.setting_boost_modal, + delete_modal: object.current_account.user.setting_delete_modal, + auto_play_gif: object.current_account.user.setting_auto_play_gif, + system_font_ui: object.current_account.user.setting_system_font_ui, + } + end + + def compose + { + me: object.current_account.id, + default_privacy: object.current_account.user.setting_default_privacy, + } + end + + def accounts + store = {} + store[object.current_account.id] = ActiveModelSerializers::SerializableResource.new(object.current_account, serializer: REST::AccountSerializer) + store[object.admin.id] = ActiveModelSerializers::SerializableResource.new(object.admin, serializer: REST::AccountSerializer) unless object.admin.nil? + store + end + + def media_attachments + { accept_content_types: MediaAttachment::IMAGE_MIME_TYPES + MediaAttachment::VIDEO_MIME_TYPES } + end +end diff --git a/app/serializers/oembed_serializer.rb b/app/serializers/oembed_serializer.rb new file mode 100644 index 000000000..78376d253 --- /dev/null +++ b/app/serializers/oembed_serializer.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +class OEmbedSerializer < ActiveModel::Serializer + include RoutingHelper + include ActionView::Helpers::TagHelper + + attributes :type, :version, :title, :author_name, + :author_url, :provider_name, :provider_url, + :cache_age, :html, :width, :height + + def type + 'rich' + end + + def version + '1.0' + end + + def author_name + object.account.display_name.presence || object.account.username + end + + def author_url + account_url(object.account) + end + + def provider_name + Rails.configuration.x.local_domain + end + + def provider_url + root_url + end + + def cache_age + 86_400 + end + + def html + tag :iframe, + src: embed_account_stream_entry_url(object.account, object), + style: 'width: 100%; overflow: hidden', + frameborder: '0', + scrolling: 'no', + width: width, + height: height + end + + def width + instance_options[:width] + end + + def height + instance_options[:height] + end +end diff --git a/app/views/api/oembed/show.json.rabl b/app/views/api/oembed/show.json.rabl deleted file mode 100644 index 11dcec538..000000000 --- a/app/views/api/oembed/show.json.rabl +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true -object @stream_entry - -node(:type) { 'rich' } -node(:version) { '1.0' } -node(:title, &:title) -node(:author_name) { |entry| entry.account.display_name.blank? ? entry.account.username : entry.account.display_name } -node(:author_url) { |entry| account_url(entry.account) } -node(:provider_name) { site_hostname } -node(:provider_url) { root_url } -node(:cache_age) { 86_400 } -node(:html) { |entry| "" } -node(:width) { @width } -node(:height) { @height } diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 33c978c89..71dcb54c6 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -1,5 +1,5 @@ - content_for :header_tags do - %script#initial-state{ type: 'application/json' }!= json_escape(render(file: 'home/initial_state', formats: :json)) + %script#initial-state{ type: 'application/json' }!= json_escape(@initial_state_json) = javascript_pack_tag 'application', integrity: true, crossorigin: 'anonymous' diff --git a/app/views/home/initial_state.json.rabl b/app/views/home/initial_state.json.rabl deleted file mode 100644 index c428a5a1f..000000000 --- a/app/views/home/initial_state.json.rabl +++ /dev/null @@ -1,38 +0,0 @@ -object false - -node(:meta) do - { - streaming_api_base_url: @streaming_api_base_url, - access_token: @token, - locale: I18n.locale, - domain: site_hostname, - me: current_account.id, - admin: @admin.try(:id), - boost_modal: current_account.user.setting_boost_modal, - delete_modal: current_account.user.setting_delete_modal, - auto_play_gif: current_account.user.setting_auto_play_gif, - system_font_ui: current_account.user.setting_system_font_ui, - } -end - -node(:compose) do - { - me: current_account.id, - default_privacy: current_account.user.setting_default_privacy, - } -end - -node(:accounts) do - store = {} - store[current_account.id] = ActiveModelSerializers::SerializableResource.new(current_account, serializer: REST::AccountSerializer) - store[@admin.id] = ActiveModelSerializers::SerializableResource.new(@admin, serializer: REST::AccountSerializer) unless @admin.nil? - store -end - -node(:media_attachments) do - { - accept_content_types: MediaAttachment::IMAGE_MIME_TYPES + MediaAttachment::VIDEO_MIME_TYPES - } -end - -node(:settings) { @web_settings } diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index cc1dbe5a1..d44d720b1 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -23,41 +23,14 @@ RSpec.describe HomeController, type: :controller do expect(assigns(:body_classes)).to eq 'app-body' end - it 'assigns @token' do - app = Doorkeeper::Application.create!(name: 'Web', superapp: true, redirect_uri: Doorkeeper.configuration.native_redirect_uri) - allow(Doorkeeper.configuration).to receive(:access_token_expires_in).and_return(42) - - subject - token = Doorkeeper::AccessToken.find_by(token: assigns(:token)) - - expect(token.application).to eq app - expect(token.resource_owner_id).to eq user.id - expect(token.scopes).to eq Doorkeeper::OAuth::Scopes.from_string('read write follow') - expect(token.expires_in_seconds).to eq 42 - expect(token.use_refresh_token?).to eq false - end - - it 'assigns @web_settings for {} if not available' do - subject - expect(assigns(:web_settings)).to eq({}) - end - - it 'assigns @web_settings for Web::Setting if available' do - setting = Fabricate('Web::Setting', data: '{"home":{}}', user: user) - subject - expect(assigns(:web_settings)).to eq setting.data - end - - it 'assigns @admin' do - admin = Fabricate(:account) - Setting.site_contact_username = admin.username - subject - expect(assigns(:admin)).to eq admin - end - - it 'assigns streaming_api_base_url' do + it 'assigns @initial_state_json' do subject - expect(assigns(:streaming_api_base_url)).to eq 'ws://localhost:4000' + initial_state_json = json_str_to_hash(assigns(:initial_state_json)) + expect(initial_state_json[:meta]).to_not be_nil + expect(initial_state_json[:compose]).to_not be_nil + expect(initial_state_json[:accounts]).to_not be_nil + expect(initial_state_json[:settings]).to_not be_nil + expect(initial_state_json[:media_attachments]).to_not be_nil end end end -- cgit From 7a889a8e125a03e109b225cd83b0abcbdc76d95b Mon Sep 17 00:00:00 2001 From: STJrInuyasha Date: Mon, 10 Jul 2017 09:05:06 -0700 Subject: Remote following success page (#4129) * Added a success page to remote following Includes follow-through links to web (the old redirect target) and back to the remote user's profile * Use Account.new in spec instead of a fake with only id (fixes spec) * Fabricate(:account) over Account.new * Remove self from the success text (and all HTML with it) --- app/controllers/authorize_follows_controller.rb | 2 +- app/javascript/styles/forms.scss | 9 +++++++++ app/views/authorize_follows/success.html.haml | 16 ++++++++++++++++ config/locales/en.yml | 6 ++++++ spec/controllers/authorize_follows_controller_spec.rb | 4 ++-- 5 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 app/views/authorize_follows/success.html.haml (limited to 'spec/controllers') diff --git a/app/controllers/authorize_follows_controller.rb b/app/controllers/authorize_follows_controller.rb index da4ef022a..dccd1c209 100644 --- a/app/controllers/authorize_follows_controller.rb +++ b/app/controllers/authorize_follows_controller.rb @@ -15,7 +15,7 @@ class AuthorizeFollowsController < ApplicationController if @account.nil? render :error else - redirect_to web_url("accounts/#{@account.id}") + render :success end rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError render :error diff --git a/app/javascript/styles/forms.scss b/app/javascript/styles/forms.scss index 7a181f36b..414dc4fe8 100644 --- a/app/javascript/styles/forms.scss +++ b/app/javascript/styles/forms.scss @@ -375,3 +375,12 @@ code { width: 50%; } } + +.post-follow-actions { + text-align: center; + color: $ui-primary-color; + + div { + margin-bottom: 4px; + } +} diff --git a/app/views/authorize_follows/success.html.haml b/app/views/authorize_follows/success.html.haml new file mode 100644 index 000000000..f0b495689 --- /dev/null +++ b/app/views/authorize_follows/success.html.haml @@ -0,0 +1,16 @@ +- content_for :page_title do + = t('authorize_follow.title', acct: @account.acct) + +.form-container + .follow-prompt + - if @account.locked? + %h2= t('authorize_follow.follow_request') + - else + %h2= t('authorize_follow.following') + + = render 'card', account: @account + + .post-follow-actions + %div= link_to t('authorize_follow.post_follow.web'), web_url("accounts/#{@account.id}"), class: 'button button--block' + %div= link_to t('authorize_follow.post_follow.return'), @account.url, class: 'button button--block' + %div= t('authorize_follow.post_follow.close') diff --git a/config/locales/en.yml b/config/locales/en.yml index 60e192491..8bb893d1c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -221,6 +221,12 @@ en: authorize_follow: error: Unfortunately, there was an error looking up the remote account follow: Follow + following: 'Success! You are now following:' + follow_request: 'You have sent a follow request to:' + post_follow: + web: Go to web + return: Return to the user's profile + close: Or, you can just close this window. prompt_html: 'You (%{self}) have requested to follow:' title: Follow %{acct} datetime: diff --git a/spec/controllers/authorize_follows_controller_spec.rb b/spec/controllers/authorize_follows_controller_spec.rb index b801aa661..26e46a23c 100644 --- a/spec/controllers/authorize_follows_controller_spec.rb +++ b/spec/controllers/authorize_follows_controller_spec.rb @@ -94,7 +94,7 @@ describe AuthorizeFollowsController do end it 'follows account when found' do - target_account = double(id: '123') + target_account = Fabricate(:account) result_account = double(target_account: target_account) service = double allow(FollowService).to receive(:new).and_return(service) @@ -103,7 +103,7 @@ describe AuthorizeFollowsController do post :create, params: { acct: 'acct:user@hostname' } expect(service).to have_received(:call).with(account, 'user@hostname') - expect(response).to redirect_to(web_url('accounts/123')) + expect(response).to render_template(:success) end end end -- cgit From 056b5ed72f6d980bceeb49eb249b8365fe8fce66 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 12 Jul 2017 03:24:04 +0200 Subject: Improve UI of admin site settings (#4163) --- app/controllers/admin/settings_controller.rb | 6 +- app/javascript/styles/forms.scss | 87 +++++++++++++++------ app/models/form/admin_settings.rb | 29 +++++++ app/views/admin/settings/edit.html.haml | 88 +++++++--------------- config/initializers/simple_form.rb | 4 +- config/locales/ca.yml | 2 - config/locales/de.yml | 2 - config/locales/en.yml | 40 +++++----- config/locales/fa.yml | 2 - config/locales/fr.yml | 2 - config/locales/he.yml | 2 - config/locales/id.yml | 2 - config/locales/io.yml | 2 - config/locales/ja.yml | 2 - config/locales/ko.yml | 2 - config/locales/nl.yml | 2 - config/locales/no.yml | 2 - config/locales/oc.yml | 2 - config/locales/pl.yml | 8 +- config/locales/pt-BR.yml | 2 - config/locales/pt.yml | 2 - config/locales/ru.yml | 2 - config/locales/th.yml | 2 - config/locales/tr.yml | 2 - config/locales/uk.yml | 2 - config/locales/zh-CN.yml | 2 - config/locales/zh-HK.yml | 2 - config/locales/zh-TW.yml | 2 - spec/controllers/admin/settings_controller_spec.rb | 8 +- 29 files changed, 151 insertions(+), 161 deletions(-) create mode 100644 app/models/form/admin_settings.rb (limited to 'spec/controllers') diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb index 29b590d7a..5985d6282 100644 --- a/app/controllers/admin/settings_controller.rb +++ b/app/controllers/admin/settings_controller.rb @@ -22,7 +22,7 @@ module Admin ).freeze def edit - @settings = Setting.all_as_records + @admin_settings = Form::AdminSettings.new end def update @@ -38,12 +38,12 @@ module Admin private def settings_params - params.permit(ADMIN_SETTINGS) + params.require(:form_admin_settings).permit(ADMIN_SETTINGS) end def value_for_update(key, value) if BOOLEAN_SETTINGS.include?(key) - value == 'true' + value == '1' else value end diff --git a/app/javascript/styles/forms.scss b/app/javascript/styles/forms.scss index e723b50ff..e1de36d55 100644 --- a/app/javascript/styles/forms.scss +++ b/app/javascript/styles/forms.scss @@ -57,10 +57,7 @@ code { } } - .input.file, - .input.select, - .input.radio_buttons, - .input.check_boxes { + .input.with_label { padding: 15px 0; margin-bottom: 0; @@ -71,6 +68,44 @@ code { display: block; padding-top: 5px; } + + &.boolean { + padding: initial; + margin-bottom: initial; + + .label_input > label { + font-family: inherit; + font-size: 14px; + color: $primary-text-color; + display: block; + width: auto; + } + + label.checkbox { + position: relative; + padding-left: 25px; + flex: 1 1 auto; + } + } + } + + .input.with_block_label { + & > label { + font-family: inherit; + font-size: 16px; + color: $primary-text-color; + display: block; + padding-top: 5px; + } + + .hint { + margin-bottom: 15px; + } + + li { + float: left; + width: 50%; + } } .fields-group { @@ -106,7 +141,7 @@ code { input[type=checkbox] { position: absolute; left: 0; - top: 1px; + top: 5px; margin: 0; } @@ -116,6 +151,29 @@ code { } } + .check_boxes { + .checkbox { + label { + font-family: inherit; + font-size: 14px; + color: $primary-text-color; + display: block; + width: auto; + position: relative; + padding-top: 5px; + padding-left: 25px; + flex: 1 1 auto; + } + + input[type=checkbox] { + position: absolute; + left: 0; + top: 5px; + margin: 0; + } + } + } + input[type=text], input[type=number], input[type=email], @@ -390,25 +448,6 @@ code { } } -.user_filtered_languages { - & > label { - font-family: inherit; - font-size: 16px; - color: $primary-text-color; - display: block; - padding-top: 5px; - } - - .hint { - margin-bottom: 15px; - } - - li { - float: left; - width: 50%; - } -} - .post-follow-actions { text-align: center; color: $ui-primary-color; diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb new file mode 100644 index 000000000..c3a04ba65 --- /dev/null +++ b/app/models/form/admin_settings.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class Form::AdminSettings + include ActiveModel::Model + + delegate( + :site_contact_username, + :site_contact_username=, + :site_contact_email, + :site_contact_email=, + :site_title, + :site_title=, + :site_description, + :site_description=, + :site_extended_description, + :site_extended_description=, + :site_terms, + :site_terms=, + :open_registrations, + :open_registrations=, + :closed_registrations_message, + :closed_registrations_message=, + :open_deletion, + :open_deletion=, + :timeline_preview, + :timeline_preview=, + to: Setting + ) +end diff --git a/app/views/admin/settings/edit.html.haml b/app/views/admin/settings/edit.html.haml index 59192530b..9f8a6640b 100644 --- a/app/views/admin/settings/edit.html.haml +++ b/app/views/admin/settings/edit.html.haml @@ -1,64 +1,32 @@ - content_for :page_title do = t('admin.settings.title') -= form_tag(admin_settings_path, method: :put, class: 'simple_form', style: 'max-width: 100%') do - %table.table - %thead - %tr - %th{ width: '40%' } - = t('admin.settings.setting') - %th - %tbody - %tr - %td - %strong= t('admin.settings.contact_information.label') - %td= text_field_tag :site_contact_username, @settings['site_contact_username'].value, place_holder: t('admin.settings.contact_information.username') - %tr - %td - %strong= t('admin.accounts.email') - %td= text_field_tag :site_contact_email, @settings['site_contact_email'].value, place_holder: t('admin.settings.contact_information.email') - %tr - %td - %strong= t('admin.settings.site_title') - %td= text_field_tag :site_title, @settings['site_title'].value - %tr - %td - %strong= t('admin.settings.site_description.title') - %p= t('admin.settings.site_description.desc_html') - %td= text_area_tag :site_description, @settings['site_description'].value, rows: 8 - %tr - %td - %strong= t('admin.settings.site_description_extended.title') - %p= t('admin.settings.site_description_extended.desc_html') - %td= text_area_tag :site_extended_description, @settings['site_extended_description'].value, rows: 8 - %tr - %td - %strong= t('admin.settings.site_terms.title') - %p= t('admin.settings.site_terms.desc_html') - %td= text_area_tag :site_terms, @settings['site_terms'].value, rows: 8 - %tr - %td - %strong= t('admin.settings.registrations.open.title') - %p= t('admin.settings.registrations.open.desc_html') - %td - = select_tag :open_registrations, options_for_select({ t('simple_form.no') => false, t('simple_form.yes') => true }, @settings['open_registrations'].value) - %tr - %td - %strong= t('admin.settings.registrations.closed_message.title') - %p= t('admin.settings.registrations.closed_message.desc_html') - %td= text_area_tag :closed_registrations_message, @settings['closed_registrations_message'].value, rows: 8 - %tr - %td - %strong= t('admin.settings.registrations.deletion.title') - %p= t('admin.settings.registrations.deletion.desc_html') - %td - = select_tag :open_deletion, options_for_select({ t('simple_form.no') => false, t('simple_form.yes') => true }, @settings['open_deletion'].value) - %tr - %td - %strong= t('admin.settings.timeline_preview.title') - %p= t('admin.settings.timeline_preview.desc_html') - %td - = select_tag :timeline_preview, options_for_select({ t('simple_form.no') => false, t('simple_form.yes') => true }, @settings['timeline_preview'].value) += simple_form_for @admin_settings, url: admin_settings_path, html: { method: :patch } do |f| + .fields-group + = f.input :site_title, placeholder: t('admin.settings.site_title') + = f.input :site_description, wrapper: :with_block_label, as: :text, label: t('admin.settings.site_description.title'), hint: t('admin.settings.site_description.desc_html'), input_html: { rows: 8 } + = f.input :site_contact_username, placeholder: t('admin.settings.contact_information.username') + = f.input :site_contact_email, placeholder: t('admin.settings.contact_information.email') - .simple_form.actions - = button_tag t('generic.save_changes'), type: :submit, class: :btn + %hr/ + + .fields-group + = f.input :timeline_preview, as: :boolean, wrapper: :with_label, label: t('admin.settings.timeline_preview.title'), hint: t('admin.settings.timeline_preview.desc_html') + + .fields-group + = f.input :open_registrations, as: :boolean, wrapper: :with_label, label: t('admin.settings.registrations.open.title'), hint: t('admin.settings.registrations.open.desc_html') + + .fields-group + = f.input :open_deletion, as: :boolean, wrapper: :with_label, label: t('admin.settings.registrations.deletion.title'), hint: t('admin.settings.registrations.deletion.desc_html') + + .fields-group + = f.input :closed_registrations_message, as: :text, wrapper: :with_block_label, label: t('admin.settings.registrations.closed_message.title'), hint: t('admin.settings.registrations.closed_message.desc_html'), input_html: { rows: 8 } + + %hr/ + + .fields-group + = f.input :site_extended_description, wrapper: :with_block_label, as: :text, label: t('admin.settings.site_description_extended.title'), hint: t('admin.settings.site_description_extended.desc_html'), input_html: { rows: 8 } + = f.input :site_terms, wrapper: :with_block_label, as: :text, label: t('admin.settings.site_terms.title'), hint: t('admin.settings.site_terms.desc_html'), input_html: { rows: 8 } + + .actions + = f.button :button, t('generic.save_changes'), type: :submit diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb index ca7531748..5983918cd 100644 --- a/config/initializers/simple_form.rb +++ b/config/initializers/simple_form.rb @@ -50,14 +50,14 @@ SimpleForm.setup do |config| # b.use :full_error, wrap_with: { tag: :span, class: :error } end - config.wrappers :with_label, class: :input, hint_class: :field_with_hint, error_class: :field_with_errors do |b| + config.wrappers :with_label, class: [:input, :with_label], hint_class: :field_with_hint, error_class: :field_with_errors do |b| b.use :html5 b.use :label_input, wrap_with: { tag: :div, class: :label_input } b.use :hint, wrap_with: { tag: :span, class: :hint } b.use :error, wrap_with: { tag: :span, class: :error } end - config.wrappers :with_block_label, class: :input, hint_class: :field_with_hint, error_class: :field_with_errors do |b| + config.wrappers :with_block_label, class: [:input, :with_block_label], hint_class: :field_with_hint, error_class: :field_with_errors do |b| b.use :html5 b.use :label b.use :hint, wrap_with: { tag: :span, class: :hint } diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 10c34498b..f63aee3e6 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -155,7 +155,6 @@ ca: settings: contact_information: email: Introduir una adreça de correu electrònic pùblica - label: Informació de contacte username: Introduir un nom d'usuari registrations: closed_message: @@ -163,7 +162,6 @@ ca: title: Missatge de registre tancat open: title: Registre obert - setting: Ajust site_description: desc_html: Es mostra com un paràgraf a la pàgina principal i s'utilitza com una etiqueta meta.
Pots utilitzar etiquetes HTML, en particular <a> i <em>. title: Descripció del lloc diff --git a/config/locales/de.yml b/config/locales/de.yml index 2bdb87708..b084aca31 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -129,7 +129,6 @@ de: settings: contact_information: email: Eine öffentliche E-Mail-Adresse angeben - label: Kontaktinformationen username: Einen Benutzernamen angeben registrations: closed_message: @@ -137,7 +136,6 @@ de: title: Nachricht über geschlossene Registrierung open: title: Offene Registrierung - setting: Einstellung site_description: desc_html: Wird als Absatz auf der Frontseite angezeigt und als Meta-Tag benutzt.
Du kannst HTML-Tags benutzen, insbesondere <a> und <em>. title: Seitenbeschreibung diff --git a/config/locales/en.yml b/config/locales/en.yml index e33dde038..c9b5d9ab8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -168,33 +168,31 @@ en: view: View settings: contact_information: - email: Enter a public e-mail address - label: Contact information - username: Enter a username + email: Business e-mail + username: Contact username registrations: closed_message: - desc_html: Displayed on frontpage when registrations are closed
You can use HTML tags + desc_html: Displayed on frontpage when registrations are closed. You can use HTML tags title: Closed registration message + deletion: + desc_html: Allow anyone to delete their account + title: Open account deletion open: desc_html: Allow anyone to create an account title: Open registration - deletion: - desc_html: Allow anyone to delete their account - title: Open deletion - timeline_preview: - desc_html: Display public timeline on landing page - title: Timeline preview - setting: Setting site_description: - desc_html: Displayed as a paragraph on the frontpage and used as a meta tag.
You can use HTML tags, in particular <a> and <em>. - title: Site description + desc_html: Introductory paragraph on the frontpage and in meta tags. You can use HTML tags, in particular <a> and <em>. + title: Instance description site_description_extended: - desc_html: Displayed on extended information page
You can use HTML tags - title: Extended site description + desc_html: A good place for your code of conduct, rules, guidelines and other things that set your instance apart. You can use HTML tags + title: Custom extended information site_terms: - desc_html: Displayed on terms page
You can use HTML tags - title: Privacy policy - site_title: Site title + desc_html: You can write your own privacy policy, terms of service or other legalese. You can use HTML tags + title: Custom terms of service + site_title: Instance name + timeline_preview: + desc_html: Display public timeline on landing page + title: Timeline preview title: Site Settings subscriptions: callback_url: Callback URL @@ -230,12 +228,12 @@ en: authorize_follow: error: Unfortunately, there was an error looking up the remote account follow: Follow - following: 'Success! You are now following:' follow_request: 'You have sent a follow request to:' + following: 'Success! You are now following:' post_follow: - web: Go to web - return: Return to the user's profile close: Or, you can just close this window. + return: Return to the user's profile + web: Go to web prompt_html: 'You (%{self}) have requested to follow:' title: Follow %{acct} datetime: diff --git a/config/locales/fa.yml b/config/locales/fa.yml index 6f0bd0839..ade76d670 100644 --- a/config/locales/fa.yml +++ b/config/locales/fa.yml @@ -141,7 +141,6 @@ fa: settings: contact_information: email: یک نشانی ایمیل عمومی وارد کنید - label: اطلاعات تماس username: یک نام کاربری وارد کنید registrations: closed_message: @@ -149,7 +148,6 @@ fa: title: پیغام برای فعال‌نبودن ثبت نام open: title: امکان ثبت نام - setting: تنظیمات site_description: desc_html: روی صفحهٔ اصلی نمایش می‌یابد و همچنین به عنوان تگ‌های HTML.
می‌توانید HTML بنویسید, به‌ویژه <a> و <em>. title: دربارهٔ سایت diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 9eeafaa6e..c2efd0c85 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -155,7 +155,6 @@ fr: settings: contact_information: email: Entrez une adresse courriel publique - label: Informations de contact username: Entrez un nom d’utilisateur⋅ice registrations: closed_message: @@ -163,7 +162,6 @@ fr: title: Message de fermeture des inscriptions open: title: Inscriptions - setting: Paramètre site_description: desc_html: Affichée sous la forme d’un paragraphe sur la page d’accueil et utilisée comme balise meta.
Vous pouvez utiliser des balises HTML, en particulier <a> et <em>. title: Description du site diff --git a/config/locales/he.yml b/config/locales/he.yml index 760ddac00..21f8f1dc4 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -149,7 +149,6 @@ he: settings: contact_information: email: נא להקליד כתובת דוא"ל פומבית - label: פרטי התקשרות username: נא להכניס שם משתמש registrations: closed_message: @@ -157,7 +156,6 @@ he: title: מסר סגירת הרשמות open: title: הרשמה פתוחה - setting: הגדרה site_description: desc_html: מוצג כפסקה על הדף הראשי ומשמש כתגית מטא.
ניתן להשתמש בתגיות HTML, ובמיוחד ב־<a> ו־<em>. title: תיאור האתר diff --git a/config/locales/id.yml b/config/locales/id.yml index 4bcd8f2ed..e3fe96331 100644 --- a/config/locales/id.yml +++ b/config/locales/id.yml @@ -140,7 +140,6 @@ id: settings: contact_information: email: Masukkan alamat email - label: Informasi kontak username: Masukkan nama pengguna registrations: closed_message: @@ -148,7 +147,6 @@ id: title: Pesan penutupan pendaftaran open: title: Pendaftaran terbuka - setting: Pengaturan site_description: desc_html: Ditampilkan sebagai sebuah paragraf di halaman depan dan digunakan sebagai tag meta.
Anda bisa menggunakan tag HTML, khususnya <a> dan <em>. title: Deskripsi situs diff --git a/config/locales/io.yml b/config/locales/io.yml index 8eb48c303..b587d4bc6 100644 --- a/config/locales/io.yml +++ b/config/locales/io.yml @@ -128,7 +128,6 @@ io: settings: contact_information: email: Enter a public e-mail address - label: Contact information username: Enter a username registrations: closed_message: @@ -136,7 +135,6 @@ io: title: Closed registration message open: title: Open registration - setting: Setting site_description: desc_html: Displayed as a paragraph on the frontpage and used as a meta tag.
You can use HTML tags, in particular <a> and <em>. title: Site description diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 5b91aa75d..d57fe8da2 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -155,7 +155,6 @@ ja: settings: contact_information: email: 公開するメールアドレスを入力 - label: 連絡先情報 username: ユーザー名を入力 registrations: closed_message: @@ -163,7 +162,6 @@ ja: title: 新規登録停止時のメッセージ open: title: 新規登録を受け付ける - setting: 設定 site_description: desc_html: トップページへの表示と meta タグに使用されます。
HTMLタグ、特に<a><em>が利用可能です。 title: サイトの説明文 diff --git a/config/locales/ko.yml b/config/locales/ko.yml index c8ad38d41..bafc19993 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -155,7 +155,6 @@ ko: settings: contact_information: email: 공개할 메일 주소를 입력 - label: 연락처 정보 username: 아이디를 입력 registrations: closed_message: @@ -163,7 +162,6 @@ ko: title: 신규 등록 정지 시 메시지 open: title: 신규 등록을 받음 - setting: 설정 site_description: desc_html: 탑 페이지와 meta 태그에 사용됩니다.
HTML 태그, 예를 들어<a> 태그와 <em> 태그를 사용할 수 있습니다. title: 사이트 설명 diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 633061b06..dfc58f6b3 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -55,7 +55,6 @@ nl: settings: contact_information: email: Vul een openbaar gebruikt e-mailadres in - label: Contactgegevens username: Vul een gebruikersnaam in registrations: closed_message: @@ -63,7 +62,6 @@ nl: title: Bericht wanneer registratie is uitgeschakeld open: title: Open registratie - setting: Instelling site_description: desc_html: Dit wordt als een alinea op de voorpagina getoond en gebruikt als meta-tag in de paginabron.
Je kan HTML gebruiken, zoals <a> en <em>. title: Omschrijving Mastodon-server diff --git a/config/locales/no.yml b/config/locales/no.yml index 05714959d..004e1ff80 100644 --- a/config/locales/no.yml +++ b/config/locales/no.yml @@ -142,7 +142,6 @@ settings: contact_information: email: Skriv en offentlig e-postadresse - label: Kontaktinformasjon username: Skriv brukernavn registrations: closed_message: @@ -150,7 +149,6 @@ title: Melding for lukket registrering open: title: Åpen registrering - setting: Innstilling site_description: desc_html: Vises som et avsnitt på forsiden og brukes som en meta-tagg.
Du kan bruke HTML-tagger, spesielt <a> og <em>. title: Nettstedsbeskrivelse diff --git a/config/locales/oc.yml b/config/locales/oc.yml index 30d5258a5..91a6ca791 100644 --- a/config/locales/oc.yml +++ b/config/locales/oc.yml @@ -149,7 +149,6 @@ oc: settings: contact_information: email: Picatz una adreça de corrièl - label: Informacions de contacte username: Picatz un nom d’utilizaire registrations: closed_message: @@ -157,7 +156,6 @@ oc: title: Messatge de barradura de las inscripcions open: title: Inscripcions - setting: Paramètre site_description: desc_html: Afichada jos la forma de paragrafe sus la pagina d’acuèlh e utilizada coma balisa meta.
Podètz utilizar de balisas HTML, coma <a> et <em>. title: Descripcion del site diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 018ff3c7b..c6588e846 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -155,7 +155,6 @@ pl: settings: contact_information: email: Wprowadź publiczny adres e-mail - label: Informacje kontaktowe username: Wprowadź nazwę użytkownika registrations: closed_message: @@ -163,7 +162,6 @@ pl: title: Wiadomość o nieaktywnej rejestracji open: title: Otwarta rejestracja - setting: Ustawienie site_description: desc_html: Wyświetlany jako nagłówek na stronie głównej oraz jako meta tag.
Możesz korzystać z tagów HTML, w szczególności z <a> i <em>. title: Opis strony @@ -208,12 +206,12 @@ pl: authorize_follow: error: Niestety, podczas sprawdzania zdalnego konta wystąpił błąd follow: Śledź - following: 'Pomyślnie! Od teraz śledzisz:' follow_request: 'Wysłano prośbę o pozwolenie na obserwację:' + following: 'Pomyślnie! Od teraz śledzisz:' post_follow: - web: Przejdź do sieci - return: Powróć do strony użytkownika close: Ewentualnie, możesz po prostu zamknąć tą stronę. + return: Powróć do strony użytkownika + web: Przejdź do sieci prompt_html: 'Ty (%{self}) chcesz śledzić:' title: Śledź %{acct} datetime: diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index fb5e03c8c..355c20d05 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -141,7 +141,6 @@ pt-BR: settings: contact_information: email: Entre um endereço de email público - label: Informação de contato username: Entre com usuário registrations: closed_message: @@ -149,7 +148,6 @@ pt-BR: title: Mensagem de registro fechados open: title: Aberto para registro - setting: Preferências site_description: desc_html: Mostrar como parágrafo e usado como meta tag.
Vôce pode usar tags HTML, em particular <a> e <em>. title: Descrição do site diff --git a/config/locales/pt.yml b/config/locales/pt.yml index 0f59185a7..40be8a6c5 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -136,7 +136,6 @@ pt: settings: contact_information: email: Inserir um endereço de email para tornar público - label: Informação de contacto username: Insira um nome de utilizador registrations: closed_message: @@ -144,7 +143,6 @@ pt: title: Mensagem de registos encerrados open: title: Aceitar novos registos - setting: Preferências site_description: desc_html: Mostrar como parágrafo na página inicial e usado como meta tag.
Podes usar tags HTML, em particular <a> e <em>. title: Descrição do site diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 414d39dd2..5cfc2b1ca 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -123,7 +123,6 @@ ru: settings: contact_information: email: Введите публичный e-mail - label: Контактная информация username: Введите имя пользователя registrations: closed_message: @@ -131,7 +130,6 @@ ru: title: Сообщение о закрытой регистрации open: title: Открыть регистрацию - setting: Настройка site_description: desc_html: Отображается в качестве параграфа на титульной странице и используется в качестве мета-тега.
Можно использовать HTML-теги, в особенности <a> и <em>. title: Описание сайта diff --git a/config/locales/th.yml b/config/locales/th.yml index a71252afe..263babdd0 100644 --- a/config/locales/th.yml +++ b/config/locales/th.yml @@ -142,7 +142,6 @@ th: settings: contact_information: email: กรอกที่อยู่อีเมล์สาธารณะ - label: ข้อมูลที่ติดต่อ username: กรอกชื่อผู้ใช้ registrations: closed_message: @@ -150,7 +149,6 @@ th: title: ปิดข้อความลงทะเบียน open: title: เปิดรับลงทะเบียน - setting: ตั้งค่า site_description: desc_html: Displayed as a paragraph on the frontpage and used as a meta tag.
ใช้ HTML tags ได้, in particular <a> และ <em>. title: คำอธิบายไซต์ diff --git a/config/locales/tr.yml b/config/locales/tr.yml index a8927eaa8..e7864cc57 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -141,7 +141,6 @@ tr: settings: contact_information: email: Herkese açık e-posta adresiniz - label: İletişim bilgisi username: Bir kullanıcı adı giriniz registrations: closed_message: @@ -149,7 +148,6 @@ tr: title: Kayıt alımları kapatılma mesajı open: title: Kayıt alımları - setting: Ayar adı site_description: desc_html: Ana sayfada paragraf olarak görüntülenecek bilgidir.
Özellikle <a> ve <em> olmak suretiyle HTML etiketlerini kullanabilirsiniz. title: Site açıklaması diff --git a/config/locales/uk.yml b/config/locales/uk.yml index 65f1aabf5..129fc5bb7 100644 --- a/config/locales/uk.yml +++ b/config/locales/uk.yml @@ -123,7 +123,6 @@ uk: settings: contact_information: email: Введіть публічний email - label: Контактна інформація username: Введіть ім'я користувача registrations: closed_message: @@ -131,7 +130,6 @@ uk: title: Повідомлення про закриту реєстрацію open: title: Відкрити реєстрацію - setting: Налаштування site_description: desc_html: Відображається у якості параграфа на титульній сторінці та використовується у якості мета-тега.
Можна використовувати HTML-теги, особливо <a> і <em>. title: Опис сайту diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index d5d1b672c..650d4bd15 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -148,7 +148,6 @@ zh-CN: settings: contact_information: email: 输入一个公开的电邮地址 - label: 联系数据 username: 输入用户名称 registrations: closed_message: @@ -156,7 +155,6 @@ zh-CN: title: 暂停注册消息 open: title: 开放注册 - setting: 设置 site_description: desc_html: 在首页显示,及在 meta 标签中用作网站介绍。
你可以在此使用 HTML 标签,尤其是<a><em>。 title: 本站介绍 diff --git a/config/locales/zh-HK.yml b/config/locales/zh-HK.yml index aa9f27912..d2db78be1 100644 --- a/config/locales/zh-HK.yml +++ b/config/locales/zh-HK.yml @@ -141,7 +141,6 @@ zh-HK: settings: contact_information: email: 輸入一個公開的電郵地址 - label: 聯絡資料 username: 輸入用戶名稱 registrations: closed_message: @@ -149,7 +148,6 @@ zh-HK: title: 暫停註冊訊息 open: title: 開放註冊 - setting: 設定 site_description: desc_html: 在首頁顯示,及在 meta 標籤使用作網站介紹。
你可以在此使用 <a><em> 等 HTML 標籤。 title: 本站介紹 diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index 58caf7848..67aa2830f 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -102,7 +102,6 @@ zh-TW: settings: contact_information: email: 請輸入輸入一個公開電子信箱 - label: 聯絡資訊 username: 請輸入使用者名稱 registrations: closed_message: @@ -110,7 +109,6 @@ zh-TW: title: 關閉註冊訊息 open: title: 開放註冊 - setting: 設定 site_description: desc_html: 顯示在首頁並且作為 meta 標籤的短文。
可使用 HTML 標籤,包括 <a><em>。 title: 網站描述 diff --git a/spec/controllers/admin/settings_controller_spec.rb b/spec/controllers/admin/settings_controller_spec.rb index d9dde3c92..609bc762b 100644 --- a/spec/controllers/admin/settings_controller_spec.rb +++ b/spec/controllers/admin/settings_controller_spec.rb @@ -31,7 +31,7 @@ RSpec.describe Admin::SettingsController, type: :controller do it 'cannot create a setting value for a non-admin key' do expect(Setting.new_setting_key).to be_blank - patch :update, params: { new_setting_key: 'New key value' } + patch :update, params: { form_admin_settings: { new_setting_key: 'New key value' } } expect(response).to redirect_to(edit_admin_settings_path) expect(Setting.new_setting_key).to be_nil @@ -40,7 +40,7 @@ RSpec.describe Admin::SettingsController, type: :controller do it 'creates a settings value that didnt exist before for eligible key' do expect(Setting.site_extended_description).to be_blank - patch :update, params: { site_extended_description: 'New key value' } + patch :update, params: { form_admin_settings: { site_extended_description: 'New key value' } } expect(response).to redirect_to(edit_admin_settings_path) expect(Setting.site_extended_description).to eq 'New key value' @@ -56,7 +56,7 @@ RSpec.describe Admin::SettingsController, type: :controller do it 'updates a settings value' do Setting.site_title = 'Original' - patch :update, params: { site_title: 'New title' } + patch :update, params: { form_admin_settings: { site_title: 'New title' } } expect(response).to redirect_to(edit_admin_settings_path) expect(Setting.site_title).to eq 'New title' @@ -72,7 +72,7 @@ RSpec.describe Admin::SettingsController, type: :controller do it 'typecasts open_registrations to boolean' do Setting.open_registrations = false - patch :update, params: { open_registrations: 'true' } + patch :update, params: { form_admin_settings: { open_registrations: '1' } } expect(response).to redirect_to(edit_admin_settings_path) expect(Setting.open_registrations).to eq true -- cgit