18 Commits

Author SHA1 Message Date
MrYummy
8bf5164301 just making this so I don't lose work when I switch branches 2017-06-17 17:22:58 +02:00
MrYummy
6a0eedc585 Fixed compatability issues in methods for thread-like messages 2017-06-16 22:27:03 +02:00
MrYummy
4e8d94a7b6 see previous commit 2017-06-16 21:19:13 +02:00
MrYummy
f60edea1be Fixed 'No private messages' bug 2017-06-16 21:16:35 +02:00
MrYummy
2bb75bb0b6 tweaked message 'read' system 2017-06-16 21:14:09 +02:00
MrYummy
dd193e740a Added 'read' check; message name is only bold if unread 2017-06-15 15:04:15 +02:00
MrYummy
9b50ec652c Made messages more thread-like (replies, editing, etc.) 2017-06-15 14:29:25 +02:00
MrYummy
80026caebc Added subject support to messages 2017-06-13 03:48:30 +02:00
MrYummy
f00677a68b Added subject column to messages 2017-06-13 02:35:22 +02:00
MrYummy
b075a5fd75 Apparently that 'unnecessary permission check' was necessary. ¯\_(ツ)_/¯ 2017-06-13 02:19:29 +02:00
MrYummy
4d42fdfeb4 Moved messages index link to users/show.html.erb, added 'message this user' button 2017-06-13 02:08:13 +02:00
MrYummy
dd63941657 Added message length validity (1..8000) and rewrote 'target' method 2017-06-12 21:59:39 +02:00
MrYummy
fbae985d86 Prettified link style in message mail 2017-06-12 21:47:21 +02:00
MrYummy
32231e4eea Updated user_target autocomplete regex, removed unnecessary permission check 2017-06-12 21:40:33 +02:00
MrYummy
895e56ff06 Link to 'all messages' in message email fixed, added "delete_all" action 2017-06-12 21:17:18 +02:00
MrYummy
68ee779c11 Now sends mail to user_target on message creation 2017-06-04 20:02:57 +02:00
MrYummy
7c233c8fef fixed routes and made 'Delete message' appear on cursor hover 2017-06-03 21:29:14 +02:00
MrYummy
e378dfab02 Added messaging feature 2017-05-27 00:34:47 +02:00
101 changed files with 926 additions and 1144 deletions

View File

@@ -15,8 +15,6 @@ gem 'activerecord-session_store'
gem 'highlight_js-rails', github: 'RedstonerServer/highlight_js-rails' gem 'highlight_js-rails', github: 'RedstonerServer/highlight_js-rails'
gem 'kaminari', github: 'jomo/kaminari', branch: 'patch-2' # pagination gem 'kaminari', github: 'jomo/kaminari', branch: 'patch-2' # pagination
gem 'jquery-textcomplete-rails', github: 'RedstonerServer/jquery-textcomplete-rails' # @mentions gem 'jquery-textcomplete-rails', github: 'RedstonerServer/jquery-textcomplete-rails' # @mentions
gem 'actionpack-action_caching', github: 'antulik/actionpack-action_caching', ref: '8c6e52c69315d67437f480da5dce4b7c8737fb32'
gem 'mail-gpg', github: 'jomo/mail-gpg', ref: 'a666b48ee866dfa3eaa700f9c5edf4d195d0f8c9'
# Gems used only for assets and not required # Gems used only for assets and not required
# in production environments by default. # in production environments by default.
@@ -45,4 +43,4 @@ end
group :production do group :production do
# Use unicorn as the app server # Use unicorn as the app server
gem 'unicorn' gem 'unicorn'
end end

View File

@@ -14,14 +14,6 @@ GIT
railties (>= 3.2.0) railties (>= 3.2.0)
sass-rails (>= 3.2.0) sass-rails (>= 3.2.0)
GIT
remote: git://github.com/antulik/actionpack-action_caching.git
revision: 8c6e52c69315d67437f480da5dce4b7c8737fb32
ref: 8c6e52c69315d67437f480da5dce4b7c8737fb32
specs:
actionpack-action_caching (1.2.0)
actionpack (>= 4.0.0, < 6)
GIT GIT
remote: git://github.com/jomo/kaminari.git remote: git://github.com/jomo/kaminari.git
revision: e49066e94d77a6abb03a0819f3c4b0cc6923cb70 revision: e49066e94d77a6abb03a0819f3c4b0cc6923cb70
@@ -31,15 +23,6 @@ GIT
actionpack (>= 3.0.0) actionpack (>= 3.0.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
GIT
remote: git://github.com/jomo/mail-gpg.git
revision: a666b48ee866dfa3eaa700f9c5edf4d195d0f8c9
ref: a666b48ee866dfa3eaa700f9c5edf4d195d0f8c9
specs:
mail-gpg (0.3.1)
gpgme (~> 2.0, >= 2.0.2)
mail (~> 2.5, >= 2.5.3)
GIT GIT
remote: git://github.com/rails/rails.git remote: git://github.com/rails/rails.git
revision: 2c8f567e53580872d8c6dfe61201e58793ca131e revision: 2c8f567e53580872d8c6dfe61201e58793ca131e
@@ -144,8 +127,6 @@ GEM
execjs (2.6.0) execjs (2.6.0)
globalid (0.3.6) globalid (0.3.6)
activesupport (>= 4.1.0) activesupport (>= 4.1.0)
gpgme (2.0.11)
mini_portile (>= 0.5.0)
hirb (0.7.3) hirb (0.7.3)
http-cookie (1.0.2) http-cookie (1.0.2)
domain_name (~> 0.5) domain_name (~> 0.5)
@@ -161,7 +142,6 @@ GEM
mail (2.6.3) mail (2.6.3)
mime-types (>= 1.16, < 3) mime-types (>= 1.16, < 3)
mime-types (2.99) mime-types (2.99)
mini_portile (0.6.2)
mini_portile2 (2.0.0) mini_portile2 (2.0.0)
minitest (5.8.4) minitest (5.8.4)
mysql2 (0.4.2) mysql2 (0.4.2)
@@ -243,7 +223,6 @@ PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
actionpack-action_caching!
activerecord-session_store activerecord-session_store
bcrypt bcrypt
better_errors better_errors
@@ -256,7 +235,6 @@ DEPENDENCIES
jquery-rails jquery-rails
jquery-textcomplete-rails! jquery-textcomplete-rails!
kaminari! kaminari!
mail-gpg!
mysql2 mysql2
rails! rails!
rails-erd rails-erd

Binary file not shown.

Before

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 581 B

View File

@@ -1,105 +0,0 @@
body {
background-color:rgb(50, 50, 50);
text-shadow:none !important;
color:rgb(190, 190, 190) !important;
}
::selection {
background-color:rgb(100, 150, 255);
}
a {
color:rgb(203, 75, 22);
border-color:black !important;
}
a:hover {
color:rgb(215, 100, 40);
}
#main-content {
border-color:black !important;
padding:30px 100px;
box-shadow:none;
}
#main-content-scroll {
padding: 131px 100px;
border: 1px solid #000;
box-shadow: 0 0 5px #000;
}
hr {
background-color:black !important;
border-color:black !important;
}
code {
background-color:rgb(30, 30, 30) !important;
border-color:black !important;
color:white !important;
}
#head_top {
width:100%;
z-index:100;
}
#head_scroll {
@extend #head_top;
position: fixed;
width: 100%;
z-index: 1;
}
div#userbar {
background-color:rgb(90, 90, 90) !important;
border-color:black !important;
color:white !important;
text-shadow:none !important;
}
#head a {
text-shadow:none !important;
color:white !important;
}
#head a:hover {
color:rgb(190, 190, 190) !important;
}
.header {
background-color:rgb(0, 0, 0);
border:none !important;
}
input[type="email"], input[type="text"], input[type="password"] {
background-color:rgb(110, 110, 110) !important;
color:white !important;
}
::placeholder {
color:lightgray;
}
.item {
background-color:rgb(40, 40, 40) !important;
border-color:black !important;
}
.item-group {
border-color:black !important;
}
div.header {
background-color:rgb(20, 20, 20) !important;
}
.avatar {
border-color:black !important;
}
.items {
border-color:black !important;
}
.markdown-help {
background-color:rgb(90, 90, 90);
color:white;
border-color:black;
}
textarea {
background-color:rgb(100, 100, 100);
color:white;
}
.headline {
border-color:black !important;
}
.role {
opacity:0.7 !important;
}
.label {
opacity:0.7 !important;
}
.notice {
color:white;
}

View File

@@ -4,12 +4,12 @@
th, td { th, td {
// force tables into line-mode // force tables into line-mode
// it''s a bit ugly, but probably the best // it's a bit ugly, but probably the best
// solution for small screens // solution for small screens
display: block; display: block;
} }
#head_top { #head {
#menu { #menu {
#logo { #logo {
display: none; display: none;
@@ -17,19 +17,10 @@
} }
} }
#head_scroll {
@extend #head_top;
position: fixed;
}
#main-content { #main-content {
padding: 30px 5px; padding: 30px 5px;
} }
#main-content-scroll {
padding: 181px 5px;
}
.front-page { .front-page {
h1 { h1 {
font-size: 2em !important; font-size: 2em !important;
@@ -75,4 +66,4 @@
margin: 50px 20px 0; margin: 50px 20px 0;
} }
} }

View File

@@ -80,7 +80,7 @@ a {
} }
} }
#head_top { #head {
background: #3f3f3f; background: #3f3f3f;
#menu { #menu {
@@ -181,13 +181,6 @@ a {
} }
} }
#head_scroll {
@extend #head_top;
position: fixed;
width: 100%;
z-index: 1;
}
.front-page { .front-page {
margin: auto; margin: auto;
text-align: center; text-align: center;
@@ -267,11 +260,6 @@ span.no-about {
} }
} }
#main-content-scroll {
@extend #main-content;
padding: 131px 100px;
}
#user-info { #user-info {
.user-avatar { .user-avatar {
margin-bottom: 30px; margin-bottom: 30px;
@@ -449,14 +437,18 @@ blockquote p {
color: #ddd !important; color: #ddd !important;
} }
} }
.donor {
color: #fff;
background: #f60 !important;
margin-left: 2px !important;
}
.ign { .ign {
display: block; display: block;
color: #000; color: #000;
font-style: italic; font-style: italic;
} }
.badge {
margin-left: 2px !important;
}
} }
#online-users { #online-users {
@@ -466,7 +458,6 @@ blockquote p {
} }
.md_editor { .md_editor {
.field_container { .field_container {
position: relative; position: relative;
@@ -474,7 +465,7 @@ blockquote p {
position: absolute; position: absolute;
top: 1em; top: 1em;
left: 1em; left: 1em;
z-index: 0; z-index: 10;
} }
.editor_field { .editor_field {
@@ -659,6 +650,7 @@ tr.spacer {
} }
.profile-action { .profile-action {
font-size: 0;
float: right; float: right;
} }
@@ -688,13 +680,6 @@ tr.spacer {
color: #ddd; color: #ddd;
} }
&.variable-size {
background: #4096ee;
@media only screen and (max-width: 500px) {
font-size: 9px;
}
}
&.blue { &.blue {
background: #4096ee; background: #4096ee;
@@ -1047,19 +1032,3 @@ nav.pagination {
border-radius: 0.2em; border-radius: 0.2em;
text-shadow: none; text-shadow: none;
} }
.searchfield {
height:40px;
display: inline-block;
&.field {
width: 300px;
}
&.btn {
margin: 4px 1px 0 0;
cursor: default;
color: #fff;
font-size: 12px;
background: #4096ee;
width: 40px;
}
}

View File

@@ -4,7 +4,7 @@ class BlogpostsController < ApplicationController
before_filter :auth, except: [:index, :show] before_filter :auth, except: [:index, :show]
def index def index
@posts = Blogpost.order(id: :desc).page(params[:page]).per(10) @posts = Blogpost.order("created_at desc").page(params[:page]).per(10)
end end
def show def show
@@ -69,10 +69,10 @@ class BlogpostsController < ApplicationController
end end
def auth def auth
unless mod? && current_user.confirmed? unless mod?
flash[:alert] = "You are not allowed to edit posts!" flash[:alert] = "You are not allowed to edit posts!"
redirect_to @post ? @post : blogposts_path redirect_to @post ? @post : blogposts_path
end end
end end
end end

View File

@@ -17,7 +17,7 @@ class ForumgroupsController < ApplicationController
end end
def update def update
if admin? && current_user.confirmed? if admin?
@group = Forumgroup.find(params[:id]) @group = Forumgroup.find(params[:id])
if @group.update_attributes(group_params) if @group.update_attributes(group_params)
flash[:notice] = "Forum group updated" flash[:notice] = "Forum group updated"
@@ -41,7 +41,7 @@ class ForumgroupsController < ApplicationController
end end
def create def create
if admin? && current_user.confirmed? if admin?
@group = Forumgroup.new(group_params) @group = Forumgroup.new(group_params)
if @group.save if @group.save
flash[:notice] = "Forum group created." flash[:notice] = "Forum group created."
@@ -57,7 +57,7 @@ class ForumgroupsController < ApplicationController
end end
def destroy def destroy
if admin? && current_user.confirmed? if admin?
@group = Forumgroup.find(params[:id]) @group = Forumgroup.find(params[:id])
if @group.destroy if @group.destroy
flash[:notice] = "forum group deleted." flash[:notice] = "forum group deleted."
@@ -77,4 +77,4 @@ class ForumgroupsController < ApplicationController
params.require(:forumgroup).permit(a) params.require(:forumgroup).permit(a)
end end
end end

View File

@@ -1,5 +1,4 @@
class ForumsController < ApplicationController class ForumsController < ApplicationController
before_filter :check_permission, only: [:show, :edit, :update, :destroy] before_filter :check_permission, only: [:show, :edit, :update, :destroy]
def index def index
@@ -11,7 +10,7 @@ class ForumsController < ApplicationController
@threads = @forum.forumthreads.select {|f| f.can_read?(current_user) }.to_a @threads = @forum.forumthreads.select {|f| f.can_read?(current_user) }.to_a
@threads.sort_by! do |t| @threads.sort_by! do |t|
# sticky goes first, then sort by last activity (new replies) # sticky goes first, then sort by last activity (new replies)
[t.sticky ? 0 : 1, -(t.replies.order(:id).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])
end end
@@ -34,7 +33,7 @@ class ForumsController < ApplicationController
end end
def update def update
if admin? && current_user.confirmed? if admin?
if @forum.update_attributes(forum_params) if @forum.update_attributes(forum_params)
flash[:notice] = "Forum updated" flash[:notice] = "Forum updated"
redirect_to @forum redirect_to @forum
@@ -48,7 +47,7 @@ class ForumsController < ApplicationController
end end
def create def create
if admin? && current_user.confirmed? if admin?
@forum = Forum.new(forum_params([:forumgroup_id])) @forum = Forum.new(forum_params([:forumgroup_id]))
if @forum.save if @forum.save
flash[:notice] = "Forum created." flash[:notice] = "Forum created."
@@ -64,7 +63,7 @@ class ForumsController < ApplicationController
end end
def destroy def destroy
if admin? && current_user.confirmed? if admin?
if @forum.destroy if @forum.destroy
flash[:notice] = "Forum deleted." flash[:notice] = "Forum deleted."
else else
@@ -78,6 +77,7 @@ class ForumsController < ApplicationController
redirect_to forums_path redirect_to forums_path
end end
private private
def check_permission def check_permission
@@ -89,7 +89,7 @@ class ForumsController < ApplicationController
end end
def forum_params(add = []) def forum_params(add = [])
a = [:name, :position, :role_read_id, :role_write_id, :necro_length] + add a = [:name, :position, :role_read_id, :role_write_id] + add
params.require(:forum).permit(a) params.require(:forum).permit(a)
end end
end end

View File

@@ -3,19 +3,11 @@ class ForumthreadsController < ApplicationController
before_filter :check_permission, only: [:show, :edit, :update, :destroy] before_filter :check_permission, only: [:show, :edit, :update, :destroy]
def index def index
params[:forum] = nil if params[:forum] && !Forum.find_by(id: params[:forum]) redirect_to forum_path(@thread.forum.forumgroup, f)
params.delete_if{|k,v| v.blank?}
@threads = Forumthread.filter(current_user, params[:title].try(:slice, 0..255), params[:content].try(:slice, 0..255), params[:reply].try(:slice, 0..255), params[:label], User.find_by(ign: params[:author].to_s.strip) || params[:author], params[:query].try(:slice, 0..255), Forum.find_by(id: params[:forum]))
.page(params[:page]).per(30)
end end
def show def show
if params[:reverse] == "true" @replies = @thread.replies.page(params[:page])
@replies = @thread.replies.order(id: :desc).page(params[:page])
else
@replies = @thread.replies.order(:id).page(params[:page])
end
end end
def edit def edit
@@ -84,9 +76,6 @@ class ForumthreadsController < ApplicationController
redirect_to @thread.forum redirect_to @thread.forum
end end
def search
end
private private
def check_permission def check_permission

View File

@@ -22,9 +22,9 @@ class InfoController < ApplicationController
def create def create
@info = Info.new(info_params) @info = Info.new(info_params)
if @info.save if @info.save
redirect_to @info, notice: 'The info page has been created!' redirect_to @info, notice: 'Info has been created.'
else else
flash[:alert] = "An error occured while creating the info page." flash[:alert] = "Error creating info"
render action: "new" render action: "new"
end end
end end
@@ -32,18 +32,18 @@ class InfoController < ApplicationController
def update def update
@info.attributes = info_params() @info.attributes = info_params()
if @info.save if @info.save
redirect_to @info, notice: 'The info page has been updated!' redirect_to @info, notice: 'Info has been updated.'
else else
flash[:alert] = "An error occured while updating the info page." flash[:alert] = "There was a problem while updating the info"
render action: "edit" render action: "edit"
end end
end end
def destroy def destroy
if @info.destroy if @info.destroy
flash[:notice] = "The info page has been deleted!" flash[:notice] = "Info deleted!"
else else
flash[:alert] = "An error occured while deleting the info page." flash[:alert] = "There was a problem while deleting this info"
end end
redirect_to info_index_path redirect_to info_index_path
end end
@@ -62,9 +62,9 @@ class InfoController < ApplicationController
end end
def auth def auth
unless mod? && current_user.confirmed? unless mod?
flash[:alert] = "You are not allowed to edit info pages!" flash[:alert] = "You are not allowed to edit info!"
redirect_to @info ? @info : info_index_path redirect_to @info ? @info : info_index_path
end end
end end
end end

View File

@@ -0,0 +1,77 @@
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

View File

@@ -0,0 +1,128 @@
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

View File

@@ -1,7 +1,5 @@
class StaticsController < ApplicationController class StaticsController < ApplicationController
caches_action :online, expires_in: 10.seconds, layout: false
def index def index
if current_user if current_user
redirect_to blogposts_path redirect_to blogposts_path
@@ -16,30 +14,4 @@ class StaticsController < ApplicationController
def donate def donate
end end
def online
@players = []
@count = 0
begin
json = JSON.parse(File.read("/etc/minecraft/redstoner/plugins/ModuleLoader/players.json"))
rescue
flash.now[:alert] = "The server is currently offline."
else
case json["dataFormat"]
when "v1"
@players = json["players"].collect!{ |p| User.find_by(uuid: p["UUID"].tr("-", "")) or User.new(name: p["name"], ign: p["name"], uuid: p["UUID"].tr("-", ""), role: Role.get("normal"), badge: Badge.get("none"), confirmed: true) }
@count = json["amount"]
when "v2"
json["players"].reject{|p| !mod? && p["vanished"] == "true"}.each do |p|
@players.push(User.find_by(uuid: p["UUID"].tr("-", "")) || User.new(name: p["name"], ign: p["name"], uuid: p["UUID"].tr("-", ""), role: Role.get("normal"), badge: Badge.get("none"), confirmed: true))
end
@count = @players.count
else
flash.now[:alert] = "The server is using an incompatible data format. We are aware of this issue and are most likely already working on it."
end
@players.sort_by!(&:role).reverse!
end
end
def privacy
end
end end

View File

@@ -37,7 +37,7 @@ class ThreadrepliesController < ApplicationController
if @reply.update_attributes(reply_params) if @reply.update_attributes(reply_params)
@reply.send_new_reply_mail(old_content) @reply.send_new_reply_mail(old_content)
flash[:notice] = "Reply updated!" flash[:notice] = "Reply updated!"
position = @reply.thread.replies.order(:id).index(@reply) position = @reply.thread.replies.index(@reply)
page = position / Kaminari.config.default_per_page + 1 page = position / Kaminari.config.default_per_page + 1
redirect_to forumthread_path(@reply.thread, page: page) + "#reply-#{@reply.id}" redirect_to forumthread_path(@reply.thread, page: page) + "#reply-#{@reply.id}"
else else
@@ -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

View File

@@ -7,25 +7,29 @@ class UsersController < ApplicationController
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]
def index def index
role = Role.find_by(name: params[:role]) if params[:role]
badge = Badge.find_by(name: params[:badge]) if params[:role].downcase == "staff"
@users = User.joins(:role).where("roles.value >= ?", Role.get(:mod).to_i)
@users = User.search(params[:search], role, badge, params.include?(:staff), params.include?(:donor)) elsif params[:role].downcase == "donor"
@users = User.joins(:role).where(donor: true)
else
if role = Role.get(params[:role])
@users = User.joins(:role).where(role: role)
else
flash[:alert] = "role '#{params[:role]}' does not exist!"
redirect_to users_path
return
end
end
else
@users = User.joins(:role).where.not(id: User.first.id) #Remove first user
end
@users = @users.order("roles.value desc", "confirmed desc", :name)
@count = @users.size @count = @users.size
@users = @users.page(params[:page]).per(100) @users = @users.page(params[:page]).per(100)
end end
def show def show
begin
@ban_json = JSON.parse(File.read("/etc/minecraft/redstoner/banned-players.json")).detect {|u| u["uuid"].tr("-", "") == @user.uuid}
rescue
if @user.is?(current_user)
flash.now[:alert] = "An error occured while checking if you are banned from the server!"
else
flash.now[:alert] = "An error occured while checking if this user is banned from the server!"
end
@ban_json = nil
end
end end
# SIGNUP # SIGNUP
@@ -135,7 +139,7 @@ class UsersController < ApplicationController
end end
def resend_mail def resend_mail
if (@user.is?(current_user) || (mod? && current_user.confirmed?)) && !@user.confirmed? if (@user.is?(current_user) || mod?) && !@user.confirmed?
RedstonerMailer.register_mail(@user, false).deliver_now RedstonerMailer.register_mail(@user, false).deliver_now
flash[:notice] = "Check your inbox for the confirmation mail." flash[:notice] = "Check your inbox for the confirmation mail."
else else
@@ -145,16 +149,11 @@ class UsersController < ApplicationController
end end
def update def update
if (mod? && current_user.role >= @user.role && current_user.confirmed?) || (@user.is?(current_user) && confirmed?) if (mod? && current_user.role >= @user.role ) || (@user.is?(current_user) && confirmed?)
if mod? if mod?
userdata = user_params([:name, :skype, :youtube, :twitter, :about, :role, :badge, :confirmed, :header_scroll, :utc_time, :dark]) userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about, :role, :confirmed, :donor])
else else
userdata = user_params([:name, :skype, :youtube, :twitter, :about, :header_scroll, :utc_time, :dark]) userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about])
end
if User.find_by(name: userdata[:name]) && User.find_by(name: userdata[:name]) != @user
flash[:alert] = "You have entered a name that belongs to someone else. Please try another."
redirect_to edit_user_path(@user)
return
end end
if userdata[:role] if userdata[:role]
role = Role.get(userdata[:role]) role = Role.get(userdata[:role])
@@ -165,9 +164,6 @@ class UsersController < ApplicationController
userdata.delete(:role) userdata.delete(:role)
end end
end end
if userdata[:badge]
userdata[:badge] = Badge.get(userdata[:badge])
end
if @user.youtube != userdata[:youtube] if @user.youtube != userdata[:youtube]
youtube = get_youtube(userdata[:youtube]) youtube = get_youtube(userdata[:youtube])
userdata[:youtube] = youtube[:channel] userdata[:youtube] = youtube[:channel]
@@ -188,7 +184,7 @@ class UsersController < ApplicationController
end end
def ban def ban
if mod? && current_user.role >= @user.role && current_user.confirmed? if mod? && current_user.role >= @user.role
@user.role = Role.get :banned @user.role = Role.get :banned
flash[:notice] = "'#{@user.name}' has been banned!" flash[:notice] = "'#{@user.name}' has been banned!"
else else
@@ -198,7 +194,7 @@ class UsersController < ApplicationController
end end
def unban def unban
if mod? && current_user.role >= @user.role && current_user.confirmed? if mod? && current_user.role >= @user.role
@user.role = Role.get :normal @user.role = Role.get :normal
flash[:notice] = "\"#{@user.name}\" has been unbanned!" flash[:notice] = "\"#{@user.name}\" has been unbanned!"
else else
@@ -208,7 +204,7 @@ class UsersController < ApplicationController
end end
def destroy def destroy
if superadmin? && current_user.confirmed? if superadmin?
if @user.destroy if @user.destroy
flash[:notice] = "User deleted forever." flash[:notice] = "User deleted forever."
redirect_to users_url redirect_to users_url
@@ -223,28 +219,21 @@ class UsersController < ApplicationController
end end
def edit_notifications def edit_notifications
unless @user.is?(current_user) || (admin? && current_user.role > @user.role) || superadmin? unless @user.is?(current_user) || admin? && current_user.role > @user.role || superadmin?
flash[:alert] = "You are not allowed to edit this user's notification settings!" flash[:alert] = "You are not allowed to edit this user's notification settings!"
redirect_to @user redirect_to @user
end end
end end
def edit_login def edit_login
unless @user.is?(current_user) || (admin? && current_user.role > @user.role) || superadmin? unless @user.is?(current_user) || admin? && current_user.role > @user.role || superadmin?
flash[:alert] = "You are not allowed to edit this user's login details!" flash[:alert] = "You are not allowed to edit this user's login details!"
redirect_to @user redirect_to @user
end end
end end
def edit_website_settings
unless @user.is?(current_user) || (admin? && current_user.role > @user.role) || superadmin?
flash[:alert] = "You are not allowed to edit this user's website settings!"
redirect_to @user
end
end
def update_login def update_login
if @user.is?(current_user) || (admin? && current_user.role > @user.role && current_user.confirmed?) || (superadmin? && current_user.confirmed?) if @user.is?(current_user) || admin? && current_user.role > @user.role || superadmin?
authenticated = !@user.is?(current_user) || @user.authenticate(params[:current_password]) authenticated = !@user.is?(current_user) || @user.authenticate(params[:current_password])
if params[:user][:password].present? if params[:user][:password].present?
@user.password = params[:user][:password] @user.password = params[:user][:password]
@@ -362,7 +351,7 @@ class UsersController < ApplicationController
end end
def user_params(add = []) def user_params(add = [])
a = [:ign, :email, :password, :password_confirmation, :mail_own_thread_reply, :mail_other_thread_reply, :mail_own_blogpost_comment, :mail_other_blogpost_comment, :mail_mention, :public_key] + add a = [:ign, :email, :password, :password_confirmation, :mail_own_thread_reply, :mail_other_thread_reply, :mail_own_blogpost_comment, :mail_other_blogpost_comment, :mail_mention] + add
params.require(:user).permit(a) params.require(:user).permit(a)
end end
end end

View File

@@ -11,12 +11,10 @@ module ApplicationHelper
end end
def ago(tm) def ago(tm)
if tm && current_user.try(:utc_time) != true if tm
content_tag :time, title: tm.strftime("%e %b %Y, %H:%M %Z"), datetime: tm.to_datetime.rfc3339 do content_tag :time, title: tm.strftime("%e %b %Y, %H:%M %Z"), datetime: tm.to_datetime.rfc3339 do
tm.strftime("%e %b %Y, %H:%M") tm.strftime("%e %b %Y, %H:%M")
end end
else
tm
end end
end end

View File

@@ -19,49 +19,35 @@ class RedstonerMailer < ActionMailer::Base
def new_thread_mention_mail(user, thread) def new_thread_mention_mail(user, thread)
@user = user @user = user
@thread = thread @thread = thread
if @user.public_key? mail(to: @user.email, subject: "#{thread.author.name} mentioned you in '#{thread.title}' on Redstoner")
mail(to: @user.email, subject: "Encrypted Notification from Redstoner", gpg: {encrypt: true, keys: {@user.email => @user.public_key}})
else
mail(to: @user.email, subject: "#{thread.author.name} mentioned you in '#{thread.title}' on Redstoner")
end
end end
def new_thread_reply_mail(user, reply) def new_thread_reply_mail(user, reply)
@user = user @user = user
@reply = reply @reply = reply
if @user.public_key? mail(to: @user.email, subject: "#{reply.author.name} replied to '#{reply.thread.title}' on Redstoner")
mail(to: @user.email, subject: "Encrypted Notification from Redstoner", gpg: {encrypt: true, keys: {@user.email => @user.public_key}})
else
mail(to: @user.email, subject: "#{reply.author.name} replied to '#{reply.thread.title}' on Redstoner")
end
end end
def new_post_mention_mail(user, post) def new_post_mention_mail(user, post)
@user = user @user = user
@post = post @post = post
if @user.public_key? mail(to: @user.email, subject: "#{post.author.name} mentioned you in '#{post.title}' on Redstoner")
mail(to: @user.email, subject: "Encrypted Notification from Redstoner", gpg: {encrypt: true, keys: {@user.email => @user.public_key}})
else
mail(to: @user.email, subject: "#{post.author.name} mentioned you in '#{post.title}' on Redstoner")
end
end end
def new_post_comment_mail(user, comment) def new_post_comment_mail(user, comment)
@user = user @user = user
@comment = comment @comment = comment
if @user.public_key? mail(to: @user.email, subject: "#{comment.author.name} replied to '#{comment.blogpost.title}' on Redstoner")
mail(to: @user.email, subject: "Encrypted Notification from Redstoner", gpg: {encrypt: true, keys: {@user.email => @user.public_key}})
else
mail(to: @user.email, subject: "#{comment.author.name} replied to '#{comment.blogpost.title}' on Redstoner")
end
end end
def email_change_confirm_mail(user) def email_change_confirm_mail(user)
@user = user @user = user
if @user.public_key? mail(to: @user.email, subject: "Email change on Redstoner.com")
mail(to: @user.email, subject: "Encrypted Notification from Redstoner", gpg: {encrypt: true, keys: {@user.email => @user.public_key}}) end
else
mail(to: @user.email, subject: "Email change on Redstoner.com") def new_message_mail(user, message)
end @user = user
@message = message
mail(to: @user.email, subject: "#{message.user_sender.name} sent you a new message")
end end
end end

View File

@@ -1,18 +0,0 @@
class Badge < ActiveRecord::Base
include Comparable
has_many :users
def self.get (input)
if input.is_a?(String) || input.is_a?(Symbol)
Badge.find_by(name: input)
elsif input.is_a?(Fixnum)
Badge.find_by(id: input)
elsif input.is_a?(Badge)
return input
end
end
def to_s
self.name
end
end

View File

@@ -8,8 +8,6 @@ class Blogpost < ActiveRecord::Base
belongs_to :user_editor, class_name: "User", foreign_key: "user_editor_id" belongs_to :user_editor, class_name: "User", foreign_key: "user_editor_id"
has_many :comments, :dependent => :destroy has_many :comments, :dependent => :destroy
accepts_nested_attributes_for :comments accepts_nested_attributes_for :comments
validates_length_of :title, in: 5..255
validates_length_of :content, in: 5..20000
def author def author
@author ||= if self.user_author.present? @author ||= if self.user_author.present?

View File

@@ -4,7 +4,6 @@ class Forum < ActiveRecord::Base
belongs_to :role_read, class_name: "Role", foreign_key: "role_read_id" belongs_to :role_read, class_name: "Role", foreign_key: "role_read_id"
belongs_to :role_write, class_name: "Role", foreign_key: "role_write_id" belongs_to :role_write, class_name: "Role", foreign_key: "role_write_id"
has_and_belongs_to_many :labels has_and_belongs_to_many :labels
validates_length_of :name, in: 4..30
def to_s def to_s
name name
@@ -33,4 +32,4 @@ class Forum < ActiveRecord::Base
def to_param def to_param
[id, to_s.parameterize].join("-") [id, to_s.parameterize].join("-")
end end
end end

View File

@@ -7,7 +7,7 @@ class Forumgroup < ActiveRecord::Base
validates_presence_of :name, :position validates_presence_of :name, :position
validates_length_of :name, in: 4..20 validates_length_of :name, in: 2..20
def to_s def to_s
name name

View File

@@ -11,7 +11,6 @@ class Forumthread < ActiveRecord::Base
validates_presence_of :title, :author, :forum validates_presence_of :title, :author, :forum
validates_presence_of :content validates_presence_of :content
validates_length_of :title, in: 5..255
validates_length_of :content, in: 5..20000 validates_length_of :content, in: 5..20000
accepts_nested_attributes_for :threadreplies accepts_nested_attributes_for :threadreplies
@@ -66,49 +65,4 @@ class Forumthread < ActiveRecord::Base
def to_param def to_param
[id, to_s.parameterize].join("-") [id, to_s.parameterize].join("-")
end end
def self.filter (user, title, content, reply, label, author, query, forum)
order_phrase = query || [title, content, reply].select(&:present?).join(" ")
user_id = user.try(:id).to_i
role_value = user.try(:role).to_i
can_read = "COALESCE(forum_role_read.value, 0) <= ? AND COALESCE(forumgroup_role_read.value, 0) <= ?"
# A user can view sticky threads in write-only forums without read permissions.
sticky_can_write = "sticky = true AND (COALESCE(forum_role_write.value, 0) <= ? AND COALESCE(forumgroup_role_write.value, 0) <= ?)"
match = ["MATCH (title, forumthreads.content) AGAINST (#{Forumthread.sanitize(order_phrase)})", "MATCH (threadreplies.content) AGAINST (#{Forumthread.sanitize(order_phrase)})", "MATCH (title, forumthreads.content) AGAINST (?) OR MATCH (threadreplies.content) AGAINST (?)", "MATCH (title) AGAINST (?)", "MATCH (forumthreads.content) AGAINST (?)", "MATCH (threadreplies.content) AGAINST (?)"]
threads = forum.try(:forumthreads) || Forumthread
threads = threads.select("forumthreads.*", "#{match[0]} AS relevance", "#{match[1]} AS reply_rel")
threads = threads.joins(forum: :forumgroup)
.joins("LEFT JOIN threadreplies ON forumthreads.id = threadreplies.forumthread_id")
.joins("LEFT JOIN roles as forum_role_read ON forums.role_read_id = forum_role_read.id")
.joins("LEFT JOIN roles as forum_role_write ON forums.role_write_id = forum_role_write.id")
.joins("LEFT JOIN roles as forumgroup_role_read ON forumgroups.role_read_id = forumgroup_role_read.id")
.joins("LEFT JOIN roles as forumgroup_role_write ON forumgroups.role_write_id = forumgroup_role_write.id")
threads = threads.where("forumthreads.user_author_id = ? OR (#{can_read}) OR (#{sticky_can_write})", user_id, role_value, role_value, role_value, role_value)
if query
threads = threads.where("#{match[2]}", query[0..99], query[0..99])
elsif [title, content, reply].any?
threads = threads.where("#{match[3]}", title[0..99]) if title
threads = threads.where("#{match[4]}", content[0..99]) if content
threads = threads.where("#{match[5]}", reply[0..99]) if reply
end
if label.try(:downcase) == "no label"
threads = threads.where(label: nil)
elsif label && l = Label.find_by(name: label)
threads = threads.where(label: l)
end
threads = threads.where(user_author: author) if author
threads = threads.group("forumthreads.id")
if order_phrase.present?
threads = threads.order("GREATEST(relevance, reply_rel) DESC")
else
threads = threads.order("sticky DESC", "threadreplies.id DESC", "forumthreads.id DESC")
end
threads
end
end end

View File

@@ -11,4 +11,4 @@ class Info < ActiveRecord::Base
[id, to_s.parameterize].join("-") [id, to_s.parameterize].join("-")
end end
end end

View File

@@ -23,4 +23,4 @@ class Label < ActiveRecord::Base
end end
end end
end end
end end

75
app/models/message.rb Normal file
View File

@@ -0,0 +1,75 @@
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

View File

@@ -0,0 +1,67 @@
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

View File

@@ -1,2 +1,2 @@
class RegisterToken < ActiveRecord::Base class RegisterToken < ActiveRecord::Base
end end

View File

@@ -14,14 +14,14 @@ class Role < ActiveRecord::Base
end end
def is? (name) def is? (name)
!!(Role.find_by(name: name) == self) !!(Role.find_by_name(name) == self)
end end
def self.get (input) def self.get (input)
if input.is_a?(String) || input.is_a?(Symbol) if input.is_a?(String) || input.is_a?(Symbol)
Role.find_by(name: input) Role.find_by_name(input)
elsif input.is_a?(Fixnum) elsif input.is_a?(Fixnum)
Role.find_by(id: input) Role.find_by_id(input)
elsif input.is_a?(Role) elsif input.is_a?(Role)
return input return input
end end
@@ -31,7 +31,7 @@ class Role < ActiveRecord::Base
if role.is_a?(Role) if role.is_a?(Role)
self.value - role.value self.value - role.value
elsif role.is_a?(Symbol) elsif role.is_a?(Symbol)
self <=> Role.find_by(name: role) self <=> Role.find_by_name(role)
else else
self.to_i <=> role self.to_i <=> role
end end
@@ -53,4 +53,4 @@ class Role < ActiveRecord::Base
Role.order(:value).select {|r| r >= from}.select {|r| r <= to} Role.order(:value).select {|r| r >= from}.select {|r| r <= to}
end end
end end

View File

@@ -43,7 +43,7 @@ class Threadreply < ActiveRecord::Base
unless old_content.present? unless old_content.present?
posts.each do |post| posts.each do |post|
# don't send mail to the author of this reply, don't send to banned/disabled users # 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? && thread.can_read?(post.author) if post.author != author && post.author.normal? && post.author.confirmed? # &&
users << post.author if post.author.mail_other_thread_reply? users << post.author if post.author.mail_other_thread_reply?
end end
end end

View File

@@ -5,11 +5,10 @@ class User < ActiveRecord::Base
strip_attributes strip_attributes
belongs_to :role belongs_to :role
belongs_to :badge
has_secure_password has_secure_password
before_validation :strip_whitespaces, :set_uuid, :set_name, :set_email_token, :set_role, :set_badge before_validation :strip_whitespaces, :set_uuid, :set_name, :set_email_token, :set_role
validates_presence_of :password, :password_confirmation, :email_token, on: :create validates_presence_of :password, :password_confirmation, :email_token, on: :create
validates_presence_of :name, :email, :ign validates_presence_of :name, :email, :ign
@@ -22,16 +21,20 @@ class User < ActiveRecord::Base
validates :email, uniqueness: {case_sensitive: false}, format: {with: /\A.+@(.+\..{2,}|\[(IPv6)?[0-9a-f:.]+\])\z/i, message: "That doesn't look like an email address."} validates :email, uniqueness: {case_sensitive: false}, format: {with: /\A.+@(.+\..{2,}|\[(IPv6)?[0-9a-f:.]+\])\z/i, message: "That doesn't look like an email address."}
validates :ign, uniqueness: {case_sensitive: false}, format: {with: /\A[a-z\d_]+\z/i, message: "Username is invalid (a-z, 0-9, _)."} validates :ign, uniqueness: {case_sensitive: false}, format: {with: /\A[a-z\d_]+\z/i, message: "Username is invalid (a-z, 0-9, _)."}
validates :public_key, format: {with: /\A(-----BEGIN PGP PUBLIC KEY BLOCK-----((.|\n)*?)-----END PGP PUBLIC KEY BLOCK-----)?\z/i, message: "That doesn't look like a PGP formatted public key."}
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
end end
def donor?
!!self.donor
end
def confirmed? def confirmed?
!!self.confirmed !!self.confirmed
end end
@@ -149,10 +152,6 @@ class User < ActiveRecord::Base
self.role ||= Role.get(:normal) self.role ||= Role.get(:normal)
end end
def set_badge
self.badge ||= Badge.get(:none)
end
def set_uuid def set_uuid
if !self.uuid.present? if !self.uuid.present?
# idk # idk
@@ -176,23 +175,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
def self.search (search, role, badge, staff, donor)
users = User.joins(:role)
if role
users = users.where(role: role)
elsif staff
users = users.where("roles.value >= ?", Role.get(:mod).to_i)
elsif donor
users = users.where("badge_id = ? OR badge_id = ?", Badge.get(:donor), Badge.get(:donorplus))
end
users = users.where(badge: badge) if badge
if search
search_san = User.send(:sanitize_sql_like, search.to_s)
users = users.where("users.name like ? OR ign like ?", "%#{search_san}%", "%#{search_san}%")
end
users = users.where.not(id: User.first.id) unless [search, role, badge].any?
users = users.order("roles.value desc", "confirmed desc", :name)
users
end
end end

View File

@@ -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>

View File

@@ -1,20 +1,10 @@
<% title "Edit News: #{@post.title}" %> <% title "Edit News: #{@post.title}" %>
<%
def can_edit?
mod? && current_user.confirmed?
end
%>
<h1>Edit post</h1> <h1>Edit post</h1>
<%= form_for @post do |f|%> <%= form_for @post do |f|%>
<%= f.text_field :title, disabled: !can_edit? %> <%= f.text_field :title %>
<%= render partial: "md_editor", locals: {name: "blogpost[content]", content: @post.content, options: {disabled: !can_edit?}} %> <%= render partial: "md_editor", locals: {name: "blogpost[content]", content: @post.content} %>
<p><%= f.submit "Update Post", class: "btn blue left", disabled: !can_edit? %></p> <p><%= f.submit "Update Post", class: "btn blue left" %></p>
<% end %>
<p><%= button_to "Delete post", @post, method: "delete", data: {confirm: "Delete post & comments forever?"}, class: "btn red right", disabled: !can_edit? %></p>
<div class="clear"></div>
<% if !current_user.confirmed? %>
<span class='red-alert'>You must confirm your email before you can edit blog posts.</span>
<% end %> <% end %>
<p><%= button_to "Delete post", @post, method: "delete", data: {confirm: "Delete post & comments forever?"}, class: "btn red right" %></p>
<div class="clear"></div>

View File

@@ -1,5 +1,4 @@
<% 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">

View File

@@ -1,19 +1,9 @@
<% title "New Blog Post" %> <% title "New Blog Post" %>
<%
def can_create?
admin? && current_user.confirmed?
end
%>
<h1>New Post</h1> <h1>New Post</h1>
<%= form_for @post do |f|%> <%= form_for @post do |f|%>
<%= f.text_field :title, placeholder: "Title", disabled: !can_create? %> <%= f.text_field :title, placeholder: "Title" %>
<%= render partial: "md_editor", locals: {name: "blogpost[content]", content: @post.content, options: {disabled: !can_create?}} %> <%= render partial: "md_editor", locals: {name: "blogpost[content]", content: @post.content} %>
<p><%= f.submit "Create Post", class: "btn blue left", disabled: !can_create? %></p> <p><%= f.submit "Create Post", class: "btn blue left" %></p>
<div class="clear"></div> <div class="clear"></div>
<% if !current_user.confirmed? %>
<span class='red-alert'>You must confirm your email before you can create new blog posts.</span>
<% end %>
<% end %> <% end %>

View File

@@ -1,11 +1,5 @@
<% title "Manage Forums" %> <% title "Manage Forums" %>
<%
def can_edit?
admin? && current_user.confirmed?
end
%>
<h1>Manage Forums</h1> <h1>Manage Forums</h1>
<div class="item-group"> <div class="item-group">
<div class="header"> <div class="header">
@@ -25,26 +19,22 @@
<table> <table>
<tr> <tr>
<td><%= f.label :name %></td> <td><%= f.label :name %></td>
<td><%= f.text_field :name, placeholder: "Name", disabled: !can_edit? %></td> <td><%= f.text_field :name, placeholder: "Name" %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :position %></td> <td><%= f.label :position %></td>
<td><%= f.number_field :position, placeholder: "Position", disabled: !can_edit? %></td> <td><%= f.number_field :position, placeholder: "Position" %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :role_read_id, "Min. read role" %></td> <td><%= f.label :role_read_id, "Min. read role" %></td>
<td><%= f.select :role_read_id, role_selection, { include_blank: "None" }, { disabled: !can_edit? } %></td> <td><%= f.select :role_read_id, role_selection, include_blank: "None" %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :role_write_id, "Min. write role" %></td> <td><%= f.label :role_write_id, "Min. write role" %></td>
<td><%= f.select :role_write_id, role_selection, { include_blank: false }, { disabled: !can_edit? } %></td> <td><%= f.select :role_write_id, role_selection, include_blank: false %></td>
</tr> </tr>
</table> </table>
<p><%= f.submit "Update group", class: "btn blue left", disabled: !can_edit? %></p> <p><%= f.submit "Update group", class: "btn blue left" %></p>
<% end %>
<p><%= button_to "Delete group", @group, :method => "delete", data: {confirm: "Delete group?\nForums + Threads will not be accessible!"}, class: "btn red right", disabled: !can_edit? %></p>
<div class="clear"></div>
<% if !current_user.confirmed? %>
<span class='red-alert'>You must confirm your email before you can edit forum groups.</span>
<% end %> <% end %>
<p><%= button_to "Delete group", @group, :method => "delete", data: {confirm: "Delete group?\nForums + Threads will not be accessible!"}, class: "btn red right" %></p>
<div class="clear"></div>

View File

@@ -1,36 +1,26 @@
<% title "New Forum: #{@group.name}" %> <% title "New Forum: #{@group.name}" %>
<%
def can_create?
admin? && current_user.confirmed?
end
%>
<h1>New forum group</h1> <h1>New forum group</h1>
<% role_selection = Role.all_from_to(:normal, :admin).collect{|p|[p.name, p.id]} %> <% role_selection = Role.all_from_to(:normal, :admin).collect{|p|[p.name, p.id]} %>
<%= form_for @group do |f|%> <%= form_for @group do |f|%>
<table> <table>
<tr> <tr>
<td><%= f.label :name %></td> <td><%= f.label :name %></td>
<td><%= f.text_field :name, placeholder: "Name", disabled: !can_create? %></td> <td><%= f.text_field :name, placeholder: "Name" %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :position %></td> <td><%= f.label :position %></td>
<td><%= f.number_field :position, placeholder: "Position", disabled: !can_create? %></td> <td><%= f.number_field :position, placeholder: "Position" %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :role_read_id, "Min. read role" %></td> <td><%= f.label :role_read_id, "Min. read role" %></td>
<td><%= f.select :role_read_id, role_selection, { include_blank: "None" }, { disabled: !can_create? } %></td> <td><%= f.select :role_read_id, role_selection, include_blank: "None" %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :role_write_id, "Min. write role" %></td> <td><%= f.label :role_write_id, "Min. write role" %></td>
<td><%= f.select :role_write_id, role_selection, { include_blank: false }, { disabled: !can_create? } %></td> <td><%= f.select :role_write_id, role_selection, include_blank: false %></td>
</tr> </tr>
</table> </table>
<p><%= f.submit "Create group", class: "btn blue left", disabled: !can_create? %></p> <p><%= f.submit "Create group", class: "btn blue left" %></p>
<div class="clear"></div> <div class="clear"></div>
<% end %>
<% if !current_user.confirmed? %>
<span class='red-alert'>You must confirm your email before you can create new forum groups.</span>
<% end %>
<% end %>

View File

@@ -1,11 +1,5 @@
<% title "Edit Forum: #{@forum.name}" %> <% title "Edit Forum: #{@forum.name}" %>
<%
def can_edit?
admin? && current_user.confirmed?
end
%>
<%= link_to "(Edit) #{@forum.group.name}", edit_forumgroup_path(@forum.group) %> → <%= @forum.name %> <%= link_to "(Edit) #{@forum.group.name}", edit_forumgroup_path(@forum.group) %> → <%= @forum.name %>
<h1>Edit Forum</h1> <h1>Edit Forum</h1>
<% role_selection = Role.all_from_to(:normal, :admin).collect{|p|[p.name, p.id]} %> <% role_selection = Role.all_from_to(:normal, :admin).collect{|p|[p.name, p.id]} %>
@@ -13,30 +7,22 @@
<table> <table>
<tr> <tr>
<td><%= f.label :name %></td> <td><%= f.label :name %></td>
<td><%= f.text_field :name, placeholder: "Name", disabled: !can_edit? %></td> <td><%= f.text_field :name, placeholder: "Name" %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :position %></td> <td><%= f.label :position %></td>
<td><%= f.number_field :position, placeholder: "Position", disabled: !can_edit? %></td> <td><%= f.number_field :position, placeholder: "Position" %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :role_read_id, "Min. read role" %></td> <td><%= f.label :role_read_id, "Min. read role" %></td>
<td><%= f.select :role_read_id, role_selection, { include_blank: "None" }, { disabled: !can_edit? } %></td> <td><%= f.select :role_read_id, role_selection, include_blank: "None" %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :role_write_id, "Min. write role" %></td> <td><%= f.label :role_write_id, "Min. write role" %></td>
<td><%= f.select :role_write_id, role_selection, { include_blank: false }, { disabled: !can_edit? } %></td> <td><%= f.select :role_write_id, role_selection, include_blank: false %></td>
</tr>
<tr>
<td><%= f.label :necro_length, "Necropost warning delay (in days)" %></td>
<td><%= f.number_field :necro_length, placeholder: "Warning Delay (leave blank for no warning)", disabled: !can_edit? %></td>
</tr> </tr>
</table> </table>
<p><%= f.submit "Update forum", class: "btn blue left", disabled: !can_edit? %></p> <p><%= f.submit "Update forum", class: "btn blue left" %></p>
<% end %>
<p><%= button_to "Delete forum", @forum, method: "delete", data: {confirm: "Delete forum forever?\nThreads won't be accessible!"}, class: "btn red right", disabled: !can_edit? %></p>
<div class="clear"></div>
<% if !current_user.confirmed? %>
<span class='red-alert'>You must confirm your email before you can edit forums.</span>
<% end %> <% end %>
<p><%= button_to "Delete forum", @forum, method: "delete", data: {confirm: "Delete forum forever?\nThreads won't be accessible!"}, class: "btn red right" %></p>
<div class="clear"></div>

View File

@@ -1,7 +1,5 @@
<% title "Forums" %> <% title "Forums" %>
<%= link_to "All threads", forumthreads_path, class: "btn blue right" %>
<br>
<div id="forum_groups"> <div id="forum_groups">
<% @groups.each do |group| %> <% @groups.each do |group| %>
<div class="item-group" id="group-<%= group.id %>"> <div class="item-group" id="group-<%= group.id %>">
@@ -18,7 +16,7 @@
<%= link_to f.name, f, id: "forum-#{f.id}"%> <%= link_to f.name, f, id: "forum-#{f.id}"%>
<div class="item-info"> <div class="item-info">
<% if last_thread = f.threads.last %> <% if last_thread = f.threads.last %>
<% last_reply = Threadreply.where(forumthread: f.threads).order(:id).last %> <% last_reply = Threadreply.where(forumthread: f.threads).order(:created_at).last %>
<% if last_reply && last_reply.created_at > last_thread.created_at %> <% if last_reply && last_reply.created_at > last_thread.created_at %>
<% if last_reply.thread.can_read?(current_user) %> <% if last_reply.thread.can_read?(current_user) %>
<%= last_reply.author.name %> <%= last_reply.author.name %>
@@ -56,4 +54,6 @@
<% if admin? %> <% if admin? %>
<%= link_to "New group", new_forumgroup_path, class: "btn blue" %> <%= link_to "New group", new_forumgroup_path, class: "btn blue" %>
<% end %> <% elsif mod? %>
<%= link_to "New group", "#", class: "btn blue", disabled: true %>
<% end %>

View File

@@ -1,11 +1,5 @@
<% title "New Forum: #{@forum.group.name}" %> <% title "New Forum: #{@forum.group.name}" %>
<%
def can_create?
admin? && current_user.confirmed?
end
%>
<%= link_to @forum.group, forumgroup_path(@forum.group) %> → New forum <%= link_to @forum.group, forumgroup_path(@forum.group) %> → New forum
<h1>New Forum</h1> <h1>New Forum</h1>
<% role_selection = Role.all_from_to(:normal, :admin).collect{|p|[p.name, p.id]} %> <% role_selection = Role.all_from_to(:normal, :admin).collect{|p|[p.name, p.id]} %>
@@ -13,30 +7,22 @@
<table> <table>
<tr> <tr>
<td><%= f.label :name %></td> <td><%= f.label :name %></td>
<td><%= f.text_field :name, placeholder: "Name", disabled: !can_create? %></td> <td><%= f.text_field :name, placeholder: "Name" %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :position %></td> <td><%= f.label :position %></td>
<td><%= f.number_field :position, placeholder: "Position", disabled: !can_create? %></td> <td><%= f.number_field :position, placeholder: "Position" %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :role_read_id, "Min. read role" %></td> <td><%= f.label :role_read_id, "Min. read role" %></td>
<td><%= f.select :role_read_id, role_selection, { include_blank: "None"}, { disabled: !can_create? } %></td> <td><%= f.select :role_read_id, role_selection, include_blank: "None" %></td>
</tr> </tr>
<tr> <tr>
<td><%= f.label :role_write_id, "Min. write role" %></td> <td><%= f.label :role_write_id, "Min. write role" %></td>
<td><%= f.select :role_write_id, role_selection, { include_blank: false }, { disabled: !can_create? } %></td> <td><%= f.select :role_write_id, role_selection, include_blank: false %></td>
</tr>
<tr>
<td><%= f.label :necro_length, "Necropost warning delay (in days)" %></td>
<td><%= f.number_field :necro_length, placeholder: "Warning Delay (leave blank for no warning)", disabled: !can_create? %></td>
</tr> </tr>
</table> </table>
<%= f.hidden_field :forumgroup_id %> <%= f.hidden_field :forumgroup_id %>
<p><%= f.submit "Create forum", class: "btn blue left", disabled: !can_create? %></p> <p><%= f.submit "Create forum", class: "btn blue left" %></p>
<div class="clear"></div> <div class="clear"></div>
<% end %>
<% if !current_user.confirmed? %>
<span class='red-alert'>You must confirm your email before you can create new forums.</span>
<% end %>
<% end %>

View File

