combined mastodon and mastodon_instance columns into a single mastodon column

This commit is contained in:
MrYummy
2017-07-07 19:42:37 +02:00
parent 668c9a2960
commit 2289d37e69
6 changed files with 11 additions and 8 deletions
+4
View File
@@ -153,6 +153,10 @@ class UsersController < ApplicationController
if userdata[:badge]
userdata[:badge] = Badge.get(userdata[:badge])
end
unless userdata[:mastodon].blank?
userdata[:mastodon] = "#{userdata[:mastodon].gsub("@", "")}#{("@" + userdata[:mastodon_instance].gsub("@", "")) unless userdata[:mastodon_instance].blank?}"
end
userdata.delete(:mastodon_instance)
if @user.youtube != userdata[:youtube]
youtube = get_youtube(userdata[:youtube])
userdata[:youtube] = youtube[:channel]
-1
View File
@@ -168,7 +168,6 @@ class User < ActiveRecord::Base
self.about.strip! if self.about
self.skype.strip! if self.skype
self.mastodon.strip! if self.mastodon
self.mastodon_instance.strip! if self.mastodon_instance
self.youtube.strip! if self.youtube
self.twitter.strip! if self.twitter
end
+3 -2
View File
@@ -57,8 +57,9 @@
<tr>
<td>Mastodon</td>
<td style="display:inline;padding:0px">
<%= f.text_field :mastodon, placeholder: "Mastodon username", disabled: !(@user.is?(current_user) && confirmed? || (mod? && current_user.role >= @user.role)), style: "width:49%;float:left;margin-right:2%" %>
<%= f.text_field :mastodon_instance, placeholder: "Mastodon instance", disabled: !(@user.is?(current_user) && confirmed? || (mod? && current_user.role >= @user.role)), style: "width:49%" %>
<% mstdn_array = @user.mastodon.split("@") if @user.mastodon %>
<%= f.text_field :mastodon, value: (mstdn_array[0] if mstdn_array), placeholder: "Mastodon username", disabled: !(@user.is?(current_user) && confirmed? || (mod? && current_user.role >= @user.role)), style: "width:49%;float:left;margin-right:2%" %>
<%= f.text_field :mastodon_instance, value: (mstdn_array[1] if mstdn_array), placeholder: "Mastodon instance", disabled: !(@user.is?(current_user) && confirmed? || (mod? && current_user.role >= @user.role)), style: "width:49%" %>
</td>
</tr>
<tr>
+4 -3
View File
@@ -62,10 +62,11 @@
<tr>
<td><b>Mastodon</b></td>
<td>
<% if @user.mastodon_instance %>
<%= link_to "@#{@user.mastodon}", "https://#{CGI.escape(@user.mastodon_instance)}/@#{CGI.escape(@user.mastodon)}", :target => "_blank" %></td>
<% mstdn_array = @user.mastodon.split("@") %>
<% if mstdn_array.length > 1 %>
<%= link_to "@#{mstdn_array[0]}", "https://#{CGI.escape(mstdn_array[1])}/@#{CGI.escape(mstdn_array[0])}", :target => "_blank" %></td>
<% else %>
<%= @user.mastodon %>
<%= "@" + @user.mastodon %>
<% end %>
</tr>
<% end %>