3 Commits

Author SHA1 Message Date
MrYummy
0aad3bb71a Added choice of project, r/w perms, and fixed up some css 2017-07-04 22:27:07 +02:00
MrYummy
0f74795159 Added basic hexfile reading that respects r/w perms 2017-07-01 04:48:52 +02:00
MrYummy
3bfc74045f hi 2017-06-21 01:59:02 +02:00
77 changed files with 307 additions and 955 deletions

View File

@@ -15,7 +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'
# 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.

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
@@ -231,7 +223,6 @@ PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
actionpack-action_caching!
activerecord-session_store activerecord-session_store
bcrypt bcrypt
better_errors better_errors

Binary file not shown.

View File

@@ -15,3 +15,4 @@
//= require editor //= require editor
//= require highlight //= require highlight
//= require jquery-textcomplete //= require jquery-textcomplete
//= require memory

View File

@@ -88,45 +88,5 @@ $(function() {
}], { }], {
debounce: 300 debounce: 300
}); });
$('.md_editor .field_container_user .editor_field').textcomplete([{
// match up to 2 words (everything except some special characters)
// each word can have up to 16 characters (up to 32 total)
// words must be separated by a single space
match: /(^|\s)([^!"§$%&\/()=?.,;+*@\s]{1,16})$/,
search: function (text, callback, match) {
console.log("Searching " + text);
text = text.toLowerCase();
$.ajax("/users/suggestions", {
type: "post",
data: {name: text},
dataType: "json",
headers: {
"X-CSRF-Token": $('meta[name="csrf-token"]').attr("content")
},
success: function(data) {
callback(data);
},
error: function(xhr, status, err) {
console.error(err);
callback([]);
}
});
},
template: function(user) {
var name = user[0];
var ign = user[1];
if (name != ign) {
return name + " <small>(" + ign + ")</small>";
} else {
return ign;
}
},
cache: true,
replace: function (word) {
return "$1" + word[1] + " ";
}
}], {
debounce: 300
});
}); });

View File