@@ -1,13 +1,8 @@
<%= link_to @forum.group, forumgroup_path(@forum.group) %> → <%= @forum %> <%= link_to @forum.group, forumgroup_path(@forum.group) %> → <%= @forum %>
<h1> <h1><%= title @forum %></h1>
<%= title @forum %>
<%= link_to "Search Threads", forumthreads_path(forum: @forum.id), class: "btn blue right" %>
</h1>
<% if @forum.can_write?(current_user) %> <% if @forum.can_write?(current_user) %>
<p> <p><%= link_to "New thread", new_forumthread_path(forum: @forum), class: "btn blue" %></p>
<%= link_to "New thread", new_forumthread_path(forum: @forum), class: "btn blue" %>
</p>
<% end %> <% end %>
<% if @forum.role_read && @forum.role_write && @forum.role_write < @forum.role_read %> <% if @forum.role_read && @forum.role_write && @forum.role_write < @forum.role_read %>
@@ -38,7 +33,7 @@
<div class="item <%= "#{"locked" if thread.locked}#{"sticky" if thread.sticky}" %>"> <div class="item <%= "#{"locked" if thread.locked}#{"sticky" if thread.sticky}" %>">
<%= render partial: "labels/label", locals: {label: thread.label} %><%= link_to truncate(thread.title, length: 60, omission: " …"), forumthread_path(thread), title: thread.title %> <%= render partial: "labels/label", locals: {label: thread.label} %><%= link_to truncate(thread.title, length: 60, omission: " …"), forumthread_path(thread), title: thread.title %>
<div class="item-info"> <div class="item-info">
<% if rpl = thread.replies.order(:id).last %> <% if rpl = thread.replies.last %>
<%= rpl.author.name %> <%= rpl.author.name %>
<% <%
position = thread.replies.count - 1 position = thread.replies.count - 1

View File

@@ -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>

View File

@@ -1,85 +0,0 @@
<%= link_to "Forums", forums_path %> →
<% params_list = params.slice(:query, :title, :content, :author, :label, :reply) %>
<% if params_list.any? %>
<%= link_to "All Threads", forumthreads_path %> → Search Results
<% else %>
<%= "All Threads" %>
<% end %>
<h1>
<%
if params[:forum]
text = "forum '#{Forum.find(params[:forum]).name}'"
if params_list.except(:forum).any?
text = "Search results in #{text} (#{@threads.total_count})"
else
text = text.capitalize
end
elsif params_list.any?
text = "Search results (#{@threads.total_count})"
else
text = "All threads"
end
%>
<%= title text %>
</h1>
<br>
<%= form_tag(forumthreads_path, method: :get) do %>
<%= text_field_tag "query", params[:query], placeholder: "Search...", class: "searchfield field" %>
<%= submit_tag "Go", class: "searchfield btn" %>
<%= link_to "Advanced Search", search_forumthreads_path(params_list), class: "btn right blue" %>
<% if params_list.any? %>
<% if params[:forum] %>
<%= link_to "Show All Threads", forumthreads_path(params_list.except("forum")), class: "btn right blue" %>
<% elsif params_list.except(:controller, :action).any? %>
<%= link_to "Show All Threads", forumthreads_path, class: "btn right blue" %>
<% end %>
<% end %>
<% if params[:forum] %>
<%= link_to "Go to Forum", forum_path(params[:forum]), class: "btn right blue" %>
<% end %>
<% params.slice(:forum, :title, :content, :reply, :label, :author).each do |key, value| %>
<%= hidden_field_tag key, params[key] %>
<% end %>
<% end %>
<div id="forum_groups">
<% @threads.each do |thread| %>
<div class="item-group with-avatar" id="thread-<%= thread.id %>">
<div class="header">
<%= link_to(thread.author.avatar(64), thread.author, title: thread.author.ign) %>
<%= render partial: "users/username", locals: { user: thread.author } %>
<%= link_to thread do %>
<%= ago thread.created_at %>
<% end %>
<span class="comment-counter">
<%= link_to pluralize(thread.replies.count, "Reply"), thread %>
</span>
<div class="clear-right"></div>
</div>
<div class="items bold">
<div class="item <%= "#{"locked" if thread.locked}#{"sticky" if thread.sticky}" %>">
<%= render partial: "labels/label", locals: {label: thread.label} %><%= link_to truncate(thread.title, length: 60, omission: " …"), forumthread_path(thread), title: thread.title %>
<div class="item-info">
<% if rpl = thread.replies.order(:id).last %>
<%= rpl.author.name %>
<%
position = thread.replies.count - 1
page = position / Kaminari.config.default_per_page + 1
%>
<%= link_to "replied", forumthread_path(thread, page: page) + "#reply-#{rpl.id}" %>
<%= ago rpl.created_at %>.
<% else %>
No replies yet.
<% end %>
</div>
<div class="clear"></div>
</div>
</div>
</div>
<% end %>
<% if @threads.empty? %>
<br>
<h3>No results found</h3>
<% end %>
<%= paginate @threads %>
</div>

View File

@@ -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 %>

View File

@@ -1,54 +0,0 @@
<% title "Thread Search" %>
<h1>Thread Search</h1>
<h3>Leave a field blank to ignore that search aspect.</h3>
<% label = Label.where(name: params[:label]).first %>
<table>
<tbody>
<%= form_tag(forumthreads_path, method: :get) do %>
<%
forums = []
Forum.select{|f| f.can_read?(current_user)}.sort_by{ |f| f.forumgroup && f.forumgroup.position || 0 }.each do |f|
forums << ["#{f.forumgroup.name} → #{f.name}", f.id] if f.forumgroup
end
%>
<% label_list = Label.pluck(:name).prepend("No Label") %>
<tr>
<td>Forum</td>
<td><%= select_tag "forum", options_for_select(forums, params[:forum]), include_blank: "Search All Threads" %></td>
</tr>
<tr>
<td>Label</td>
<td>
<%= select_tag "label", options_for_select(label_list, params[:label]), include_blank: "Label" %>
</td>
</tr>
<tr>
<td>Title</td>
<td>
<%= text_field_tag "title", params[:title], placeholder: "Search Titles" %>
</td>
</tr>
<tr>
<td>Content</td>
<td>
<%= text_field_tag "content", params[:content], placeholder: "Search Contents" %>
</td>
<tr>
<td>Author</td>
<td>
<%= render partial: "md_editor_user", locals: {name: "author", content: params[:author]} %>
</td>
</tr>
<td>Replies</td>
<td>
<%= text_field_tag "reply", params[:reply], placeholder: "Search Replies" %>
</td>
</tr>
<tr>
<td>
<%= submit_tag "Go", class: "btn blue", style: "width:50px", name: nil %>
</td>
</tr>
<% end %>
</tbody>
</table>

View File

@@ -1,8 +1,6 @@
<%= link_to @thread.forum.group, forumgroup_path(@thread.forum.group) %> → <%= link_to @thread.forum, @thread.forum %> → <%=truncate(@thread.title, length: 60, omission: " …") %> <%= link_to @thread.forum.group, forumgroup_path(@thread.forum.group) %> → <%= link_to @thread.forum, @thread.forum %> → <%=truncate(@thread.title, length: 60, omission: " …") %>
<h1> <h1><%= render partial: "labels/label", locals: {label: @thread.label} %><%= title @thread.title %></h1>
<%= render partial: "labels/label", locals: {label: @thread.label} %><%= title @thread.title %>
<%= link_to "Reverse Replies", forumthread_path(@thread, reverse: params[:reverse] != "true"), class: "btn right blue" %>
</h1>
<div class="item-group thread with-avatar" id="thread-<%= @thread.id %>"> <div class="item-group thread with-avatar" id="thread-<%= @thread.id %>">
<div class="header"> <div class="header">
<%= link_to(@thread.author.avatar(64), @thread.author, title: @thread.author.ign) %> <%= link_to(@thread.author.avatar(64), @thread.author, title: @thread.author.ign) %>

View File

@@ -1,20 +1,10 @@
<% title "Edit Info: #{@info.title}" %> <% title "Edit Info: #{@info.title}" %>
<%
def can_edit?
mod? && current_user.confirmed?
end
%>
<h1>Edit Info</h1> <h1>Edit Info</h1>
<%= form_for @info do |f|%> <%= form_for @info do |f|%>
<%= f.text_field :title, disabled: !can_edit? %> <%= f.text_field :title%>
<%= render partial: "md_editor", locals: {name: "info[content]", content: @info.content, options: {disabled: !can_edit?}} %> <%= render partial: "md_editor", locals: {name: "info[content]", content: @info.content} %>
<p><%= f.submit "Update Info", class: "btn blue left", disabled: !can_edit? %></p> <p><%= f.submit "Update Info", class: "btn blue left" %></p>
<% end %>
<p><%= button_to "Delete Info", @info, method: "delete", data: {confirm: "Are you sure you want to delete this info page?"}, class: "btn red right", disabled: !can_edit? %></p>
<div class="clear"></div>
<% if !current_user.confirmed? %>
<span class='red-alert'>You must confirm your email before you can edit info pages.</span>
<% end %> <% end %>
<p><%= button_to "Delete Info", @info, method: "delete", data: {confirm: "Delete Info forever?"}, class: "btn red right" %></p>
<div class="clear"></div>

View File

@@ -1,19 +1,9 @@
<% title "New Info" %> <% title "New Info" %>
<%
def can_create?
mod? && current_user.confirmed?
end
%>
<h1>New Info</h1> <h1>New Info</h1>
<%= form_for @info, url: info_index_path do |f|%> <%= form_for @info, url: info_index_path do |f|%>
<%= f.text_field :title, placeholder: "Title", disabled: !can_create? %> <%= f.text_field :title, placeholder: "Title" %>
<%= render partial: "md_editor", locals: {name: "info[content]", content: @info.content, options: {disabled: !can_create?}} %> <%= render partial: "md_editor", locals: {name: "info[content]", content: @info.content} %>
<p><%= f.submit "Create Info", class: "btn blue left", disabled: !can_create? %></p> <p><%= f.submit "Create Info", class: "btn blue left" %></p>
<div class="clear"></div> <div class="clear"></div>
<% if !current_user.confirmed? %>
<span class='red-alert'>You must confirm your email before you can create new info pages.</span>
<% end %>
<% end %> <% end %>

View File

@@ -13,12 +13,6 @@
<% end %> | <% end %> |
<%= link_to "https://twitter.com/RedstonerServer", title: "Redstoner on Twitter" do %> <%= link_to "https://twitter.com/RedstonerServer", title: "Redstoner on Twitter" do %>
Twitter <%= image_tag("twitter.png") %> Twitter <%= image_tag("twitter.png") %>
<% end %> |
<%= link_to "https://mstdn.io/@RedstonerServer", title: "Redstoner on Mastodon" do %>
Mastodon <%= image_tag("mastodon.png") %>
<% end %> |
<%= link_to "http://rdstnr4biap5nao2.onion", title: "Redstoner over Tor" do %>
Onion Service <%= image_tag("tor.png") %>
<% end %> <% end %>
<% if current_user %> <% if current_user %>
| <%= link_to "/slack/?" + {mail: current_user.try(:email)}.to_param do %> | <%= link_to "/slack/?" + {mail: current_user.try(:email)}.to_param do %>
@@ -26,4 +20,4 @@
<% end %> <% end %>
<% end %> <% end %>
</div> </div>
</div> </div>

View File

@@ -1,9 +1,4 @@
<% head = "head_top" %> <div id="head">
<% if current_user != nil && current_user.header_scroll == true %>
<% head = "head_scroll" %>
<% end %>
<div id="<%= head %>">
<div id="menu"> <div id="menu">
<%= link_to "", root_path, id: "logo" %> <%= link_to "", root_path, id: "logo" %>
<ul> <ul>
@@ -31,9 +26,6 @@
<li> <li>
<%= link_to "Donate", donate_statics_path, class: ("active" if con == "statics" && params[:action] == "donate") %> <%= link_to "Donate", donate_statics_path, class: ("active" if con == "statics" && params[:action] == "donate") %>
</li> </li>
<li>
<%= link_to "Who's Playing?", online_statics_path, class: ("active" if con == "statics" && params[:action] == "online") %>
</li>
</ul> </ul>
</div> </div>
<div id="userbar"> <div id="userbar">
@@ -49,4 +41,4 @@
<% end %> <% end %>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -5,9 +5,6 @@
<meta name="viewport" content="initial-scale=1,maximum-scale=1"> <meta name="viewport" content="initial-scale=1,maximum-scale=1">
<meta name="description" content="Redstoner is a creative minecraft server made for redstoners"> <meta name="description" content="Redstoner is a creative minecraft server made for redstoners">
<%= stylesheet_link_tag "application", :media => "all" %> <%= stylesheet_link_tag "application", :media => "all" %>
<% if current_user.try(:dark) == true %>
<%= stylesheet_link_tag "dark", :media => "all" %>
<% end %>
<%= csrf_meta_tags %> <%= csrf_meta_tags %>
<%= favicon_link_tag "favicon.ico" %> <%= favicon_link_tag "favicon.ico" %>
<%= javascript_include_tag "https://cdn.rawgit.com/jomo/ago.js/v0.0.1/ago.min.js", crossorigin: :anonymous, integrity: "sha256-xw0JUUdbuZQCVO+QScoxrlEsD4nZGCjMRh9PP8GLhcY=" %> <%= javascript_include_tag "https://cdn.rawgit.com/jomo/ago.js/v0.0.1/ago.min.js", crossorigin: :anonymous, integrity: "sha256-xw0JUUdbuZQCVO+QScoxrlEsD4nZGCjMRh9PP8GLhcY=" %>
@@ -17,11 +14,7 @@
</head> </head>
<body> <body>
<%= render partial: "/layouts/head" %> <%= render partial: "/layouts/head" %>
<% content = "main-content" %> <div id="main-content" class="<%= yield(:main_class) %>">
<% if current_user.try(:header_scroll) == true %>
<% content = "main-content-scroll" %>
<% end %>
<div id="<%=content%>" class="<%=yield(:main_class) %>">
<% if alert %> <% if alert %>
<div class='flash alert'><%= alert %></div> <div class='flash alert'><%= alert %></div>
<% end %> <% end %>
@@ -32,4 +25,4 @@
</div> </div>
<%= render partial: "/layouts/footer" %> <%= render partial: "/layouts/footer" %>
</body> </body>
</html> </html>

View File

@@ -0,0 +1,5 @@
<%= 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 %>

View File

@@ -0,0 +1,17 @@
<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>

View File

@@ -0,0 +1,15 @@
<% 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>

View File

@@ -0,0 +1,17 @@
<% 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>

View File

@@ -0,0 +1,60 @@
<% 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">
&nbsp;
<span class="<%= "bold" if message.user_unread_id && message.user_unread != current_user %>"><%= link_to message.subject, message %></span>
&nbsp; | &nbsp;
</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>

