Add Settings::SharingController

This commit is contained in:
Andreas Nedbal 2023-02-05 19:15:20 +01:00 committed by Andreas Nedbal
parent 83d386267a
commit 926be13fa6
7 changed files with 61 additions and 4 deletions

View file

@ -0,0 +1,19 @@
# frozen_string_literal: true
class Settings::SharingController < ApplicationController
before_action :authenticate_user!
def edit; end
def update
user_attributes = params.require(:user).permit(:sharing_enabled,
:sharing_autoclose,
:sharing_custom_url)
if current_user.update(user_attributes)
flash[:success] = t(".success")
else
flash[:error] = t(".error")
end
redirect_to settings_sharing_path
end
end

View file

@ -0,0 +1,20 @@
= bootstrap_form_for(current_user, url: settings_sharing_path, method: :patch, data: { turbo: false }) do |f|
.card
.card-body
= f.form_group :sharing, help: t("activerecord.help.user.sharing_enabled") do
= f.check_box :sharing_enabled
= f.form_group :sharing, help: t("activerecord.help.user.sharing_autoclose"), class: false do
= f.check_box :sharing_autoclose
.card
.card-body
%h3= t(".advanced.title")
= t(".advanced.body_html")
= f.url_field :sharing_custom_url
.card
.card-body
= f.primary
- provide(:title, generate_title(t(".title")))
- parent_layout "user/settings"

View file

@ -4,7 +4,7 @@
= list_group_item t(".profile"), edit_settings_profile_path
= list_group_item t(".privacy"), edit_settings_privacy_path
= list_group_item t(".security"), settings_two_factor_authentication_otp_authentication_path
= list_group_item t(".sharing"), services_path
= list_group_item t(".sharing"), settings_sharing_path
= list_group_item t(".mutes"), settings_muted_path
= list_group_item t(".blocks"), settings_blocks_path
= list_group_item t(".theme"), edit_settings_theme_path

View file

@ -74,6 +74,9 @@ en:
privacy_allow_stranger_answers: "Allow other people to answer your questions"
privacy_noindex: "Prevent search engines from indexing your profile"
privacy_hide_social_graph: "Hide your social graph from others"
sharing_enabled: "Enable sharing"
sharing_autoclose: "Automatically close inbox entry after sharing once"
sharing_custom_url: "Custom Share Link"
profile_picture: "Profile picture"
profile_header: "Profile header"
sign_in_count: "Sign in count"
@ -85,6 +88,9 @@ en:
screen_name: "Alphanumerical and underscores allowed, max. 16 characters"
email: "Don't forget to check your spam folder in case our email might have landed there!"
current_password: "We need your current password to confirm your changes"
sharing_enabled: "Shows a sharing dialog after answering a question from your inbox"
sharing_autoclose: "Use this if you mainly post to a single service"
sharing_custom_url: "Example: https://mastodon.social/share?text="
profile:
anon_display_name: "This name will be used for questions asked to you by anonymous users."
motivation_header: "Shown in the header of the question box on your profile. Motivate users to ask you questions!"

View file

@ -170,6 +170,10 @@ en:
notice:
profile_picture: " It might take a few minutes until your new profile picture is shown everywhere."
profile_header: " It might take a few minutes until your new profile header is shown everywhere."
sharing:
update:
success: "Sharing settings updated successfully."
error: "Unable to update sharing settings."
theme:
update:
success: "Theme saved successfully."

View file

@ -363,9 +363,6 @@ en:
heading: "Twitter connection expired"
text_html: "If you would like to continue automatically sharing your answers to Twitter, head to %{settings_sharing} and re-connect your account."
settings_services: "Sharing Settings"
services:
index:
title: "Service Settings"
settings:
account:
email_confirm: "Currently awaiting confirmation for %{resource}"
@ -453,6 +450,14 @@ en:
profile_picture: "Adjust your new profile picture"
profile_header: "Adjust your new profile header"
submit_picture: "Save pictures"
sharing:
edit:
title: "Sharing Settings"
advanced:
title: "Advanced options"
body_html: |
<p>If you use a service other than Twitter or Tumblr, which has support for sharing from external services, you can enter their sharing URL here so it will be listed as an option for sharing after an answer has been sent.</p>
<p>We will prepend a URL-encoded version of the answer to the end of the given link.</p>
two_factor_authentication:
otp_authentication:
index:

View file

@ -78,6 +78,9 @@ Rails.application.routes.draw do
get :privacy, to: redirect("/settings/privacy/edit")
resource :privacy, controller: :privacy, only: %i[edit update]
get :sharing, to: redirect("/settings/sharing/edit")
resource :sharing, controller: :sharing, only: %i[edit update]
get :export, to: "export#index"
post :export, to: "export#create"