many things, comments working.
|
Before Width: | Height: | Size: 265 B |
BIN
app/assets/images/arrow-grey.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 283 B |
BIN
app/assets/images/arrow-red.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 580 B After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 6.5 KiB |
@@ -1,3 +0,0 @@
|
||||
// Place all the styles related to the Blogposts controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
@@ -1,3 +0,0 @@
|
||||
// Place all the styles related to the Comments controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
@@ -1,69 +0,0 @@
|
||||
body {
|
||||
background-color: #fff;
|
||||
color: #333;
|
||||
font-family: verdana, arial, helvetica, sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
p, ol, ul, td {
|
||||
font-family: verdana, arial, helvetica, sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
pre {
|
||||
background-color: #eee;
|
||||
padding: 10px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #000;
|
||||
&:visited {
|
||||
color: #666;
|
||||
}
|
||||
&:hover {
|
||||
color: #fff;
|
||||
background-color: #000;
|
||||
}
|
||||
}
|
||||
|
||||
div {
|
||||
&.field, &.actions {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
#notice {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.field_with_errors {
|
||||
padding: 2px;
|
||||
background-color: red;
|
||||
display: table;
|
||||
}
|
||||
|
||||
#error_explanation {
|
||||
width: 450px;
|
||||
border: 2px solid red;
|
||||
padding: 7px;
|
||||
padding-bottom: 0;
|
||||
margin-bottom: 20px;
|
||||
background-color: #f0f0f0;
|
||||
h2 {
|
||||
text-align: left;
|
||||
font-weight: bold;
|
||||
padding: 5px 5px 5px 15px;
|
||||
font-size: 12px;
|
||||
margin: -7px;
|
||||
margin-bottom: 0px;
|
||||
background-color: #c00;
|
||||
color: #fff;
|
||||
}
|
||||
ul li {
|
||||
font-size: 12px;
|
||||
list-style: square;
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,21 @@
|
||||
|
||||
|
||||
$lightgrey: #D1D1D1;
|
||||
$lightergrey: #959595;
|
||||
$midgrey: #787878;
|
||||
$darkgrey: #434343;
|
||||
$darkred: #AB0000;
|
||||
|
||||
|
||||
|
||||
@media only screen
|
||||
and (min-width: 1000px)
|
||||
{
|
||||
|
||||
html {
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
a {
|
||||
transition: color 0.25s;
|
||||
color: $darkred;
|
||||
@@ -19,17 +25,6 @@ and (min-width: 1000px)
|
||||
color: #F00;
|
||||
}
|
||||
}
|
||||
a.arrow {
|
||||
background: url('/assets/arrow-midgrey.png') no-repeat left;
|
||||
color: $midgrey;
|
||||
padding-left: 0.7em;
|
||||
margin: 0.6em;
|
||||
&:hover {
|
||||
background: url('/assets/arrow-darkred.png') no-repeat left;
|
||||
color: $darkred;
|
||||
padding-left: 0.7em;
|
||||
}
|
||||
}
|
||||
#notice {
|
||||
background: #8e8;
|
||||
text-align: center;
|
||||
@@ -54,7 +49,6 @@ and (min-width: 1000px)
|
||||
box-shadow: 0 0 2px;
|
||||
z-index: 99;
|
||||
position: relative;
|
||||
text-shadow: 1px 1px #555;
|
||||
#logo {
|
||||
margin: 9px;
|
||||
margin-left: 20px;
|
||||
@@ -88,10 +82,16 @@ and (min-width: 1000px)
|
||||
float: right;
|
||||
padding: 0 10px;
|
||||
margin-top: 6px;
|
||||
text-align: right;
|
||||
&.logged-out {
|
||||
margin-top: 2px;
|
||||
}
|
||||
img.avatar {
|
||||
border: 1px solid #000;
|
||||
border-radius: 16px;
|
||||
vertical-align: middle;
|
||||
height: 32px;
|
||||
width: 32px;
|
||||
&:hover {
|
||||
box-shadow: 0 0 2px;
|
||||
}
|
||||
@@ -107,7 +107,19 @@ and (min-width: 1000px)
|
||||
img.user-avatar {
|
||||
border: 1px solid #000;
|
||||
border-radius: 4px;
|
||||
height: 128px;
|
||||
width: 128px;
|
||||
}
|
||||
|
||||
img.avatar {
|
||||
image-rendering:optimizeSpeed;
|
||||
image-rendering:-moz-crisp-edges;
|
||||
image-rendering:-o-crisp-edges;
|
||||
image-rendering:optimize-contrast;
|
||||
image-rendering:-webkit-optimize-contrast;
|
||||
-ms-interpolation-mode: nearest-neighbor;
|
||||
}
|
||||
|
||||
span.no-about {
|
||||
color: #888;
|
||||
font-style: italic;
|
||||
@@ -165,6 +177,15 @@ and (min-width: 1000px)
|
||||
|
||||
#comments {
|
||||
margin: 50px 0 0 40px;
|
||||
.comment {
|
||||
margin-bottom: 12px;
|
||||
padding: 15px;
|
||||
box-shadow: 0 0 10px #bbb inset;
|
||||
&.author {
|
||||
background: #dadada;
|
||||
box-shadow: 0 0 10px #a7a7a7 inset;
|
||||
}
|
||||
}
|
||||
textarea {
|
||||
width: 480px;
|
||||
height: 106px;
|
||||
@@ -172,4 +193,77 @@ and (min-width: 1000px)
|
||||
}
|
||||
}
|
||||
|
||||
input {
|
||||
&[type=text], &[type=email], &[type=password] {
|
||||
border: 1px solid #aaa;
|
||||
border-radius: 3px;
|
||||
background: #eee;
|
||||
margin: 4px;
|
||||
box-shadow: 0 0 5px $lightgrey inset;
|
||||
height: 17px;
|
||||
width: 300px;
|
||||
padding: 1px 0;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
textarea {
|
||||
border: 1px solid #aaa;
|
||||
border-radius: 3px;
|
||||
background: #eee;
|
||||
margin: 4px;
|
||||
box-shadow: 0 0 5px $lightgrey inset;
|
||||
height: 300px;
|
||||
width: 300px;
|
||||
max-width: 100%;
|
||||
min-width: 300px;
|
||||
min-height: 50px;
|
||||
padding: 1px 0;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.field_with_errors {
|
||||
input {
|
||||
&[type=text], &[type=email], &[type=password] {
|
||||
border: 1px solid #f00;
|
||||
box-shadow: 0 0 5px #faa inset;
|
||||
}
|
||||
}
|
||||
.error {
|
||||
color: #f60;
|
||||
}
|
||||
}
|
||||
|
||||
#form_labels {
|
||||
text-align: right;
|
||||
float: left;
|
||||
label {
|
||||
display: block;
|
||||
padding: 0 0 4px 0;
|
||||
margin: 0 4px 4px;
|
||||
height: 17px;
|
||||
}
|
||||
}
|
||||
#form_inputs {
|
||||
|
||||
}
|
||||
|
||||
#edit_profile {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.btn-blue {
|
||||
border: 1px solid;
|
||||
padding: 6px;
|
||||
background: #4096ee;
|
||||
cursor: default;
|
||||
color: #fff;
|
||||
&:hover {
|
||||
box-shadow: 0 0 5px #095fb7 inset;
|
||||
color: #fff;
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery
|
||||
force_ssl
|
||||
require "Tools"
|
||||
# force_ssl
|
||||
helper :all
|
||||
include ToolsHelper
|
||||
helper_method :current_user
|
||||
|
||||
private
|
||||
def current_user
|
||||
@current_user ||= User.find(session[:user_id]) if session[:user_id]
|
||||
@current_user ||= User.find_by_id(session[:user_id])
|
||||
end
|
||||
helper_method :current_user
|
||||
end
|
||||
@@ -1,19 +1,14 @@
|
||||
class BlogpostsController < ApplicationController
|
||||
# GET /blogposts
|
||||
# GET /blogposts.json
|
||||
|
||||
def index
|
||||
@posts = Blogpost.all.reverse
|
||||
end
|
||||
|
||||
# GET /blogposts/1
|
||||
# GET /blogposts/1.json
|
||||
def show
|
||||
@post = Blogpost.find(params[:id])
|
||||
@comment = Comment.new(:blogpost_id => @post.id)
|
||||
@comment = Comment.new(:blogpost => @post)
|
||||
end
|
||||
|
||||
# GET /blogposts/new
|
||||
# GET /blogposts/new.json
|
||||
def new
|
||||
@post = Blogpost.new
|
||||
end
|
||||
@@ -26,6 +21,7 @@ class BlogpostsController < ApplicationController
|
||||
# POST /blogposts
|
||||
# POST /blogposts.json
|
||||
def create
|
||||
if current_user && current_user.rank >= rank_to_int("mod")
|
||||
@post = Blogpost.new(params[:blogpost])
|
||||
@post.user_id = current_user.id unless current_user.nil?
|
||||
if @post.save
|
||||
@@ -33,6 +29,10 @@ class BlogpostsController < ApplicationController
|
||||
else
|
||||
render action: "new"
|
||||
end
|
||||
else
|
||||
flash[:alert] = "You are not allowed to create new posts"
|
||||
redirect_to blog_path
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /blogposts/1
|
||||
@@ -53,6 +53,6 @@ class BlogpostsController < ApplicationController
|
||||
@post = Blogpost.find(params[:id])
|
||||
@post.destroy
|
||||
|
||||
redirect_to blogposts_url
|
||||
redirect_to blog_url
|
||||
end
|
||||
end
|
||||
|
||||
@@ -42,13 +42,12 @@ class CommentsController < ApplicationController
|
||||
def create
|
||||
@comment = Comment.new(params[:comment])
|
||||
@comment.user_id = current_user.id
|
||||
respond_to do |format|
|
||||
@comment.blogpost = Blogpost.find(params[:blogpost_id])
|
||||
if @comment.save
|
||||
format.html { redirect_to @comment, notice: 'Comment was successfully created.' }
|
||||
format.json { render json: @comment, status: :created, location: @comment }
|
||||
redirect_to @comment.blogpost, notice: 'Comment was successfully created.'
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @comment.errors, status: :unprocessable_entity }
|
||||
flash[:alert] = "There was a problem while saving your comment"
|
||||
redirect_to blogpost_path(params[:blogpost_id])
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -67,7 +66,6 @@ class CommentsController < ApplicationController
|
||||
format.json { render json: @comment.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /comments/1
|
||||
# DELETE /comments/1.json
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class ServercheckerController < ApplicationController
|
||||
def show
|
||||
require "Tools"
|
||||
if Tools.mc_running?
|
||||
|
||||
if mc_running?
|
||||
send_file "app/assets/images/on.png", :type => "image/png", :disposition => "inline"
|
||||
else
|
||||
send_file "app/assets/images/off.png", :type => "image/png", :disposition => "inline"
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
class SessionsController < ApplicationController
|
||||
|
||||
def new
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
user = User.find_by_email(params[:email])
|
||||
if user && user.authenticate(params[:password])
|
||||
user.last_ip = request.remote_ip
|
||||
user.last_login = Time.now
|
||||
user.save
|
||||
if user.banned
|
||||
flash[:alert] = "You are banned!"
|
||||
@@ -24,6 +20,6 @@ class SessionsController < ApplicationController
|
||||
|
||||
def destroy
|
||||
session[:user_id] = nil
|
||||
redirect_to root_path, :notice => "Logged out!"
|
||||
redirect_to login_path, :notice => "Logged out!"
|
||||
end
|
||||
end
|
||||
@@ -14,12 +14,22 @@ class UsersController < ApplicationController
|
||||
# GET /users/new
|
||||
# GET /users/new.json
|
||||
def new
|
||||
if current_user
|
||||
flash[:alert] = "You are already registered!"
|
||||
redirect_to user_path(current_user.id)
|
||||
else
|
||||
@user = User.new
|
||||
end
|
||||
end
|
||||
|
||||
# GET /users/1/edit
|
||||
def edit
|
||||
if current_user && (current_user.id = params[:id] || current_user.rank >= rank_to_int("mod"))
|
||||
@user = User.find(params[:id])
|
||||
else
|
||||
flash[:alert] = "You are not allwoed to edit this user"
|
||||
redirect_to user_path(params[:id])
|
||||
end
|
||||
end
|
||||
|
||||
# POST /users
|
||||
|
||||
2
app/helpers/tools_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module ToolsHelper
|
||||
end
|
||||
@@ -1,2 +1,39 @@
|
||||
module UsersHelper
|
||||
def avatar_url(user_id)
|
||||
u = User.find_by_id(user_id)
|
||||
u.nil? ? ign = :char : ign = u.ign
|
||||
return "https://minotar.net/avatar/#{ign}/8"
|
||||
end
|
||||
|
||||
def mc_running?
|
||||
host = "play.redstoner.com"
|
||||
port = 25565
|
||||
wait = 300/1000.0 #milliseconds, the .0 is required!!
|
||||
require 'timeout'
|
||||
require 'socket'
|
||||
r = false
|
||||
begin
|
||||
Timeout::timeout(wait) {
|
||||
TCPSocket.new host, port
|
||||
r = true
|
||||
}
|
||||
rescue Exception
|
||||
# could not connect to the server
|
||||
end
|
||||
return r
|
||||
end
|
||||
|
||||
def rank_to_int(rank)
|
||||
r = ranks[rank]
|
||||
end
|
||||
|
||||
def int_to_rank(int)
|
||||
r = ranks.rassoc(int)
|
||||
r.nil? ? "unknown" : r[0].to_s
|
||||
end
|
||||
|
||||
def ranks
|
||||
# Lower case !!!
|
||||
{"visitor" => 10, "member" => 20, "builder" => 30, "donor" => 40, "donor+" => 45, "mod" => 100, "admin" => 200, "superadmin" => 500}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,4 +3,5 @@ class Blogpost < ActiveRecord::Base
|
||||
validates_presence_of :title, :text, :user
|
||||
belongs_to :user
|
||||
has_many :comments
|
||||
accepts_nested_attributes_for :comments
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Comment < ActiveRecord::Base
|
||||
attr_accessible :text, :user_id, :blogpost_id
|
||||
attr_accessible :text, :user_id, :blogpost, :post
|
||||
validates_presence_of :text, :user_id, :blogpost_id
|
||||
belongs_to :blogpost
|
||||
belongs_to :user
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
class User < ActiveRecord::Base
|
||||
attr_accessible :name, :ign, :email, :about, :password, :password_confirmation
|
||||
attr_accessible :name, :ign, :email, :about, :password, :password_confirmation, :rank
|
||||
has_secure_password
|
||||
validates_presence_of :password, :on => :create
|
||||
validates_presence_of :password, :name, :email, :ign, :password_confirmation, :on => :create
|
||||
validates :email, :uniqueness => true
|
||||
validates :name, :uniqueness => true
|
||||
validates :ign, :uniqueness => true
|
||||
|
||||
has_many :blogposts
|
||||
has_many :comments
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<%= simple_form_for @post do |f|%>
|
||||
<%= f.input :title %>
|
||||
<%= f.input :text %>
|
||||
<%= f.submit %>
|
||||
<%= f.input :title, :label => false %>
|
||||
<%= f.input :text, :label => false %>
|
||||
<%= f.submit "Create Post" %>
|
||||
<% end %>
|
||||
@@ -2,10 +2,19 @@
|
||||
<div id="posts">
|
||||
<% @posts.each do |p| %>
|
||||
<div id="post">
|
||||
<div id="post-title"><h2><%= link_to p.title, p %></h2><span class="comment-counter"><%= link_to pluralize(p.comments.count, "Comment"), p %></span></div>
|
||||
<span class="post-info">by <%= link_to p.user.name, p.user %> on <%= p.created_at.strftime("%e. %b %Y") %></span>
|
||||
<div id="post-content"><%= RbbCode.new.convert(p.text).html_safe %></div>
|
||||
<div id="post-title">
|
||||
<h2><%= link_to p.title, p %></h2>
|
||||
<span class="comment-counter">
|
||||
<%= link_to pluralize(p.comments.count, "Comment"), p %>
|
||||
</span>
|
||||
</div>
|
||||
<span class="post-info">
|
||||
by <%= link_to p.user.name, p.user %> on <%= p.created_at.strftime("%e. %b %Y") %>
|
||||
</span>
|
||||
<div id="post-content">
|
||||
<%= RbbCode.new.convert(p.text).html_safe %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<%= link_to 'New Blogpost', new_blogpost_path if current_user && current_user.rank >= Tools.rank_to_int(:mod) %>
|
||||
<%= link_to 'Make new Post', new_blogpost_path if current_user && current_user.rank >= rank_to_int("mod") %>
|
||||
</div>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<h1>New Blogpost</h1>
|
||||
<h1>New Post</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<h1><%= @post.title %></h1>
|
||||
<span class="post-info"><%= link_to @post.user.name, @post.user %> on <%= @post.created_at.strftime("%e. %b %Y") %>
|
||||
<% if current_user.rank >= Tools.rank_to_int(:mod) %>
|
||||
<% if current_user && current_user.rank >= rank_to_int("mod") %>
|
||||
- <%= link_to "edit", edit_blogpost_path(@post.id) %>
|
||||
<% end %>
|
||||
</span>
|
||||
@@ -9,19 +9,20 @@
|
||||
</div>
|
||||
<div id="comments">
|
||||
<% @post.comments.each do |c| %>
|
||||
<div class="comment">
|
||||
<div class="comment <%= "author" if c.user == @post.user %>">
|
||||
<span class="comment-info"><%= link_to c.user.name, c.user %> on <%= c.created_at.strftime("%e. %b %Y") %>
|
||||
<% if current_user.rank >= Tools.rank_to_int(:mod) %>
|
||||
<% if current_user && current_user.rank >= rank_to_int("mod") %>
|
||||
- <%= link_to "edit", edit_blogpost_comment_path(c.id) %>
|
||||
<% end %>
|
||||
</span>
|
||||
<div class="comment-content"><%= c.text %></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if current_user && current_user.rank >= Tools.rank_to_int(:visitor) %>
|
||||
<% if current_user %>
|
||||
<h3>New comment</h3>
|
||||
<%= simple_form_for [@post, @comment] do |f| %>
|
||||
<%= f.input :text, :label => false, :as => "text", :placeholder => "Comment" %><%= f.submit %>
|
||||
<%= f.input :text, :label => false, :as => "text", :placeholder => "Comment" %>
|
||||
<%= f.submit %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -2,15 +2,16 @@
|
||||
<%= link_to(root_path) do %>
|
||||
<div id="logo"></div>
|
||||
<% end %>
|
||||
<div id="userinfo">
|
||||
<div id="userinfo" <%= "class=\"logged-out\"".html_safe if !current_user %>>
|
||||
<% if !current_user.nil? %>
|
||||
<span id="userinfo-box">
|
||||
<%= link_to current_user.name.truncate(14), current_user %><br/>
|
||||
<%= link_to image_tag("logout.png"), logout_path %>
|
||||
<%= link_to "Logout", logout_path %>
|
||||
</span>
|
||||
<%= link_to image_tag(Tools.avatar_url(current_user.id, 32), :class => "avatar"), current_user %>
|
||||
<%= link_to image_tag(avatar_url(current_user.id), :class => "avatar size32"), current_user %>
|
||||
<% else %>
|
||||
<%= link_to "Log in", login_path, :action => "new" %>
|
||||
<%= link_to "Log in", login_path, :action => "new" %><br/>
|
||||
<%= link_to "Register", register_path %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div id="menu">
|
||||
|
||||
|
Before Width: | Height: | Size: 6.5 KiB |
@@ -1,8 +1,14 @@
|
||||
<h1>Log in</h1>
|
||||
<%= form_tag login_path do |f| %>
|
||||
<%= label_tag :email %><br/>
|
||||
<%= text_field_tag :email %><br/>
|
||||
<%= label_tag :password %><br/>
|
||||
<%= password_field_tag :password %><br/>
|
||||
<%= submit_tag %>
|
||||
<div id="form_labels">
|
||||
<%= label_tag :email %>
|
||||
<%= label_tag :password %>
|
||||
</div>
|
||||
|
||||
<div id="form_inputs">
|
||||
<%= text_field_tag :email %>
|
||||
<%= password_field_tag :password %>
|
||||
</div>
|
||||
|
||||
<%= submit_tag "Log in" %>
|
||||
<% end %>
|
||||
@@ -1,8 +0,0 @@
|
||||
<%= simple_form_for @user do |f| %>
|
||||
<%= f.input :name %>
|
||||
<%= f.input :ign %>
|
||||
<%= f.input :email %>
|
||||
<%= f.input :password %>
|
||||
<%= f.input :password_confirmation %>
|
||||
<%= f.submit %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<h1>New user</h1>
|
||||
<h1>Register</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', users_path %>
|
||||
<%= simple_form_for @user do |f| %>
|
||||
<%= f.input :name %>
|
||||
<%= f.input :ign, label: "Ingame name" %>
|
||||
<%= f.input :email %>
|
||||
<%= f.input :password %>
|
||||
<%= f.input :password_confirmation %>
|
||||
<%= f.submit "Register" %>
|
||||
<% end %>
|
||||
@@ -1,10 +1,14 @@
|
||||
<div id="user-info"%>
|
||||
<%= image_tag Tools.avatar_url(@user.id, 128), :class => "user-avatar", :alt => "avatar" %><br/>
|
||||
<% if @user.banned %>
|
||||
<div id="user-info">
|
||||
<div id="edit_profile"><%= link_to "edit profile", edit_user_path(@user), :class => "btn-blue" %></div>
|
||||
<%= image_tag avatar_url(@user.id), :class => "user-avatar avatar", :alt => "avatar" %><br/>
|
||||
<% if @user.banned %>
|
||||
<span class="user-banned">This user is banned!</span>
|
||||
<% end %>
|
||||
IGN: <%= @user.ign %><br/>
|
||||
Rank: <%= Tools.int_to_rank(@user.rank) %><br/>
|
||||
Joined: <%= @user.created_at.strftime("%e. %b %Y") %><br/>
|
||||
Last IP: <%= @user.last_ip %><br/>
|
||||
About: <%= @user.about.blank? ? "<span class=\"no-about\">nothing</span>".html_safe : @user.about %>
|
||||
<% end %>
|
||||
IGN: <%= @user.ign %><br/>
|
||||
Rank: <%= int_to_rank(@user.rank) %><br/>
|
||||
Joined: <%= @user.created_at.strftime("%e. %b %Y") %><br/>
|
||||
<% if current_user && current_user.rank >= rank_to_int("mod") %>
|
||||
Last IP: <%= @user.last_ip %><br/>
|
||||
<% end %>
|
||||
About: <%= @user.about.blank? ? "<span class=\"no-about\">nothing</span>".html_safe : @user.about %>
|
||||
</div>
|
||||
142
config/initializers/simple_form.rb
Normal file
@@ -0,0 +1,142 @@
|
||||
# Use this setup block to configure all options available in SimpleForm.
|
||||
SimpleForm.setup do |config|
|
||||
# Wrappers are used by the form builder to generate a
|
||||
# complete input. You can remove any component from the
|
||||
# wrapper, change the order or even add your own to the
|
||||
# stack. The options given below are used to wrap the
|
||||
# whole input.
|
||||
config.wrappers :default, :class => :input,
|
||||
:hint_class => :field_with_hint, :error_class => :field_with_errors do |b|
|
||||
## Extensions enabled by default
|
||||
# Any of these extensions can be disabled for a
|
||||
# given input by passing: `f.input EXTENSION_NAME => false`.
|
||||
# You can make any of these extensions optional by
|
||||
# renaming `b.use` to `b.optional`.
|
||||
|
||||
# Determines whether to use HTML5 (:email, :url, ...)
|
||||
# and required attributes
|
||||
b.use :html5
|
||||
|
||||
# Calculates placeholders automatically from I18n
|
||||
# You can also pass a string as f.input :placeholder => "Placeholder"
|
||||
b.use :placeholder
|
||||
|
||||
## Optional extensions
|
||||
# They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
|
||||
# to the input. If so, they will retrieve the values from the model
|
||||
# if any exists. If you want to enable the lookup for any of those
|
||||
# extensions by default, you can change `b.optional` to `b.use`.
|
||||
|
||||
# Calculates maxlength from length validations for string inputs
|
||||
b.optional :maxlength
|
||||
|
||||
# Calculates pattern from format validations for string inputs
|
||||
b.optional :pattern
|
||||
|
||||
# Calculates min and max from length validations for numeric inputs
|
||||
b.optional :min_max
|
||||
|
||||
# Calculates readonly automatically from readonly attributes
|
||||
b.optional :readonly
|
||||
|
||||
## Inputs
|
||||
b.use :label_input
|
||||
b.use :hint, :wrap_with => { :tag => :span, :class => :hint }
|
||||
b.use :error, :wrap_with => { :tag => :span, :class => :error }
|
||||
end
|
||||
|
||||
# The default wrapper to be used by the FormBuilder.
|
||||
config.default_wrapper = :default
|
||||
|
||||
# Define the way to render check boxes / radio buttons with labels.
|
||||
# Defaults to :nested for bootstrap config.
|
||||
# :inline => input + label
|
||||
# :nested => label > input
|
||||
config.boolean_style = :nested
|
||||
|
||||
# Default class for buttons
|
||||
config.button_class = 'btn'
|
||||
|
||||
# Method used to tidy up errors. Specify any Rails Array method.
|
||||
# :first lists the first message for each field.
|
||||
# Use :to_sentence to list all errors for each field.
|
||||
# config.error_method = :first
|
||||
|
||||
# Default tag used for error notification helper.
|
||||
config.error_notification_tag = :div
|
||||
|
||||
# CSS class to add for error notification helper.
|
||||
config.error_notification_class = 'alert alert-error'
|
||||
|
||||
# ID to add for error notification helper.
|
||||
# config.error_notification_id = nil
|
||||
|
||||
# Series of attempts to detect a default label method for collection.
|
||||
# config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
|
||||
|
||||
# Series of attempts to detect a default value method for collection.
|
||||
# config.collection_value_methods = [ :id, :to_s ]
|
||||
|
||||
# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
|
||||
# config.collection_wrapper_tag = nil
|
||||
|
||||
# You can define the class to use on all collection wrappers. Defaulting to none.
|
||||
# config.collection_wrapper_class = nil
|
||||
|
||||
# You can wrap each item in a collection of radio/check boxes with a tag,
|
||||
# defaulting to :span. Please note that when using :boolean_style = :nested,
|
||||
# SimpleForm will force this option to be a label.
|
||||
# config.item_wrapper_tag = :span
|
||||
|
||||
# You can define a class to use in all item wrappers. Defaulting to none.
|
||||
# config.item_wrapper_class = nil
|
||||
|
||||
# How the label text should be generated altogether with the required text.
|
||||
# config.label_text = lambda { |label, required| "#{required} #{label}" }
|
||||
|
||||
# You can define the class to use on all labels. Default is nil.
|
||||
config.label_class = 'control-label'
|
||||
|
||||
# You can define the class to use on all forms. Default is simple_form.
|
||||
# config.form_class = :simple_form
|
||||
|
||||
# You can define which elements should obtain additional classes
|
||||
# config.generate_additional_classes_for = [:wrapper, :label, :input]
|
||||
|
||||
# Whether attributes are required by default (or not). Default is true.
|
||||
# config.required_by_default = true
|
||||
|
||||
# Tell browsers whether to use default HTML5 validations (novalidate option).
|
||||
# Default is enabled.
|
||||
config.browser_validations = false
|
||||
|
||||
# Collection of methods to detect if a file type was given.
|
||||
# config.file_methods = [ :mounted_as, :file?, :public_filename ]
|
||||
|
||||
# Custom mappings for input types. This should be a hash containing a regexp
|
||||
# to match as key, and the input type that will be used when the field name
|
||||
# matches the regexp as value.
|
||||
# config.input_mappings = { /count/ => :integer }
|
||||
|
||||
# Custom wrappers for input types. This should be a hash containing an input
|
||||
# type as key and the wrapper that will be used for all inputs with specified type.
|
||||
# config.wrapper_mappings = { :string => :prepend }
|
||||
|
||||
# Default priority for time_zone inputs.
|
||||
# config.time_zone_priority = nil
|
||||
|
||||
# Default priority for country inputs.
|
||||
# config.country_priority = nil
|
||||
|
||||
# Default size for text inputs.
|
||||
# config.default_input_size = 50
|
||||
|
||||
# When false, do not use translations for labels.
|
||||
# config.translate_labels = true
|
||||
|
||||
# Automatically discover new inputs in Rails' autoload path.
|
||||
# config.inputs_discovery = true
|
||||
|
||||
# Cache SimpleForm inputs discovery
|
||||
# config.cache_discovery = !Rails.env.development?
|
||||
end
|
||||
@@ -2,4 +2,7 @@
|
||||
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
||||
|
||||
en:
|
||||
hello: "Hello world"
|
||||
simple_form:
|
||||
required:
|
||||
text: 'required'
|
||||
mark: ''
|
||||
25
config/locales/simple_form.en.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
en:
|
||||
simple_form:
|
||||
"yes": 'Yes'
|
||||
"no": 'No'
|
||||
required:
|
||||
text: 'required'
|
||||
mark: ''
|
||||
# You can uncomment the line below if you need to overwrite the whole required html.
|
||||
# When using html, text and mark won't be used.
|
||||
html: ''
|
||||
error_notification:
|
||||
default_message: "Please fill out all required fields:"
|
||||
# Labels and hints examples
|
||||
# labels:
|
||||
# defaults:
|
||||
# password: 'Password'
|
||||
# user:
|
||||
# new:
|
||||
# email: 'E-mail to sign in.'
|
||||
# edit:
|
||||
# email: 'E-mail.'
|
||||
# hints:
|
||||
# defaults:
|
||||
# username: 'User name to sign in.'
|
||||
# password: 'No special characters, please.'
|
||||
@@ -6,9 +6,14 @@ Site::Application.routes.draw do
|
||||
resources :users
|
||||
|
||||
match '/serverstatus.png' => 'serverchecker#show'
|
||||
|
||||
get "logout" => 'sessions#destroy'
|
||||
get 'login' => 'sessions#new'
|
||||
get 'register' => 'users#new'
|
||||
post 'login' => 'sessions#create'
|
||||
|
||||
post 'paypal' => 'paypal#create'
|
||||
|
||||
|
||||
root :to => 'blogposts#index'
|
||||
end
|
||||
@@ -9,6 +9,10 @@ class CreateUsers < ActiveRecord::Migration
|
||||
t.text :about
|
||||
t.string :password_digest, :null => false
|
||||
t.string :last_ip
|
||||
t.string :skype
|
||||
t.boolean :skype_public, :default => false
|
||||
t.datetime :last_login
|
||||
t.datetime :last_active
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ class CreateBlogposts < ActiveRecord::Migration
|
||||
create_table :blogposts do |t|
|
||||
t.string :title
|
||||
t.text :text
|
||||
t.integer :user_id
|
||||
t.references :user
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ class CreateComments < ActiveRecord::Migration
|
||||
create_table :comments do |t|
|
||||
t.text :text
|
||||
t.integer :user_id
|
||||
t.integer :blogpost_id
|
||||
t.references :blogpost
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
@@ -38,6 +38,10 @@ ActiveRecord::Schema.define(:version => 20130526020734) do
|
||||
t.text "about"
|
||||
t.string "password_digest", :null => false
|
||||
t.string "last_ip"
|
||||
t.string "skype"
|
||||
t.boolean "skype_public", :default => false
|
||||
t.datetime "last_login"
|
||||
t.datetime "last_active"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
19
db/seeds.rb
@@ -1,4 +1,21 @@
|
||||
# This file should contain all the record creation needed to seed the database with its default values.
|
||||
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
||||
#
|
||||
User.create(name: "Redstone Sheep", ign: "noobkackboon", email: "theredstonesheep@gmail.com", about: "Hi, I am the admin :)", password: "123", password_confirmation: "123")
|
||||
User.create(
|
||||
name: "Redstone Sheep",
|
||||
ign: "noobkackboon",
|
||||
email: "theredstonesheep@gmail.com",
|
||||
about: "Hi, I am the admin :)",
|
||||
password: "123",
|
||||
password_confirmation: "123",
|
||||
rank: 500
|
||||
)
|
||||
User.create(
|
||||
name: "Tarkztor",
|
||||
ign: "TraksAG",
|
||||
email: "tacko@gmail.com",
|
||||
about: "Hi, I am another user :)",
|
||||
password: "123",
|
||||
password_confirmation: "123",
|
||||
rank: 10
|
||||
)
|
||||
39
lib/Tools.rb
@@ -1,39 +0,0 @@
|
||||
module Tools
|
||||
def Tools.avatar_url(user_id, size)
|
||||
u = User.find_by_id(user_id)
|
||||
u.nil? ? ign = :char : ign = u.ign
|
||||
return "https://minotar.net/avatar/#{ign}/#{size}"
|
||||
end
|
||||
|
||||
def Tools.mc_running?
|
||||
host = "play.redstoner.com"
|
||||
port = 25565
|
||||
wait = 300/1000.0 #milliseconds, the .0 is required!!
|
||||
require 'timeout'
|
||||
require 'socket'
|
||||
r = false
|
||||
begin
|
||||
Timeout::timeout(wait) {
|
||||
TCPSocket.new host, port
|
||||
r = true
|
||||
}
|
||||
rescue Exception
|
||||
# could not connect to the server
|
||||
end
|
||||
return r
|
||||
end
|
||||
|
||||
def Tools.rank_to_int(rank)
|
||||
r = Tools.ranks[rank]
|
||||
end
|
||||
|
||||
def Tools.int_to_rank(int)
|
||||
r = Tools.ranks.rassoc(int)
|
||||
r.nil? ? "unknown" : r[0].to_s
|
||||
end
|
||||
|
||||
def Tools.ranks
|
||||
# Lower case !!!
|
||||
{:visitor => 10, :member => 20, "member+" => 25, :builder => 30, :donor => 40, "donor+" => 45, :mod => 100, :admin => 200, :superadmin => 500}
|
||||
end
|
||||
end
|
||||
13
lib/templates/erb/scaffold/_form.html.erb
Normal file
@@ -0,0 +1,13 @@
|
||||
<%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
|
||||
<%%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%- attributes.each do |attribute| -%>
|
||||
<%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %>
|
||||
<%- end -%>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<%%= f.button :submit %>
|
||||
</div>
|
||||
<%% end %>
|
||||
7
test/functional/registration_mailer_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class RegistrationMailerTest < ActionMailer::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||