View File

@@ -0,0 +1,26 @@
<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 %>

View File

@@ -0,0 +1,33 @@
<%= 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>

View File

@@ -13,7 +13,7 @@
</div> </div>
<p></p> <p></p>
<p>If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(staff: ""), style: "text-decoration: none; color: #4096EE;" %> in-game.</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.</p>
<p>Your Redstoner team</p> <p>Your Redstoner team</p>
</div> </div>
@@ -25,9 +25,9 @@
<p>You can contact us via: <p>You can contact us via:
<%= link_to "Website", root_url, style: "text-decoration: none; color: #4096EE;" %> | <%= 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 "Twitter", "https://twitter.com/RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> |
<%= link_to "Mastodon", "https://mstdn.io/@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;" %> <%= link_to "Email", "mailto:redstonerserver+website@gmail.com", style: "text-decoration: none; color: #4096EE;" %>
</p> </p>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -0,0 +1,28 @@
<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>

View File

@@ -14,7 +14,7 @@
%> %>
<p><%= link_to "Click here", blogpost_url(@comment.blogpost, page: page) + "#comment-#{@comment.id}", style: "text-decoration: none; color: #4096EE;" %> to view the blog post.</p> <p><%= link_to "Click here", blogpost_url(@comment.blogpost, page: page) + "#comment-#{@comment.id}", style: "text-decoration: none; color: #4096EE;" %> to view the blog post.</p>
<p>If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(staff: ""), style: "text-decoration: none; color: #4096EE;" %> in-game or on the forums!</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> <p>Your Redstoner team</p>
</div> </div>
@@ -24,7 +24,7 @@
<p>You can contact us via: <p>You can contact us via:
<%= link_to "Website", root_url, style: "text-decoration: none; color: #4096EE;" %> | <%= 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 "Twitter", "https://twitter.com/RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> |
<%= link_to "Mastodon", "https://mstdn.io/@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;" %> <%= link_to "Email", "mailto:redstonerserver+website@gmail.com", style: "text-decoration: none; color: #4096EE;" %>
</p> </p>
</div> </div>

View File

@@ -10,7 +10,7 @@
<p><%= link_to "Click here", blogpost_url(@post), style: "text-decoration: none; color: #4096EE;" %> to view the blog post.</p> <p><%= link_to "Click here", blogpost_url(@post), style: "text-decoration: none; color: #4096EE;" %> to view the blog post.</p>
<p>If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(staff: ""), style: "text-decoration: none; color: #4096EE;" %> in-game or on the forums!</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> <p>Your Redstoner team</p>
</div> </div>
@@ -21,9 +21,9 @@
<p>You can contact us via: <p>You can contact us via:
<%= link_to "Website", root_url, style: "text-decoration: none; color: #4096EE;" %> | <%= 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 "Twitter", "https://twitter.com/RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> |
<%= link_to "Mastodon", "https://mstdn.io/@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;" %> <%= link_to "Email", "mailto:redstonerserver+website@gmail.com", style: "text-decoration: none; color: #4096EE;" %>
</p> </p>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -11,7 +11,7 @@
<p><%= link_to "Click here", forumthread_url(@thread), style: "text-decoration: none; color: #4096EE;" %> to view the thread.</p> <p><%= link_to "Click here", forumthread_url(@thread), style: "text-decoration: none; color: #4096EE;" %> to view the thread.</p>
<p>If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(staff: ""), style: "text-decoration: none; color: #4096EE;" %> in-game or on the forums!</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> <p>Your Redstoner team</p>
</div> </div>
@@ -23,9 +23,9 @@
<p>You can contact us via: <p>You can contact us via:
<%= link_to "Website", root_url, style: "text-decoration: none; color: #4096EE;" %> | <%= 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 "Twitter", "https://twitter.com/RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> |
<%= link_to "Mastodon", "https://mstdn.io/@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;" %> <%= link_to "Email", "mailto:redstonerserver+website@gmail.com", style: "text-decoration: none; color: #4096EE;" %>
</p> </p>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -15,7 +15,7 @@
%> %>
<p><%= link_to "Click here", forumthread_url(@reply.thread, page: page) + "#reply-#{@reply.id}", style: "text-decoration: none; color: #4096EE;" %> to view the thread.</p> <p><%= link_to "Click here", forumthread_url(@reply.thread, page: page) + "#reply-#{@reply.id}", style: "text-decoration: none; color: #4096EE;" %> to view the thread.</p>
<p>If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(staff: ""), style: "text-decoration: none; color: #4096EE;" %> in-game or on the forums!</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> <p>Your Redstoner team</p>
</div> </div>
@@ -26,7 +26,7 @@
<p>You can contact us via: <p>You can contact us via:
<%= link_to "Website", root_url, style: "text-decoration: none; color: #4096EE;" %> | <%= 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 "Twitter", "https://twitter.com/RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> |
<%= link_to "Mastodon", "https://mstdn.io/@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;" %> <%= link_to "Email", "mailto:redstonerserver+website@gmail.com", style: "text-decoration: none; color: #4096EE;" %>
</p> </p>
</div> </div>

View File

@@ -25,7 +25,7 @@
</div> </div>
<p></p> <p></p>
<p>If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(staff: ""), style: "text-decoration: none; color: #4096EE;" %> in-game.</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.</p>
<p>Your Redstoner team</p> <p>Your Redstoner team</p>
</div> </div>
@@ -37,9 +37,9 @@
<p>You can contact us via: <p>You can contact us via:
<%= link_to "Website", root_url, style: "text-decoration: none; color: #4096EE;" %> | <%= 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 "Twitter", "https://twitter.com/RedstonerServer", style: "text-decoration: none; color: #4096EE;" %> |
<%= link_to "Mastodon", "https://mstdn.io/@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;" %> <%= link_to "Email", "mailto:redstonerserver+website@gmail.com", style: "text-decoration: none; color: #4096EE;" %>
</p> </p>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -1,4 +1,3 @@
<% title "Donate" %>
<h1>Donate</h1> <h1>Donate</h1>
<p>Running a server is really stressful and requires a lot of work.<br> <p>Running a server is really stressful and requires a lot of work.<br>
@@ -12,7 +11,7 @@
<li>Donator+ ($20 or more) <li>Donator+ ($20 or more)
</ul> </ul>
<p>We also have a <%= link_to "list of users who donated", users_path(donor: "") %> already!</p> <p>We also have <%= link_to "list of users who donated", users_path(role: "donor") %> already!</p>
<h3>Perks for you</h3> <h3>Perks for you</h3>
<p>For <i>Donator</i> and <i>Donator+</i></p> <p>For <i>Donator</i> and <i>Donator+</i></p>
@@ -20,17 +19,16 @@
<li>The warm feeling of donating for a good thing, plus a huge "<b>thank you</b>"! <li>The warm feeling of donating for a good thing, plus a huge "<b>thank you</b>"!
<li>You can have a nickname. See <%= link_to "our nickname guidelines", info_path("12-nickname-guidelines") %> <li>You can have a nickname. See <%= link_to "our nickname guidelines", info_path("12-nickname-guidelines") %>
<li>A "$" next to your name <i>(Including website)</i> <li>A "$" next to your name <i>(Including website)</i>
<li><i>Donator+</i> has access to the in-game command <code>/lol id</code></li>
</ul> </ul>
<hr> <hr>
<div class="donations"> <div class="donations">
<div class="donation"> <div class="donation">
<div class="left"> <div class="left">
<img src="https://crafatar.com/renders/body/97a4928198f045998e0e7a97eabae6ae?overlay=true&scale=3" alt="sponsor's skin" class="body"> <img src="<%= image_url("anonymous_skin.png") %>" alt="sponsor's skin" class="body">
</div> </div>
<div> <div>
<h1>Donate to our server sponsor</h1> <h1>Donate to our server sponsor</h1>
<h4>PotatoKek pays for the server hardware. You can help him by donating here.</h4> <h4>They pay for our server, but prefer to stay anonymous</h4>
<form target="_blank" method="post" action="https://www.paypal.com/cgi-bin/webscr"> <form target="_blank" method="post" action="https://www.paypal.com/cgi-bin/webscr">
<% if current_user %> <% if current_user %>
<input name="custom" type="hidden" placeholder="Your Minecraft name" value="<%= current_user.ign %>"> <input name="custom" type="hidden" placeholder="Your Minecraft name" value="<%= current_user.ign %>">
@@ -47,4 +45,4 @@
</div> </div>
<hr> <hr>
<p class="small">Please note that you are not buying anything. We do not guarantee for these perks, however, we will try hard to make sure you'll get them! Donations are processed manually, it can take a few hours.</p> <p class="small">Please note that you are not buying anything. We do not guarantee for these perks, however, we will try hard to make sure you'll get them! Donations are processed manually, it can take a few hours.</p>

View File

@@ -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>

View File

@@ -1,18 +0,0 @@
<% title "Who's Playing?" %>
<h1>These players are currently playing on Redstoner (<%= @count %>):</h1>
<div id="userlist">
<% @players.each do |u| %>
<div class="list-user">
<%= link_to(u.avatar(64), u) %>
<div class="detail">
<%= render partial: "users/username", locals: { user: u } %><br>
<% if u.id %>
<i><%= u.ign %></i>
<% else %>
<i>(Not signed up)</i>
<% end %>
</div>
</div>
<% end %>
</div>

View File

@@ -1,41 +0,0 @@
<% title "Privacy Policy" %>
<h1>Privacy Policy</h1>
<p>Please note that this privacy policy is not legally binding. It is simply a reference intended to inform you about what is done with your information. Also, this privacy policy only applies to the Redstoner website and forums. The Minecraft server will have its own privacy policy at some point.</p>
<h2>How your information is stored and protected</h2>
<p>Everything on the website is stored in a database, to which access is strictly limited. Only users of the administrator rank or former administrators who are well known and are trusted by the rest of the current administrators may access the database. Offsite backups of this data are made daily only to the network and servers of at least one current administrator via an encrypted SSH connection.</p>
<p>Passwords are stored using the bcrypt algorithm. Plaintext passwords are never logged or stored anywhere.</p>
<p>The website code is <%= link_to "open source", "https://github.com/RedstonerServer/redstoner.com" %> and undergoes heavy testing and review before it is deployed to ensure no exploitable bugs or backdoors make it onto the production server.</p>
<p>All connections to our website are automatically forced to be made over HTTPS to ensure your data is protected while in transit. We maintain <%= link_to "good TLS paramters", "https://www.ssllabs.com/ssltest/analyze.html?d=redstoner.com" %> and also employ other techniques to ensure secure connections such as <%= link_to "being on the HSTS preload list", "https://hstspreload.org/?domain=redstoner.com" %> and OCSP stapling.</p>
<h2>Information we collect</h2>
<p>This information is needed in order for your account to be created:</p>
<ul>
<li>Your Minecraft account's IGN and UUID.</li>
<li>Your email address.</li>
<li>A unique password.</li>
</ul>
<p>This information is optional and is obtained only if you provide it:</p>
<ul>
<li>Your Skype username.</li>
<li>Your YouTube channel ID.</li>
<li>Your Twitter username.</li>
</ul>
<p>This information is also collected, however does not affect your Redstoner account directly:</p>
<ul>
<li>Your IP address.</li>
</ul>
<h2>How your information is used and who it is visible to</h2>
<ul>
<li><b>Minecraft account IGN and UUID</b> - This is used to link your Minecraft account with your Redstoner account. Anyone can see these.</li>
<li><b>Your email address</b> - This is used to send you email notifications about forums activity that you are involved in. These notifications can be disabled in your account settings. This is also used to perform a password reuse check, which is explained in more detail below. Only users of the moderator rank or higher can see your email address.</li>
<li><b>Your password</b> - This is used to authenticate you. This too is used to perform a password reuse check. The plaintext version is visible to no one, but the hashed version is visible only to users of the administrator rank or higher.</li>
<li><b>Your Skype username</b> - This is used to add a link to your profile that allows others to easily contact you over Skype. Anyone can see this.</li>
<li><b>Your YouTube channel</b> - This is used to add a link to your profile that allows others to easily find your YouTube channel. Anyone can see this.</li>
<li><b>Your Twitter username</b> - This is used to add a link to your profile that allows others to easily contact you over Twitter. Anyone can see this.</li>
<li><b>Your IP address</b> - This is used to help us identify and ban troublemakers from our forums. Only users of the moderator rank and above can see this.</li>
</ul>
<h2>Password reuse check</h2>
<p>When you first sign up on our website, we use your email address and password to check if you are reusing your password with your Mojang account. This is done by attempting to log into Mojang's server using this information. If it succeeds, then your confirmation email will contain a note warning you not to reuse your password. <b>The information used to perform this check is never used to actually take over your Minecraft account. In fact, we can't because your password is hashed after the check and is totally unusable to us. If you get this warning not to reuse your password, it is still highly recommended that you change your password for your Mojang account and also use a password manager.</b></p>
<h2>Who your information is shared with</h2>
<p>We do not share your information with any third parties. The only time we will release information is if we are legally required to.</p>
<hr>
<p><sup>This privacy policy was last revised October 31, 2017.</sup></p>

View File

@@ -1,19 +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} %>
<% nec_msg = "" %> <p><%= f.submit "Reply#{ ' (Locked)' if reply.thread.locked? }", class: "btn blue" %></p>
<% forum = Forum.find(reply.thread.forum_id) %>
<% if forum.necro_length %>
<% if reply.thread.label.try(:name).try(:downcase) == "closed" %>
<% nec_msg = "This thread is closed. Are you sure you want to make this reply? If so, press 'Ok'" %>
<% elsif Threadreply.where(forumthread: reply.thread).any? %>
<% prevAgo = Threadreply.where(forumthread: reply.thread).order(:id).last.created_at %>
<% if prevAgo <= forum.necro_length.days.ago.utc %>
<% nec_msg = "You may be necroposting, as the last reply was made at least #{forum.necro_length} days ago. If you still wish to make this reply, press 'Ok'." %>
<% end %>
<% elsif reply.thread.created_at <= forum.necro_length.days.ago.utc %>
<% nec_msg = "You may be necroposting, as this thread was posted at least #{forum.necro_length} days ago. If you still wish to make this reply, press 'Ok'." %>
<% end %>
<% end %>
<p><%= f.submit "Reply#{ ' (Locked)' if reply.thread.locked? }", class: "btn blue", data: { confirm: nec_msg } %></p>
<% nec_msg = "" %>
<% end %> <% end %>

