mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
rebrand remote follow #186
This commit is contained in:
parent
0eadceda63
commit
2e0d27c4f0
7 changed files with 70 additions and 31 deletions
|
@ -32,11 +32,11 @@ class SiteMiscForm(FlaskForm):
|
|||
community_creation_admin_only = BooleanField(_l('Only admins can create new local communities'))
|
||||
reports_email_admins = BooleanField(_l('Notify admins about reports, not just moderators'))
|
||||
types = [('Open', _l('Open')), ('RequireApplication', _l('Require application')), ('Closed', _l('Closed'))]
|
||||
registration_mode = SelectField(_l('Registration mode'), choices=types, default=1, coerce=str)
|
||||
registration_mode = SelectField(_l('Registration mode'), choices=types, default=1, coerce=str, render_kw={'class': 'form-select'})
|
||||
application_question = TextAreaField(_l('Question to ask people applying for an account'))
|
||||
auto_decline_referrers = TextAreaField(_l('Block registrations from these referrers (one per line)'))
|
||||
log_activitypub_json = BooleanField(_l('Log ActivityPub JSON for debugging'))
|
||||
default_theme = SelectField(_l('Default theme'), coerce=str)
|
||||
default_theme = SelectField(_l('Default theme'), coerce=str, render_kw={'class': 'form-select'})
|
||||
submit = SubmitField(_l('Save'))
|
||||
|
||||
|
||||
|
@ -78,12 +78,12 @@ class EditCommunityForm(FlaskForm):
|
|||
(1825, _l('5 years')),
|
||||
(3650, _l('10 years')),
|
||||
]
|
||||
content_retention = SelectField(_l('Retain content'), choices=options, default=1, coerce=int)
|
||||
topic = SelectField(_l('Topic'), coerce=int, validators=[Optional()])
|
||||
content_retention = SelectField(_l('Retain content'), choices=options, default=1, coerce=int, render_kw={'class': 'form-select'})
|
||||
topic = SelectField(_l('Topic'), coerce=int, validators=[Optional()], render_kw={'class': 'form-select'})
|
||||
layouts = [('', _l('List')),
|
||||
('masonry', _l('Masonry')),
|
||||
('masonry_wide', _l('Wide masonry'))]
|
||||
default_layout = SelectField(_l('Layout'), coerce=str, choices=layouts, validators=[Optional()])
|
||||
default_layout = SelectField(_l('Layout'), coerce=str, choices=layouts, validators=[Optional()], render_kw={'class': 'form-select'})
|
||||
posting_warning = StringField(_l('Posting warning'), validators=[Optional(), Length(min=3, max=512)])
|
||||
languages = SelectMultipleField(_l('Languages'), coerce=int, validators=[Optional()], render_kw={'class': 'form-select'})
|
||||
ignore_remote_language = BooleanField(_l('Override remote language setting'))
|
||||
|
@ -105,7 +105,7 @@ class EditCommunityForm(FlaskForm):
|
|||
class EditTopicForm(FlaskForm):
|
||||
name = StringField(_l('Name'), validators=[DataRequired()])
|
||||
machine_name = StringField(_l('Url'), validators=[DataRequired()])
|
||||
parent_id = SelectField(_l('Parent topic'), coerce=int, validators=[Optional()])
|
||||
parent_id = SelectField(_l('Parent topic'), coerce=int, validators=[Optional()], render_kw={'class': 'form-select'})
|
||||
submit = SubmitField(_l('Save'))
|
||||
|
||||
|
||||
|
@ -131,7 +131,7 @@ class AddUserForm(FlaskForm):
|
|||
(3, _l('Staff')),
|
||||
(4, _l('Admin')),
|
||||
]
|
||||
role = SelectField(_l('Role'), choices=role_options, default=2, coerce=int)
|
||||
role = SelectField(_l('Role'), choices=role_options, default=2, coerce=int, render_kw={'class': 'form-select'})
|
||||
submit = SubmitField(_l('Save'))
|
||||
|
||||
def validate_email(self, email):
|
||||
|
@ -181,7 +181,7 @@ class EditUserForm(FlaskForm):
|
|||
(3, _l('Staff')),
|
||||
(4, _l('Admin')),
|
||||
]
|
||||
role = SelectField(_l('Role'), choices=role_options, default=2, coerce=int)
|
||||
role = SelectField(_l('Role'), choices=role_options, default=2, coerce=int, render_kw={'class': 'form-select'})
|
||||
remove_avatar = BooleanField(_l('Remove avatar'))
|
||||
remove_banner = BooleanField(_l('Remove banner'))
|
||||
submit = SubmitField(_l('Save'))
|
||||
|
|
|
@ -54,12 +54,12 @@ class EditCommunityForm(FlaskForm):
|
|||
local_only = BooleanField(_l('Only accept posts from current instance'))
|
||||
restricted_to_mods = BooleanField(_l('Only moderators can post'))
|
||||
new_mods_wanted = BooleanField(_l('New moderators wanted'))
|
||||
topic = SelectField(_l('Topic'), coerce=int, validators=[Optional()])
|
||||
topic = SelectField(_l('Topic'), coerce=int, validators=[Optional()], render_kw={'class': 'form-select'})
|
||||
languages = SelectMultipleField(_l('Languages'), coerce=int, validators=[Optional()], render_kw={'class': 'form-select'})
|
||||
layouts = [('', _l('List')),
|
||||
('masonry', _l('Masonry')),
|
||||
('masonry_wide', _l('Wide masonry'))]
|
||||
default_layout = SelectField(_l('Layout'), coerce=str, choices=layouts, validators=[Optional()])
|
||||
default_layout = SelectField(_l('Layout'), coerce=str, choices=layouts, validators=[Optional()], render_kw={'class': 'form-select'})
|
||||
submit = SubmitField(_l('Save'))
|
||||
|
||||
|
||||
|
@ -191,7 +191,7 @@ class CreatePollForm(FlaskForm):
|
|||
communities = SelectField(_l('Community'), validators=[DataRequired()], coerce=int, render_kw={'class': 'form-select'})
|
||||
poll_title = StringField(_l('Title'), validators=[DataRequired(), Length(min=3, max=255)])
|
||||
poll_body = TextAreaField(_l('Body'), validators=[Optional(), Length(min=3, max=5000)], render_kw={'rows': 5})
|
||||
mode = SelectField(_('Mode'), validators=[DataRequired()], choices=[('single', _l('Single choice')), ('multiple', _l('Multiple choices'))])
|
||||
mode = SelectField(_('Mode'), validators=[DataRequired()], choices=[('single', _l('Single choice')), ('multiple', _l('Multiple choices'))], render_kw={'class': 'form-select'})
|
||||
finish_choices=[
|
||||
('30m', _l('30 minutes')),
|
||||
('1h', _l('1 hour')),
|
||||
|
@ -201,7 +201,7 @@ class CreatePollForm(FlaskForm):
|
|||
('3d', _l('3 days')),
|
||||
('7d', _l('7 days')),
|
||||
]
|
||||
finish_in = SelectField(_('End voting in'), validators=[DataRequired()], choices=finish_choices)
|
||||
finish_in = SelectField(_('End voting in'), validators=[DataRequired()], choices=finish_choices, render_kw={'class': 'form-select'})
|
||||
local_only = BooleanField(_l('Accept votes from this instance only'))
|
||||
choice_1 = StringField('Choice') # intentionally left out of internationalization (no _l()) as this label is not used
|
||||
choice_2 = StringField('Choice')
|
||||
|
|
17
app/static/images/fediverse_logo.svg
Normal file
17
app/static/images/fediverse_logo.svg
Normal file
|
@ -0,0 +1,17 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="196.52mm" height="196.52mm" viewBox="0 0 196.52 196.52">
|
||||
<path fill="#a730b8" d="M47.9242 72.7966a18.2278 18.2278 0 0 1-7.7959 7.7597l42.7984 42.9653 10.3182-5.2291zm56.4524 56.6704-10.3182 5.2291 21.686 21.7708a18.2278 18.2278 0 0 1 7.7975-7.7608z"/>
|
||||
<path fill="#5496be" d="M129.6645 102.0765l1.7865 11.4272 27.4149-13.8942a18.2278 18.2278 0 0 1-4.9719-9.8124zm-14.0658 7.1282-57.2891 29.0339a18.2278 18.2278 0 0 1 4.9728 9.8133l54.1027-27.4194z"/>
|
||||
<path fill="#ce3d1a" d="M69.5312 91.6539l8.1618 8.1933 29.269-57.1387a18.2278 18.2278 0 0 1-9.787-5.0219zm-7.1897 14.0363-14.0022 27.3353a18.2278 18.2278 0 0 1 9.786 5.0214l12.3775-24.1639z"/>
|
||||
<path fill="#d0188f" d="M39.8906 80.6763a18.2278 18.2278 0 0 1-10.8655 1.7198l8.1762 52.2981a18.2278 18.2278 0 0 1 10.8645-1.7198z"/>
|
||||
<path fill="#5b36e9" d="M63.3259 148.3109a18.2278 18.2278 0 0 1-1.7322 10.8629l52.2893 8.3907a18.2278 18.2278 0 0 1 1.7322-10.8629z"/>
|
||||
<path fill="#30b873" d="M134.9148 146.9182a18.2278 18.2278 0 0 1 9.788 5.0224l24.1345-47.117a18.2278 18.2278 0 0 1-9.7875-5.0229z"/>
|
||||
<path fill="#ebe305" d="M126.1329 33.1603a18.2278 18.2278 0 0 1-7.7975 7.7608l37.3765 37.5207a18.2278 18.2278 0 0 1 7.7969-7.7608z"/>
|
||||
<path fill="#f47601" d="M44.7704 51.6279a18.2278 18.2278 0 0 1 4.9723 9.8123l47.2478-23.9453a18.2278 18.2278 0 0 1-4.9718-9.8113z"/>
|
||||
<path fill="#57c115" d="M118.2491 40.9645a18.2278 18.2278 0 0 1-10.8511 1.8123l4.1853 26.8 11.42 1.8324zm-4.2333 44.1927 9.8955 63.3631a18.2278 18.2278 0 0 1 10.88-1.6278l-9.355-59.9035z"/>
|
||||
<path fill="#dbb210" d="M49.7763 61.6412a18.2278 18.2278 0 0 1-1.694 10.8686l26.8206 4.3077 5.2715-10.2945zm45.9677 7.382-5.272 10.2955 63.3713 10.1777a18.2278 18.2278 0 0 1 1.7606-10.8593z"/>
|
||||
<path fill="#ffca00" d="M93.4385 23.8419a1 1 0 1 0 33.0924 1.8025 1 1 0 1 0-33.0924-1.8025"/>
|
||||
<path fill="#64ff00" d="M155.314 85.957a1 1 0 1 0 33.0923 1.8025 1 1 0 1 0-33.0923-1.8025"/>
|
||||
<path fill="#00a3ff" d="M115.3466 163.9824a1 1 0 1 0 33.0923 1.8025 1 1 0 1 0-33.0923-1.8025"/>
|
||||
<path fill="#9500ff" d="M28.7698 150.0898a1 1 0 1 0 33.0923 1.8025 1 1 0 1 0-33.0923-1.8025"/>
|
||||
<path fill="#ff0000" d="M15.2298 63.4781a1 1 0 1 0 33.0923 1.8025 1 1 0 1 0-33.0923-1.8025"/>
|
||||
</svg>
|
After Width: | Height: | Size: 2.2 KiB |
|
@ -14,11 +14,11 @@
|
|||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="/">{{ _('Home') }}</a></li>
|
||||
<li class="breadcrumb-item"><a href="/u/{{ user.link() }}">{{ user.display_name() }}</a></li>
|
||||
<li class="breadcrumb-item active">{{ _('Follow on Mastodon') }}</li>
|
||||
<li class="breadcrumb-item active">{{ _('Follow on remote instance') }}</li>
|
||||
</ol>
|
||||
</nav>
|
||||
<h1>{{ _('Follow on Mastodon') }}</h1>
|
||||
<p>{{ _('We are about to send you to your mastodon instance where you will then need to click the "Follow" button.') }}</p>
|
||||
<h1>{{ _('Follow on remote instance') }}</h1>
|
||||
<p>{{ _('We are about to send you to your instance where you will then need to click the "Follow" button.') }}</p>
|
||||
{{ render_form(form) }}
|
||||
|
||||
{% if send_to %}
|
||||
|
@ -26,7 +26,7 @@
|
|||
<script defer nonce="{{ session['nonce'] }}">
|
||||
window.addEventListener("load", function () {
|
||||
var redirectTimeout;
|
||||
var cookieName = "mastodon_instance_url";
|
||||
var cookieName = "remote_instance_url";
|
||||
var redirectURL = getCookie(cookieName);
|
||||
|
||||
if (redirectURL) {
|
|
@ -85,7 +85,7 @@
|
|||
<a class="btn btn-primary" href="{{ url_for('user.report_profile', actor=user.link()) }}" rel="nofollow">{{ _('Report') }}</a>
|
||||
{% endif %}
|
||||
{% if user.is_local() %}
|
||||
<a class="btn btn-primary" href="{{ url_for('user.mastodon_redirect', actor=user.link()) }}" rel="nofollow"><img src="/static/images/mastodon_white.png" width="25" height="25"> {{ _('Follow on Mastodon') }}</a>
|
||||
<a class="btn btn-primary" href="{{ url_for('user.fediverse_redirect', actor=user.link()) }}" rel="nofollow"><img src="/static/images/fediverse_logo.svg" width="25" height="25"> {{ _('Follow') }}</a>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
|
|
@ -48,8 +48,8 @@ class SettingsForm(FlaskForm):
|
|||
('new', _l('New')),
|
||||
('active', _l('Active')),
|
||||
]
|
||||
default_sort = SelectField(_l('By default, sort posts by'), choices=sorts, validators=[DataRequired()], coerce=str)
|
||||
theme = SelectField(_l('Theme'), coerce=str)
|
||||
default_sort = SelectField(_l('By default, sort posts by'), choices=sorts, validators=[DataRequired()], coerce=str, render_kw={'class': 'form-select'})
|
||||
theme = SelectField(_l('Theme'), coerce=str, render_kw={'class': 'form-select'})
|
||||
submit = SubmitField(_l('Save settings'))
|
||||
|
||||
|
||||
|
@ -101,7 +101,16 @@ class FilterEditForm(FlaskForm):
|
|||
submit = SubmitField(_l('Save'))
|
||||
|
||||
|
||||
class FollowOnMastodonForm(FlaskForm):
|
||||
instance_url = StringField(_l('Your mastodon instance:'), validators=[DataRequired(), Length(min=3, max=50)],
|
||||
class RemoteFollowForm(FlaskForm):
|
||||
instance_url = StringField(_l('Your remote instance:'), validators=[DataRequired(), Length(min=3, max=50)],
|
||||
render_kw={'placeholder': 'e.g. mastodon.social'})
|
||||
submit = SubmitField(_l('View profile in Mastodon'))
|
||||
type_choices = [
|
||||
('mastodon', _l('Mastodon, Misskey, Akkoma, Iceshrimp and friends')),
|
||||
('friendica', _l('Friendica')),
|
||||
('hubzilla', _l('Hubzilla')),
|
||||
('lemmy', _l('Lemmy')),
|
||||
('pixelfed', _l('Pixelfed')),
|
||||
]
|
||||
|
||||
instance_type = SelectField(_l('Instance type'), choices=type_choices, render_kw={'class': 'form-select'})
|
||||
submit = SubmitField(_l('View profile on remote instance'))
|
||||
|
|
|
@ -15,7 +15,7 @@ from app.models import Post, Community, CommunityMember, User, PostReply, PostVo
|
|||
InstanceBlock, NotificationSubscription
|
||||
from app.user import bp
|
||||
from app.user.forms import ProfileForm, SettingsForm, DeleteAccountForm, ReportUserForm, FilterEditForm, \
|
||||
FollowOnMastodonForm
|
||||
RemoteFollowForm
|
||||
from app.user.utils import purge_user_then_delete, unsubscribe_from_community
|
||||
from app.utils import get_setting, render_template, markdown_to_html, user_access, markdown_to_text, shorten_string, \
|
||||
is_image_url, ensure_directory_exists, gibberish, file_get_contents, community_membership, user_filters_home, \
|
||||
|
@ -807,19 +807,32 @@ def user_email_notifs_unsubscribe(user_id, token):
|
|||
return render_template('user/email_notifs_unsubscribed.html')
|
||||
|
||||
|
||||
@bp.route('/u/<actor>/mastodon_redirect', methods=['GET', 'POST'])
|
||||
def mastodon_redirect(actor):
|
||||
@bp.route('/u/<actor>/fediverse_redirect', methods=['GET', 'POST'])
|
||||
def fediverse_redirect(actor):
|
||||
actor = actor.strip()
|
||||
user = User.query.filter_by(user_name=actor, deleted=False, ap_id=None).first()
|
||||
if user and user.is_local():
|
||||
form = FollowOnMastodonForm()
|
||||
form = RemoteFollowForm()
|
||||
if form.validate_on_submit():
|
||||
resp = make_response(redirect(f'https://{form.instance_url.data}/@{user.user_name}@{current_app.config["SERVER_NAME"]}'))
|
||||
resp.set_cookie('mastodon_instance_url', form.instance_url.data, expires=datetime(year=2099, month=12, day=30))
|
||||
redirect_url = ''
|
||||
if form.instance_type.data == 'mastodon':
|
||||
redirect_url = f'https://{form.instance_url.data}/@{user.user_name}@{current_app.config["SERVER_NAME"]}'
|
||||
elif form.instance_type.data == 'lemmy':
|
||||
flash(_("Lemmy can't follow profiles, sorry"), 'error')
|
||||
return render_template('user/fediverse_redirect.html', form=form, user=user, send_to='', current_app=current_app)
|
||||
elif form.instance_type.data == 'friendica':
|
||||
redirect_url = f'https://{form.instance_url.data}/search?q={user.user_name}@{current_app.config["SERVER_NAME"]}'
|
||||
elif form.instance_type.data == 'hubzilla':
|
||||
redirect_url = f'https://{form.instance_url.data}/search?q={user.user_name}@{current_app.config["SERVER_NAME"]}'
|
||||
elif form.instance_type.data == 'pixelfed':
|
||||
redirect_url = f'https://{form.instance_url.data}/i/results?q={user.user_name}@{current_app.config["SERVER_NAME"]}'
|
||||
|
||||
resp = make_response(redirect(redirect_url))
|
||||
resp.set_cookie('remote_instance_url', form.instance_url.data, expires=datetime(year=2099, month=12, day=30))
|
||||
return resp
|
||||
else:
|
||||
send_to = ''
|
||||
if request.cookies.get('mastodon_instance_url'):
|
||||
send_to = request.cookies.get('mastodon_instance_url')
|
||||
if request.cookies.get('remote_instance_url'):
|
||||
send_to = request.cookies.get('remote_instance_url')
|
||||
form.instance_url.data = send_to
|
||||
return render_template('user/mastodon_redirect.html', form=form, user=user, send_to=send_to, current_app=current_app)
|
||||
return render_template('user/fediverse_redirect.html', form=form, user=user, send_to=send_to, current_app=current_app)
|
||||
|
|
Loading…
Add table
Reference in a new issue