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

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