Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
361b15e398 | ||
|
|
0972181e75 |
@@ -88,45 +88,5 @@ $(function() {
|
|||||||
}], {
|
}], {
|
||||||
debounce: 300
|
debounce: 300
|
||||||
});
|
});
|
||||||
$('.md_editor .field_container_user .editor_field').textcomplete([{
|
|
||||||
// match up to 2 words (everything except some special characters)
|
|
||||||
// each word can have up to 16 characters (up to 32 total)
|
|
||||||
// words must be separated by a single space
|
|
||||||
match: /(^|\s)([^!"§$%&\/()=?.,;+*@\s]{1,16})$/,
|
|
||||||
search: function (text, callback, match) {
|
|
||||||
console.log("Searching " + text);
|
|
||||||
text = text.toLowerCase();
|
|
||||||
$.ajax("/users/suggestions", {
|
|
||||||
type: "post",
|
|
||||||
data: {name: text},
|
|
||||||
dataType: "json",
|
|
||||||
headers: {
|
|
||||||
"X-CSRF-Token": $('meta[name="csrf-token"]').attr("content")
|
|
||||||
},
|
|
||||||
success: function(data) {
|
|
||||||
callback(data);
|
|
||||||
},
|
|
||||||
error: function(xhr, status, err) {
|
|
||||||
console.error(err);
|
|
||||||
callback([]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
template: function(user) {
|
|
||||||
var name = user[0];
|
|
||||||
var ign = user[1];
|
|
||||||
if (name != ign) {
|
|
||||||
return name + " <small>(" + ign + ")</small>";
|
|
||||||
} else {
|
|
||||||
return ign;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
cache: true,
|
|
||||||
replace: function (word) {
|
|
||||||
return "$1" + word[1] + " ";
|
|
||||||
}
|
|
||||||
}], {
|
|
||||||
debounce: 300
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -480,10 +480,6 @@ blockquote p {
|
|||||||
padding: 4em 1em 1em;
|
padding: 4em 1em 1em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.field_container_user {
|
|
||||||
.editor_field {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.dropdown-menu {
|
ul.dropdown-menu {
|
||||||
@@ -650,7 +646,6 @@ tr.spacer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.profile-action {
|
.profile-action {
|
||||||
font-size: 0;
|
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1031,4 +1026,4 @@ nav.pagination {
|
|||||||
padding: 0.1em 0.2em;
|
padding: 0.1em 0.2em;
|
||||||
border-radius: 0.2em;
|
border-radius: 0.2em;
|
||||||
text-shadow: none;
|
text-shadow: none;
|
||||||
}
|
}
|
||||||
@@ -75,4 +75,4 @@ class ApplicationController < ActionController::Base
|
|||||||
!!(current_user && current_user.confirmed?)
|
!!(current_user && current_user.confirmed?)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -8,8 +8,16 @@ class BlogpostsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@comment = Comment.new(blogpost: @post)
|
if @post
|
||||||
@comments = @post.comments.page(params[:page])
|
@comment = Comment.new(blogpost: @post)
|
||||||
|
@comments = @post.comments.page(params[:page])
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
format.json {render json: @post.attributes.merge(replies: Comment.where(blogpost: @post).ids).to_json}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
respond_to {|format| format.json {render json: Comment.find_by(id: params[:id][1..-1]).try(:attributes).to_json}}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@@ -64,7 +72,9 @@ class BlogpostsController < ApplicationController
|
|||||||
|
|
||||||
def set_post
|
def set_post
|
||||||
if params[:id]
|
if params[:id]
|
||||||
@post = Blogpost.find(params[:id])
|
unless action_name == "show" && params[:id][0].downcase == "c"
|
||||||
|
@post = Blogpost.find(params[:id])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -75,4 +85,4 @@ class BlogpostsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,6 +2,12 @@ class CommentsController < ApplicationController
|
|||||||
|
|
||||||
include MailerHelper
|
include MailerHelper
|
||||||
|
|
||||||
|
def show
|
||||||
|
respond_to do |format|
|
||||||
|
format.json {render json: @comment.attributes.to_json}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@comment = Comment.find(params[:id])
|
@comment = Comment.find(params[:id])
|
||||||
if mod? || @comment.author.is?(current_user)
|
if mod? || @comment.author.is?(current_user)
|
||||||
@@ -72,4 +78,4 @@ class CommentsController < ApplicationController
|
|||||||
def comment_params
|
def comment_params
|
||||||
params.require(:comment).permit(:content)
|
params.require(:comment).permit(:content)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,7 +5,12 @@ class ForumgroupsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
redirect_to forums_path + "#group-#{params[:id].to_i}"
|
if request.format.html?
|
||||||
|
redirect_to forums_path + "#group-#{params[:id].to_i}"
|
||||||
|
else
|
||||||
|
fg = Forumgroup.find_by(id: params[:id])
|
||||||
|
respond_to {|format| format.json {render json: (fg.attributes.to_json if fg.try(:can_read?, :current_user))}}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@@ -77,4 +82,4 @@ class ForumgroupsController < ApplicationController
|
|||||||
params.require(:forumgroup).permit(a)
|
params.require(:forumgroup).permit(a)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,6 +13,11 @@ class ForumsController < ApplicationController
|
|||||||
[t.sticky ? 0 : 1, -(t.replies.last.try(:created_at) || t.created_at).to_i]
|
[t.sticky ? 0 : 1, -(t.replies.last.try(:created_at) || t.created_at).to_i]
|
||||||
end
|
end
|
||||||
@threads = Kaminari.paginate_array(@threads).page(params[:page])
|
@threads = Kaminari.paginate_array(@threads).page(params[:page])
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
f = Forum.find_by(id: params[:id])
|
||||||
|
format.json {render json: f.attributes.to_json}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
|||||||
@@ -7,7 +7,12 @@ class ForumthreadsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@replies = @thread.replies.page(params[:page])
|
if @thread
|
||||||
|
@replies = @thread.replies.page(params[:page])
|
||||||
|
else
|
||||||
|
respond_to {|format| format.json {render json: Comment.find_by(id: params[:id][1..-1]).try(:attributes).to_json}}
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
|||||||
@@ -1,77 +0,0 @@
|
|||||||
class MessagerepliesController < ApplicationController
|
|
||||||
|
|
||||||
def edit
|
|
||||||
@reply = Messagereply.find(params[:id])
|
|
||||||
if mod? || @reply.author.is?(current_user)
|
|
||||||
else
|
|
||||||
flash[:alert] = "You are not allowed to edit this reply"
|
|
||||||
redirect_to @reply.message
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def create
|
|
||||||
message = Message.find(params[:message_id])
|
|
||||||
if [message.user_sender, message.user_target].include? current_user
|
|
||||||
@reply = Messagereply.new(reply_params)
|
|
||||||
@reply.user_author = current_user
|
|
||||||
@reply.message = message
|
|
||||||
if @reply.save
|
|
||||||
if false
|
|
||||||
@reply.send_new_message_reply_mail
|
|
||||||
end
|
|
||||||
Message.find(params[:message_id]).update_attributes(user_hidden: nil, user_unread_id: current_user.id)
|
|
||||||
position = message.replies.count - 1
|
|
||||||
page = position / Kaminari.config.default_per_page + 1
|
|
||||||
redirect_to message_path(@reply.message, page: page) + "#reply-#{@reply.id}", notice: 'Reply created!'
|
|
||||||
else
|
|
||||||
flash[:alert] = "Could not create reply."
|
|
||||||
redirect_to Message.find(params[:message_id])
|
|
||||||
end
|
|
||||||
else
|
|
||||||
flash[:alert] = "You are not allowed to create replies."
|
|
||||||
redirect_to Message.find(params[:message_id])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def update
|
|
||||||
@reply = Messagereply.find(params[:id])
|
|
||||||
if mod? || @reply.author.is?(current_user)
|
|
||||||
old_content = @reply.text_was
|
|
||||||
if @reply.update_attributes(reply_params)
|
|
||||||
if false
|
|
||||||
@reply.send_new_reply_mail(old_content)
|
|
||||||
end
|
|
||||||
flash[:notice] = "Reply updated!"
|
|
||||||
position = @reply.message.replies.index(@reply)
|
|
||||||
page = position / Kaminari.config.default_per_page + 1
|
|
||||||
redirect_to message_path(@reply.message, page: page) + "#reply-#{@reply.id}"
|
|
||||||
else
|
|
||||||
flash[:alert] = "There was a problem while updating your reply"
|
|
||||||
render action: "edit"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
flash[:alert] = "You are not allowed to edit this reply"
|
|
||||||
redirect_to @reply.message
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
|
||||||
@reply = Messagereply.find(params[:id])
|
|
||||||
if mod? || @reply.author.is?(current_user)
|
|
||||||
if @reply.destroy
|
|
||||||
flash[:notice] = "Reply deleted!"
|
|
||||||
else
|
|
||||||
flash[:alert] = "There was a problem while deleting this reply"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
flash[:alert] = "You are not allowed to delete this reply"
|
|
||||||
end
|
|
||||||
redirect_to @reply.message
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def reply_params
|
|
||||||
params.require(:messagereply).permit(:text)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
class MessagesController < ApplicationController
|
|
||||||
|
|
||||||
before_filter :set_current
|
|
||||||
def set_current
|
|
||||||
User.current = current_user
|
|
||||||
end
|
|
||||||
|
|
||||||
before_filter :check_permission, only: [:show, :edit, :update, :destroy]
|
|
||||||
|
|
||||||
def index
|
|
||||||
if current_user
|
|
||||||
@messages = Message.where("(user_sender_id = ? OR user_target_id = ?) AND (user_hidden_id != ? OR user_hidden_id IS NULL)", current_user.id, current_user.id, current_user.id).page(params[:page])
|
|
||||||
else
|
|
||||||
flash[:alert] = "Please log in to see your private messages."
|
|
||||||
redirect_to blogposts_path
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def show
|
|
||||||
Message.find(@message.id).update_attributes(user_unread: nil) unless @message.user_unread == current_user
|
|
||||||
@replies = @message.replies.page(params[:page])
|
|
||||||
end
|
|
||||||
|
|
||||||
def edit
|
|
||||||
unless mod? || @message.author.is?(current_user)
|
|
||||||
flash[:alert] = "You are not allowed to edit this message!"
|
|
||||||
redirect_to @message
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def new
|
|
||||||
if current_user
|
|
||||||
@message = Message.new
|
|
||||||
else
|
|
||||||
flash[:alert] = "Please log in to send a private message."
|
|
||||||
redirect_to blogposts_path
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def create
|
|
||||||
unless message_params[:user_target_id]
|
|
||||||
flash[:alert] = "Please enter a valid IGN before sending."
|
|
||||||
redirect_to new_message_path
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if message_params[:subject].blank?
|
|
||||||
flash[:alert] = "Please write a subject before sending."
|
|
||||||
redirect_to new_message_path
|
|
||||||
return
|
|
||||||
elsif message_params[:text].blank?
|
|
||||||
flash[:alert] = "Please write a message before sending."
|
|
||||||
redirect_to new_message_path
|
|
||||||
return
|
|
||||||
end
|
|
||||||
@message = Message.new(message_params)
|
|
||||||
@message.user_target = User.find(@message.user_target_id)
|
|
||||||
@message.user_unread = User.find(@message.user_unread_id) if @message.user_unread_id
|
|
||||||
if @message.save
|
|
||||||
@message.send_new_message_mail
|
|
||||||
flash[:notice] = "Message sent!"
|
|
||||||
redirect_to messages_path
|
|
||||||
else
|
|
||||||
flash[:alert] = "Something went wrong while creating your message."
|
|
||||||
render action: "new"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def update
|
|
||||||
if mod? || @message.user_sender.is?(current_user)
|
|
||||||
@message.user_editor_id = current_user.id
|
|
||||||
@message.attributes = message_params
|
|
||||||
if @message.save
|
|
||||||
redirect_to @message, notice: 'Message has been updated.'
|
|
||||||
else
|
|
||||||
flash[:alert] = "There was a problem while updating the message."
|
|
||||||
render action: "edit"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
flash[:alert] = "You are not allowed to edit this message!"
|
|
||||||
redirect_to @message
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
|
||||||
if [@message.user_target, @message.user_sender].include?(current_user)
|
|
||||||
if @message.destroy
|
|
||||||
flash[:notice] = "Message deleted!"
|
|
||||||
else
|
|
||||||
unless @message.user_hidden
|
|
||||||
flash[:alert] = "There was a problem while deleting this message."
|
|
||||||
else
|
|
||||||
Message.find(@message.id).update_attributes(user_hidden: current_user)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
flash[:alert] = "You are not allowed to delete this message."
|
|
||||||
end
|
|
||||||
redirect_to messages_path
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy_all
|
|
||||||
Message.destroy_all(user_target_id: current_user.id)
|
|
||||||
if Message.where(user_target_id: current_user.id).empty?
|
|
||||||
flash[:notice] = "Your messages have been deleted!"
|
|
||||||
else
|
|
||||||
flash[:alert] = "There was a problem while deleting your messages."
|
|
||||||
end
|
|
||||||
redirect_to messages_path
|
|
||||||
end
|
|
||||||
|
|
||||||
def message_params(add = [])
|
|
||||||
params[:message][:user_target_id] = User.find_by(ign: params[:message][:user_target].strip).try(:id)
|
|
||||||
params[:message][:user_sender_id] = User.find_by(ign: params[:message][:user_sender]).id
|
|
||||||
params[:message][:user_hidden_id] = User.find_by(ign: params[:message][:user_hidden]).try(:id)
|
|
||||||
params[:message][:user_unread_id] = User.find_by(ign: params[:message][:user_unread]).try(:id)
|
|
||||||
params.require(:message).permit([:subject, :text, :user_target_id, :user_sender_id, :user_hidden_id, :user_unread_id])
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def check_permission
|
|
||||||
@message = Message.find(params[:id])
|
|
||||||
unless [@message.user_target, @message.user_sender].include? current_user
|
|
||||||
flash[:alert] = "You are not allowed to view this message"
|
|
||||||
redirect_to home_statics_path
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -69,4 +69,4 @@ class ThreadrepliesController < ApplicationController
|
|||||||
def reply_params
|
def reply_params
|
||||||
params.require(:threadreply).permit(:content)
|
params.require(:threadreply).permit(:content)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -4,7 +4,7 @@ class UsersController < ApplicationController
|
|||||||
include MailerHelper
|
include MailerHelper
|
||||||
include ERB::Util
|
include ERB::Util
|
||||||
|
|
||||||
before_filter :set_user, except: [:index, :new, :create, :lost_password, :reset_password, :suggestions]
|
before_filter :set_user, except: [:index, :new, :create, :lost_password, :reset_password, :suggestions, :update_memory]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
if params[:role]
|
if params[:role]
|
||||||
@@ -30,6 +30,10 @@ class UsersController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
format.json {render json: @user.attributes.slice("id", "uuid", "ign", "name", "about", "donor", "confirmed", "last_seen", "created_at").to_json}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# SIGNUP
|
# SIGNUP
|
||||||
@@ -323,6 +327,26 @@ class UsersController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def memory
|
||||||
|
params[:page] ||= (page ||= 1)
|
||||||
|
file = File.open("/etc/minecraft/redstoner/plugins/JavaUtils/memory/hexfile.hex")
|
||||||
|
@hex_a = file.read.unpack("C*").map {|h| h.to_s(16)}
|
||||||
|
@hex_a = Kaminari.paginate_array(@hex_a).page(params[:page]).per(2048)
|
||||||
|
file.close
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_memory
|
||||||
|
file = File.open("/etc/minecraft/redstoner/plugins/JavaUtils/memory/hexfile.hex")
|
||||||
|
new_text = file.read
|
||||||
|
file.close
|
||||||
|
new_text = new_text.unpack("C*").collect{|h| h.to_s(16)}
|
||||||
|
new_text[params[:mem_id].split("-")[1].to_i] = params[:value]
|
||||||
|
file = File.open("/etc/minecraft/redstoner/plugins/JavaUtils/memory/hexfile.hex", "w")
|
||||||
|
file.write((new_text.collect{|h| h.to_s.to_i(16)}).pack("C*").force_encoding("UTF-8"))
|
||||||
|
file.close
|
||||||
|
render nothing: true
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def validate_token(uuid, email, token)
|
def validate_token(uuid, email, token)
|
||||||
|
|||||||
@@ -90,4 +90,4 @@ module ApplicationHelper
|
|||||||
https://www.youtube-nocookie.com/embed/\\1?theme=light&vq=hd720&hd=1&iv_load_policy=3&showinfo=1&showsearch=0&rel=0&modestbranding&hd=1&autohide=1&html5=1&start=\\3'>
|
https://www.youtube-nocookie.com/embed/\\1?theme=light&vq=hd720&hd=1&iv_load_policy=3&showinfo=1&showsearch=0&rel=0&modestbranding&hd=1&autohide=1&html5=1&start=\\3'>
|
||||||
</iframe>")
|
</iframe>")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -24,4 +24,4 @@ module MailerHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -52,4 +52,4 @@ module UsersHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -44,10 +44,4 @@ class RedstonerMailer < ActionMailer::Base
|
|||||||
@user = user
|
@user = user
|
||||||
mail(to: @user.email, subject: "Email change on Redstoner.com")
|
mail(to: @user.email, subject: "Email change on Redstoner.com")
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_message_mail(user, message)
|
|
||||||
@user = user
|
|
||||||
@message = message
|
|
||||||
mail(to: @user.email, subject: "#{message.user_sender.name} sent you a new message")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -61,4 +61,4 @@ class Comment < ActiveRecord::Base
|
|||||||
background_mailer(mails)
|
background_mailer(mails)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
class Message < ActiveRecord::Base
|
|
||||||
|
|
||||||
include MailerHelper
|
|
||||||
|
|
||||||
belongs_to :user_sender, class_name: "User", foreign_key: "user_sender_id"
|
|
||||||
belongs_to :user_target, class_name: "User", foreign_key: "user_target_id"
|
|
||||||
belongs_to :user_editor, class_name: "User", foreign_key: "user_editor_id"
|
|
||||||
belongs_to :user_hidden, class_name: "User", foreign_key: "user_hidden_id"
|
|
||||||
belongs_to :user_unread, class_name: "User", foreign_key: "user_unread_id"
|
|
||||||
|
|
||||||
|
|
||||||
validates_presence_of :user_sender, :user_target, :text, :subject
|
|
||||||
|
|
||||||
validates_length_of :text, in: 1..8000
|
|
||||||
validates_length_of :subject, in: 1..2000
|
|
||||||
|
|
||||||
has_many :messagereplies
|
|
||||||
|
|
||||||
accepts_nested_attributes_for :messagereplies
|
|
||||||
|
|
||||||
before_destroy :do_destroy?
|
|
||||||
|
|
||||||
def do_destroy?
|
|
||||||
if user_hidden || user_sender == user_target
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
update_attributes(user_hidden: User.current)
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_s
|
|
||||||
subject
|
|
||||||
end
|
|
||||||
|
|
||||||
def sender
|
|
||||||
@sender ||= if self.user_sender.present?
|
|
||||||
user_sender
|
|
||||||
else
|
|
||||||
User.first
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def target
|
|
||||||
@target ||= if self.user_target.present?
|
|
||||||
user_target
|
|
||||||
else
|
|
||||||
User.first
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def editor
|
|
||||||
@editor ||= (self.user_editor || User.first)
|
|
||||||
end
|
|
||||||
|
|
||||||
def edited?
|
|
||||||
!!user_editor_id
|
|
||||||
end
|
|
||||||
|
|
||||||
def replies
|
|
||||||
messagereplies
|
|
||||||
end
|
|
||||||
|
|
||||||
def send_new_message_mail
|
|
||||||
begin
|
|
||||||
mail = RedstonerMailer.new_message_mail(user_target, self)
|
|
||||||
rescue => e
|
|
||||||
Rails.logger.error "---"
|
|
||||||
Rails.logger.error "WARNING: Failed to create new_message_mail (view) for message#: #{@message.id}, user: #{@user.name}, #{@user.email}"
|
|
||||||
Rails.logger.error e.message
|
|
||||||
Rails.logger.error "---"
|
|
||||||
end
|
|
||||||
background_mailer([mail])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
class Messagereply < ActiveRecord::Base
|
|
||||||
|
|
||||||
include MailerHelper
|
|
||||||
include UsersHelper
|
|
||||||
|
|
||||||
belongs_to :message
|
|
||||||
belongs_to :user_author, class_name: "User", foreign_key: "user_author_id"
|
|
||||||
belongs_to :user_editor, class_name: "User", foreign_key: "user_editor_id"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
validates_presence_of :text
|
|
||||||
validates_length_of :text, in: 1..8000
|
|
||||||
|
|
||||||
def get_message
|
|
||||||
message
|
|
||||||
end
|
|
||||||
|
|
||||||
def author
|
|
||||||
@author ||= if self.user_author.present?
|
|
||||||
user_author
|
|
||||||
else
|
|
||||||
User.first
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def editor
|
|
||||||
# can be nil
|
|
||||||
@editor ||= user_editor
|
|
||||||
end
|
|
||||||
|
|
||||||
def edited?
|
|
||||||
!!user_editor_id
|
|
||||||
end
|
|
||||||
|
|
||||||
def send_new_reply_mail(old_content = "")
|
|
||||||
users = mentions(content) - mentions(old_content)
|
|
||||||
|
|
||||||
# thread + replies
|
|
||||||
posts = message.replies.to_a
|
|
||||||
posts << message if message.author.mail_own_message_reply?
|
|
||||||
# only send "reply" mail when reply is new
|
|
||||||
unless old_content.present?
|
|
||||||
posts.each do |post|
|
|
||||||
# don't send mail to the author of this reply, don't send to banned/disabled users
|
|
||||||
if post.author != author && post.author.normal? && post.author.confirmed? # &&
|
|
||||||
users << post.author if post.author.mail_other_thread_reply?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
# making sure we don't send multiple mails to the same user
|
|
||||||
users.uniq!
|
|
||||||
|
|
||||||
mails = []
|
|
||||||
users.each do |usr|
|
|
||||||
begin
|
|
||||||
mails << RedstonerMailer.new_thread_reply_mail(usr, self)
|
|
||||||
rescue => e
|
|
||||||
Rails.logger.error "---"
|
|
||||||
Rails.logger.error "WARNING: Failed to create new_thread_reply_mail (view) for reply#: #{@self.id}, user: #{@user.name}, #{@user.email}"
|
|
||||||
Rails.logger.error e.message
|
|
||||||
Rails.logger.error "---"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
background_mailer(mails)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -64,4 +64,4 @@ class Threadreply < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
background_mailer(mails)
|
background_mailer(mails)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -24,8 +24,6 @@ class User < ActiveRecord::Base
|
|||||||
has_many :blogposts
|
has_many :blogposts
|
||||||
has_many :comments
|
has_many :comments
|
||||||
|
|
||||||
cattr_accessor :current
|
|
||||||
|
|
||||||
# foo.bar.is?(current_user)
|
# foo.bar.is?(current_user)
|
||||||
def is? (user)
|
def is? (user)
|
||||||
self == user
|
self == user
|
||||||
@@ -175,4 +173,4 @@ class User < ActiveRecord::Base
|
|||||||
def set_email_token
|
def set_email_token
|
||||||
self.email_token ||= SecureRandom.hex(16)
|
self.email_token ||= SecureRandom.hex(16)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -8,4 +8,4 @@
|
|||||||
<%= text_area_tag name, content, options %>
|
<%= text_area_tag name, content, options %>
|
||||||
<div class="preview"><i>(Loading...)</i></div>
|
<div class="preview"><i>(Loading...)</i></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<div class="md_editor">
|
|
||||||
<div class="field_container_user">
|
|
||||||
<% options = (defined?(options) && options || {}) %>
|
|
||||||
<% options[:class] = "#{options[:class]} editor_field" %>
|
|
||||||
<% options[:placeholder] ||= "Enter user's name." %>
|
|
||||||
<%= text_field_tag name, content, options %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<% title "News" %>
|
<% title "News" %>
|
||||||
|
|
||||||
<h1>News</h1>
|
<h1>News</h1>
|
||||||
<%= link_to 'Make new Post', new_blogpost_path, class: "btn blue" if mod? %>
|
<%= link_to 'Make new Post', new_blogpost_path, class: "btn blue" if mod? %>
|
||||||
<div id="posts">
|
<div id="posts">
|
||||||
|
|||||||
@@ -51,4 +51,4 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= paginate @threads %>
|
<%= paginate @threads %>
|
||||||
</div>
|
</div>
|
||||||
@@ -38,4 +38,4 @@
|
|||||||
<p><%= f.submit "Update thread", class: "btn blue left" %></p>
|
<p><%= f.submit "Update thread", class: "btn blue left" %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= button_to "Delete thread", @thread, :method => "delete", data: {confirm: "Delete thread & comments forever?"}, class: "btn red right" %>
|
<%= button_to "Delete thread", @thread, :method => "delete", data: {confirm: "Delete thread & comments forever?"}, class: "btn red right" %>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
@@ -32,4 +32,4 @@
|
|||||||
<%= f.hidden_field :forum_id %>
|
<%= f.hidden_field :forum_id %>
|
||||||
<p><%= f.submit "Create thread", class: "btn blue left" %></p>
|
<p><%= f.submit "Create thread", class: "btn blue left" %></p>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -44,4 +44,4 @@
|
|||||||
<% else %>
|
<% else %>
|
||||||
<p>Please <%= link_to "Log in", login_path(return_path: request.env['PATH_INFO']), action: "new" %> to post a reply.</p>
|
<p>Please <%= link_to "Log in", login_path(return_path: request.env['PATH_INFO']), action: "new" %> to post a reply.</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<%= form_for [reply.get_message, reply] do |f| %>
|
|
||||||
<%= render partial: "md_editor", locals: {name: "messagereply[text]", content: reply.text} %>
|
|
||||||
<p><%= f.submit "Reply", class: "btn blue" %></p>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<div class="item-group thread-reply with-avatar" id="reply-<%= reply.id %>">
|
|
||||||
<div class="header">
|
|
||||||
<%= link_to(reply.author.avatar(64), reply.author, title: reply.author.ign) %>
|
|
||||||
<%= render partial: "users/username", locals: { user: reply.author } %>
|
|
||||||
<%= link_to "#reply-#{reply.id}" do %>
|
|
||||||
<%= ago reply.created_at %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= link_to "edit", edit_message_messagereply_path(reply.message, reply), class: "editlink" if mod? || reply.author.is?(current_user) %>
|
|
||||||
<div class="clear-right"></div>
|
|
||||||
</div>
|
|
||||||
<div class="items">
|
|
||||||
<div class="item content">
|
|
||||||
<%= render_md(reply.text).html_safe %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<% title "Edit Message Reply: #{@reply.message.subject}" %>
|
|
||||||
|
|
||||||
<%
|
|
||||||
position = @reply.message.replies.index(@reply)
|
|
||||||
page = position / Kaminari.config.default_per_page + 1
|
|
||||||
%>
|
|
||||||
|
|
||||||
<%= link_to "Messages", messages_path %> → <%= link_to @reply.message, message_path(@reply.message, page: page) + "#reply-#{@reply.id}" %> → Edit reply
|
|
||||||
<h1>Edit reply</h1>
|
|
||||||
<%= form_for [@reply.message, @reply] do |f| %>
|
|
||||||
<%= render partial: "md_editor", locals: {name: "messagereply[text]", content: @reply.text} %>
|
|
||||||
<p><%= f.submit "Reply", class: "btn blue left" %></p>
|
|
||||||
<% end %>
|
|
||||||
<p><%= button_to "Delete reply", [@reply.message, @reply], method: "delete", data: {confirm: "Delete reply forever?"}, class: "btn red right" %></p>
|
|
||||||
<div class="clear"></div>
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<% title "Edit Thread: #{@message}" %>
|
|
||||||
|
|
||||||
<h1>Edit thread</h1>
|
|
||||||
<%= link_to "Messages", messages_path %> → <%= link_to @message, @message %> → Edit Message
|
|
||||||
<%= form_for @message do |f|%>
|
|
||||||
<div class="table-cell full-width">
|
|
||||||
<%= f.text_field :subject, placeholder: "Subject" %>
|
|
||||||
</div>
|
|
||||||
<br>
|
|
||||||
<%= render partial: "md_editor", locals: {name: "message[text]", content: @message.text} %>
|
|
||||||
<p><%= f.submit "Update message", class: "btn blue left" %></p>
|
|
||||||
<%= f.hidden_field :user_sender, value: @message.user_sender %>
|
|
||||||
<%= f.hidden_field :user_target, value: @message.user_target %>
|
|
||||||
<% end %>
|
|
||||||
<%= button_to "Delete ", @message, :method => "delete", data: {confirm: "Delete message & comments forever?"}, class: "btn red right" %>
|
|
||||||
<div class="clear"></div>
|
|
||||||
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
<% if @messages.any? %>
|
|
||||||
<%= link_to "delete all messages", destroy_all_messages_path, method: "post", class: "btn blue right", data: {confirm: "Delete all of your messages forever?"} %>
|
|
||||||
<% end %>
|
|
||||||
<%= link_to "create new message", new_message_path, class: "btn blue right" %>
|
|
||||||
<br>
|
|
||||||
<h2>
|
|
||||||
<% if Message.where("(user_target_id = ? OR user_sender_id = ?) AND user_hidden_id != ?", current_user.id, current_user.id, current_user.id).any? %>
|
|
||||||
Your private messages:
|
|
||||||
<% else %>
|
|
||||||
You have no private messages.
|
|
||||||
<% end %>
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
<div id="forum_groups">
|
|
||||||
<% @messages.each do |message| %>
|
|
||||||
<div class="item-group with-avatar">
|
|
||||||
<div class="header">
|
|
||||||
<%
|
|
||||||
if current_user == message.user_sender
|
|
||||||
user = message.user_target
|
|
||||||
else
|
|
||||||
user = message.user_sender
|
|
||||||
end
|
|
||||||
%>
|
|
||||||
<%= link_to(user.avatar(64), user, title: user.ign) %>
|
|
||||||
<%= render partial: "users/username", locals: { user: user } %>
|
|
||||||
<span style="font-size:16px">
|
|
||||||
|
|
||||||
<span class="<%= "bold" if message.user_unread_id && message.user_unread != current_user %>"><%= link_to message.subject, message %></span>
|
|
||||||
|
|
|
||||||
</span>
|
|
||||||
<%= ago message.created_at %>
|
|
||||||
<div class="right">
|
|
||||||
<%= link_to "Delete message", message, :method => "delete", class: "editlink", data: {confirm: "Delete this message forever?"} %>
|
|
||||||
</div>
|
|
||||||
<div class="clear-right"></div>
|
|
||||||
</div>
|
|
||||||
<div class="items">
|
|
||||||
<div class="item">
|
|
||||||
<%= truncate message.text, length: 20, omission: "..." %>
|
|
||||||
<div class="item-info items bold">
|
|
||||||
<% if rpl = message.replies.last %>
|
|
||||||
<%= rpl.author.name %>
|
|
||||||
<%
|
|
||||||
position = message.replies.count - 1
|
|
||||||
page = position / Kaminari.config.default_per_page + 1
|
|
||||||
%>
|
|
||||||
<%= link_to "replied", message_path(message, page: page) + "#reply-#{rpl.id}" %>
|
|
||||||
<%= ago rpl.created_at %>.
|
|
||||||
<% else %>
|
|
||||||
No replies yet.
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
<div class="clear"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
<%= paginate @messages %>
|
|
||||||
</div>
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
<h1>New Message</h1>
|
|
||||||
<%= form_for @message do |f| %>
|
|
||||||
</table>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<%= render partial: "md_editor_user", locals: {name: "message[user_target]", content: params[:user_target]} %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<br>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<%= f.text_field :subject, placeholder: "Subject" %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<br><br>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<%= render partial: "md_editor", locals: {name: "message[text]", content: params[:text]} %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<%= f.hidden_field :user_sender, value: current_user %>
|
|
||||||
<%= f.hidden_field :user_unread, value: current_user %>
|
|
||||||
<br>
|
|
||||||
<p><%= f.submit "Send Message", class: "btn blue left" %></p>
|
|
||||||
<% end %>
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<%= link_to "Messages", messages_path %>
|
|
||||||
<h1><%= title @message.subject %></h1>
|
|
||||||
<div class="item-group thread with-avatar" id="message-<%= @message.id %>">
|
|
||||||
<div class="header">
|
|
||||||
<%= link_to(@message.sender.avatar(64), @message.sender, title: @message.sender.ign) %>
|
|
||||||
<%= render partial: "users/username", locals: { user: @message.sender } %>
|
|
||||||
<%= link_to p do %>
|
|
||||||
<%= ago @message.created_at %>
|
|
||||||
<% end %>
|
|
||||||
<%= link_to "edit", edit_message_path(@message), class: "editlink" if mod? || @message.sender.is?(current_user) %>
|
|
||||||
<div class="clear-right"></div>
|
|
||||||
</div>
|
|
||||||
<div class="items">
|
|
||||||
<% if @message.edited? %>
|
|
||||||
<div class="item edited">
|
|
||||||
Last edited <%= ago @message.updated_at %> by <%= link_to @message.editor.name, @message.editor %>.
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
<div class="item content">
|
|
||||||
<%= render_md(@message.text).html_safe %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="replies">
|
|
||||||
<h3><%= "#{pluralize(@message.replies.size, 'reply')}." %></h3>
|
|
||||||
<% @replies.each do |reply| %>
|
|
||||||
<%= render partial: "messagereplies/reply", locals: {reply: reply} %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= paginate @replies %>
|
|
||||||
|
|
||||||
<%= render partial: "messagereplies/new", locals: {reply: Messagereply.new(message: @message)} %>
|
|
||||||
</div>
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
<div style="font-family: 'Oswald','Calibri','Arial','DejaVu Sans','Open Sans','Lucida Sans','Lucida Grande','Lucida Sans Unicode',sans-serif; background: #F2F2F2">
|
|
||||||
<div style="color: #3f3f3f; width: 600px; max-width: 100%; padding: 2em 0; margin: auto;">
|
|
||||||
Hi <%= @user.name %>!
|
|
||||||
|
|
||||||
<p><%= link_to @message.user_sender.name, user_url(@message.user_sender), style: "text-decoration: none; color: #4096EE;" %> has sent you a new message!</p>
|
|
||||||
|
|
||||||
<blockquote>
|
|
||||||
<%= render_md(@message.text).html_safe %>
|
|
||||||
</blockquote>
|
|
||||||
|
|
||||||
<p><%= link_to "Click here", messages_url, style: "text-decoration: none; color: #4096EE;" %> to view your current messages.</p>
|
|
||||||
|
|
||||||
<p>If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(role: "staff"), style: "text-decoration: none; color: #4096EE;" %> in-game or on the forums!</p>
|
|
||||||
<p>Your Redstoner team</p>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div style="background: #444; width: 100%; color: #fff; margin: auto; text-align: center; display: inline-block;">
|
|
||||||
<div style="margin: 2em;">
|
|
||||||
<p><i>Too much spam? Change <%= link_to "your notification settings", edit_notifications_user_url(@user), style: "text-decoration: none; color: #4096EE;" %>!</i></p>
|
|
||||||
<p>You can contact us via:
|
|
||||||
<%= link_to "Website", root_url, style: "text-decoration: none; color: #4096EE;" %> |
|
|
||||||
<%= link_to "Twitter", "https://twitter.com/RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> |
|
|
||||||
<%= link_to "Google+", "https://google.com/+Redstoner", style: "text-decoration: none; color: #4096EE;" %> |
|
|
||||||
<%= link_to "Email", "mailto:redstonerserver+website@gmail.com", style: "text-decoration: none; color: #4096EE;" %>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -29,4 +29,4 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -30,4 +30,4 @@
|
|||||||
<%= link_to "Email", "mailto:redstonerserver+website@gmail.com", style: "text-decoration: none; color: #4096EE;" %>
|
<%= link_to "Email", "mailto:redstonerserver+website@gmail.com", style: "text-decoration: none; color: #4096EE;" %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -30,4 +30,4 @@
|
|||||||
<span>for those who just want to mine some ore</span>
|
<span>for those who just want to mine some ore</span>
|
||||||
<span>and we have a freebuild world for large projects.</span>
|
<span>and we have a freebuild world for large projects.</span>
|
||||||
</p>
|
</p>
|
||||||
<p>Join us now!</p>
|
<p>Join us now!</p>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<%= form_for [reply.thread, reply] do |f| %>
|
<%= form_for [reply.thread, reply] do |f| %>
|
||||||
<%= render partial: "md_editor", locals: {name: "threadreply[content]", content: reply.content} %>
|
<%= render partial: "md_editor", locals: {name: "threadreply[content]", content: reply.content} %>
|
||||||
<p><%= f.submit "Reply#{ ' (Locked)' if reply.thread.locked? }", class: "btn blue" %></p>
|
<p><%= f.submit "Reply#{ ' (Locked)' if reply.thread.locked? }", class: "btn blue" %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -12,4 +12,4 @@
|
|||||||
<p><%= f.submit "Reply", class: "btn blue left" %></p>
|
<p><%= f.submit "Reply", class: "btn blue left" %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<p><%= button_to "Delete reply", [@reply.thread, @reply], method: "delete", data: {confirm: "Delete reply forever?"}, class: "btn red right" %></p>
|
<p><%= button_to "Delete reply", [@reply.thread, @reply], method: "delete", data: {confirm: "Delete reply forever?"}, class: "btn red right" %></p>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
@@ -87,4 +87,4 @@
|
|||||||
<span class='red-alert'>This user has not confirmed his email!</span>
|
<span class='red-alert'>This user has not confirmed his email!</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -1,19 +1,14 @@
|
|||||||
<% title @user.name %>
|
<% title @user.name %>
|
||||||
|
|
||||||
<div id="user-info">
|
<div id="user-info">
|
||||||
<div class="profile-action">
|
<% if @user.is?(current_user) || (mod? && current_user.role >= @user.role) %>
|
||||||
<% if session[:original_user_id] %>
|
<div class="profile-action" ><%= link_to "edit profile", edit_user_path(@user), :class => "btn blue" %></div>
|
||||||
<%= link_to "revert", revert_path, :class => "btn blue" %>
|
<% end %>
|
||||||
<% elsif admin? %>
|
<div class="profile-action" >
|
||||||
|
<% if !session[:original_user_id] && admin? %>
|
||||||
<%= link_to "become this user", become_path(user: @user), :class => "btn blue" %>
|
<%= link_to "become this user", become_path(user: @user), :class => "btn blue" %>
|
||||||
<% end %>
|
<% elsif session[:original_user_id] %>
|
||||||
<% if @user.is?(current_user) || (mod? && current_user.role >= @user.role) %>
|
<%= link_to "revert", revert_path, :class => "btn blue" %>
|
||||||
<%= link_to "edit profile", edit_user_path(@user), :class => "btn blue" %>
|
|
||||||
<% end %>
|
|
||||||
<% if @user.is?(current_user) %>
|
|
||||||
<%= link_to "private messages (#{Message.where.not(user_unread: current_user).count})", messages_path, :class => "btn blue" %>
|
|
||||||
<% elsif current_user %>
|
|
||||||
<%= link_to "Send this user a message", new_message_path(user_target: @user.ign), :class => "btn blue" %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -41,13 +41,6 @@ Redstoner::Application.routes.draw do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :messages do
|
|
||||||
resources :messagereplies, path: 'replies'
|
|
||||||
collection do
|
|
||||||
post 'destroy_all'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# get '/status' => 'status#show'
|
# get '/status' => 'status#show'
|
||||||
|
|
||||||
get 'login' => 'sessions#new'
|
get 'login' => 'sessions#new'
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
class CreateMessages < ActiveRecord::Migration
|
|
||||||
def change
|
|
||||||
create_table :messages do |t|
|
|
||||||
t.text :message
|
|
||||||
t.references :user_sender
|
|
||||||
t.references :user_target
|
|
||||||
t.references :user_editor
|
|
||||||
t.references :user_hidden
|
|
||||||
t.references :user_unread
|
|
||||||
|
|
||||||
t.timestamps null: true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
class ChangeMessageToText < ActiveRecord::Migration
|
|
||||||
def change
|
|
||||||
rename_column :messages, :message, :text
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
class AddSubjectToMessages < ActiveRecord::Migration
|
|
||||||
def change
|
|
||||||
add_column :messages, :subject, :string
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
class CreateMessagereplies < ActiveRecord::Migration
|
|
||||||
def change
|
|
||||||
create_table :messagereplies do |t|
|
|
||||||
t.text :text
|
|
||||||
|
|
||||||
t.references :user_author
|
|
||||||
t.references :user_editor
|
|
||||||
t.references :message
|
|
||||||
|
|
||||||
t.timestamps null: true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
71
db/schema.rb
71
db/schema.rb
@@ -11,10 +11,10 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20170613021450) do
|
ActiveRecord::Schema.define(version: 20160926220738) do
|
||||||
|
|
||||||
create_table "blogposts", force: :cascade do |t|
|
create_table "blogposts", force: :cascade do |t|
|
||||||
t.string "title", limit: 191
|
t.string "title"
|
||||||
t.text "content", limit: 65535
|
t.text "content", limit: 65535
|
||||||
t.integer "user_author_id", limit: 4
|
t.integer "user_author_id", limit: 4
|
||||||
t.integer "user_editor_id", limit: 4
|
t.integer "user_editor_id", limit: 4
|
||||||
@@ -32,14 +32,14 @@ ActiveRecord::Schema.define(version: 20170613021450) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "forumgroups", force: :cascade do |t|
|
create_table "forumgroups", force: :cascade do |t|
|
||||||
t.string "name", limit: 191
|
t.string "name"
|
||||||
t.integer "position", limit: 4
|
t.integer "position", limit: 4
|
||||||
t.integer "role_read_id", limit: 4
|
t.integer "role_read_id", limit: 4
|
||||||
t.integer "role_write_id", limit: 4
|
t.integer "role_write_id", limit: 4
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "forums", force: :cascade do |t|
|
create_table "forums", force: :cascade do |t|
|
||||||
t.string "name", limit: 191
|
t.string "name"
|
||||||
t.integer "position", limit: 4
|
t.integer "position", limit: 4
|
||||||
t.integer "role_read_id", limit: 4
|
t.integer "role_read_id", limit: 4
|
||||||
t.integer "role_write_id", limit: 4
|
t.integer "role_write_id", limit: 4
|
||||||
@@ -52,7 +52,7 @@ ActiveRecord::Schema.define(version: 20170613021450) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "forumthreads", force: :cascade do |t|
|
create_table "forumthreads", force: :cascade do |t|
|
||||||
t.string "title", limit: 191
|
t.string "title"
|
||||||
t.text "content", limit: 65535
|
t.text "content", limit: 65535
|
||||||
t.boolean "sticky", default: false
|
t.boolean "sticky", default: false
|
||||||
t.boolean "locked", default: false
|
t.boolean "locked", default: false
|
||||||
@@ -65,54 +65,33 @@ ActiveRecord::Schema.define(version: 20170613021450) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "info", force: :cascade do |t|
|
create_table "info", force: :cascade do |t|
|
||||||
t.string "title", limit: 191
|
t.string "title"
|
||||||
t.text "content", limit: 65535
|
t.text "content", limit: 65535
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "labels", force: :cascade do |t|
|
create_table "labels", force: :cascade do |t|
|
||||||
t.string "name", limit: 191
|
t.string "name"
|
||||||
t.string "color", limit: 191
|
t.string "color"
|
||||||
end
|
|
||||||
|
|
||||||
create_table "messagereplies", force: :cascade do |t|
|
|
||||||
t.text "text", limit: 65535
|
|
||||||
t.integer "user_author_id", limit: 4
|
|
||||||
t.integer "user_editor_id", limit: 4
|
|
||||||
t.integer "message_id", limit: 4
|
|
||||||
t.datetime "created_at"
|
|
||||||
t.datetime "updated_at"
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "messages", force: :cascade do |t|
|
|
||||||
t.text "text", limit: 65535
|
|
||||||
t.integer "user_sender_id", limit: 4
|
|
||||||
t.integer "user_target_id", limit: 4
|
|
||||||
t.integer "user_editor_id", limit: 4
|
|
||||||
t.integer "user_hidden_id", limit: 4
|
|
||||||
t.integer "user_unread_id", limit: 4
|
|
||||||
t.datetime "created_at"
|
|
||||||
t.datetime "updated_at"
|
|
||||||
t.string "subject", limit: 191
|
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "register_tokens", force: :cascade do |t|
|
create_table "register_tokens", force: :cascade do |t|
|
||||||
t.string "uuid", limit: 32, null: false
|
t.string "uuid", null: false
|
||||||
t.string "token", limit: 6, null: false
|
t.string "token", null: false
|
||||||
t.string "email", limit: 191, null: false
|
t.string "email", null: false
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "register_tokens", ["uuid"], name: "index_register_tokens_on_uuid", unique: true, using: :btree
|
add_index "register_tokens", ["uuid"], name: "index_register_tokens_on_uuid", unique: true, using: :btree
|
||||||
|
|
||||||
create_table "roles", force: :cascade do |t|
|
create_table "roles", force: :cascade do |t|
|
||||||
t.string "name", limit: 191
|
t.string "name"
|
||||||
t.integer "value", limit: 4
|
t.integer "value", limit: 4
|
||||||
t.string "color", limit: 191
|
t.string "color"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "sessions", force: :cascade do |t|
|
create_table "sessions", force: :cascade do |t|
|
||||||
t.string "session_id", limit: 191, null: false
|
t.string "session_id", null: false
|
||||||
t.text "data", limit: 65535
|
t.text "data", limit: 65535
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
@@ -131,20 +110,20 @@ ActiveRecord::Schema.define(version: 20170613021450) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "users", force: :cascade do |t|
|
create_table "users", force: :cascade do |t|
|
||||||
t.string "uuid", limit: 191, null: false
|
t.string "uuid", null: false
|
||||||
t.string "name", limit: 191, null: false
|
t.string "name", null: false
|
||||||
t.string "password_digest", limit: 191, null: false
|
t.string "password_digest", null: false
|
||||||
t.string "ign", limit: 191, null: false
|
t.string "ign", null: false
|
||||||
t.string "email", limit: 191, null: false
|
t.string "email", null: false
|
||||||
t.text "about", limit: 65535
|
t.text "about", limit: 65535
|
||||||
t.string "last_ip", limit: 191
|
t.string "last_ip"
|
||||||
t.string "skype", limit: 191
|
t.string "skype"
|
||||||
t.boolean "skype_public", default: false
|
t.boolean "skype_public", default: false
|
||||||
t.string "youtube", limit: 191
|
t.string "youtube"
|
||||||
t.string "youtube_channelname", limit: 191
|
t.string "youtube_channelname"
|
||||||
t.string "twitter", limit: 191
|
t.string "twitter"
|
||||||
t.boolean "donor", default: false
|
t.boolean "donor", default: false
|
||||||
t.string "email_token", limit: 191
|
t.string "email_token"
|
||||||
t.boolean "confirmed", default: false
|
t.boolean "confirmed", default: false
|
||||||
t.datetime "last_seen"
|
t.datetime "last_seen"
|
||||||
t.integer "role_id", limit: 4, null: false
|
t.integer "role_id", limit: 4, null: false
|
||||||
|
|||||||
27
db/seeds.rb
27
db/seeds.rb
@@ -38,29 +38,4 @@ User.create!(
|
|||||||
password: "123456789", # high seructity!
|
password: "123456789", # high seructity!
|
||||||
password_confirmation: "123456789",
|
password_confirmation: "123456789",
|
||||||
role: Role.get(:superadmin)
|
role: Role.get(:superadmin)
|
||||||
)
|
)
|
||||||
User.create!(
|
|
||||||
uuid: "7f52491ab5d64c11b4a43806db47a101",
|
|
||||||
ign: "Yummy_",
|
|
||||||
name: "Yummy",
|
|
||||||
email: "yummy@example.com",
|
|
||||||
password: "123456789", # high seructity!
|
|
||||||
password_confirmation: "123456789",
|
|
||||||
role: Role.get(:superadmin)
|
|
||||||
)
|
|
||||||
User.create!(
|
|
||||||
uuid: "62fe35da05ae437ea44b4deae1be1dc4",
|
|
||||||
ign: "Logal",
|
|
||||||
email: "logal@example.com",
|
|
||||||
password: "123456789", # high seructity!
|
|
||||||
password_confirmation: "123456789",
|
|
||||||
role: Role.get(:superadmin)
|
|
||||||
)
|
|
||||||
|
|
||||||
Message.create!(
|
|
||||||
user_sender_id: 2,
|
|
||||||
user_target_id: 2,
|
|
||||||
text: "This is a very long message that I will be using to test a plentitude of things. :)",
|
|
||||||
created_at: Time.utc(0).to_datetime,
|
|
||||||
subject: "Hello there!"
|
|
||||||
)
|
|
||||||
Reference in New Issue
Block a user