many tiny changes

This commit is contained in:
jomo
2013-06-25 02:53:12 +02:00
parent c5dfdbeb8f
commit ceb39bf0c3
22 changed files with 209 additions and 80 deletions

View File

@@ -13,3 +13,5 @@
//= #require jquery
//= #require jquery_ujs
//= #require_tree .
//= require jquery
//= require confirm

View File

@@ -1,3 +0,0 @@
# 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,3 +0,0 @@
# 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,6 @@
$(function(){
$('[data-confirm]').click(function(){
var c = confirm($(this).attr('data-confirm'));
if (!c) return false;
})
})

6
app/assets/javascripts/jquery.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

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

@@ -173,6 +173,9 @@ and (min-width: 1000px)
#post-content {
margin-top: 10px;
clear: both;
img {
max-width: 100%;
}
}
#comments {
@@ -181,10 +184,18 @@ and (min-width: 1000px)
margin-bottom: 12px;
padding: 15px;
box-shadow: 0 0 10px #bbb inset;
&:hover .editlink {
opacity: 1;
margin-right: 0;
}
&.author {
background: #dadada;
box-shadow: 0 0 10px #a7a7a7 inset;
}
.comment-content {
word-wrap: break-word;
overflow: hidden;
}
}
textarea {
width: 480px;
@@ -296,7 +307,24 @@ and (min-width: 1000px)
}
}
.editlink {
float: right;
opacity: 0;
margin-right: -10px;
transition: opacity 0.3s, margin 0.3s;
}
#edit_create_post {
float: left;
}
#delete_post {
float: right;
}
#blogpost_text {
width: 100%;
}

View File

@@ -64,6 +64,6 @@ class BlogpostsController < ApplicationController
else
flash[:alert] = "You are not allowed to delete this Post"
end
redirect_to blogpots_path
redirect_to blogposts_path
end
end

View File

@@ -3,7 +3,6 @@ class CommentsController < ApplicationController
def edit
@comment = Comment.find(params[:id])
if current_user && ((current_user.rank >= rank_to_int("mod") && current_user.rank.to_i >= @comment.user.rank.to_i) || (current_user == @comment.user))
@comment = Comment.find(params[:id])
session[:return_to] = blogpost_path(@comment.blogpost)
else
flash[:alert] = "You are not allowed to edit this comment"
@@ -19,7 +18,7 @@ class CommentsController < ApplicationController
if @comment.save
redirect_to @comment.blogpost, notice: 'Comment created!'
else
flash[:alert] = "There was a problem while saving your comment"
flash[:alert] = @comment.errors.full_messages.first
redirect_to blogpost_path(params[:blogpost_id])
end
end

View File

@@ -8,56 +8,70 @@ class UsersController < ApplicationController
@user = User.find(params[:id])
end
# GET /users/new
# GET /users/new.json
# REGISTER
def new
if current_user
flash[:alert] = "You are already registered!"
flash[:notice] = "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
@user = User.find(params[:id])
unless current_user && ((current_user.rank >= rank_to_int("mod") && current_user.rank.to_i >= @user.rank.to_i) || (current_user == @user) && @user.id != 1 )
flash[:alert] = "You are not allowed to edit this user"
redirect_to user_path(params[:id])
redirect_to user_path(@user)
end
end
# POST /users
# POST /users.json
def create
@user = User.new(params[:user])
@user.last_ip = request.remote_ip
if @user.save
redirect_to @user, notice: 'User was successfully created.'
if current_user
flash[:notice] = "You are already registered!"
redirect_to current_user
else
flash[:alert] = "Something went wrong"
render action: "new"
@user = User.new(params[:user])
@user.last_ip = request.remote_ip
if @user.save
session[:user_id] = @user.id
redirect_to @user, notice: 'Successfully registered!'
else
flash[:alert] = "Something went wrong"
render action: "new"
end
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.'
if (current_user && @user.id != 1) && ( (current_user.rank >= rank_to_int("mod") && current_user.rank.to_i >= @user.rank.to_i) || current_user == @user)
if @user.update_attributes(params[:user])
redirect_to @user, notice: 'User was successfully updated.'
else
flash[:alert] = "There was a problem while updating this user"
render action: "edit"
end
else
render action: "edit"
flash[:alert] = "You are not allowed to edit this user"
redirect_to @user
end
end
# DELETE /users/1
# DELETE /users/1.json
def destroy
@user = User.find(params[:id])
@user.destroy
redirect_to users_url
if (current_user && @user.id != 1) && (current_user.rank >= rank_to_int("superadmin") && current_user.rank.to_i >= @user.rank.to_i)
if @user.destroy
flash[:notice] = "User deleted forever."
redirect_to users_url
else
flash[:alert] = "Problem while deleting user"
redirect_to @user
end
else
flash[:alert] = "You are not allowed to delete this user"
redirect_to @user
end
end
end

View File

@@ -4,4 +4,12 @@ class Blogpost < ActiveRecord::Base
belongs_to :user
has_many :comments
accepts_nested_attributes_for :comments
def author
@author ||= if user.present?
user
else
User.find_by_name("Deleted user")
end
end
end

View File

@@ -1,6 +1,10 @@
class Comment < ActiveRecord::Base
attr_accessible :text, :user, :blogpost, :post
validates_presence_of :text, :user, :blogpost
validates_length_of :text, :in => 4..1000
belongs_to :blogpost
belongs_to :user
end

View File

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

View File

@@ -1,6 +1,10 @@
<h1>Editing blogpost</h1>
<h1>Edit post</h1>
<%= render 'form' %>
<%= link_to 'Show', @blogpost %> |
<%= link_to 'Back', blogposts_path %>
<%= simple_form_for @post do |f|%>
<%= f.input :title, :label => false %>
<%= f.input :text, :label => false %>
<%= f.submit "Update Post", :id => "edit_create_post" %>
<% end %>
<div id="delete_post">
<%= button_to "Delete post", @post, :method => "delete", :confirm => "Delete post forever?" %>
</div>

