From 54b051a7e77c9d376019758739bf95173ee38533 Mon Sep 17 00:00:00 2001 From: Yuki Date: Fri, 24 Jul 2015 22:42:14 +0530 Subject: [PATCH] Temp. layout for testing --- app/controllers/user_controller.rb | 4 + app/views/layouts/application.html.haml | 24 +++--- app/views/moderation/_userbox.html.haml | 4 +- app/views/shared/_sidebar.html.haml | 4 +- app/views/shared/_userbox.html.haml | 4 +- app/views/user/theme.css.erb | 95 +++++++++++++++++++++ config/routes.rb | 1 + db/20150724154106_create_themes_table.rb | 6 ++ db/schema.rb | 101 +++++------------------ 9 files changed, 148 insertions(+), 95 deletions(-) create mode 100644 app/views/user/theme.css.erb create mode 100644 db/20150724154106_create_themes_table.rb diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 5e660905..98b602eb 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -91,4 +91,8 @@ class UserController < ApplicationController def data end + + def theme + render 'user/theme', formats: [:css], handlers: [:scss, :erb] + end end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index bb116be0..b113baf7 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -19,22 +19,24 @@ - if user_signed_in? - if current_user.mod? = javascript_include_tag 'moderation', 'data-turbolinks-track' => true + %link{rel: 'stylesheet', href: '/yuki/theme.css', media: :all, 'data-turbolinks-track' => true} = csrf_meta_tags - %body + %body#version1 = render 'layouts/header' = yield = render 'shared/locales' - if Rails.env.development? - %hr - .container - %p - Current branch: - %code= `git rev-parse --abbrev-ref HEAD` - (commit - = succeed ')' do - = `git rev-parse --short HEAD`.strip - %p.text-danger Debug params: - = debug params + #debug + %hr + .container + %p + Current branch: + %code= `git rev-parse --abbrev-ref HEAD` + (commit + = succeed ')' do + = `git rev-parse --short HEAD`.strip + %p.text-danger Debug params: + = debug params - if Rails.env.production? %noscript %p diff --git a/app/views/moderation/_userbox.html.haml b/app/views/moderation/_userbox.html.haml index 2ef0d465..b9cc793d 100644 --- a/app/views/moderation/_userbox.html.haml +++ b/app/views/moderation/_userbox.html.haml @@ -1,5 +1,7 @@ +- header_class = if user.profile_header.exists? then "userbox--header-container" else "userbox--no-header" end .panel.panel-default - %img.userbox--header{src: user.profile_header.url(:mobile)} + %div{class: header_class} + %img.userbox--header{src: user.profile_header.url(:mobile)} .panel-body %img.userbox--avatar{src: user.profile_picture.url(:small)} %p.userbox--username diff --git a/app/views/shared/_sidebar.html.haml b/app/views/shared/_sidebar.html.haml index 16d06cd0..7809a2fc 100644 --- a/app/views/shared/_sidebar.html.haml +++ b/app/views/shared/_sidebar.html.haml @@ -1,5 +1,7 @@ +- header_class = if current_user.profile_header.exists? then "userbox--header-container" else "userbox--no-header" end .panel.panel-default.hidden-xs - %img.userbox--header{src: current_user.profile_header.url(:mobile)} + %div{class: header_class} + %img.userbox--header{src: current_user.profile_header.url(:mobile)} .panel-body %img.userbox--avatar{src: current_user.profile_picture.url(:small)} %p.userbox--username diff --git a/app/views/shared/_userbox.html.haml b/app/views/shared/_userbox.html.haml index 56f171b8..c8826f90 100644 --- a/app/views/shared/_userbox.html.haml +++ b/app/views/shared/_userbox.html.haml @@ -1,6 +1,8 @@ - type ||= @type || :nil +- header_class = if user.profile_header.exists? then "userbox--header-container" else "userbox--no-header" end .panel.panel-default - %img.userbox--header{src: user.profile_header.url(:mobile)} + %div{class: header_class} + %img.userbox--header{src: user.profile_header.url(:mobile)} .panel-body %img.userbox--avatar{src: user.profile_picture.url(:small)} %p.userbox--username diff --git a/app/views/user/theme.css.erb b/app/views/user/theme.css.erb new file mode 100644 index 00000000..e625308c --- /dev/null +++ b/app/views/user/theme.css.erb @@ -0,0 +1,95 @@ +<% @primary_color ||= "#222" %> +<% @primary_border ||= "#151515" %> +<% @primary_text ||= "#eee" %> +<% @primary_link ||= "#666" %> +<% @primary_hover ||= "#222" %> +<% @secondary_color ||= "#333" %> +<% @secondary_border ||= "#111" %> +<% @secondary_text ||= "#eee" %> +<% @secondary_link ||= "#fff" %> +<% @background_color ||= "#555" %> +body#version1 { + background-color: <%= @background_color %>; +} + +body#version1 nav.navbar, body#version1 nav.navbar .dropdown-menu { + background-color: <%= @primary_color %>; + border-color: <%= @primary_border %>; +} + +body#version1 nav.navbar * { + color: <%= @primary_text %>; +} + +body#version1 .nav > li:not(.profile--image-dropdown):before { + background-color: <%= @primary_text %>; +} + +body#version1 a, body#version1 .dropdown-menu a { + color: <%= @primary_link %>; +} + +body#version1 .dropdown-menu .list-group-item-warning { + background-color: <%= @primary_border %>; +} + +body#version1 .dropdown-menu > li > a:hover, +body#version1 .dropdown-menu > li > a:focus, +body#version1 .list-group > a:hover, +body#version1 .list-group > a:focus, +body#version1 .list-group > a.active { + background-color: <%= @primary_border %>; + border-color: <%= @primary_border %>; + color: <%= @primary_text %>; +} + +body#version1 .btn { + color: <%= @primary_text %>; +} + +body#version1 .panel { + border-color: <%= @primary_border %>; + background-color: <%= @secondary_color %>; + color: <%= @primary_text %>; + box-shadow: none; +} + +body#version1 .list-group > a { + background-color: <%= @secondary_color %>; + border-color: <%= @secondary_border %>; +} + +body#version1 .locales, body .locales a { + color: <%= @primary_text %> !important; +} + +body#version1 .text-muted { + color: <%= @secondary_text %>; +} + +body#version1 .text-muted a { + color: <%= @secondary_link %>; +} + +body#version1 #profile--header.profile--no-header::before, body#version1 .userbox--no-header::before { + content: ""; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: <%= @primary_border %>; +} + +body#version1 .userbox--no-header, body#version1 .panel-body { + position: relative; +} + +body#version1 #profile--header.profile--no-header img, body#version1 .userbox--no-header img { + opacity: 0; +} + +body#version1 #debug { + background: white; + color: black; +} diff --git a/config/routes.rb b/config/routes.rb index eef8a30f..068a2c28 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -113,6 +113,7 @@ Rails.application.routes.draw do match '/:username(/p/:page)', to: 'user#show', via: 'get', as: :show_user_profile, defaults: {page: 1} match '/:username/a/:id', to: 'answer#show', via: 'get', as: :show_user_answer match '/:username/q/:id', to: 'question#show', via: 'get', as: :show_user_question + match '/:username/theme.css', to: 'user#theme', via: 'get', as: :show_user_theme match '/:username/followers(/p/:page)', to: 'user#followers', via: 'get', as: :show_user_followers, defaults: {page: 1} match '/:username/friends(/p/:page)', to: 'user#friends', via: 'get', as: :show_user_friends, defaults: {page: 1} match '/:username/groups(/p/:page)', to: 'user#groups', via: 'get', as: :show_user_groups, defaults: {page: 1} diff --git a/db/20150724154106_create_themes_table.rb b/db/20150724154106_create_themes_table.rb new file mode 100644 index 00000000..64ac0fd1 --- /dev/null +++ b/db/20150724154106_create_themes_table.rb @@ -0,0 +1,6 @@ +class CreateThemesTable < ActiveRecord::Migration + def change + create_table :themes do |t| + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 627cde56..13998567 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -19,12 +19,11 @@ ActiveRecord::Schema.define(version: 20150721154255) do create_table "answers", force: :cascade do |t| t.text "content" t.integer "question_id" - t.integer "comment_count", default: 0, null: false + t.integer "comment_count", default: 0, null: false t.integer "user_id" t.datetime "created_at" t.datetime "updated_at" - t.integer "smile_count", default: 0, null: false - t.boolean "nsfw", default: false + t.integer "smile_count", default: 0, null: false end add_index "answers", ["user_id", "created_at"], name: "index_answers_on_user_id_and_created_at", using: :btree @@ -114,60 +113,6 @@ ActiveRecord::Schema.define(version: 20150721154255) do t.datetime "updated_at" end - create_table "oauth_access_grants", force: :cascade do |t| - t.integer "resource_owner_id", null: false - t.integer "application_id", null: false - t.string "token", null: false - t.integer "expires_in", null: false - t.text "redirect_uri", null: false - t.datetime "created_at", null: false - t.datetime "revoked_at" - t.string "scopes" - end - - add_index "oauth_access_grants", ["token"], name: "index_oauth_access_grants_on_token", unique: true, using: :btree - - create_table "oauth_access_tokens", force: :cascade do |t| - t.integer "resource_owner_id" - t.integer "application_id" - t.string "token", null: false - t.string "refresh_token" - t.integer "expires_in" - t.datetime "revoked_at" - t.datetime "created_at", null: false - t.string "scopes" - end - - add_index "oauth_access_tokens", ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true, using: :btree - add_index "oauth_access_tokens", ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id", using: :btree - add_index "oauth_access_tokens", ["token"], name: "index_oauth_access_tokens_on_token", unique: true, using: :btree - - create_table "oauth_applications", force: :cascade do |t| - t.string "name", null: false - t.string "uid", null: false - t.string "secret", null: false - t.text "redirect_uri", null: false - t.string "scopes", default: "", null: false - t.datetime "created_at" - t.datetime "updated_at" - t.integer "owner_id" - t.string "owner_type" - t.string "description" - t.string "icon_file_name" - t.string "icon_content_type" - t.integer "icon_file_size" - t.datetime "icon_updated_at" - t.integer "crop_x" - t.integer "crop_y" - t.integer "crop_w" - t.integer "crop_h" - t.boolean "icon_processing" - end - - add_index "oauth_applications", ["name"], name: "index_oauth_applications_on_name", unique: true, using: :btree - add_index "oauth_applications", ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type", using: :btree - add_index "oauth_applications", ["uid"], name: "index_oauth_applications_on_uid", unique: true, using: :btree - create_table "questions", force: :cascade do |t| t.string "content" t.boolean "author_is_anonymous" @@ -176,8 +121,7 @@ ActiveRecord::Schema.define(version: 20150721154255) do t.integer "user_id" t.datetime "created_at" t.datetime "updated_at" - t.integer "answer_count", default: 0, null: false - t.boolean "nsfw", default: false + t.integer "answer_count", default: 0, null: false end add_index "questions", ["user_id", "created_at"], name: "index_questions_on_user_id_and_created_at", using: :btree @@ -234,12 +178,12 @@ ActiveRecord::Schema.define(version: 20150721154255) do end create_table "users", force: :cascade do |t| - t.string "email", default: "", null: false - t.string "encrypted_password", default: "", null: false + t.string "email", default: "", null: false + t.string "encrypted_password", default: "", null: false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0, null: false + t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" @@ -247,19 +191,19 @@ ActiveRecord::Schema.define(version: 20150721154255) do t.datetime "created_at" t.datetime "updated_at" t.string "screen_name" - t.integer "friend_count", default: 0, null: false - t.integer "follower_count", default: 0, null: false - t.integer "asked_count", default: 0, null: false - t.integer "answered_count", default: 0, null: false - t.integer "commented_count", default: 0, null: false + t.integer "friend_count", default: 0, null: false + t.integer "follower_count", default: 0, null: false + t.integer "asked_count", default: 0, null: false + t.integer "answered_count", default: 0, null: false + t.integer "commented_count", default: 0, null: false t.string "display_name" - t.integer "smiled_count", default: 0, null: false - t.boolean "admin", default: false, null: false - t.string "motivation_header", default: "", null: false - t.string "website", default: "", null: false - t.string "location", default: "", null: false - t.text "bio", default: "", null: false - t.boolean "moderator", default: false, null: false + t.integer "smiled_count", default: 0, null: false + t.boolean "admin", default: false, null: false + t.string "motivation_header", default: "", null: false + t.string "website", default: "", null: false + t.string "location", default: "", null: false + t.text "bio", default: "", null: false + t.boolean "moderator", default: false, null: false t.string "profile_picture_file_name" t.string "profile_picture_content_type" t.integer "profile_picture_file_size" @@ -276,13 +220,10 @@ ActiveRecord::Schema.define(version: 20150721154255) do t.boolean "privacy_show_in_search", default: true t.boolean "permanently_banned", default: false t.boolean "blogger", default: false - t.boolean "nsfw", default: false - t.boolean "show_nsfw", default: false - t.boolean "privacy_allow_nsfw_questions", default: true t.boolean "contributor", default: false t.string "ban_reason" t.datetime "banned_until" - t.integer "comment_smiled_count", default: 0, null: false + t.integer "comment_smiled_count", default: 0, null: false t.string "profile_header_file_name" t.string "profile_header_content_type" t.integer "profile_header_file_size" @@ -292,10 +233,8 @@ ActiveRecord::Schema.define(version: 20150721154255) do t.integer "crop_h_y" t.integer "crop_h_w" t.integer "crop_h_h" - t.string "socket_key", default: "" - t.datetime "socket_key_expiry", default: '0001-01-01 00:00:00' t.string "locale", default: "en" - t.boolean "translator" + t.boolean "translator", default: false t.string "confirmation_token" t.datetime "confirmed_at" t.datetime "confirmation_sent_at"