Skip to content

Commit

Permalink
add cpanels
Browse files Browse the repository at this point in the history
  • Loading branch information
IceskYsl committed Nov 7, 2013
1 parent 81a3730 commit e9a14c5
Show file tree
Hide file tree
Showing 35 changed files with 472 additions and 30 deletions.
3 changes: 3 additions & 0 deletions app/assets/javascripts/cpanel/accounts.js.coffee
Original file line number Diff line number Diff line change
@@ -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/
3 changes: 3 additions & 0 deletions app/assets/javascripts/cpanel/base.js.coffee
Original file line number Diff line number Diff line change
@@ -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/
3 changes: 3 additions & 0 deletions app/assets/javascripts/cpanel/blogs.js.coffee
Original file line number Diff line number Diff line change
@@ -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/
3 changes: 3 additions & 0 deletions app/assets/javascripts/cpanel/chats.js.coffee
Original file line number Diff line number Diff line change
@@ -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/
3 changes: 3 additions & 0 deletions app/assets/javascripts/cpanel/home.js.coffee
Original file line number Diff line number Diff line change
@@ -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/
256 changes: 256 additions & 0 deletions app/assets/stylesheets/cpanel.css.scss
Original file line number Diff line number Diff line change
@@ -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; }
3 changes: 0 additions & 3 deletions app/assets/stylesheets/search.css.scss

This file was deleted.

5 changes: 5 additions & 0 deletions app/controllers/cpanel/accounts_controller.rb
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions app/controllers/cpanel/base_controller.rb
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions app/controllers/cpanel/blogs_controller.rb
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions app/controllers/cpanel/chats_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Cpanel::ChatsController < Cpanel::BaseController
def index
end
end
4 changes: 4 additions & 0 deletions app/controllers/cpanel/home_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Cpanel::HomeController < Cpanel::BaseController
def index
end
end
2 changes: 2 additions & 0 deletions app/helpers/cpanel/accounts_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module Cpanel::AccountsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/cpanel/base_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module Cpanel::BaseHelper
end
2 changes: 2 additions & 0 deletions app/helpers/cpanel/blogs_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module Cpanel::BlogsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/cpanel/chats_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module Cpanel::ChatsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/cpanel/home_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module Cpanel::HomeHelper
end
2 changes: 2 additions & 0 deletions app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class Account
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::BaseModel
include Mongoid::SoftDelete

extend OmniauthCallbacks


Expand Down
2 changes: 1 addition & 1 deletion app/views/blogs/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div class="pull-right"><%=link_to "编辑",edit_blog_path(blog.id)%></div>
<%end%>
<p class="p-cat">
By: <%= raw blog.account.try(:username) %>
By: <a href="/u/<%=blog.account.u_login%>"><%= raw blog.account.try(:username) %></a>
Tag:<%=blog_tags_tag(blog)%>
</p>
<small class="p-time">
Expand Down
31 changes: 31 additions & 0 deletions app/views/cpanel/accounts/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<% content_for :sitemap do %>
<span class="current">用户列表</span>
<% end %>
<h1>用户列表</h1>

<table class="table table-condensed">
<tr class="head">
<td class="first">ID</td>
<td style="width:200px">Username</td>
<td >email</td>
<td >login</td>
<td>at</td>
<td>State</td>
<td></td>
</tr>

<% @items.each do |account| %>
<tr class="<%= "deleted" if !account.deleted_at.blank? %>">
<td class="first"><%= account.id %></td>
<td><%= truncate(account.username,:length => 30) %></td>
<td><%= account.email %></td>
<td><%= account.login %></td>
<td><%= account.created_at %></td>
<td>
</td>
</tr>
<% end %>
</table>
<%= will_paginate @items %>


2 changes: 2 additions & 0 deletions app/views/cpanel/blogs/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Cpanel::Blogs#index</h1>
<p>Find me in app/views/cpanel/blogs/index.html.erb</p>
2 changes: 2 additions & 0 deletions app/views/cpanel/chats/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Cpanel::Chats#index</h1>
<p>Find me in app/views/cpanel/chats/index.html.erb</p>
2 changes: 2 additions & 0 deletions app/views/cpanel/home/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>管理中心</h1>
<p>这里是管理员的地盘,其他人不许进来~</p>
Loading

0 comments on commit e9a14c5

Please sign in to comment.