@@ -0,0 +1,26 @@
$(function() {
$('td').focus(function() {
if (this.id.split("-")[0] == "memory") {
$(this).css("background-color", "lightblue")
}
});
var data = [];
$('td').keydown(function() {
data.push(this.id, $(this).html().substr(0, 2)); //position, value
})
$('td').blur(function() {
$(this).css("background", "none");
if ((id_i = data.indexOf(this.id) != -1) && data[id_i+1] != $(this).html().substr(0, 2)) {
$(this).css("color", "darkgreen");
var int_id = this.id.split("-")[1]
$.post("/memory/update_memory?project="+$(this).closest("table").data("project")+"&file="+Math.floor((int_id/2048)+1)+"&mem_id="+int_id%2048+"&value="+$(this).html().substr(0, 2));
data.splice(id_i, 2);
}
});
$('select').change(function() {
$.get("/memory/table?project="+$(this).data("project")+"&file="+$(this).find("option:selected").text()+".hex")
});
});

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;

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 {
@@ -489,10 +480,6 @@ blockquote p {
padding: 4em 1em 1em; padding: 4em 1em 1em;
} }
} }
.field_container_user {
.editor_field {
}
}
} }
ul.dropdown-menu { ul.dropdown-menu {
@@ -688,13 +675,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 +1027,12 @@ nav.pagination {
border-radius: 0.2em; border-radius: 0.2em;
text-shadow: none; text-shadow: none;
} }
.memory-table {
.searchfield { width: 980px;
height:40px; margin: auto;
display: inline-block; text-align: center;
&.field { th, td {
width: 300px; height: 20px;
} border: 1px solid black;
&.btn {
margin: 4px 1px 0 0;
cursor: default;
color: #fff;
font-size: 12px;
background: #4096ee;
width: 40px;
} }
} }

View File

@@ -4,12 +4,20 @@ 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
if @post
@comment = Comment.new(blogpost: @post) @comment = Comment.new(blogpost: @post)
@comments = @post.comments.page(params[:page]) @comments = @post.comments.page(params[:page])
respond_to do |format|
format.html
format.json {render json: @post.attributes.merge(replies: Comment.where(blogpost: @post).ids).to_json}
end
else
respond_to {|format| format.json {render json: Comment.find_by(id: params[:id][1..-1]).try(:attributes).to_json}}
end
end end
def new def new
@@ -64,9 +72,11 @@ class BlogpostsController < ApplicationController
def set_post def set_post
if params[:id] if params[:id]
unless action_name == "show" && params[:id][0].downcase == "c"
@post = Blogpost.find(params[:id]) @post = Blogpost.find(params[:id])
end end
end end
end
def auth def auth
unless mod? unless mod?

View File

@@ -2,6 +2,12 @@ class CommentsController < ApplicationController
include MailerHelper include MailerHelper
def show
respond_to do |format|
format.json {render json: @comment.attributes.to_json}
end
end
def edit def edit
@comment = Comment.find(params[:id]) @comment = Comment.find(params[:id])
if mod? || @comment.author.is?(current_user) if mod? || @comment.author.is?(current_user)

View File

@@ -19,19 +19,6 @@ class ForumgroupsController < ApplicationController
def update def update
if admin? if admin?
@group = Forumgroup.find(params[:id]) @group = Forumgroup.find(params[:id])
group_badges = Badgeassociation.where(forumgroup: @group)
["read-", "write-"].each_with_index do |p,i|
current_badges = group_badges.where(permission: i+1).pluck(:badge_id)
params.select{|k,v| k.start_with? p}.each do |k,v|
name = k.gsub(p, "")
if current_badges.include? (bid = Badge.find_by(name: name).id)
current_badges.delete bid
else
Badgeassociation.create!(badge: Badge.find_by(name: name), forumgroup: @group, permission: i+1)
end
end
current_badges.each {|b| Badgeassociation.find_by(badge_id: b, forumgroup: @group, permission: i+1).delete}
end
if @group.update_attributes(group_params) if @group.update_attributes(group_params)
flash[:notice] = "Forum group updated" flash[:notice] = "Forum group updated"
redirect_to @group redirect_to @group
@@ -56,11 +43,6 @@ class ForumgroupsController < ApplicationController
def create def create
if admin? if admin?
@group = Forumgroup.new(group_params) @group = Forumgroup.new(group_params)
["read-", "write-"].each_with_index do |p,i|
params.select{|k,v| k.start_with? p}.each do |k,v|
Badgeassociation.create!(badge: Badge.find_by(name: k.gsub(p, "")), forumgroup: @group, permission: i+1)
end
end
if @group.save if @group.save
flash[:notice] = "Forum group created." flash[:notice] = "Forum group created."
redirect_to @group redirect_to @group

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
@@ -35,19 +34,6 @@ class ForumsController < ApplicationController
def update def update
if admin? if admin?
forum_badges = Badgeassociation.where(forum: @forum)
["read-", "write-"].each_with_index do |p,i|
current_badges = forum_badges.where(permission: i+1).pluck(:badge_id)
params.select{|k,v| k.start_with? p}.each do |k,v|
name = k.gsub(p, "")
if current_badges.include? (bid = Badge.find_by(name: name).id)
current_badges.delete bid
else
Badgeassociation.create!(badge: Badge.find_by(name: name), forum: @forum, permission: i+1)
end
end
current_badges.each {|b| Badgeassociation.find_by(badge_id: b, forum: @forum, permission: i+1).delete}
end
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
@@ -63,11 +49,6 @@ class ForumsController < ApplicationController
def create def create
if admin? if admin?
@forum = Forum.new(forum_params([:forumgroup_id])) @forum = Forum.new(forum_params([:forumgroup_id]))
["read-", "write-"].each_with_index do |p,i|
params.select{|k,v| k.start_with? p}.each do |k,v|
Badgeassociation.create!(badge: Badge.find_by(name: k.gsub(p, "")), forum: @forum, permission: i+1)
end
end
if @forum.save if @forum.save
flash[:notice] = "Forum created." flash[:notice] = "Forum created."
redirect_to @forum redirect_to @forum
@@ -96,6 +77,7 @@ class ForumsController < ApplicationController
redirect_to forums_path redirect_to forums_path
end end
private private
def check_permission def check_permission
@@ -107,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

@@ -0,0 +1,54 @@
class MemoryController < ApplicationController
before_filter :logged_in
def index
current_uuid = current_user.uuid.gsub("-", "")
Dir.chdir("/etc/minecraft/redstoner/plugins/JavaUtils/memory/players/#{current_uuid}")
psjson = JSON.parse(File.read("projects.json"))
@projects = psjson["owns"] + psjson["read"] + psjson["write"]
@project_names = @projects.collect{|p| (data = JSON.parse(File.read(File.expand_path("../..")+"/projects/#{p}/project.json")))["name"] + " | #{"own" if data["owner"] == current_uuid}#{"write" if data["write"].include? current_uuid}#{"read" if data["read"].include? current_uuid}"}
end
def list
render :index
end
def table
Dir.chdir("/etc/minecraft/redstoner/plugins/JavaUtils/memory/projects/#{params[:project].gsub(/[^a-zA-Z0-9-]/,"")[0..35]}")
@data = []
Dir.glob('*').reverse.each do |f|
File.open(Dir.pwd+"/#{f}") do |file|
@data.concat(file.read.unpack("C*").map{|h| h.to_s(16)})
unless (parse = JSON.parse((jf = File.open(Dir.pwd+"/project.json")).read))["read"].include? current_user.uuid.gsub("-","")
@can_edit = true
end
@name = parse["name"]
jf.close
end
end
end
def update_memory
Dir.chdir("/etc/minecraft/redstoner/plugins/JavaUtils/memory/projects/#{params[:project].gsub(/[^a-zA-Z0-9-]/,"")[0..35]}")
unless params[:mem_id].to_i > JSON.parse(File.read("project.json"))["size"] || (/[^A-Fa-f0-9]/.match params[:value])
new_text = ""
File.open("#{params[:file]}.hex"){|f| new_text = f.read.unpack("C*").collect{|h| h.to_s(16)}}
new_text[params[:mem_id].to_i] = params[:value]
File.open("#{params[:file]}.hex", "w") do |f|
f.write((new_text.collect{|h| h.to_s.to_i(16)}).pack("C*").force_encoding("UTF-8"))
end
render nothing: true
end
end
private
def logged_in
unless current_user
flash[:alert] = "Please log in before viewing memory files."
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,9 +14,4 @@ class StaticsController < ApplicationController
def donate def donate
end end
def online
json = JSON.parse(File.read("/etc/minecraft/redstoner/plugins/JavaUtils/players.json"))
@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) }.sort_by!(&:role).reverse!
@count = json["amount"]
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