View File

@@ -1,7 +1,7 @@
<% title "Edit Thread Reply: #{@reply.thread.title}" %> <% title "Edit Thread Reply: #{@reply.thread.title}" %>
<% <%
position = @reply.thread.replies.order(:id).index(@reply) position = @reply.thread.replies.index(@reply)
page = position / Kaminari.config.default_per_page + 1 page = position / Kaminari.config.default_per_page + 1
%> %>
@@ -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>

View File

@@ -1,6 +1,4 @@
<div class="user"> <div class="user">
<%= link_to user.name, user, class: "role #{user.role.name} #{"banned" if user.banned?} #{"disabled" if user.disabled?} #{"unconfirmed" unless user.confirmed?}", title: "#{user.ign} #{user.role}", style: "color: #{fcolor(user.role.color)}; background-color: #{user.role.color}" %> <%= link_to user.name, user, class: "role #{user.role.name} #{"banned" if user.banned?} #{"disabled" if user.disabled?} #{"unconfirmed" unless user.confirmed?}", title: "#{user.ign} #{user.role}", style: "color: #{fcolor(user.role.color)}; background-color: #{user.role.color}" %>
<% if user.badge %> <%= link_to "$", donate_statics_path, class: "role donor", title: "Donator" if user.donor? %>
<%= link_to user.badge.symbol, users_path(badge: user.badge.name), class: "role badge", title: user.badge.name, style: "color: #{fcolor(user.badge.color)}; background-color: #{user.badge.color}" unless user.badge.symbol.blank? %> </div>
<% end %>
</div>

View File

@@ -2,7 +2,7 @@
<% <%
def can_edit? def can_edit?
(@user.is?(current_user) && confirmed?) || (mod? && current_user.role >= @user.role && current_user.confirmed?) (@user.is?(current_user) && confirmed?) || (mod? && current_user.role >= @user.role)
end end
%> %>
@@ -23,15 +23,7 @@
<td>Role</td> <td>Role</td>
<td> <td>
<% if current_user.role >= @user.role %> <% if current_user.role >= @user.role %>
<%= f.select :role, Role.all_to(current_user.role), {}, { disabled: !can_edit? } %> <%= f.select :role, Role.all_to(current_user.role) %>
<% end %>
</td>
</tr>
<tr>
<td>Badge</td>
<td>
<% if current_user.role >= Role.get(:mod) %>
<%= f.select :badge, Badge.all, {}, { disabled: !can_edit? } %>
<% end %> <% end %>
</td> </td>
</tr> </tr>
@@ -41,6 +33,12 @@
<%= f.select :confirmed, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %> <%= f.select :confirmed, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %>
</td> </td>
</tr> </tr>
<tr>
<td>Donator</td>
<td>
<%= f.select :donor, [["No", false], ["Yes", true]], {}, { disabled: !can_edit? } %>
</td>
</tr>
<% end %> <% end %>
<tr> <tr>
<td>Skype username</td> <td>Skype username</td>
@@ -48,6 +46,12 @@
<%= f.text_field :skype, placeholder: "Skype username", disabled: !can_edit? %> <%= f.text_field :skype, placeholder: "Skype username", disabled: !can_edit? %>
</td> </td>
</tr> </tr>
<tr>
<td>Show Skype to</td>
<td>
<%= f.select :skype_public, [["Staff only", false], ["All users", true]], {}, { disabled: !can_edit? } %>
</td>
</tr>
<tr> <tr>
<td>YouTube Channel ID</td> <td>YouTube Channel ID</td>
<td> <td>
@@ -57,7 +61,7 @@
<tr> <tr>
<td>Twitter username</td> <td>Twitter username</td>
<td> <td>
<%= f.text_field :twitter, placeholder: "Twitter username", disabled: !can_edit? %> <%= f.text_field :twitter, placeholder: "Twitter username", disabled: !(@user.is?(current_user) && confirmed? || (mod? && current_user.role >= @user.role)) %>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -69,17 +73,14 @@
</tbody> </tbody>
</table> </table>
<p><%= f.submit "Save profile", class: "btn variable-size left", disabled: !can_edit? %></p> <p><%= f.submit "Save profile", class: "btn blue left", disabled: (!@user.confirmed? && @user.is?(current_user)) %></p>
<p> <p>
<%= link_to "Edit login details", edit_login_user_path(@user), class: "btn variable-size right" %> <%= link_to "Edit login details", edit_login_user_path(@user), class: "btn blue right" %>
<%= link_to "Notification settings", edit_notifications_user_path(@user), class: "btn variable-size right" %> <%= link_to "Notification settings", edit_notifications_user_path(@user), class: "btn blue right" %>
<%= link_to "Website settings", edit_website_settings_user_path(@user), class: "btn variable-size right" %>
</p> </p>
<div class="clear"></div> <div class="clear"></div>
<% if !@user.is?(current_user) && !current_user.confirmed? %> <% if !@user.confirmed? %>
<span class='red-alert'>You must confirm your own email before you can edit other profiles.</span>
<% elsif !@user.confirmed? %>
<% if @user.is?(current_user) %> <% if @user.is?(current_user) %>
<span class='red-alert'>Please confirm your email address first!</span> <span class='red-alert'>Please confirm your email address first!</span>
<% else %> <% else %>

View File

@@ -1,11 +1,5 @@
<% title "Edit Notification Settings: #{@user.name}" %> <% title "Edit Notification Settings: #{@user.name}" %>
<%
def can_edit?
(@user.is?(current_user) && confirmed?) || (mod? && current_user.role >= @user.role && current_user.confirmed?)
end
%>
<%= link_to @user.name, @user %> → Edit Notification Settings <%= link_to @user.name, @user %> → Edit Notification Settings
<h1>Edit Notification Settings</h1> <h1>Edit Notification Settings</h1>
@@ -17,13 +11,13 @@
<tr> <tr>
<td>replies to my thread</td> <td>replies to my thread</td>
<td> <td>
<%= f.check_box :mail_own_thread_reply, disabled: !can_edit? %> <%= f.check_box :mail_own_thread_reply %>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>replies to a thread I already replied to</td> <td>replies to a thread I already replied to</td>
<td> <td>
<%= f.check_box :mail_other_thread_reply, disabled: !can_edit? %> <%= f.check_box :mail_other_thread_reply %>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -32,13 +26,13 @@
<i>(Currently used for staff only)</i> <i>(Currently used for staff only)</i>
</td> </td>
<td> <td>
<%= f.check_box :mail_own_blogpost_comment, disabled: !can_edit? %> <%= f.check_box :mail_own_blogpost_comment %>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>comments a blog post I already commented</td> <td>comments a blog post I already commented</td>
<td> <td>
<%= f.check_box :mail_other_blogpost_comment, disabled: !can_edit? %> <%= f.check_box :mail_other_blogpost_comment %>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -46,20 +40,11 @@
mentions me in a thread or comment mentions me in a thread or comment
</td> </td>
<td> <td>
<%= f.check_box :mail_mention, disabled: !can_edit? %> <%= f.check_box :mail_mention %>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<h3>Public Key</h1> <p><%= f.submit "Save changes", class: "btn blue left" %></p>
<p>All notification emails will be encrypted with this key if you supply it.</p>
<%= f.text_area :public_key, placeholder: "-----BEGIN PGP PUBLIC KEY BLOCK-----", disabled: !can_edit? %>
<p><%= f.submit "Save changes", class: "btn blue left", disabled: !can_edit? %></p>
<div class="clear"></div> <div class="clear"></div>
<% end %>
<% if !@user.is?(current_user) && !current_user.confirmed? %>
<span class='red-alert'>You must confirm your own email before you can edit other user's notification settings.</span>
<% elsif !@user.confirmed? && @user.is?(current_user) %>
<span class='red-alert'>You need to confirm your email before you can edit your notification settings.</span>
<% end %>
<% end %>

View File

@@ -1,46 +0,0 @@
<% title "Edit Website Settings: #{@user.name}" %>
<%
def can_edit?
(@user.is?(current_user) && confirmed?) || (mod? && current_user.role >= @user.role && current_user.confirmed?)
end
%>
<%= link_to @user.name, @user %> → Edit Website Settings
<h1>Edit Website Settings</h1>
<%= form_for @user do |f| %>
<table>
<tbody>
<tr>
<td>Header moves with scrolling (Experimental - do not report bugs)</td>
<td>
<%= f.check_box :header_scroll, disabled: !can_edit? %>
</td>
</tr>
<tr>
<td>Show exact UTC times</td>
<td>
<%= f.check_box :utc_time, disabled: !can_edit? %>
</td>
</tr>
<tr>
<td>Dark theme*</td>
<td>
<%= f.check_box :dark, disabled: !can_edit? %>
</td>
</tr>
</tbody>
</table>
<p><%= f.submit "Save changes", class: "btn blue left", disabled: !can_edit? %></p>
<div class="clear"></div>
<% if !@user.is?(current_user) && !current_user.confirmed? %>
<span class='red-alert'>You must confirm your own email before you can edit other user's website settings.</span>
<% elsif !@user.confirmed? && @user.is?(current_user) %>
<span class='red-alert'>You need to confirm your email before you can edit your website settings.</span>
<% end %>
<% end %>
<br><br><br>
*Warning: If as a result to enabling this style your eyes get infected with a severe case of eye cancer, we are not reliable for any damage. Please contact your doctor in advance to ensure that in case of infection you will be treated accordingly. Quality theme brought to you by Redempt™.

View File

@@ -1,34 +1,12 @@
<%= form_tag(users_path, method: :get) do %>
<%= text_field_tag "search", params[:search], placeholder: "Search for a user", class: "searchfield field" %>
<%= submit_tag "Go", class: "searchfield btn", name: nil %>
<%= hidden_field_tag "role", params[:role] if params[:role] %>
<%= hidden_field_tag "badge", params[:badge] if params[:badge]%>
<% end %>
<h1> <h1>
<% <% if params[:role] %>
if params[:role] && !params[:badge] <%= title "All '#{params[:role]}' users" %>
text = "All '#{params[:role]}' users"
elsif params[:badge] && !params[:role]
text = "All '#{params[:badge]}' users"
elsif params[:role] && params[:badge]
text = "All '#{params[:role]}' and '#{params[:badge]}' users"
elsif params.include?(:staff)
text = "All staff"
elsif params.include?(:donor)
text = "All donors"
else
text = "All users"
end
text += " that contain '#{params[:search]}'" if params[:search]
%>
<%= title text %>
<% if params[:search] %>
(<%= @users.total_count %>)
<% else %> <% else %>
(<%= @count %>) <%= title "All Users" %>
<% end %> <% end %>
(<%= @count %>)
</h1> </h1>
<%= link_to "show all", users_path if params[:role] || params[:badge] %> <%= link_to "show all", users_path if params[:role] %>
<div id="userlist"> <div id="userlist">
<% @users.each do |u| %> <% @users.each do |u| %>
@@ -41,4 +19,4 @@
</div> </div>
<% end %> <% end %>
<%= paginate @users %> <%= paginate @users %>
</div> </div>

View File

@@ -40,5 +40,5 @@
<%= f.submit "Sign up", class: "btn blue" %> <%= f.submit "Sign up", class: "btn blue" %>
<p>Contact us ingame if you have problems signing up!</p> <p>Contact us ingame if you have problems singing up!</p>
<% end %> <% end %>

View File

@@ -1,42 +1,34 @@
<% title @user.name %> <% title @user.name %>
<div id="user-info"> <div id="user-info">
<% if @user.is?(current_user) || (mod? && current_user.role >= @user.role) %> <div class="profile-action">
<div class="profile-action" ><%= link_to "edit profile", edit_user_path(@user), :class => "btn blue" %></div> <% if session[:original_user_id] %>
<% end %>
<div class="profile-action" >
<% if !session[:original_user_id] && admin? %>
<%= link_to "become this user", become_path(user: @user), :class => "btn blue" %>
<% elsif session[:original_user_id] %>
<%= link_to "revert", revert_path, :class => "btn blue" %> <%= link_to "revert", revert_path, :class => "btn blue" %>
<% elsif admin? %>
<%= link_to "become this user", become_path(user: @user), :class => "btn blue" %>
<% end %>
<% if @user.is?(current_user) || (mod? && current_user.role >= @user.role) %>
<%= 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>
<h1><%= @user.name %></h1> <h1><%= @user.name %></h1>
<div class="clear"></div> <div class="clear"></div>
<% if @ban_json && (@ban_json["expires"] == "forever" || !(DateTime.parse(@ban_json["expires"]) <= DateTime.now)) %>
<% if @user.is?(current_user) %>
<span class="user-banned">You are banned on the server for "<%=@ban_json["reason"]%>"<%=" until #{@ban_json["expires"]}" unless @ban_json["expires"] == "forever"%></span>
<% else %>
<span class="user-banned">This user is banned on the server for "<%=@ban_json["reason"]%>"<%=" until #{@ban_json["expires"]}" unless @ban_json["expires"] == "forever"%></span>
<% end %>
<% end %>
<% if @user.banned? %> <% if @user.banned? %>
<% if @user.is?(current_user) %> <span class="user-banned">This user is banned!</span>
<span class="user-banned">You are banned on the website!</span>
<% else %>
<span class="user-banned">This user is banned on the website!</span>
<% end %>
<% end %> <% end %>
<br>
<% if !@user.confirmed? %> <% if !@user.confirmed? %>
<% if @user.is?(current_user) %> <% if @user.is?(current_user) || mod? %>
<span class="user-unconfirmed">You haven't confirmed your email "<u><%= @user.email %></u>" yet!</span> <span class="user-unconfirmed">Please confirm your email <u><%= @user.email %></u> !</span>
<%= button_to "Resend the confirmation mail", resend_mail_user_path, class: "btn dark", form_class: "inline-block", data: {confirm: "Did you check your spam folder?"} %> <%= button_to "Resend the confirmation mail", resend_mail_user_path, class: "btn dark", form_class: "inline-block", data: {confirm: "Did you check your spam folder?"} %>
<% elsif mod? %>
<span class="user-unconfirmed">This user hasn't confirmed their email "<u><%= @user.email %></u>" yet!</span>
<%= button_to "Resend the confirmation mail", resend_mail_user_path, class: "btn dark", form_class: "inline-block" %>
<% else %> <% else %>
<span class="user-unconfirmed">This user hasn't confirmed their email yet!</span> <span class="user-unconfirmed">This user hasn't confirmed their email yet!</span>
<% end %> <% end %>
@@ -65,7 +57,7 @@
<td><b>Role</b></td> <td><b>Role</b></td>
<td><%= link_to @user.role, users_path(:role => @user.role.name) %></td> <td><%= link_to @user.role, users_path(:role => @user.role.name) %></td>
</tr> </tr>
<% if current_user && !@user.skype.blank? %> <% if current_user && !@user.skype.blank? && (@user.skype_public || current_user == @user || mod?) %>
<tr> <tr>
<td><b>Skype</b></td> <td><b>Skype</b></td>
<td><%= link_to @user.skype, "skype:#{@user.skype}?chat", target: "_blank" %></a></td> <td><%= link_to @user.skype, "skype:#{@user.skype}?chat", target: "_blank" %></a></td>

