fixes & forums started

This commit is contained in:
jomo
2013-08-02 07:55:32 +02:00
parent 45ebd0bd05
commit e052ad8859
39 changed files with 358 additions and 436 deletions

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1015 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -1,6 +1,9 @@
$(function(){
$('[data-confirm]').click(function(){
var c = confirm($(this).attr('data-confirm'));
if (!c) return false;
})
$('#flash').delay(3000).fadeOut('slow');
})

View File

@@ -10,8 +10,5 @@
// 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 confirm
//= require app

View File

@@ -17,6 +17,10 @@ and (min-width: 1000px)
overflow-y: scroll;
}
body {
background-image: url('/assets/bg.png');
}
a {
transition: color 0.25s;
color: $darkred;
@@ -25,67 +29,39 @@ and (min-width: 1000px)
color: #F00;
}
}
#notice {
background: #8e8;
#flash {
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;
position: fixed;
top: 0;
left: 0;
right: 0;
&.notice {
background: #8e8;
border-bottom: 3px dashed #8d8;
}
&.alert {
background: #ebb;
border-bottom: 3px dashed #fdd;
}
}
#head {
width: 100%;
height: 50px;
background: $lightgrey;
border-bottom: 10px solid $darkgrey;
vertical-align: middle;
font-weight: bold;
box-shadow: 0 0 2px;
z-index: 99;
position: relative;
width: 800px;
margin: -10px auto 20px auto;
padding: 20px 13px 13px 13px;
background-image: url('/assets/head_bg.png');
box-shadow: 0 0 10px -7px inset;
border-bottom: 1px solid #fff;
border-radius: 0 0 10px 10px;
overflow: hidden;
#logo {
margin: 9px;
margin-left: 20px;
height: 32px;
width: 32px;
float: left;
background: url('/assets/logo.png');
}
a {
color: $midgrey;
&:hover {
color: $darkred;
}
}
#menu {
margin: auto;
display: table;
ul {
float: left;
margin-top: 0;
li {
float: left;
height: 100%;
margin: auto 10px;
display: block;
font-size: 2.3em;
}
}
}
#userinfo {
float: right;
padding: 0 10px;
margin-top: 6px;
text-align: right;
&.logged-out {
margin-top: 2px;
}
margin-top: 14px;
img.avatar {
border: 1px solid #000;
border-radius: 16px;
@@ -103,6 +79,30 @@ and (min-width: 1000px)
line-height: 1em;
}
}
a {
color: $midgrey;
&:hover {
color: $darkred;
}
}
#menu {
width: 100%;
background: url('/assets/head_bg.png') #fff;
input {
display: inline;
}
ul {
float: left;
margin-top: 0;
li {
float: left;
height: 100%;
margin: auto 10px;
display: block;
font-size: 1.5em;
}
}
}
}
img.user-avatar {
border: 1px solid #000;
@@ -133,53 +133,50 @@ and (min-width: 1000px)
h1 {
font-weight: normal;
font-size: 400%;
font-size: 200%;
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 {
margin-bottom: 50px;
.post-title {
margin-bottom: 10px;
word-wrap: break-word;
h2 {
font-weight: normal;
color: #700;
text-transform: uppercase;
display: inline;
font-size: 200%;
}
.comment-counter {
float: right;
}
}
.post-info {
border-bottom: 2px dashed #999;
color: #888;
a {
color: #755;
&:hover{
color: #d55;
}
}
}
}
.post-info {
border-bottom: 2px dashed #999;
color: #888;
a {
color: #755;
&:hover{
color: #d55;
.post-content {
margin-top: 10px;
clear: both;
word-wrap: break-word;
overflow: hidden;
img {
max-width: 100%;
}
}
}
#post-content {
margin-top: 10px;
clear: both;
word-wrap: break-word;
overflow: hidden;
img {
max-width: 100%;
}
}
#comments {
margin: 50px 0 0 40px;
.comment {
@@ -350,8 +347,34 @@ and (min-width: 1000px)
width: 100%;
}
.clear {
clear: both;
display: block;
visibility: hidden;
}
#forum_groups {
.group {
margin: 10px 0;
.header {
background: #ddd;
border-radius: 5px 5px 0 0;
padding: 5px 10px;
border-bottom: 1px solid #ccc;
}
.forums {
border: 1px solid #ddd;
border-top: none;
border-bottom: none;
.forum {
display: block;
font-weight: bold;
padding: 5px 10px;
border-bottom: 1px solid #ddd;
}
}
}
}
}

View File

@@ -0,0 +1,6 @@
class ForumgroupsController < ApplicationController
def index
@groups = Forumgroup.all.sort{|s| s[:position]}
end
end

View File

@@ -0,0 +1,2 @@
class ForumsController < ApplicationController
end

View File

@@ -1,8 +1,9 @@
class SessionsController < ApplicationController
require 'resolv'
def create
user = User.find_by_email(params[:email])
if user && user.authenticate(params[:password])
user.last_ip = request.remote_ip
user.last_ip = "#{request.remote_ip} | #{Resolv.getname(request.remote_ip)}"
user.last_login = Time.now
user.save
if user.banned

View File

@@ -11,17 +11,17 @@ require 'open-uri'
end
def show
@user = User.find_by_id(params[:id])
@user = User.find(params[:id])
unless @user
flash[:alert] = "User ##{params[:id]} does not exist!"
flash[:alert] = "User \"#{params[:id]}\" does not exist!"
redirect_to User.find(1)
end
end
# REGISTER
# SIGNUP
def new
if current_user
flash[:notice] = "You are already registered!"
flash[:notice] = "You are already signed up!"
redirect_to user_path(current_user.id)
else
@user = User.new
@@ -38,7 +38,7 @@ require 'open-uri'
def create
if current_user
flash[:notice] = "You are already registered!"
flash[:notice] = "You are already signed up!"
redirect_to current_user
else
@user = User.new(params[:user])
@@ -56,7 +56,7 @@ require 'open-uri'
if mclogin.downcase.include?(data[:ign].downcase)
redirect_to "http://youareanidiot.org/"
else
redirect_to @user, notice: 'Successfully registered!'
redirect_to edit_user_path(@user), notice: 'Successfully signed up!'
end
else
flash[:alert] = "Something went wrong"

View File

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

View File

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

View File

@@ -34,6 +34,6 @@ module UsersHelper
def ranks
# Lower case !!!
{"default" => 10, "donor" => 40, "mod" => 100, "admin" => 200, "superadmin" => 500}
{"banned" => 1, "unconfirmed" => 5, "default" => 10, "donor" => 40, "mod" => 100, "admin" => 200, "superadmin" => 500}
end
end

3
app/models/forum.rb Normal file
View File

@@ -0,0 +1,3 @@
class Forum < ActiveRecord::Base
belongs_to :forumgroup
end

3
app/models/forumgroup.rb Normal file
View File

@@ -0,0 +1,3 @@
class Forumgroup < ActiveRecord::Base
has_many :forums
end

View File

@@ -2,7 +2,7 @@ class User < ActiveRecord::Base
attr_accessible :name, :ign, :email, :about, :password, :password_confirmation, :rank, :skype, :skype_public, :youtube, :youtube_channelname, :twitter
has_secure_password
validates_presence_of :password, :name, :email, :ign, :password_confirmation, :on => :create
validates :email, :uniqueness => true
validates :email, uniqueness: {case_sensitive: false}
validates :name, :uniqueness => true
validates :ign, :uniqueness => true

View File

@@ -1,9 +1,8 @@
<h1>Blog</h1>
<div id="posts">
<% @posts.each do |p| %>
<div id="post">
<div id="post-title">
<h2><%= link_to p.title, p %></h2>
<div class="post">
<div class="post-title">
<h2><%= link_to truncate(p.title, length: 60, omission: " …"), p %></h2>
<span class="comment-counter">
<%= link_to pluralize(p.comments.count, "Comment"), p %>
</span>
@@ -11,7 +10,7 @@
<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">
<div class="post-content">
<%= RbbCode.new.convert(p.text).html_safe %>
</div>
</div>

View File

@@ -1,15 +1,19 @@
<h1><%= @post.title %></h1>
<span class="post-info"><%= link_to @post.author.name, @post.author %> on <%= @post.created_at.strftime("%e. %b %Y") %>
<% if current_user && current_user.rank >= 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| %>
<%= render "comments/comment", :c => c %>
<% end %>
<%= render "comments/new" %>
<div class="post">
<div class="post-title">
<h1><%= @post.title %></h1>
</div>
<span class="post-info"><%= link_to @post.author.name, @post.author %> on <%= @post.created_at.strftime("%e. %b %Y") %>
<% if current_user && current_user.rank >= rank_to_int("mod") %>
- <%= link_to "edit", edit_blogpost_path(@post.id) %>
<% end %>
</span>
<div class="post-content">
<%= RbbCode.new.convert(@post.text).html_safe %>
</div>
<div id="comments">
<% @post.comments.each do |c| %>
<%= render "comments/comment", :c => c %>
<% end %>
<%= render "comments/new" %>
</div>
</div>

View File

@@ -4,5 +4,5 @@
<div class="editlink"><%= link_to "edit", edit_blogpost_comment_path(c.blogpost, c) %></div>
<% end %>
</span>
<div class="comment-content"><%= h(c.text).gsub("\n", "<br>").html_safe %></div>
<div class="comment-content"><%= h(c.text).gsub(/(\w*[\r\n]){3,}/, "\n\n").gsub("\n", "<br>").html_safe %></div>
</div>

View File

@@ -0,0 +1,18 @@
<div id="forum_groups">
<% @groups.each do |g| %>
<div class="group">
<div class="header">
<%= g.name %>
</div>
<div class="forums">
<% g.forums.sort{|s| s[:position]}.each do |f| %>
<div class="forum">
<%= f.name %>
</div>
<% end %>
</div>
</div>
<% end %>
</div>

View File

@@ -1,7 +1,5 @@
<div id="head">
<%= link_to(root_path) do %>
<div id="logo"><%= image_tag "logo" %></div>
<% end %>
<div id="logo"><%= image_tag "logo.png" %></div>
<div id="userinfo" <%= "class=\"logged-out\"".html_safe if !current_user %>>
<% if !current_user.nil? %>
<span id="userinfo-box">
@@ -10,16 +8,24 @@
</span>
<%= link_to image_tag(avatar_url(current_user.id, 32), :class => "avatar"), current_user %>
<% else %>
<%= link_to "Log in", login_path, :action => "new" %><br/>
<%= link_to "Register", register_path %>
<%= link_to "Log in", login_path, :action => "new" %> | <%= link_to "Sign up", signup_path %>
<% end %>
</div>
<div class="clear"></div>
<div id="menu">
<ul>
<li><%= link_to "BLOG", root_path, :class => "arrow" %></li>
<li><%= link_to "FORUM", nil, :class => "arrow" %></li>
<li><%= link_to "INFO", nil, :class => "arrow" %></li>
<li><%= link_to "DONATE", nil, :class => "arrow" %></li>
<li><%= link_to image_tag('icons/home.png'), root_path %></li>
<li>Info</li>
<%= link_to forums_path do %>
<li>Forums</li>
<% end %>
<li>Donate</li>
<li>
<%= simple_form_for "asdf", method: "get", action: users_path do |f| %>
<%= f.input :rank %>
<% end %>
</li>
</ul>
<div class="clear"></div>
</div>
</div>
</div>

View File

@@ -9,8 +9,8 @@
</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='flash' class='alert'>#{alert}</div>".html_safe if alert %>
<%= "<div id='flash' class='notice'>#{notice}</div>".html_safe if notice %>
<div id="main-content">
<%= yield %>
</div>

View File

@@ -3,6 +3,10 @@
<%= simple_form_for @user do |f| %>
<table>
<tbody>
<tr>
<td></td>
<td><%= image_tag avatar_url(@user.id, 128), :class => "user-avatar avatar", :alt => "avatar" %></td>
</tr>
<tr>
<td>Display name</td>
<td><%= f.input :name, :label => false %></td>

View File

@@ -12,33 +12,63 @@
</div>
<% end %>
<%= image_tag avatar_url(@user.id, 128), :class => "user-avatar avatar", :alt => "avatar" %><br>
<% if @user.banned %>
<% if @user.rank.to_i == rank_to_int("banned") %>
<span class="user-banned">This user is banned!</span>
<% end %>
IGN: <%= @user.ign %><br>
Rank: <%= link_to int_to_rank(@user.rank), users_path(:rank => int_to_rank(@user.rank)) %><br>
<% if current_user && @user.skype && (@user.skype_public || current_user == @user || mod?) %>
YouTube: <%= link_to @user.youtube_channelname, "https://youtube.com/user/#{CGI::escape(@user.youtube)}", :target => "_blank" if !@user.youtube.blank? %><br>
Twitter: <%= link_to @user.twitter, "https://twitter.com/#{CGI::escape(@user.twitter)}", :target => "_blank" if !@user.twitter.blank? %><br>
Skype: <a href="skype:<%= @user.skype %>?chat" target="_blank"><%= @user.skype %></a><br>
<% if @user.rank.to_i == rank_to_int("unconfirmed") %>
<span class="user-unconfirmed">This user hasn't confirmed his email yet!</span>
<% end %>
Joined: <%= @user.created_at.strftime("%e. %b %Y") %><br>
<% if mod? %>
<hr>
Last IP: <%= @user.last_ip %><br>
Email: <a href="mailto:<%= @user.email %>"><%= @user.email %></a><br>
Last login: <%= @user.last_login.strftime("%e. %b %Y, %H:%M") %>
<% end %>
<hr>
<%= @user.about.blank? ? "<span class=\"no-about\">nothing</span>".html_safe : @user.about.gsub("\n", "<br>").html_safe %>
<%= image_tag avatar_url(@user.id, 128), :class => "user-avatar avatar", :alt => "avatar" %>
<table>
<tbody>
<tr>
<td>IGN</td>
<td><%= @user.ign %></td>
</tr>
<tr>
<td>Rank</td>
<td><%= link_to int_to_rank(@user.rank), users_path(:rank => int_to_rank(@user.rank)) %></td>
</tr>
<% if current_user && !@user.skype.blank? && (@user.skype_public || current_user == @user || mod?) %>
<tr>
<td>Skype</td>
<td><a href="skype:<%= @user.skype %>?chat" target="_blank"><%= @user.skype %></a></td>
</tr>
<% end %>
<% if !@user.youtube.blank? && @user.youtube_channelname.blank? %>
<tr>
<td>YouTube</td>
<td><%= link_to @user.youtube_channelname, "https://youtube.com/user/#{CGI::escape(@user.youtube)}", :target => "_blank" %></td>
</tr>
<% end %>
<% if !@user.twitter.blank? %>
<tr>
<td>Twitter</td>
<td><%= link_to @user.twitter, "https://twitter.com/#{CGI::escape(@user.twitter)}", :target => "_blank" %></td>
</tr>
<% end %>
<tr>
<td>Joined</td>
<td><%= @user.created_at.strftime("%e. %b %Y") %></td>
</tr>
<% if mod? || current_user == @user %>
<tr>
<td>Last IP</td>
<td><%= @user.last_ip %></td>
</tr>
<tr>
<td>Email</td>
<td><%= mail_to @user.email, @user.email, :subject => "Redstoner" %></td>
</tr>
<tr>
<td>Last login</td>
<td><%= @user.last_login.strftime("%e. %b %Y, %H:%M") %></td>
</tr>
<% end %>
</tbody>
</table>
<hr>
<%= @user.about.blank? ? "<span class=\"no-about\">nothing</span>".html_safe : h(@user.about).gsub("\n", "<br>").html_safe %>
</div>