diff --git a/app/assets/stylesheets/admin/dashboard.css.scss b/app/assets/stylesheets/admin/dashboard.css.scss new file mode 100644 index 0000000..f8b22f9 --- /dev/null +++ b/app/assets/stylesheets/admin/dashboard.css.scss @@ -0,0 +1,3 @@ +.dash-title { + padding-top: 2rem; +} diff --git a/app/assets/stylesheets/admin/posts.css.scss b/app/assets/stylesheets/admin/posts.css.scss index 51192ad..81e3cbd 100644 --- a/app/assets/stylesheets/admin/posts.css.scss +++ b/app/assets/stylesheets/admin/posts.css.scss @@ -1,57 +1,12 @@ -// Place all the styles related to the admin/posts controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ +.admin-posts-field { -#post_content { - width: 800px; - height: 390px; -} + #post_content { + min-height: 20rem; + } -div.submit { - display: block; - line-height: 40px; - width: 805px; - background-color: #CCC; - padding-left: 16px; - font-size: 20px; -} + #upload_photo { + float: right; + margin-top: 2rem; + } -ul.tab { - margin: 10px 0 10px 0; - overflow: hidden; - li { - float: left; - padding: 5px 5px; - border: 1px solid #CCC; - cursor: pointer; - } - li.active { - border-bottom: none; - border-top: 1px solid #CCC; - } - li:not(.active) { - border-top: none; - border-top-right-radius: none; - border-top-left-radius: none; - } - li#content { - border-top-left-radius: 10px; - border-right: none; - } - li#preview { - border-right-bottom-radius: 10px; - border-top-right-radius: 10px; - } -} - -div.preview { - width: 800px; - min-height: 396px; - border: 1px solid #CCC; - padding: 5px 5px; - display: none; -} - -#upload_photo { - float: right; } diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb new file mode 100644 index 0000000..640c0b2 --- /dev/null +++ b/app/controllers/admin/dashboard_controller.rb @@ -0,0 +1,7 @@ +class Admin::DashboardController < ApplicationController + layout 'layouts/admin' + before_action :authericate_user! + + def index + end +end diff --git a/app/controllers/admin/posts_controller.rb b/app/controllers/admin/posts_controller.rb index cba746e..5ea4fd2 100644 --- a/app/controllers/admin/posts_controller.rb +++ b/app/controllers/admin/posts_controller.rb @@ -1,4 +1,7 @@ class Admin::PostsController < ApplicationController + layout 'layouts/admin' + before_action :authericate_user! + def new @post = Post.new end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 80844fb..b93b985 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -10,4 +10,8 @@ class ApplicationController < ActionController::Base def format_date(time) time.strftime("%Y.%m.%d") end + + protected + def authericate_user! + end end diff --git a/app/helpers/admin/posts_helper.rb b/app/helpers/admin/posts_helper.rb deleted file mode 100644 index e9158b2..0000000 --- a/app/helpers/admin/posts_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module Admin::PostsHelper -end diff --git a/app/views/admin/dashboard/index.html.slim b/app/views/admin/dashboard/index.html.slim new file mode 100644 index 0000000..1c4f240 --- /dev/null +++ b/app/views/admin/dashboard/index.html.slim @@ -0,0 +1,20 @@ +.row + .small-12.columns + h2.dash-title 统计信息 + hr + table width="100%" + thead + tr + th 条目 + th 数据 + tbody + tr + td 总博客数 + td 1000 + tr + td 总评论数 + td 1000 + tr + td 总浏览量 + td 1000 + diff --git a/app/views/admin/posts/_form.html.slim b/app/views/admin/posts/_form.html.slim index 6ca3291..c8bea4c 100644 --- a/app/views/admin/posts/_form.html.slim +++ b/app/views/admin/posts/_form.html.slim @@ -1,14 +1,24 @@ -= simple_form_for(@post, :url=> admin_posts_path(@post)) do |f| - = f.input :title - ul.tab - li#content.active - | content - li#preview url=preview_admin_posts_path - | preview - = link_to t(:upload_photo), "#", :id=>'upload_photo' - input[type="file" style="display: none;"] - = f.input :content, :as=> :text, :label=>false - .preview.wikistyle - = f.input :type, :as=>:select, :collection=> [ Post::TECH, Post::LIFE, Post::CREATOR ], :include_blank=>false - .submit - = f.submit +.admin-posts-field + = simple_form_for(@post, :url=> admin_posts_path(@post)) do |f| + .row + .large-6.columns + = f.input :title, label: '标题' + .row + .small-6.large-3.columns + = f.input :type, :as=>:select, :collection=> [ Post::TECH, Post::LIFE, Post::CREATOR ], label: '类别' + .row + .small-12.large-6.columns + = f.simple_fields_for :label do |p| + = p.input :name, label: '标签' + dl.tabs data-tab="" + dd.active + a href="#" 正文 + dd + a href="#" 预览 + = link_to t(:upload_photo), "#", :id=>'upload_photo' + input[type="file" style="display: none;"] + = f.input :content, :as=> :text, :label=>false + .preview.wikistyle + .row + .small-12.large-6.columns.posts-button + = f.button :submit, '提交', class: 'button' diff --git a/app/views/admin/posts/new.html.slim b/app/views/admin/posts/new.html.slim index f8b33f2..81ff60a 100644 --- a/app/views/admin/posts/new.html.slim +++ b/app/views/admin/posts/new.html.slim @@ -1,2 +1,4 @@ -h3 #{t('new_post')} -= render 'form' +.row + .small-12.columns + h3 #{t('new_post')} + = render 'form' diff --git a/app/views/layouts/admin.html.slim b/app/views/layouts/admin.html.slim new file mode 100644 index 0000000..b9f256b --- /dev/null +++ b/app/views/layouts/admin.html.slim @@ -0,0 +1,38 @@ +html + head + meta charset="utf-8" + meta name="viewport" content="width=device-width, initial-scale=1.0" + title Admin Page for WinDy's Blog + = stylesheet_link_tag "application" + = javascript_include_tag "vendor/modernizr" + = javascript_include_tag "application" + = csrf_meta_tags + body + nav.top-bar data-topbar="" + ul.title-area + li.name + h1 + a href="#" Admin for WinDy + li.toggle-topbar.menu-icon + a href="#" Menu + section.top-bar-section + ul.left + li + = link_to '创建新博客', new_admin_post_path + li + a href="#" 管理博客 + = yield + = render "layouts/footer" + + + + javascript: + var _gaq = _gaq || []; + _gaq.push(['_setAccount', 'UA-32883596-1']); + _gaq.push(['_trackPageview']); + + (function() { + var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; + ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; + var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); + })(); diff --git a/config/routes.rb b/config/routes.rb index 5772c96..fef43d1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,8 +20,8 @@ WBlog::Application.routes.draw do post :preview end end + root to: 'dashboard#index' end get '/about' => 'home#index' - get '/admin' => 'admin/posts#new' get '/:type' => 'archives#index' end diff --git a/spec/controllers/admin/dashboard_controller_spec.rb b/spec/controllers/admin/dashboard_controller_spec.rb new file mode 100644 index 0000000..22a6cad --- /dev/null +++ b/spec/controllers/admin/dashboard_controller_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe Admin::DashboardController do + + describe "GET 'index'" do + it "returns http success" do + get 'index' + response.should be_success + end + end + +end