View File

@@ -7,15 +7,33 @@ 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)) 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
respond_to do |format|
format.html
format.json {render json: @user.attributes.slice("id", "uuid", "ign", "name", "about", "donor", "confirmed", "last_seen", "created_at").to_json}
end
end end
# SIGNUP # SIGNUP
@@ -137,9 +155,9 @@ class UsersController < ApplicationController
def update def update
if (mod? && current_user.role >= @user.role ) || (@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, :skype_public, :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, :skype_public, :youtube, :twitter, :about, :header_scroll, :utc_time, :dark]) userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about])
end end
if userdata[:role] if userdata[:role]
role = Role.get(userdata[:role]) role = Role.get(userdata[:role])
@@ -150,9 +168,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]
@@ -221,13 +236,6 @@ class UsersController < ApplicationController
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 || superadmin? 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])

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

@@ -0,0 +1,2 @@
module MemoryHelper
end

View File

@@ -1,19 +0,0 @@
class Badge < ActiveRecord::Base
include Comparable
has_many :users
has_and_belongs_to_many :forums
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

@@ -1,7 +0,0 @@
class Badgeassociation < ActiveRecord::Base
belongs_to :badge
belongs_to :forum
belongs_to :forumgroup
end

View File

@@ -1,10 +1,6 @@
class Forum < ActiveRecord::Base class Forum < ActiveRecord::Base
belongs_to :forumgroup belongs_to :forumgroup
has_many :forumthreads has_many :forumthreads
has_many :badgeassociations
has_many :badges, through: :badgeassociations
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
@@ -22,11 +18,11 @@ class Forum < ActiveRecord::Base
end end
def can_read?(user) def can_read?(user)
group && group.can_read?(user) && (role_read.nil? || (!user.nil? && user.role >= role_read) || Badgeassociation.find_by(badge: user.badge, forum: self, permission: 1)) group && group.can_read?(user) && (role_read.nil? || (!user.nil? && user.role >= role_read))
end end
def can_write?(user) def can_write?(user)
group.can_write?(user) && (role_write.nil? || (!user.nil? && user.role >= role_write || Badgeassociation.find_by(badge: user.badge, forum: self, permission: 2))) group.can_write?(user) && (role_write.nil? || (!user.nil? && user.role >= role_write))
end end
def can_view?(user) def can_view?(user)

View File

@@ -4,8 +4,7 @@ class Forumgroup < ActiveRecord::Base
belongs_to :role_write, class_name: "Role", foreign_key: "role_write_id" belongs_to :role_write, class_name: "Role", foreign_key: "role_write_id"
accepts_nested_attributes_for :forums accepts_nested_attributes_for :forums
has_many :badgeassociations
has_many :badges, through: :badgeassociations
validates_presence_of :name, :position validates_presence_of :name, :position
validates_length_of :name, in: 2..20 validates_length_of :name, in: 2..20
@@ -15,11 +14,11 @@ class Forumgroup < ActiveRecord::Base
end end
def can_read?(user) def can_read?(user)
role_read.nil? || (!user.nil? && user.role >= role_read) || Badgeassociation.find_by(badge: user.badge, forumgroup: self, permission: 1) role_read.nil? || (!user.nil? && user.role >= role_read)
end end
def can_write?(user) def can_write?(user)
!user.nil? && user.confirmed? && (role_write.nil? || user.role >= role_write) || Badgeassociation.find_by(badge: user.badge, forumgroup: self, permission: 2) !user.nil? && user.confirmed? && (role_write.nil? || user.role >= role_write)
end end
def can_view?(user) def can_view?(user)

View File

@@ -65,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}) OR (?)", user_id, role_value, role_value, role_value, role_value, Forum.find(forum).can_read?(user))
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

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

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
@@ -30,6 +29,10 @@ class User < ActiveRecord::Base
self == user self == user
end end
def donor?
!!self.donor
end
def confirmed? def confirmed?
!!self.confirmed !!self.confirmed
end end
@@ -147,10 +150,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
@@ -174,21 +173,4 @@ class User < ActiveRecord::Base
def set_email_token def set_email_token
self.email_token ||= SecureRandom.hex(16) self.email_token ||= SecureRandom.hex(16)
end end
def self.search (search, role, badge, staff)
users = User.joins(:role)
if role
users = users.where(role: role)
elsif staff
users = users.where("roles.value >= ?", Role.get(:mod).to_i)
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

@@ -1,8 +0,0 @@
<div class="md_editor">
<div class="field_container_user">
<% options = (defined?(options) && options || {}) %>
<% options[:class] = "#{options[:class]} editor_field" %>
<% options[:placeholder] ||= "Enter user's name." %>
<%= text_field_tag name, content, options %>
</div>
</div>

View File

@@ -29,26 +29,10 @@
<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" %></td> <td><%= f.select :role_read_id, role_selection, include_blank: "None" %></td>
</tr> </tr>
<tr>
<td><b>Badges with read permission</b></td>
<td>
<% Badge.where("name != 'none'").each do |b| %>
<%=b%><%= check_box_tag "read-#{b}", nil, Badgeassociation.find_by(badge: b, forumgroup: @group, permission: 1) %>
<% end %>
</td>
</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 %></td> <td><%= f.select :role_write_id, role_selection, include_blank: false %></td>
</tr> </tr>
<tr>
<td><b>Badges with write permission</b></td>
<td>
<% Badge.where("name != 'none'").each do |b| %>
<%=b%><%= check_box_tag "write-#{b}", nil, Badgeassociation.find_by(badge: b, forumgroup: @group, permission: 2) %>
<% end %>
</td>
</tr>
</table> </table>
<p><%= f.submit "Update group", class: "btn blue left" %></p> <p><%= f.submit "Update group", class: "btn blue left" %></p>
<% end %> <% end %>

View File

@@ -16,26 +16,10 @@
<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" %></td> <td><%= f.select :role_read_id, role_selection, include_blank: "None" %></td>
</tr> </tr>
<tr>
<td><b>Badges with read permission</b></td>
<td>
<% Badge.where("name != 'none'").each do |b| %>
<%=b%><%= check_box_tag "read-#{b}" %>
<% end %>
</td>
</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 %></td> <td><%= f.select :role_write_id, role_selection, include_blank: false %></td>
</tr> </tr>
<tr>
<td><b>Badges with write permission</b></td>
<td>
<% Badge.where("name != 'none'").each do |b| %>
<%=b%><%= check_box_tag "write-#{b}" %>
<% end %>
</td>
</tr>
</table> </table>
<p><%= f.submit "Create group", class: "btn blue left" %></p> <p><%= f.submit "Create group", class: "btn blue left" %></p>
<div class="clear"></div> <div class="clear"></div>

