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;
}
}
h1 {
color: inherit !important;
font-weight: bold !important;
text-shadow: none !important;
}
.post-info {
border-bottom: 2px dashed #999;
color: #888;
width: 100%;
a {
color: #755;
&:hover{
&:hover {
color: #d55;
}
}
.post-edit {
float: right;
}
}
.post-content {
margin-top: 10px;
@@ -409,9 +418,55 @@ and (min-width: 1000px)
background: #ddd;
}
table, tr, td, th {
border-collapse: collapse;
}
pre code {
background: inherit;
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.'
else
flash[:alert] = "There was a problem while updating the post"
raise @post.errors
render action: "edit"
end
end

View File

@@ -12,7 +12,13 @@ class SessionsController < ApplicationController
unless current_user
user = User.find_by_email(params[:email])
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.save
if user.disabled?
@@ -27,7 +33,7 @@ class SessionsController < ApplicationController
end
else
flash[:alert] = "You're doing it wrong!"
redirect_to login_path
render action: 'new'
end
else
redirect_to current_user

View File

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

View File

@@ -1,7 +1,7 @@
class User < ActiveRecord::Base
include UsersHelper
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

View File

@@ -7,11 +7,11 @@
<%= link_to pluralize(p.comments.count, "Comment"), p %>
</span>
</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") %>
</span>
</div>
<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>
<% end %>

View File

@@ -2,13 +2,13 @@
<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") %>
<div class="post-info"><%= link_to @post.author.name, @post.author %> on <%= @post.created_at.strftime("%e. %b %Y") %>
<% if mod? %>
- <%= link_to "edit", edit_blogpost_path(@post.id) %>
<%= link_to "edit", edit_blogpost_path(@post.id), class: "post-edit" %>
<% end %>
</span>
</div>
<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 id="comments">
<% @post.comments.each do |c| %>