View File

@@ -24,4 +24,4 @@ test:
adapter: sqlite3 adapter: sqlite3
database: db/test.sqlite3 database: db/test.sqlite3
pool: 5 pool: 5
timeout: 5000 timeout: 5000

View File

@@ -6,8 +6,6 @@ Redstoner::Application.configure do
# since you don't have to restart the web server when you make code changes. # since you don't have to restart the web server when you make code changes.
config.cache_classes = false config.cache_classes = false
config.action_controller.perform_caching = true
# Log error messages when you accidentally call methods on nil. # Log error messages when you accidentally call methods on nil.
config.whiny_nils = true config.whiny_nils = true
@@ -45,4 +43,4 @@ Redstoner::Application.configure do
password: ENV["GMAIL_PASSWORD"], password: ENV["GMAIL_PASSWORD"],
} }
end end

View File

@@ -1 +0,0 @@
Rails.application.config.assets.precompile += %w( dark.css )

View File

@@ -4,12 +4,10 @@ Redstoner::Application.routes.draw do
resources :comments resources :comments
end end
resources :statics, only: [:home, :donate, :online], path: '/' do resources :statics, only: [:home, :donate], path: '/' do
collection do collection do
get 'donate' get 'donate'
get 'home' get 'home'
get 'online'
get 'privacy'
get 'index' get 'index'
end end
end end
@@ -23,7 +21,6 @@ Redstoner::Application.routes.draw do
post 'resend_mail' post 'resend_mail'
get 'edit_notifications' get 'edit_notifications'
put 'update_login' put 'update_login'
get 'edit_website_settings'
end end
collection do collection do
get 'lost_password' get 'lost_password'
@@ -33,13 +30,10 @@ Redstoner::Application.routes.draw do
end end
resources :forumgroups, path: '/forums/groups' resources :forumgroups, path: '/forums/groups'
resources :forums, path: '/forums'
resources :forumthreads, path: '/forums/threads' do resources :forumthreads, path: '/forums/threads' do
resources :threadreplies, path: 'replies' resources :threadreplies, path: 'replies'
collection do
get 'search'
end
end end
resources :forums, path: '/forums'
resources :tools do resources :tools do
collection do collection do
@@ -47,6 +41,13 @@ 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'

View File

@@ -5,4 +5,4 @@ class CreateRoles < ActiveRecord::Migration
t.integer :value t.integer :value
end end
end end
end end

View File

@@ -23,4 +23,4 @@ class CreateUsers < ActiveRecord::Migration
t.timestamps null: true t.timestamps null: true
end end
end end
end end

View File

@@ -1,17 +0,0 @@
class AddBadgeIdToUsers < ActiveRecord::Migration
def change
create_table "badges", force: :cascade do |t|
t.string "name"
t.string "symbol"
t.string "color"
end
Badge.create!({name: "none", symbol: "", color: "#000"})
dbadge = Badge.create!({name: "donor", symbol: "$", color: "#f60"})
add_column :users, :badge_id, :integer, default: 1
User.where(donor: true).update_all(badge_id: dbadge.id)
remove_column :users, :donor
end
end

View File

@@ -1,5 +0,0 @@
class AddUtcTimeToUsers < ActiveRecord::Migration
def change
add_column :users, :utc_time, :boolean, default: false
end
end

View File

@@ -1,5 +0,0 @@
class AddHeaderScrollToUsers < ActiveRecord::Migration
def change
add_column :users, :header_scroll, :boolean, default: false
end
end

View File

@@ -1,5 +0,0 @@
class AddNecroLengthToForums < ActiveRecord::Migration
def change
add_column :forums, :necro_length, :integer
end
end

View File

@@ -1,5 +0,0 @@
class AddDarkToUsers < ActiveRecord::Migration
def change
add_column :users, :dark, :boolean, default: false
end
end

View File

@@ -1,8 +0,0 @@
class AddSearchIndexes < ActiveRecord::Migration
def change
add_index :forumthreads, [:title, :content], type: :fulltext
add_index :forumthreads, :title, type: :fulltext
add_index :forumthreads, :content, type: :fulltext
add_index :threadreplies, :content, type: :fulltext
end
end

View File

@@ -0,0 +1,14 @@
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

View File

@@ -0,0 +1,5 @@
class ChangeMessageToText < ActiveRecord::Migration
def change
rename_column :messages, :message, :text
end
end

View File

@@ -0,0 +1,5 @@
class AddSubjectToMessages < ActiveRecord::Migration
def change
add_column :messages, :subject, :string
end
end

View File

@@ -0,0 +1,13 @@
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

View File

@@ -1,5 +0,0 @@
class AddIndexForumthreadIdOnThreadreplies < ActiveRecord::Migration
def change
add_index :threadreplies, :forumthread_id
end
end

View File

@@ -1,6 +0,0 @@
class RemoveSkypeVisibilityFromUsers < ActiveRecord::Migration
def change
remove_column :users, :skype_public
User.update_all skype: nil
end
end

View File

@@ -1,5 +0,0 @@
class AddPublicKeyToUsers < ActiveRecord::Migration
def change
add_column :users, :public_key, :text
end
end

View File

@@ -11,18 +11,11 @@
# #
# 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: 20171013001146) do ActiveRecord::Schema.define(version: 20170613021450) do
create_table "badges", force: :cascade do |t|
t.string "name", limit: 191
t.string "symbol", limit: 191
t.string "color", limit: 191
t.integer "value", limit: 4
end
create_table "blogposts", force: :cascade do |t| create_table "blogposts", force: :cascade do |t|
t.string "title", limit: 255 t.string "title", limit: 191
t.text "content", limit: 16777215 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
t.datetime "created_at" t.datetime "created_at"
@@ -30,7 +23,7 @@ ActiveRecord::Schema.define(version: 20171013001146) do
end end
create_table "comments", force: :cascade do |t| create_table "comments", force: :cascade do |t|
t.text "content", limit: 16777215 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
t.integer "blogpost_id", limit: 4 t.integer "blogpost_id", limit: 4
@@ -39,19 +32,18 @@ ActiveRecord::Schema.define(version: 20171013001146) do
end end
create_table "forumgroups", force: :cascade do |t| create_table "forumgroups", force: :cascade do |t|
t.string "name", limit: 255 t.string "name", limit: 191
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: 255 t.string "name", limit: 191
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
t.integer "forumgroup_id", limit: 4 t.integer "forumgroup_id", limit: 4
t.integer "necro_length", limit: 4
end end
create_table "forums_labels", id: false, force: :cascade do |t| create_table "forums_labels", id: false, force: :cascade do |t|
@@ -60,10 +52,10 @@ ActiveRecord::Schema.define(version: 20171013001146) do
end end
create_table "forumthreads", force: :cascade do |t| create_table "forumthreads", force: :cascade do |t|
t.string "title", limit: 255 t.string "title", limit: 191
t.text "content", limit: 16777215 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
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
t.integer "forum_id", limit: 4 t.integer "forum_id", limit: 4
@@ -72,50 +64,65 @@ ActiveRecord::Schema.define(version: 20171013001146) do
t.integer "label_id", limit: 4 t.integer "label_id", limit: 4
end end
add_index "forumthreads", ["content"], name: "index_forumthreads_on_content", type: :fulltext
add_index "forumthreads", ["title", "content"], name: "forumthreads_title_content", type: :fulltext
add_index "forumthreads", ["title", "content"], name: "index_forumthreads_on_title_and_content", type: :fulltext
add_index "forumthreads", ["title"], name: "index_forumthreads_on_title", type: :fulltext
create_table "info", force: :cascade do |t| create_table "info", force: :cascade do |t|
t.string "title", limit: 255 t.string "title", limit: 191
t.text "content", limit: 16777215 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: 255 t.string "name", limit: 191
t.string "color", limit: 255 t.string "color", limit: 191
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", limit: 32, null: false
t.string "token", limit: 6, null: false t.string "token", limit: 6, null: false
t.string "email", limit: 191 t.string "email", limit: 191, null: false
end end
add_index "register_tokens", ["email"], name: "index_register_tokens_on_email", unique: true, using: :btree
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: 255 t.string "name", limit: 191
t.integer "value", limit: 4 t.integer "value", limit: 4
t.string "color", limit: 255 t.string "color", limit: 191
end end
create_table "sessions", force: :cascade do |t| create_table "sessions", force: :cascade do |t|
t.string "session_id", limit: 255, null: false t.string "session_id", limit: 191, null: false
t.text "data", limit: 16777215 t.text "data", limit: 65535
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
end end
add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", length: {"session_id"=>191}, using: :btree add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", using: :btree
add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at", using: :btree add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at", using: :btree
create_table "threadreplies", force: :cascade do |t| create_table "threadreplies", force: :cascade do |t|
t.text "content", limit: 16777215 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
t.integer "forumthread_id", limit: 4 t.integer "forumthread_id", limit: 4
@@ -123,22 +130,21 @@ ActiveRecord::Schema.define(version: 20171013001146) do
t.datetime "updated_at" t.datetime "updated_at"
end end
add_index "threadreplies", ["content"], name: "index_threadreplies_on_content", type: :fulltext
add_index "threadreplies", ["forumthread_id"], name: "index_threadreplies_on_forumthread_id", using: :btree
create_table "users", force: :cascade do |t| create_table "users", force: :cascade do |t|
t.string "uuid", limit: 255, null: false t.string "uuid", limit: 191, null: false
t.string "name", limit: 191 t.string "name", limit: 191, null: false
t.string "password_digest", limit: 255, null: false t.string "password_digest", limit: 191, null: false
t.string "ign", limit: 255, null: false t.string "ign", limit: 191, null: false
t.string "email", limit: 191 t.string "email", limit: 191, null: false
t.text "about", limit: 65535 t.text "about", limit: 65535
t.string "last_ip", limit: 255 t.string "last_ip", limit: 191
t.string "skype", limit: 255 t.string "skype", limit: 191
t.string "youtube", limit: 255 t.boolean "skype_public", default: false
t.string "youtube_channelname", limit: 255 t.string "youtube", limit: 191
t.string "twitter", limit: 255 t.string "youtube_channelname", limit: 191
t.string "email_token", limit: 255 t.string "twitter", limit: 191
t.boolean "donor", default: false
t.string "email_token", limit: 191
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
@@ -149,11 +155,6 @@ ActiveRecord::Schema.define(version: 20171013001146) do
t.boolean "mail_own_blogpost_comment", default: true t.boolean "mail_own_blogpost_comment", default: true
t.boolean "mail_other_blogpost_comment", default: true t.boolean "mail_other_blogpost_comment", default: true
t.boolean "mail_mention", default: true t.boolean "mail_mention", default: true
t.integer "badge_id", limit: 4, default: 0
t.boolean "utc_time", default: false
t.boolean "header_scroll", default: false
t.boolean "dark", default: false
t.text "public_key", limit: 65535
end end
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree

View File

@@ -10,14 +10,6 @@ Role.create!([
{name: "superadmin", value: 500, color: "#d22"} {name: "superadmin", value: 500, color: "#d22"}
]) ])
Badge.create!([
{name: "none", symbol: "", color: "#000"},
{name: "donor", symbol: "$", color: "#f60"},
{name: "developer", symbol: "D", color: "#a0a"},
{name: "retired", symbol: "R", color: "#0aa"},
{name: "lead", symbol: "L", color: "#a00"}
])
userpw = SecureRandom.hex(36) userpw = SecureRandom.hex(36)
@@ -31,13 +23,44 @@ deleted_user = User.create!(
password: userpw, password: userpw,
password_confirmation: userpw, password_confirmation: userpw,
role: Role.get(:disabled), role: Role.get(:disabled),
badge: Badge.get(:none),
skype: "echo123", skype: "echo123",
skype_public: true,
last_ip: "0.0.0.0", last_ip: "0.0.0.0",
confirmed: true, confirmed: true,
last_seen: Time.utc(0).to_datetime, last_seen: Time.utc(0).to_datetime
header_scroll: false,
utc_time: false,
dark: false
) )
deleted_user.update_attribute(:ign, "Steve") deleted_user.update_attribute(:ign, "Steve")
User.create!(
uuid: "ae795aa86327408e92ab25c8a59f3ba1",
ign: "jomo",
email: "jomo@example.com",
password: "123456789", # high seructity!
password_confirmation: "123456789",
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!"
)

Some files were not shown because too many files have changed in this diff Show More