summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMrYummy <elemental428@gmail.com>2017-07-07 19:41:28 +0200
committerMrYummy <elemental428@gmail.com>2017-07-07 19:42:37 +0200
commit2289d37e6985220a775402490f436aab12b3de0e (patch)
tree1b964f9512a9564250642ec6bfba94adc3bb7d0f
parent668c9a296021d37b0d1b0b2c040f2829e9213a59 (diff)
combined mastodon and mastodon_instance columns into a single mastodon column
-rw-r--r--app/controllers/users_controller.rb4
-rw-r--r--app/models/user.rb1
-rw-r--r--app/views/users/edit.html.erb5
-rw-r--r--app/views/users/show.html.erb7
-rw-r--r--db/migrate/20170707012441_add_mastodon_to_users.rb1
-rw-r--r--db/schema.rb1
6 files changed, 11 insertions, 8 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 3380482..c228857 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -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]
diff --git a/app/models/user.rb b/app/models/user.rb
index a4539ac..a724f20 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -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
diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb
index edcd33c..24bdba8 100644
--- a/app/views/users/edit.html.erb
+++ b/app/views/users/edit.html.erb
@@ -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>
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index fbf848c..db51258 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -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 %>
diff --git a/db/migrate/20170707012441_add_mastodon_to_users.rb b/db/migrate/20170707012441_add_mastodon_to_users.rb
index 3401f1b..e620741 100644
--- a/db/migrate/20170707012441_add_mastodon_to_users.rb
+++ b/db/migrate/20170707012441_add_mastodon_to_users.rb
@@ -1,6 +1,5 @@
class AddMastodonToUsers < ActiveRecord::Migration
def change
add_column :users, :mastodon, :string
- add_column :users, :mastodon_instance, :string
end
end
diff --git a/db/schema.rb b/db/schema.rb
index b32988a..9c42e9b 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -152,7 +152,6 @@ ActiveRecord::Schema.define(version: 20170707012441) do
t.boolean "header_scroll", default: false
t.boolean "dark", default: false
t.string "mastodon", limit: 191
- t.string "mastodon_instance", limit: 191
end
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree