first release

This commit is contained in:
jomo
2013-05-31 22:26:22 +02:00
parent 149232ec0c
commit 8921d108e2
70 changed files with 1080 additions and 85 deletions

15
Gemfile
View File

@@ -6,7 +6,11 @@ gem 'rails', '3.2.12'
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
gem 'jquery-rails'
gem 'therubyracer'
gem 'bcrypt-ruby', '~> 3.0.0' # To use ActiveModel has_secure_password
gem 'simple_form'
gem 'rbbcode'
# Gems used only for assets and not required
# in production environments by default.
@@ -20,11 +24,10 @@ group :assets do
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'therubyracer'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
group :development do
gem 'better_errors'
gem 'binding_of_caller'
end
# To use Jbuilder templates for JSON
# gem 'jbuilder'

View File

@@ -29,7 +29,14 @@ GEM
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
bcrypt-ruby (3.0.1)
better_errors (0.7.2)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
binding_of_caller (0.7.1)
debug_inspector (>= 0.0.1)
builder (3.0.4)
coderay (1.0.9)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
@@ -37,6 +44,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.6.2)
debug_inspector (0.0.2)
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
@@ -54,6 +62,7 @@ GEM
treetop (~> 1.4.8)
mime-types (1.23)
multi_json (1.7.3)
nokogiri (1.5.9)
polyglot (0.3.3)
rack (1.4.5)
rack-cache (1.2)
@@ -78,14 +87,23 @@ GEM
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.0.4)
rbbcode (1.0.3)
sanitize
treetop
rdoc (3.12.2)
json (~> 1.4)
ref (1.0.4)
sanitize (2.0.3)
nokogiri (>= 1.4.4, < 1.6)
nokogiri (>= 1.4.4, < 1.6)
sass (3.2.9)
sass-rails (3.2.6)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
simple_form (2.1.0)
actionpack (~> 3.0)
activemodel (~> 3.0)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
@@ -109,10 +127,15 @@ PLATFORMS
ruby
DEPENDENCIES
bcrypt-ruby (~> 3.0.0)
better_errors
binding_of_caller
coffee-rails (~> 3.2.1)
jquery-rails
rails (= 3.2.12)
rbbcode
sass-rails (~> 3.2.3)
simple_form
sqlite3
therubyracer
uglifier (>= 1.0.3)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
app/assets/images/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 B

BIN
app/assets/images/off.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

BIN
app/assets/images/on.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@@ -10,6 +10,6 @@
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require_tree .
//= #require jquery
//= #require jquery_ujs
//= #require_tree .

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@@ -1,13 +1,6 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*/
*= require style.css
*= require screen.css
*= require mobi.css
*/

View File

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

View File

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

View File

@@ -0,0 +1,6 @@
/* CSS for Phones only */
@media only screen
and (max-width: 999px)
{
}

View File

@@ -0,0 +1,69 @@
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;
}
}

View File

@@ -0,0 +1,127 @@
/* CSS for PCs only */
@media only screen
and (min-width: 1000px)
{
a {
transition: color 0.25s;
color: #700;
text-decoration: none;
&:hover {
color: #F00;
}
}
#notice {
background: #8e8;
text-align: center;
padding: 10px;
border-bottom: 3px dashed #8d8;
font-weight: bold;
}
#alert {
background: #ebb;
text-align: center;
padding: 10px;
border-bottom: 3px dashed #fdd;
font-weight: bold;
}
#head {
width: 100%;
height: 40px;
background: #ccc;
border-bottom: 2px solid #aaa;
vertical-align: middle;
#logo {
margin: 4px;
margin-left: 20px;
height: 32px;
width: 32px;
float: left;
background: url('/assets/logo.png');
}
#userinfo {
float: right;
padding: 0 10px;
margin-top: 2px;
img.avatar {
border: 1px solid #000;
border-radius: 16px;
vertical-align: middle;
&:hover {
box-shadow: 0 0 2px;
}
}
}
}
img.user-avatar {
border: 1px solid #000;
border-radius: 4px;
}
span.no-about {
color: #888;
font-style: italic;
}
#main-content {
width: 650px;
margin: 0 auto;
background: #eee;
padding: 30px;
h1 {
font-weight: normal;
font-size: 400%;
margin: 0;
color: #888;
text-shadow: 0 1px #999;
}
}
#posts {
#post {
margin-bottom: 50px;
#post-title {
margin-bottom: 10px;
h2 {
font-weight: normal;
color: #700;
text-transform: uppercase;
display: inline;
font-size: 250%;
}
.comment-counter {
float: right;
}
}
}
}
.post-info {
border-bottom: 2px dashed #999;
color: #888;
a {
color: #755;
&:hover{
color: #d55;
}
}
}
#post-content {
margin-top: 10px;
clear: both;
}
#comments {
margin: 50px 0 0 40px;
textarea {
width: 480px;
height: 106px;
max-width: 610px;
}
}
}

View File

@@ -0,0 +1,9 @@
/* General CSS for all screens */
body {
margin: 0;
padding: 0;
font: 14px/1.6 "Open Sans","Lucida Sans","Lucida Grande","Lucida Sans Unicode",Calibri,sans-serif;
}
// use screen.css
// and mobi.css

View File

@@ -1,3 +1,10 @@
class ApplicationController < ActionController::Base
protect_from_forgery
force_ssl
require "Tools"
private
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
helper_method :current_user
end

View File

@@ -0,0 +1,58 @@
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)
end
# GET /blogposts/new
# GET /blogposts/new.json
def new
@post = Blogpost.new
end
# GET /blogposts/1/edit
def edit
@post = Blogpost.find(params[:id])
end
# POST /blogposts
# POST /blogposts.json
def create
@post = Blogpost.new(params[:blogpost])
@post.user_id = current_user.id unless current_user.nil?
if @post.save
redirect_to @post, notice: 'Post has been created.'
else
render action: "new"
end
end
# PUT /blogposts/1
# PUT /blogposts/1.json
def update
@post = Blogpost.find(params[:id])
if @post.update_attributes(params[:blogpost])
redirect_to @post, notice: 'Post has been updated.'
else
render action: "edit"
end
end
# DELETE /blogposts/1
# DELETE /blogposts/1.json
def destroy
@post = Blogpost.find(params[:id])
@post.destroy
redirect_to blogposts_url
end
end

View File

@@ -0,0 +1,83 @@
class CommentsController < ApplicationController
# GET /comments
# GET /comments.json
def index
@comments = Comment.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @comments }
end
end
# GET /comments/1
# GET /comments/1.json
def show
@comment = Comment.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @comment }
end
end
# GET /comments/new
# GET /comments/new.json
def new
@comment = Comment.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @comment }
end
end
# GET /comments/1/edit
def edit
@comment = Comment.find(params[:id])
end
# POST /comments
# POST /comments.json
def create
@comment = Comment.new(params[:comment])
@comment.user_id = current_user.id
respond_to do |format|
if @comment.save
format.html { redirect_to @comment, notice: 'Comment was successfully created.' }
format.json { render json: @comment, status: :created, location: @comment }
else
format.html { render action: "new" }
format.json { render json: @comment.errors, status: :unprocessable_entity }
end
end
end
# PUT /comments/1
# PUT /comments/1.json
def update
@comment = Comment.find(params[:id])
respond_to do |format|
if @comment.update_attributes(params[:comment])
format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @comment.errors, status: :unprocessable_entity }
end
end
end
# DELETE /comments/1
# DELETE /comments/1.json
def destroy
@comment = Comment.find(params[:id])
@comment.destroy
respond_to do |format|
format.html { redirect_to comments_url }
format.json { head :no_content }
end
end
end

View File

@@ -0,0 +1,35 @@
class PaypalController < ApplicationController
protect_from_forgery :except => [:create] #Otherwise the request from PayPal wouldn't make it to the controller
def create
puts request.raw_post
response = validate_IPN_notification(request.raw_post)
case response
when "VERIFIED"
# check that paymentStatus=Completed
# check that txnId has not been previously processed
# check that receiverEmail is your Primary PayPal email
# check that paymentAmount/paymentCurrency are correct
# process payment
when "INVALID"
# log for investigation
else
# error
end
render :nothing => true
end
protected
def validate_IPN_notification(raw)
uri = URI.parse('https://www.paypal.com/cgi-bin/webscr?cmd=_notify-validate')
http = Net::HTTP.new(uri.host, uri.port)
http.open_timeout = 60
http.read_timeout = 60
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.use_ssl = true
response = http.post(uri.request_uri, raw,
'Content-Length' => "#{raw.size}",
'User-Agent' => "Redstoner.com"
).body
end
end

View File

@@ -0,0 +1,10 @@
class ServercheckerController < ApplicationController
def show
require "Tools"
if Tools.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"
end
end
end

View File

@@ -0,0 +1,29 @@
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.save
if user.banned
flash[:alert] = "You are banned!"
redirect_to login_path
else
session[:user_id] = user.id
redirect_to root_path, :notice => "Logged in!"
end
else
flash[:alert] = "You're doing it wrong!"
redirect_to login_path
end
end
def destroy
session[:user_id] = nil
redirect_to root_path, :notice => "Logged out!"
end
end

View File

@@ -0,0 +1,54 @@
class UsersController < ApplicationController
# GET /users
# GET /users.json
def index
@users = User.all
end
# GET /users/1
# GET /users/1.json
def show
@user = User.find(params[:id])
end
# GET /users/new
# GET /users/new.json
def new
@user = User.new
end
# GET /users/1/edit
def edit
@user = User.find(params[:id])
end
# POST /users
# POST /users.json
def create
@user = User.new(params[:user])
if @user.save
redirect_to @user, notice: 'User was successfully created.'
else
render action: "new"
end
end
# PUT /users/1
# PUT /users/1.json
def update
@user = User.find(params[:id])
if @user.update_attributes(params[:user])
redirect_to @user, notice: 'User was successfully updated.'
else
render action: "edit"
end
end
# DELETE /users/1
# DELETE /users/1.json
def destroy
@user = User.find(params[:id])
@user.destroy
redirect_to users_url
end
end

View File

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

View File

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

View File

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

6
app/models/blogpost.rb Normal file
View File

@@ -0,0 +1,6 @@
class Blogpost < ActiveRecord::Base
attr_accessible :title, :text
validates_presence_of :title, :text, :user
belongs_to :user
has_many :comments
end

6
app/models/comment.rb Normal file
View File

@@ -0,0 +1,6 @@
class Comment < ActiveRecord::Base
attr_accessible :text, :user_id, :blogpost_id
validates_presence_of :text, :user_id, :blogpost_id
belongs_to :blogpost
belongs_to :user
end

8
app/models/user.rb Normal file
View File

@@ -0,0 +1,8 @@
class User < ActiveRecord::Base
attr_accessible :name, :ign, :email, :about, :password, :password_confirmation
has_secure_password
validates_presence_of :password, :on => :create
has_many :blogposts
has_many :comments
end

View File

@@ -0,0 +1,5 @@
<%= simple_form_for @post do |f|%>
<%= f.input :title %>
<%= f.input :text %>
<%= f.submit %>
<% end %>

View File

@@ -0,0 +1,6 @@
<h1>Editing blogpost</h1>
<%= render 'form' %>
<%= link_to 'Show', @blogpost %> |
<%= link_to 'Back', blogposts_path %>

View File

@@ -0,0 +1,11 @@
<h1>Blog</h1>
<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>
<% end %>
<%= link_to 'New Blogpost', new_blogpost_path if current_user && current_user.rank >= Tools.rank_to_int(:mod) %>
</div>

View File

@@ -0,0 +1,3 @@
<h1>New Blogpost</h1>
<%= render 'form' %>

View File

@@ -0,0 +1,27 @@
<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) %>
- <%= link_to "edit", edit_blogpost_path(@post.id) %>
<% end %>
</span>
<div id="post-content">
<%= RbbCode.new.convert(@post.text).html_safe %>
</div>
<div id="comments">
<% @post.comments.each do |c| %>
<div class="comment">
<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) %>
- <%= 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) %>
<h3>New comment</h3>
<%= simple_form_for [@post, @comment] do |f| %>
<%= f.input :text, :label => false, :as => "text", :placeholder => "Comment" %><%= f.submit %>
<% end %>
<% end %>
</div>

View File

@@ -0,0 +1,17 @@
<%= form_for(@comment) do |f| %>
<% if @comment.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@comment.errors.count, "error") %> prohibited this comment from being saved:</h2>
<ul>
<% @comment.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="actions">
<%= f.submit %>
</div>
<% end %>

View File

@@ -0,0 +1,6 @@
<h1>Editing comment</h1>
<%= render 'form' %>
<%= link_to 'Show', @comment %> |
<%= link_to 'Back', comments_path %>

View File