View File

@@ -17,30 +17,10 @@
<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" %></td> <td><%= f.select :role_read_id, role_selection, include_blank: "None" %></td>
</tr> </tr>
<tr>
<td><b>Badges with read permission</b></td>
<td>
<% Badge.where("name != 'none'").each do |b| %>
<%=b%><%= check_box_tag "read-#{b}", nil, Badgeassociation.find_by(badge: b, forum: @forum, permission: 1) %>
<% end %>
</td>
</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 %></td> <td><%= f.select :role_write_id, role_selection, include_blank: false %></td>
</tr> </tr>
<tr>
<td><b>Badges with write permission</b></td>
<td>
<% Badge.where("name != 'none'").each do |b| %>
<%=b%><%= check_box_tag "write-#{b}", nil, Badgeassociation.find_by(badge: b, forum: @forum, permission: 2) %>
<% end %>
</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)" %></td>
</tr>
</table> </table>
<p><%= f.submit "Update forum", class: "btn blue left" %></p> <p><%= f.submit "Update forum", class: "btn blue left" %></p>
<% end %> <% end %>

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

View File

@@ -17,30 +17,10 @@
<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" %></td> <td><%= f.select :role_read_id, role_selection, include_blank: "None" %></td>
</tr> </tr>
<tr>
<td><b>Badges with read permission</b></td>
<td>
<% Badge.where("name != 'none'").each do |b| %>
<%=b%><%= check_box_tag "read-#{b}" %>
<% end %>
</td>
</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 %></td> <td><%= f.select :role_write_id, role_selection, include_blank: false %></td>
</tr> </tr>
<tr>
<td><b>Badges with write permission</b></td>
<td>
<% Badge.where("name != 'none'").each do |b| %>
<%=b%><%= check_box_tag "write-#{b}" %>
<% end %>
</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)" %></td>
</tr>
</table> </table>
<%= f.hidden_field :forumgroup_id %> <%= f.hidden_field :forumgroup_id %>
<p><%= f.submit "Create forum", class: "btn blue left" %></p> <p><%= f.submit "Create forum", class: "btn blue left" %></p>

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

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

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

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

View File

@@ -0,0 +1,5 @@
<%= form_tag url_for(controller: "memory", action: "table"), method: :get do %>
<%= select_tag "project", options_for_select(@projects.collect.with_index{|p, i| [@project_names[i], p]}) %>
<br><br>
<%= submit_tag "Load table", name: nil, class: "btn blue" %>
<% end %>

View File

@@ -0,0 +1,17 @@
<h1 style="text-align:center"><%= title @name + (" (read-only)" if !@can_edit).to_s %></h1>
<table class="memory-table", data-project="<%=params[:project]%>">
<tr>
<% ["Address","0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"].each do |i| %>
<th><b><%=i%></b></th>
<% end %>
</tr>
<% @data.in_groups_of(16).each_with_index do |row, rindex| %>
<tr>
<td><b><%=(rindex*16).to_s(16).upcase.rjust(6, "0")%></b></td>
<% row.each_with_index do |hex, hindex| %>
<td contenteditable="<%=!!@can_edit%>" id="memory-<%=(16*rindex)+hindex%>"><%=hex.to_s.upcase.rjust(2, "0")%></td>
<% end %>
</tr>
<% end %>
</table>
<br>

View File

