diff --git a/app/assets/stylesheets/screen.css.scss b/app/assets/stylesheets/screen.css.scss index d2bab1d..63a5661 100644 --- a/app/assets/stylesheets/screen.css.scss +++ b/app/assets/stylesheets/screen.css.scss @@ -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; + } + } + } \ No newline at end of file diff --git a/app/controllers/blogposts_controller.rb b/app/controllers/blogposts_controller.rb index d3a0bde..9d5077f 100644 --- a/app/controllers/blogposts_controller.rb +++ b/app/controllers/blogposts_controller.rb @@ -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 diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 3c12df4..d1c714c 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -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 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 44e2e7f..88b6b42 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 980e5f1..7802a79 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/app/views/blogposts/index.html.erb b/app/views/blogposts/index.html.erb index b0e0e1a..5997e4f 100644 --- a/app/views/blogposts/index.html.erb +++ b/app/views/blogposts/index.html.erb @@ -7,11 +7,11 @@ <%= link_to pluralize(p.comments.count, "Comment"), p %> - +
by <%= link_to p.author.name, p.author %> on <%= p.created_at.strftime("%e. %b %Y") %> - +
- <%= 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 %>
<% end %> diff --git a/app/views/blogposts/show.html.erb b/app/views/blogposts/show.html.erb index 6aec547..6fd6fb6 100644 --- a/app/views/blogposts/show.html.erb +++ b/app/views/blogposts/show.html.erb @@ -2,13 +2,13 @@

<%= @post.title %>

- <%= link_to @post.author.name, @post.author %> on <%= @post.created_at.strftime("%e. %b %Y") %> +
- <%= 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 %>
<% @post.comments.each do |c| %>