@@ -0,0 +1,21 @@
<h1>Listing comments</h1>
<table>
<tr>
<th></th>
<th></th>
<th></th>
</tr>
<% @comments.each do |comment| %>
<tr>
<td><%= link_to 'Show', comment %></td>
<td><%= link_to 'Edit', edit_comment_path(comment) %></td>
<td><%= link_to 'Destroy', comment, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New Comment', new_comment_path %>

View File

@@ -0,0 +1,5 @@
<h1>New comment</h1>
<%= render 'form' %>
<%= link_to 'Back', comments_path %>

View File

@@ -0,0 +1,5 @@
<p id="notice"><%= notice %></p>
<%= link_to 'Edit', edit_comment_path(@comment) %> |
<%= link_to 'Back', comments_path %>

View File

@@ -0,0 +1,13 @@
<div id="head">
<%= link_to(root_path) do %>
<div id="logo"></div>
<% end %>
<div id="userinfo">
<% if !current_user.nil? %>
<%= link_to image_tag(Tools.avatar_url(current_user.id, 32), :class => "avatar"), current_user %>
<%= link_to image_tag("logout.png"), logout_path %>
<% else %>
<%= link_to "Log in", login_path, :action => "new" %>
<% end %>
</div>
</div>

View File

@@ -1,14 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<title>Site</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<title>Redstoner</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= csrf_meta_tags %>
<%= favicon_link_tag "favicon.ico" %>
</head>
<body>
<%= render "/layouts/head" %>
<%= "<div id='alert'>#{alert}</div>".html_safe if alert %>
<%= "<div id='notice'>#{notice}</div>".html_safe if notice %>
<div id="main-content">
<%= yield %>
</div>
</body>
</html>
</html>

BIN
app/views/rails.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

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

View File

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

View File

@@ -0,0 +1,6 @@
<h1>Editing user</h1>
<%= render 'form' %>
<%= link_to 'Show', @user %> |
<%= link_to 'Back', users_path %>

View File

@@ -0,0 +1,4 @@
<h1>Listing users</h1>
<% @users.each do |u| %>
<%= link_to u.name, u %> (<%= u.ign %>)
<% end %>

View File

@@ -0,0 +1,5 @@
<h1>New user</h1>
<%= render 'form' %>
<%= link_to 'Back', users_path %>

View File

@@ -0,0 +1,10 @@
<div id="user-info"%>
<%= image_tag Tools.avatar_url(@user.id, 128), :class => "user-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 %>

View File

@@ -22,6 +22,18 @@ module Site
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# ******************************************************
#
# config.force_ssl = true
#
# ******************************************************
# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer

View File

@@ -1,58 +1,14 @@
Site::Application.routes.draw do
# The priority is based upon order of creation:
# first created -> highest priority.
# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action
resources :blogposts do
resources :comments
end
resources :users
# Sample of named route:
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
# This route can be invoked with purchase_url(:id => product.id)
# Sample resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Sample resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Sample resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Sample resource route with more complex sub-resources
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', :on => :collection
# end
# end
# Sample resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
# root :to => 'welcome#index'
# See how all your routes lay out with "rake routes"
# This is a legacy wild controller route that's not recommended for RESTful applications.
# Note: This route will make all actions in every controller accessible via GET requests.
# match ':controller(/:action(/:id))(.:format)'
end
match '/serverstatus.png' => 'serverchecker#show'
get "logout" => 'sessions#destroy'
get 'login' => 'sessions#new'
post 'login' => 'sessions#create'
post 'paypal' => 'paypal#create'
root :to => 'blogposts#index'
end

View File

@@ -0,0 +1,16 @@
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name, :unique => true, :null => false
t.string :ign, :unique => true, :null => false
t.integer :rank, :default => 10, :null => false
t.boolean :banned, :default => false
t.string :email, :unique => true, :null => false
t.text :about
t.string :password_digest, :null => false
t.string :last_ip
t.timestamps
end
end
end

View File

@@ -0,0 +1,11 @@
class CreateBlogposts < ActiveRecord::Migration
def change
create_table :blogposts do |t|
t.string :title
t.text :text
t.integer :user_id
t.timestamps
end
end
end

View File

@@ -0,0 +1,11 @@
class CreateComments < ActiveRecord::Migration
def change
create_table :comments do |t|
t.text :text
t.integer :user_id
t.integer :blogpost_id
t.timestamps
end
end
end

View File

@@ -11,6 +11,35 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 0) do
ActiveRecord::Schema.define(:version => 20130526020734) do
create_table "blogposts", :force => true do |t|
t.string "title"
t.text "text"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "comments", :force => true do |t|
t.text "text"
t.integer "user_id"
t.integer "blogpost_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "users", :force => true do |t|
t.string "name", :null => false
t.string "ign", :null => false
t.integer "rank", :default => 10, :null => false
t.boolean "banned", :default => false
t.string "email", :null => false
t.text "about"
t.string "password_digest", :null => false
t.string "last_ip"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
end

View File

@@ -1,7 +1,4 @@
# 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).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
User.create(name: "Redstone Sheep", ign: "noobkackboon", email: "theredstonesheep@gmail.com", about: "Hi, I am the admin :)", password: "123", password_confirmation: "123")

39
lib/Tools.rb Normal file
View File

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

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

11
test/fixtures/blogposts.yml vendored Normal file
View File

@@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
# This model initially had no columns defined. If you add columns to the
# model remove the '{}' from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
one: {}
# column: value
#
two: {}
# column: value

11
test/fixtures/comments.yml vendored Normal file
View File

@@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
# This model initially had no columns defined. If you add columns to the
# model remove the '{}' from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
one: {}
# column: value
#
two: {}
# column: value

11
test/fixtures/users.yml vendored Normal file
View File

@@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
# This model initially had no columns defined. If you add columns to the
# model remove the '{}' from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
one: {}
# column: value
#
two: {}
# column: value

View File

@@ -0,0 +1,49 @@
require 'test_helper'
class BlogpostsControllerTest < ActionController::TestCase
setup do
@blogpost = blogposts(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:blogposts)
end
test "should get new" do
get :new
assert_response :success
end
test "should create blogpost" do
assert_difference('Blogpost.count') do
post :create, blogpost: { }
end
assert_redirected_to blogpost_path(assigns(:blogpost))
end
test "should show blogpost" do
get :show, id: @blogpost
assert_response :success
end
test "should get edit" do
get :edit, id: @blogpost
assert_response :success
end
test "should update blogpost" do
put :update, id: @blogpost, blogpost: { }
assert_redirected_to blogpost_path(assigns(:blogpost))
end
test "should destroy blogpost" do
assert_difference('Blogpost.count', -1) do
delete :destroy, id: @blogpost
end
assert_redirected_to blogposts_path
end
end

View File

@@ -0,0 +1,49 @@
require 'test_helper'
class CommentsControllerTest < ActionController::TestCase
setup do
@comment = comments(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:comments)
end
test "should get new" do
get :new
assert_response :success
end
test "should create comment" do
assert_difference('Comment.count') do
post :create, comment: { }
end
assert_redirected_to comment_path(assigns(:comment))
end
test "should show comment" do
get :show, id: @comment
assert_response :success
end
test "should get edit" do
get :edit, id: @comment
assert_response :success
end
test "should update comment" do
put :update, id: @comment, comment: { }
assert_redirected_to comment_path(assigns(:comment))
end
test "should destroy comment" do
assert_difference('Comment.count', -1) do
delete :destroy, id: @comment
end
assert_redirected_to comments_path
end
end

View File

@@ -0,0 +1,49 @@
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
setup do
@user = users(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:users)
end
test "should get new" do
get :new
assert_response :success
end
test "should create user" do
assert_difference('User.count') do
post :create, user: { }
end
assert_redirected_to user_path(assigns(:user))
end
test "should show user" do
get :show, id: @user
assert_response :success
end
test "should get edit" do
get :edit, id: @user
assert_response :success
end
test "should update user" do
put :update, id: @user, user: { }
assert_redirected_to user_path(assigns(:user))
end
test "should destroy user" do
assert_difference('User.count', -1) do
delete :destroy, id: @user
end
assert_redirected_to users_path
end
end

View File

@@ -0,0 +1,7 @@
require 'test_helper'
class BlogpostTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@@ -0,0 +1,7 @@
require 'test_helper'
class CommentTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@@ -0,0 +1,4 @@
require 'test_helper'
class BlogpostsHelperTest < ActionView::TestCase
end

View File

@@ -0,0 +1,4 @@
require 'test_helper'
class CommentsHelperTest < ActionView::TestCase
end

View File

@@ -0,0 +1,4 @@
require 'test_helper'
class UsersHelperTest < ActionView::TestCase
end

7
test/unit/user_test.rb Normal file
View File

@@ -0,0 +1,7 @@
require 'test_helper'
class UserTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end