View File

@@ -1,3 +1,6 @@
<h1>New Post</h1>
<%= render 'form' %>
<%= simple_form_for @post do |f|%>
<%= f.input :title, :label => false %>
<%= f.input :text, :label => false'%>
<%= f.submit "Update Post", :id => "edit_create_post" %>
<% end %>

View File

@@ -1,5 +1,5 @@
<h1><%= @post.title %></h1>
<span class="post-info"><%= link_to @post.user.name, @post.user %> on <%= @post.created_at.strftime("%e. %b %Y") %>
<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 %>
@@ -9,20 +9,7 @@
</div>
<div id="comments">
<% @post.comments.each do |c| %>
<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 && current_user.rank >= rank_to_int("mod") %>
- <%= link_to "edit", edit_blogpost_comment_path(c.blogpost, c) %>
<% end %>
</span>
<div class="comment-content"><%= c.text %></div>
</div>
<% end %>
<% 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 %>
<% end %>
<%= render "comments/comment", :c => c %>
<% end %>
<%= render "comments/new" %>
</div>

View File

@@ -0,0 +1,8 @@
<div class="comment <%= "author" if c.user == @post.user %>">
<span class="comment-info"><%= link_to c.user.name, c.user %> <%= c.created_at.strftime("%e. %b %Y, %H:%m") %>
<% if current_user && ((current_user.rank >= rank_to_int("mod") && current_user.rank.to_i >= c.user.rank.to_i) || (current_user == c.user)) %>
<div class="editlink"><%= link_to "edit", edit_blogpost_comment_path(c.blogpost, c) %></div>
<% end %>
</span>
<div class="comment-content"><%= c.text %></div>
</div>

View File

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

View File

@@ -5,6 +5,7 @@
<%= stylesheet_link_tag "application", :media => "all" %>
<%= csrf_meta_tags %>
<%= favicon_link_tag "favicon.ico" %>
<%= javascript_include_tag "application" %>
</head>
<body>
<%= render "/layouts/head" %>

View File

@@ -1,8 +1,65 @@
# Sample localization file for English. Add more files in this directory for other locales.
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
en:
simple_form:
required:
text: 'required'
mark: ''
required:
text: 'required'
mark: ''
errors:
format: "%{message}"
activerecord:
errors:
models:
comment:
attributes:
text:
blank: "Comment can't be empty"
empty: "Comment can't be empty"
too_long: "Your comment is too long"
too_short: "Your comment is too short"
blogpost:
attributes:
text:
blank: "Post can't be empty"
user:
attributes:
ign:
blank: "IGN can't be empty"
# errors:
# accepted: must be accepted
# blank: can't be blank
# confirmation: doesn't match confirmation
# empty: can't be empty
# equal_to: must be equal to %{count}
# even: must be even
# exclusion: is reserved
# greater_than: must be greater than %{count}
# greater_than_or_equal_to: must be greater than or equal to %{count}
# inclusion: is not included in the list
# invalid: is invalid
# less_than: must be less than %{count}
# less_than_or_equal_to: must be less than or equal to %{count}
# not_a_number: is not a number
# not_an_integer: must be an integer
# odd: must be odd
# record_invalid: ! 'Validation failed: %{errors}'
# taken: has already been taken
# too_long:
# one: is too long (maximum is 1 character)
# other: is too long (maximum is %{count} characters)
# too_short:
# one: is too short (minimum is 1 character)
# other: is too short (minimum is %{count} characters)
# wrong_length:
# one: is the wrong length (should be 1 character)
# other: is the wrong length (should be %{count} characters)

View File

@@ -1,6 +1,24 @@
# 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).
#
deleted_user = User.new({
name: "Deleted user",
ign: "Steve",
email: "example@example.com",
about: "Hey, apparently, I do no longer exist. This is just a placeholder profile",
password: "D6^w,:A})@/y>@$18u%D2,_@Se{%>$=,14Nc>#Oz4.[eP$X0p'1fW'%=60H{7]i'H);<r:!'Zt$-X58])#!/l;)}=$@'2W>oX(epMK5B2>/l]t(!_T3p,,]e@Uh%]Vq%[~)_~$?=[6S#8%H&JOd#/#|PRH2/q?!]%(#1;6&_*u&%-+&G-dP*j,1x+@+.6]#6{H$]=I",
password_confirmation: "D6^w,:A})@/y>@$18u%D2,_@Se{%>$=,14Nc>#Oz4.[eP$X0p'1fW'%=60H{7]i'H);<r:!'Zt$-X58])#!/l;)}=$@'2W>oX(epMK5B2>/l]t(!_T3p,,]e@Uh%]Vq%[~)_~$?=[6S#8%H&JOd#/#|PRH2/q?!]%(#1;6&_*u&%-+&G-dP*j,1x+@+.6]#6{H$]=I",
rank: 10
})
deleted_user.update_attribute("skype", "echo123")
deleted_user.update_attribute("skype_public", true)
deleted_user.update_attribute("last_ip", "0.0.0.0")
deleted_user.update_attribute("last_login", Time.utc(0).to_datetime)
deleted_user.update_attribute("last_active", Time.utc(0).to_datetime)
deleted_user.update_attribute("created_at", Time.utc(0).to_datetime)
deleted_user.update_attribute("updated_at", Time.utc(0).to_datetime)
deleted_user.save
User.create(
name: "Redstone Sheep",
ign: "noobkackboon",
@@ -9,13 +27,4 @@ User.create(
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
)

BIN
video.mp4 Normal file

Binary file not shown.