add dark solarized theme for code preview

This commit is contained in:
Dmitriy Zaporozhets 2013-03-15 15:09:34 +02:00
parent 7799b5bda6
commit 8cad1c9f4c
7 changed files with 107 additions and 6 deletions

View file

@ -37,6 +37,7 @@
@import "highlight/white.scss";
@import "highlight/dark.scss";
@import "highlight/solarized_dark.scss";
/**
* UI themes:

View file

@ -0,0 +1,77 @@
.solarized-dark .highlight {
pre {
background-color: #002B36;
color: #eee;
}
.hll { background-color: #ffffcc }
.c { color: #586E75 } /* Comment */
.err { color: #93A1A1 } /* Error */
.g { color: #93A1A1 } /* Generic */
.k { color: #859900 } /* Keyword */
.l { color: #93A1A1 } /* Literal */
.n { color: #93A1A1 } /* Name */
.o { color: #859900 } /* Operator */
.x { color: #CB4B16 } /* Other */
.p { color: #93A1A1 } /* Punctuation */
.cm { color: #586E75 } /* Comment.Multiline */
.cp { color: #859900 } /* Comment.Preproc */
.c1 { color: #586E75 } /* Comment.Single */
.cs { color: #859900 } /* Comment.Special */
.gd { color: #2AA198 } /* Generic.Deleted */
.ge { color: #93A1A1; font-style: italic } /* Generic.Emph */
.gr { color: #DC322F } /* Generic.Error */
.gh { color: #CB4B16 } /* Generic.Heading */
.gi { color: #859900 } /* Generic.Inserted */
.go { color: #93A1A1 } /* Generic.Output */
.gp { color: #93A1A1 } /* Generic.Prompt */
.gs { color: #93A1A1; font-weight: bold } /* Generic.Strong */
.gu { color: #CB4B16 } /* Generic.Subheading */
.gt { color: #93A1A1 } /* Generic.Traceback */
.kc { color: #CB4B16 } /* Keyword.Constant */
.kd { color: #268BD2 } /* Keyword.Declaration */
.kn { color: #859900 } /* Keyword.Namespace */
.kp { color: #859900 } /* Keyword.Pseudo */
.kr { color: #268BD2 } /* Keyword.Reserved */
.kt { color: #DC322F } /* Keyword.Type */
.ld { color: #93A1A1 } /* Literal.Date */
.m { color: #2AA198 } /* Literal.Number */
.s { color: #2AA198 } /* Literal.String */
.na { color: #93A1A1 } /* Name.Attribute */
.nb { color: #B58900 } /* Name.Builtin */
.nc { color: #268BD2 } /* Name.Class */
.no { color: #CB4B16 } /* Name.Constant */
.nd { color: #268BD2 } /* Name.Decorator */
.ni { color: #CB4B16 } /* Name.Entity */
.ne { color: #CB4B16 } /* Name.Exception */
.nf { color: #268BD2 } /* Name.Function */
.nl { color: #93A1A1 } /* Name.Label */
.nn { color: #93A1A1 } /* Name.Namespace */
.nx { color: #93A1A1 } /* Name.Other */
.py { color: #93A1A1 } /* Name.Property */
.nt { color: #268BD2 } /* Name.Tag */
.nv { color: #268BD2 } /* Name.Variable */
.ow { color: #859900 } /* Operator.Word */
.w { color: #93A1A1 } /* Text.Whitespace */
.mf { color: #2AA198 } /* Literal.Number.Float */
.mh { color: #2AA198 } /* Literal.Number.Hex */
.mi { color: #2AA198 } /* Literal.Number.Integer */
.mo { color: #2AA198 } /* Literal.Number.Oct */
.sb { color: #586E75 } /* Literal.String.Backtick */
.sc { color: #2AA198 } /* Literal.String.Char */
.sd { color: #93A1A1 } /* Literal.String.Doc */
.s2 { color: #2AA198 } /* Literal.String.Double */
.se { color: #CB4B16 } /* Literal.String.Escape */
.sh { color: #93A1A1 } /* Literal.String.Heredoc */
.si { color: #2AA198 } /* Literal.String.Interpol */
.sx { color: #2AA198 } /* Literal.String.Other */
.sr { color: #DC322F } /* Literal.String.Regex */
.s1 { color: #2AA198 } /* Literal.String.Single */
.ss { color: #2AA198 } /* Literal.String.Symbol */
.bp { color: #268BD2 } /* Name.Builtin.Pseudo */
.vc { color: #268BD2 } /* Name.Variable.Class */
.vg { color: #268BD2 } /* Name.Variable.Global */
.vi { color: #268BD2 } /* Name.Variable.Instance */
.il { color: #2AA198 } /* Literal.Number.Integer.Long */
}

View file

@ -128,7 +128,13 @@ module ApplicationHelper
end
def user_color_scheme_class
current_user.dark_scheme ? :black : :white
case current_user.color_scheme_id
when 1 then 'white'
when 2 then 'black'
when 3 then 'solarized-dark'
else
'white'
end
end
def show_last_push_widget?(event)

View file

@ -40,7 +40,7 @@ class User < ActiveRecord::Base
:recoverable, :rememberable, :trackable, :validatable, :omniauthable, :registerable
attr_accessible :email, :password, :password_confirmation, :remember_me, :bio, :name, :username,
:skype, :linkedin, :twitter, :dark_scheme, :theme_id, :force_random_password,
:skype, :linkedin, :twitter, :color_scheme_id, :theme_id, :force_random_password,
:extern_uid, :provider, as: [:default, :admin]
attr_accessible :projects_limit, :can_create_team, :can_create_group, as: :admin

View file

@ -43,10 +43,15 @@
= label_tag do
.prev
= image_tag "white.png"
= f.radio_button :dark_scheme, false
= f.radio_button :color_scheme_id, 1
White code preview
= label_tag do
.prev
= image_tag "dark.png"
= f.radio_button :dark_scheme, true
= f.radio_button :color_scheme_id, 2
Dark code preview
= label_tag do
.prev
= image_tag "dark.png"
= f.radio_button :color_scheme_id, 3
Solarized Dark code preview

View file

@ -0,0 +1,12 @@
class UserColorScheme < ActiveRecord::Migration
def up
add_column :users, :color_scheme_id, :integer, null: false, default: 1
User.where(dark_scheme: true).update_all(color_scheme_id: 2)
remove_column :users, :dark_scheme
end
def down
add_column :users, :dark_scheme, :boolean, null: false, default: false
remove_column :users, :color_scheme_id
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130304105317) do
ActiveRecord::Schema.define(:version => 20130315124931) do
create_table "events", :force => true do |t|
t.string "target_type"
@ -258,7 +258,6 @@ ActiveRecord::Schema.define(:version => 20130304105317) do
t.string "linkedin", :default => "", :null => false
t.string "twitter", :default => "", :null => false
t.string "authentication_token"
t.boolean "dark_scheme", :default => false, :null => false
t.integer "theme_id", :default => 1, :null => false
t.string "bio"
t.integer "failed_attempts", :default => 0
@ -269,6 +268,7 @@ ActiveRecord::Schema.define(:version => 20130304105317) do
t.boolean "can_create_group", :default => true, :null => false
t.boolean "can_create_team", :default => true, :null => false
t.string "state"
t.integer "color_scheme_id", :default => 1, :null => false
end
add_index "users", ["admin"], :name => "index_users_on_admin"