@@ -11,7 +11,7 @@
<li>Donator+ ($20 or more) <li>Donator+ ($20 or more)
</ul> </ul>
<p>We also have <%= link_to "list of users who donated", users_path(badge: "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>
@@ -19,7 +19,6 @@
<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">

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

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? %>
<% end %>
</div> </div>

View File

@@ -27,20 +27,18 @@
<% end %> <% end %>
</td> </td>
</tr> </tr>
<tr>
<td>Badge</td>
<td>
<% if current_user.role >= Role.get(:mod) %>
<%= f.select :badge, Badge.all %>
<% end %>
</td>
</tr>
<tr> <tr>
<td>Confirmed email address</td> <td>Confirmed email address</td>
<td> <td>
<%= 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>
@@ -75,11 +73,10 @@
</tbody> </tbody>
</table> </table>
<p><%= f.submit "Save profile", class: "btn variable-size left", disabled: (!@user.confirmed? && @user.is?(current_user)) %></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>

View File

@@ -1,34 +0,0 @@
<% title "Edit Website Settings: #{@user.name}" %>
<%= 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 %>
</td>
</tr>
<tr>
<td>Show exact UTC times</td>
<td>
<%= f.check_box :utc_time %>
</td>
</tr>
<tr>
<td>Dark theme*</td>
<td>
<%= f.check_box :dark %>
</td>
</tr>
</tbody>
</table>
<p><%= f.submit "Save changes", class: "btn blue left" %></p>
<div class="clear"></div>
<% 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,32 +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"
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| %>

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

@@ -10,7 +10,7 @@ default: &default
development: development:
<<: *default <<: *default
database: redstoner-web database: redstoner-web
username: root username: web
production: production:
<<: *default <<: *default

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

View File

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

View File

@@ -4,11 +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 'index' get 'index'
end end
end end
@@ -22,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'
@@ -31,14 +29,20 @@ Redstoner::Application.routes.draw do
end end
end end
resources :memory do
collection do
get 'list'
get 'table'
post 'update_memory'
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

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

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

View File

@@ -1,10 +0,0 @@
class CreateBadgeassociations < ActiveRecord::Migration
def change
create_table :badgeassociations do |t|
t.references :badge
t.references :forum
t.references :forumgroup
t.integer :permission #1 = read, 2 = write
end
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: 20170703003647) do ActiveRecord::Schema.define(version: 20160926220738) 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"
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: 20170703003647) 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: 20170703003647) 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"
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"
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,8 +52,8 @@ ActiveRecord::Schema.define(version: 20170703003647) 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"
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
@@ -72,50 +64,44 @@ ActiveRecord::Schema.define(version: 20170703003647) 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"
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"
t.string "color", limit: 255 t.string "color"
end end
create_table "register_tokens", force: :cascade do |t| create_table "register_tokens", force: :cascade do |t|
t.string "uuid", limit: 32, null: false t.string "uuid", null: false
t.string "token", limit: 6, null: false t.string "token", null: false
t.string "email", limit: 191 t.string "email", 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"
t.integer "value", limit: 4 t.integer "value", limit: 4
t.string "color", limit: 255 t.string "color"
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", 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,23 +109,21 @@ ActiveRecord::Schema.define(version: 20170703003647) 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", null: false
t.string "name", limit: 191 t.string "name", null: false
t.string "password_digest", limit: 255, null: false t.string "password_digest", null: false
t.string "ign", limit: 255, null: false t.string "ign", null: false
t.string "email", limit: 191 t.string "email", null: false
t.text "about", limit: 65535 t.text "about", limit: 65535
t.string "last_ip", limit: 255 t.string "last_ip"
t.string "skype", limit: 255 t.string "skype"
t.boolean "skype_public", default: false t.boolean "skype_public", default: false
t.string "youtube", limit: 255 t.string "youtube"
t.string "youtube_channelname", limit: 255 t.string "youtube_channelname"
t.string "twitter", limit: 255 t.string "twitter"
t.string "email_token", limit: 255 t.boolean "donor", default: false
t.string "email_token"
t.boolean "confirmed", default: false t.boolean "confirmed", default: false
t.datetime "last_seen" t.datetime "last_seen"
t.integer "role_id", limit: 4, null: false t.integer "role_id", limit: 4, null: false
@@ -150,10 +134,6 @@ ActiveRecord::Schema.define(version: 20170703003647) 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
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,14 +23,19 @@ 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, 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)
)

View File

@@ -1,18 +0,0 @@
desc "Creates a superadmin user. Usage: rake create:create_admin_user[uuid, ign, email, pass]"
namespace :create do
task :create_admin_user, [:uuid, :ign, :email, :pass] => :environment do |task, args|
User.create!(
uuid: args.uuid,
ign: args.ign,
email: args.email,
password: args.pass,
password_confirmation: args.pass,
role: Role.get(:superadmin),
header_scroll: false,
utc_time: false,
dark: false,
badge: Badge.get(:none),
confirmed: true
)
end
end