This commit is contained in:
jomo
2013-10-09 22:06:36 +02:00
parent 292e1ae4bb
commit d4fb20d8c6
7 changed files with 77 additions and 18 deletions

View File

@@ -153,15 +153,24 @@ and (min-width: 1000px)
float: right; float: right;
} }
} }
h1 {
color: inherit !important;
font-weight: bold !important;
text-shadow: none !important;
}
.post-info { .post-info {
border-bottom: 2px dashed #999; border-bottom: 2px dashed #999;
color: #888; color: #888;
width: 100%;
a { a {
color: #755; color: #755;
&:hover{ &:hover {
color: #d55; color: #d55;
} }
} }
.post-edit {
float: right;
}
} }
.post-content { .post-content {
margin-top: 10px; margin-top: 10px;
@@ -409,9 +418,55 @@ and (min-width: 1000px)
background: #ddd; background: #ddd;
} }
table, tr, td, th {
border-collapse: collapse;
}
pre code { pre code {
background: inherit; background: inherit;
padding: 0; padding: 0;
} }
blockquote {
background: #f9f9f9;
border-left: 10px solid #ccc;
margin: 1.5em 10px;
padding: 0.5em 10px;
quotes: "\201C""\201D""\2018""\2019";
}
blockquote:before {
color: #ccc;
content: open-quote;
font-size: 4em;
line-height: 0.1em;
margin-right: 0.25em;
vertical-align: -0.4em;
}
blockquote p {
display: inline;
}
table {
tr, td, th {
border-collapse: collapse;
border: 1px solid #aaa;
}
tbody {
tr:nth-child(odd) {
background: #FFF;
}
tr:nth-child(even) {
background: #DDD
}
}
td, th {
padding: 0.3em;
}
thead {
background: #def;
}
}
} }

View File

@@ -50,7 +50,6 @@ class BlogpostsController < ApplicationController
redirect_to @post, notice: 'Post has been updated.' redirect_to @post, notice: 'Post has been updated.'
else else
flash[:alert] = "There was a problem while updating the post" flash[:alert] = "There was a problem while updating the post"
raise @post.errors
render action: "edit" render action: "edit"
end end
end end

View File

@@ -12,7 +12,13 @@ class SessionsController < ApplicationController
unless current_user unless current_user
user = User.find_by_email(params[:email]) user = User.find_by_email(params[:email])
if user && user.authenticate(params[:password]) if user && user.authenticate(params[:password])
user.last_ip = "#{request.remote_ip} | #{Resolv.getname(request.remote_ip)}" hostname = ""
begin
hostname = Resolv.getname(request.remote_ip)
rescue
hostname = ""
end
user.last_ip = "#{request.remote_ip} | #{hostname}"
user.last_login = Time.now user.last_login = Time.now
user.save user.save
if user.disabled? if user.disabled?
@@ -27,7 +33,7 @@ class SessionsController < ApplicationController
end end
else else
flash[:alert] = "You're doing it wrong!" flash[:alert] = "You're doing it wrong!"
redirect_to login_path render action: 'new'
end end
else else
redirect_to current_user redirect_to current_user

View File

@@ -104,14 +104,14 @@ require 'open-uri'
def update def update
@user = User.find(params[:id]) @user = User.find(params[:id])
if (mod? && current_user.role >= @user.role ) || (@user.is?(current_user) && confirmed?) if (mod? && current_user.role >= @user.role ) || (@user.is?(current_user) && confirmed?)
userdata = params[:user] ? params[:user].slice(:name, :ign, :role, :skype, :skype_public, :youtube, :twitter, :about, :password, :password_confirmation) : {} userdata = params[:user] ? params[:user].slice(:name, :ign, :role_id, :skype, :skype_public, :youtube, :twitter, :about, :password, :password_confirmation) : {}
if userdata[:role] if userdata[:role_id]
role = Role.find(userdata[:role]) role = Role.find(userdata[:role_id])
if (mod? && role <= current_user.role) if (mod? && role <= current_user.role)
userdata[:role] = role userdata[:role_id] = role.id
else else
#reset role #reset role
userdata[:role] = @user.role userdata[:role_id] = @user.role.id
end end
end end
unless userdata[:ign] && (mod? && current_user.role >= @user.role) unless userdata[:ign] && (mod? && current_user.role >= @user.role)
@@ -127,7 +127,6 @@ require 'open-uri'
if @user.update_attributes(userdata) if @user.update_attributes(userdata)
flash[:notice] = 'Profile updated.' flash[:notice] = 'Profile updated.'
else else
raise @user.errors.inspect
flash[:alert] = "There was a problem while updating the profile" flash[:alert] = "There was a problem while updating the profile"
render action: "edit" render action: "edit"
return return

View File

@@ -1,7 +1,7 @@
class User < ActiveRecord::Base class User < ActiveRecord::Base
include UsersHelper include UsersHelper
belongs_to :role belongs_to :role
attr_accessible :name, :password, :password_confirmation, :ign, :email, :confirm_code, :about, :last_ip, :skype, :skype_public, :youtube, :youtube_channelname, :twitter, :last_login, :role attr_accessible :name, :password, :password_confirmation, :ign, :email, :confirm_code, :about, :last_ip, :skype, :skype_public, :youtube, :youtube_channelname, :twitter, :last_login, :role, :role_id
has_secure_password has_secure_password

View File

@@ -7,11 +7,11 @@
<%= link_to pluralize(p.comments.count, "Comment"), p %> <%= link_to pluralize(p.comments.count, "Comment"), p %>
</span> </span>
</div> </div>
<span class="post-info"> <div class="post-info">
by <%= link_to p.author.name, p.author %> on <%= p.created_at.strftime("%e. %b %Y") %> by <%= link_to p.author.name, p.author %> on <%= p.created_at.strftime("%e. %b %Y") %>
</span> </div>
<div class="post-content"> <div class="post-content">
<%= GitHub::Markdown.render_gfm(Sanitize.clean(p.content, Sanitize::Config::RESTRICTED)).html_safe %> <%= Sanitize.clean(GitHub::Markdown.render_gfm(p.content), Sanitize::Config::RELAXED).html_safe %>
</div> </div>
</div> </div>
<% end %> <% end %>

View File

@@ -2,13 +2,13 @@
<div class="post-title"> <div class="post-title">
<h1><%= @post.title %></h1> <h1><%= @post.title %></h1>
</div> </div>
<span class="post-info"><%= link_to @post.author.name, @post.author %> on <%= @post.created_at.strftime("%e. %b %Y") %> <div class="post-info"><%= link_to @post.author.name, @post.author %> on <%= @post.created_at.strftime("%e. %b %Y") %>
<% if mod? %> <% if mod? %>
- <%= link_to "edit", edit_blogpost_path(@post.id) %> <%= link_to "edit", edit_blogpost_path(@post.id), class: "post-edit" %>
<% end %> <% end %>
</span> </div>
<div class="post-content"> <div class="post-content">
<%= GitHub::Markdown.render_gfm(Sanitize.clean(@post.content, Sanitize::Config::RESTRICTED)).html_safe %> <%= Sanitize.clean(GitHub::Markdown.render_gfm(@post.content), Sanitize::Config::RELAXED).html_safe %>
</div> </div>
<div id="comments"> <div id="comments">
<% @post.comments.each do |c| %> <% @post.comments.each do |c| %>