diff --git a/app/assets/javascripts/cpanel/accounts.js.coffee b/app/assets/javascripts/cpanel/accounts.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/cpanel/accounts.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/cpanel/base.js.coffee b/app/assets/javascripts/cpanel/base.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/cpanel/base.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/cpanel/blogs.js.coffee b/app/assets/javascripts/cpanel/blogs.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/cpanel/blogs.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/cpanel/chats.js.coffee b/app/assets/javascripts/cpanel/chats.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/cpanel/chats.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/cpanel/home.js.coffee b/app/assets/javascripts/cpanel/home.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/cpanel/home.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/cpanel.css.scss b/app/assets/stylesheets/cpanel.css.scss new file mode 100644 index 0000000..65ca9b5 --- /dev/null +++ b/app/assets/stylesheets/cpanel.css.scss @@ -0,0 +1,256 @@ +/* + *= require twitter/bootstrap + *= require_tree ./sprites/ + *= require_self + */ +body { color: #333; } + +body, p, ol, ul, td { + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +pre { + background-color: #eee; + padding: 10px; + font-size: 11px; +} +.group { margin-bottom:20px; } +.group h2 { font-size:12px; margin-bottom:8px; } +.group ul { margin:0 20px;} +.pagination { clear:both; margin-top:10px; text-align: left;} + +table tr.deleted td { text-decoration: line-through; color:#999} + +html { + width: 100%; + height: 100%; + background:#eee image-url('bg.png') bottom left repeat; +} +body { background:none;} + +code { background:none; } + +.breadcrumb { color:#999;} + + +.container-fluid { padding:0; } +.container-fluid > .sidebar { + position:absolute; + left:auto; + right:0; + top:0; + width: 220px; +} + +.container-fluid > .content { + margin-left:0; + margin-right: 240px; +} + +fieldset { margin-bottom:0;} +fieldset legend { font-size:16px; font-weight:bold;} +.actions { margin-bottom:0;} +.buttons { margin-top:10px; } +form { + margin-bottom:0; + + .input { + > [class*="span"] { + float: left; + display: inline; + margin-right: 10px; + + input, textarea, select, .uneditable-input { + width: 100%; + } + input[type=checkbox], + input[type=radio], + input[type=button], + input[type=reset], + input[type=submit] { + width: auto; + } + } + } +} + +p.tips{ color:#f00; } + +.pagination { margin:0; margin-top:10px; } + +a.label:hover { text-decoration: none; color:#FFF;} + +.popover { + h3.title { + font-size:14px; padding:5px 8px; + i { float:right; font-size:12px; color:#999; font-style: normal;} + } + .content { padding:8px; font-size:12px; color:#666; } +} + +a[rel=userpopover] { + display: inline-block; +} + +.box { + background-color: #fff; + padding:10px; + margin: 0 0 20px 0; /* negative indent the amount of the padding to maintain the grid system */ + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; + -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.15); + -moz-box-shadow: 0 1px 2px rgba(0,0,0,.15); + box-shadow: 0 1px 2px rgba(0,0,0,.15); + h2.title { + margin:0 -10px; padding:0 10px; + font-size:14px; color:#999; line-height:100%; + border-bottom:1px solid #ddd; padding-bottom:8px; + } +} + + +.footer { + border-top:0; + min-width: 940px; + margin-bottom:30px; + margin-top:0px; + padding:0; + text-shadow: 0 1px 0 #fff; +} +.footer p { + margin:3px 0; + color: #555; +} +#main h1 { font-size:14px; line-height:26px; font-weight:bold; color:#333; margin-bottom:10px; } + +.topbar { position: static; margin-bottom:20px;} + +textarea.long { width:670px;} +textarea.span16 { width:910px;} +.input-xxlarge, input.xxlarge, textarea.xxlarge, select.xxlarge { width:520px;} + +div.field, div.actions { + margin-bottom: 10px; +} +div.field .hint { font-size:12px; color:#999;} + +.field_with_errors { + display:inline; + color:#b16125; +} + +.alert-message { margin-bottom:8px;} + +.secondary-nav .notifications a { + font-weight: bold; + padding: 11px 8px 10px; +} + +.secondary-nav .notifications a:hover { + background: #444; + background: rgba(255, 255, 255, 0.05); +} + +.secondary-nav .notifications a .count { + background-color: #666; + padding: 2px 6px; + border-radius: 2px; + color: #999; + -moz-border-radius: 2px; +} + +.secondary-nav .notifications.unread a .count { + background-color: #C43C35; + color: white; +} + +.icon { display:inline-block;} + + +.simple_form { + label.required { + abbr { color:#c00;} + } +} + +/* bootstrap puts .clearfix inside form, doesn't make much sense */ +.clearfix { + margin-bottom: 18px; + zoom: 1; + &:before, &:after { + display: table; + content: ""; + zoom: 1; + } + &:after { + clear: both; + } +} + +#error_page { + padding:60px; + h1 { font-size:600%; color:#aaa; margin-bottom:100px;} + p { font-size:16px; } +} + +#preview { + /* copied from twitter bootstrap */ + margin-top:0px; + border: 1px solid #ccc; + padding:4px; + min-height:400px; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; + #reply & { + width:578px; + margin-bottom:10px; + min-height:72px; + } +} + +.help-block ul { margin-bottom:0; } +.editor_toolbar { + position:relative; + margin-bottom:5px; + .icons { position:absolute; top:3px; right:0; } + .pills { + margin: 0; + list-style: none; + li { display:inline;} + a { + -moz-border-radius: 8px; + -webkit-border-radius: 8px; + border-radius: 8px; + padding:0 5px; + line-height:18px; + font-size:12px; + margin-right:6px; + text-shadow:0; + color:#444; + border:1px solid #fff; + } + a:hover { + background:#fff; + color:#00438A; + text-decoration: underline; + text-shadow:0; + } + .active { + a { + background:#fff; + border:1px solid #ddd; + color:#666; + text-shadow:0; + } + a:hover { text-decoration: none;} + } + } +} + + + +#post_upload_images { position:absolute;bottom:0;right:0;width:0;height:0;overflow:hidden; } \ No newline at end of file diff --git a/app/assets/stylesheets/search.css.scss b/app/assets/stylesheets/search.css.scss deleted file mode 100644 index 22fd394..0000000 --- a/app/assets/stylesheets/search.css.scss +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the search controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/cpanel/accounts_controller.rb b/app/controllers/cpanel/accounts_controller.rb new file mode 100644 index 0000000..0095e75 --- /dev/null +++ b/app/controllers/cpanel/accounts_controller.rb @@ -0,0 +1,5 @@ +class Cpanel::AccountsController < Cpanel::BaseController + def index + @items = Account.unscoped.desc(:_id).paginate :page => params[:page], :per_page => 100 + end +end diff --git a/app/controllers/cpanel/base_controller.rb b/app/controllers/cpanel/base_controller.rb new file mode 100644 index 0000000..7b04a0b --- /dev/null +++ b/app/controllers/cpanel/base_controller.rb @@ -0,0 +1,14 @@ +# coding: utf-8 +class Cpanel::BaseController < ApplicationController + layout "cpanel" + before_filter :require_admin + + protected + + def require_admin + authenticate_or_request_with_http_basic do |username, password| + username == "zoe" && password == "huodongrili" + end + end + +end diff --git a/app/controllers/cpanel/blogs_controller.rb b/app/controllers/cpanel/blogs_controller.rb new file mode 100644 index 0000000..45a82fd --- /dev/null +++ b/app/controllers/cpanel/blogs_controller.rb @@ -0,0 +1,6 @@ +class Cpanel::BlogsController < Cpanel::BaseController + def index + @blogs = Blog.unscoped.desc(:_id).paginate :page => params[:page], :per_page => 30 + end + +end diff --git a/app/controllers/cpanel/chats_controller.rb b/app/controllers/cpanel/chats_controller.rb new file mode 100644 index 0000000..f4f2eea --- /dev/null +++ b/app/controllers/cpanel/chats_controller.rb @@ -0,0 +1,4 @@ +class Cpanel::ChatsController < Cpanel::BaseController + def index + end +end diff --git a/app/controllers/cpanel/home_controller.rb b/app/controllers/cpanel/home_controller.rb new file mode 100644 index 0000000..811d2e2 --- /dev/null +++ b/app/controllers/cpanel/home_controller.rb @@ -0,0 +1,4 @@ +class Cpanel::HomeController < Cpanel::BaseController + def index + end +end diff --git a/app/helpers/cpanel/accounts_helper.rb b/app/helpers/cpanel/accounts_helper.rb new file mode 100644 index 0000000..79ffc62 --- /dev/null +++ b/app/helpers/cpanel/accounts_helper.rb @@ -0,0 +1,2 @@ +module Cpanel::AccountsHelper +end diff --git a/app/helpers/cpanel/base_helper.rb b/app/helpers/cpanel/base_helper.rb new file mode 100644 index 0000000..c7daeef --- /dev/null +++ b/app/helpers/cpanel/base_helper.rb @@ -0,0 +1,2 @@ +module Cpanel::BaseHelper +end diff --git a/app/helpers/cpanel/blogs_helper.rb b/app/helpers/cpanel/blogs_helper.rb new file mode 100644 index 0000000..7fc582c --- /dev/null +++ b/app/helpers/cpanel/blogs_helper.rb @@ -0,0 +1,2 @@ +module Cpanel::BlogsHelper +end diff --git a/app/helpers/cpanel/chats_helper.rb b/app/helpers/cpanel/chats_helper.rb new file mode 100644 index 0000000..843b281 --- /dev/null +++ b/app/helpers/cpanel/chats_helper.rb @@ -0,0 +1,2 @@ +module Cpanel::ChatsHelper +end diff --git a/app/helpers/cpanel/home_helper.rb b/app/helpers/cpanel/home_helper.rb new file mode 100644 index 0000000..f466a5d --- /dev/null +++ b/app/helpers/cpanel/home_helper.rb @@ -0,0 +1,2 @@ +module Cpanel::HomeHelper +end diff --git a/app/models/account.rb b/app/models/account.rb index 3021d89..3f92388 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -6,6 +6,8 @@ class Account include Mongoid::Document include Mongoid::Timestamps include Mongoid::BaseModel + include Mongoid::SoftDelete + extend OmniauthCallbacks diff --git a/app/views/blogs/index.html.erb b/app/views/blogs/index.html.erb index e624c68..6bed637 100644 --- a/app/views/blogs/index.html.erb +++ b/app/views/blogs/index.html.erb @@ -20,7 +20,7 @@
<%=link_to "编辑",edit_blog_path(blog.id)%>
<%end%>

- By: <%= raw blog.account.try(:username) %> + By: <%= raw blog.account.try(:username) %> Tag:<%=blog_tags_tag(blog)%>

diff --git a/app/views/cpanel/accounts/index.html.erb b/app/views/cpanel/accounts/index.html.erb new file mode 100644 index 0000000..64d0c20 --- /dev/null +++ b/app/views/cpanel/accounts/index.html.erb @@ -0,0 +1,31 @@ +<% content_for :sitemap do %> + 用户列表 +<% end %> +

用户列表

+ + + + + + + + + + + + +<% @items.each do |account| %> + "> + + + + + + + +<% end %> +
IDUsernameemailloginatState
<%= account.id %><%= truncate(account.username,:length => 30) %><%= account.email %><%= account.login %><%= account.created_at %> +
+<%= will_paginate @items %> + + \ No newline at end of file diff --git a/app/views/cpanel/blogs/index.html.erb b/app/views/cpanel/blogs/index.html.erb new file mode 100644 index 0000000..57a4522 --- /dev/null +++ b/app/views/cpanel/blogs/index.html.erb @@ -0,0 +1,2 @@ +

Cpanel::Blogs#index

+

Find me in app/views/cpanel/blogs/index.html.erb

diff --git a/app/views/cpanel/chats/index.html.erb b/app/views/cpanel/chats/index.html.erb new file mode 100644 index 0000000..2b13438 --- /dev/null +++ b/app/views/cpanel/chats/index.html.erb @@ -0,0 +1,2 @@ +

Cpanel::Chats#index

+

Find me in app/views/cpanel/chats/index.html.erb

diff --git a/app/views/cpanel/home/index.html.erb b/app/views/cpanel/home/index.html.erb new file mode 100644 index 0000000..0e39c58 --- /dev/null +++ b/app/views/cpanel/home/index.html.erb @@ -0,0 +1,2 @@ +

管理中心

+

这里是管理员的地盘,其他人不许进来~

diff --git a/app/views/layouts/cpanel.html.erb b/app/views/layouts/cpanel.html.erb index 0ae0665..51e9ce0 100644 --- a/app/views/layouts/cpanel.html.erb +++ b/app/views/layouts/cpanel.html.erb @@ -1,43 +1,37 @@ - RubyChina - Control Panel - " /> + Control Panel <%= stylesheet_link_tag "cpanel" %> - <%= javascript_include_tag "app" %> <%= csrf_meta_tag %> -
@@ -45,10 +39,18 @@ <%= yield %>
+ + + + + + \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index fce237d..4145c32 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,8 @@ Huodong::Application.routes.draw do + get "blogs/index" + get "chats/index" + get "accounts/index" + get "home/index" get "search/index" get "users/index" get "index/index" @@ -59,6 +63,29 @@ end end + + namespace :cpanel do + root :to => "home#index" + resources :blogs + resources :posts do + collection do + post :preview + end + end + + resources :chats + resources :accounts do + collection do + get :merge + post :merge + end + end + + + end + + + # Example of regular route: # get 'products/:id' => 'catalog#view' diff --git a/test/controllers/cpanel/accounts_controller_test.rb b/test/controllers/cpanel/accounts_controller_test.rb new file mode 100644 index 0000000..c11699b --- /dev/null +++ b/test/controllers/cpanel/accounts_controller_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class Cpanel::AccountsControllerTest < ActionController::TestCase + test "should get index" do + get :index + assert_response :success + end + +end diff --git a/test/controllers/cpanel/base_controller_test.rb b/test/controllers/cpanel/base_controller_test.rb new file mode 100644 index 0000000..d3c3895 --- /dev/null +++ b/test/controllers/cpanel/base_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class Cpanel::BaseControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/controllers/cpanel/blogs_controller_test.rb b/test/controllers/cpanel/blogs_controller_test.rb new file mode 100644 index 0000000..88e8158 --- /dev/null +++ b/test/controllers/cpanel/blogs_controller_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class Cpanel::BlogsControllerTest < ActionController::TestCase + test "should get index" do + get :index + assert_response :success + end + +end diff --git a/test/controllers/cpanel/chats_controller_test.rb b/test/controllers/cpanel/chats_controller_test.rb new file mode 100644 index 0000000..1f5bafc --- /dev/null +++ b/test/controllers/cpanel/chats_controller_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class Cpanel::ChatsControllerTest < ActionController::TestCase + test "should get index" do + get :index + assert_response :success + end + +end diff --git a/test/controllers/cpanel/home_controller_test.rb b/test/controllers/cpanel/home_controller_test.rb new file mode 100644 index 0000000..9838e2b --- /dev/null +++ b/test/controllers/cpanel/home_controller_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class Cpanel::HomeControllerTest < ActionController::TestCase + test "should get index" do + get :index + assert_response :success + end + +end diff --git a/test/helpers/cpanel/accounts_helper_test.rb b/test/helpers/cpanel/accounts_helper_test.rb new file mode 100644 index 0000000..835c303 --- /dev/null +++ b/test/helpers/cpanel/accounts_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class Cpanel::AccountsHelperTest < ActionView::TestCase +end diff --git a/test/helpers/cpanel/base_helper_test.rb b/test/helpers/cpanel/base_helper_test.rb new file mode 100644 index 0000000..4bb1eeb --- /dev/null +++ b/test/helpers/cpanel/base_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class Cpanel::BaseHelperTest < ActionView::TestCase +end diff --git a/test/helpers/cpanel/blogs_helper_test.rb b/test/helpers/cpanel/blogs_helper_test.rb new file mode 100644 index 0000000..50f3483 --- /dev/null +++ b/test/helpers/cpanel/blogs_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class Cpanel::BlogsHelperTest < ActionView::TestCase +end diff --git a/test/helpers/cpanel/chats_helper_test.rb b/test/helpers/cpanel/chats_helper_test.rb new file mode 100644 index 0000000..4dff521 --- /dev/null +++ b/test/helpers/cpanel/chats_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class Cpanel::ChatsHelperTest < ActionView::TestCase +end diff --git a/test/helpers/cpanel/home_helper_test.rb b/test/helpers/cpanel/home_helper_test.rb new file mode 100644 index 0000000..02ef553 --- /dev/null +++ b/test/helpers/cpanel/home_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class Cpanel::HomeHelperTest < ActionView::TestCase +end