diff --git a/Gemfile b/Gemfile index da253f7..f1e3dfb 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'http://ruby.taobao.org' -gem 'rails', '3.2.6' +gem 'rails', '3.2.3' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' diff --git a/Gemfile.lock b/Gemfile.lock index 5119d5b..9de07a4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,37 +1,38 @@ GEM remote: http://ruby.taobao.org/ specs: - actionmailer (3.2.6) - actionpack (= 3.2.6) + actionmailer (3.2.3) + actionpack (= 3.2.3) mail (~> 2.4.4) - actionpack (3.2.6) - activemodel (= 3.2.6) - activesupport (= 3.2.6) + actionpack (3.2.3) + activemodel (= 3.2.3) + activesupport (= 3.2.3) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.1) rack (~> 1.4.0) rack-cache (~> 1.2) rack-test (~> 0.6.1) - sprockets (~> 2.1.3) - activemodel (3.2.6) - activesupport (= 3.2.6) + sprockets (~> 2.1.2) + activemodel (3.2.3) + activesupport (= 3.2.3) builder (~> 3.0.0) - activerecord (3.2.6) - activemodel (= 3.2.6) - activesupport (= 3.2.6) + activerecord (3.2.3) + activemodel (= 3.2.3) + activesupport (= 3.2.3) arel (~> 3.0.2) tzinfo (~> 0.3.29) - activeresource (3.2.6) - activemodel (= 3.2.6) - activesupport (= 3.2.6) - activesupport (3.2.6) + activeresource (3.2.3) + activemodel (= 3.2.3) + activesupport (= 3.2.3) + activesupport (3.2.3) i18n (~> 0.6) multi_json (~> 1.0) + addressable (2.2.8) arel (3.0.2) - bson (1.6.0) - bson_ext (1.6.0) - bson (= 1.6.0) + bson (1.6.4) + bson_ext (1.6.4) + bson (~> 1.6.4) builder (3.0.0) capybara (1.1.2) mime-types (>= 1.16) @@ -40,7 +41,7 @@ GEM rack-test (>= 0.5.4) selenium-webdriver (~> 2.0) xpath (~> 0.1.4) - childprocess (0.3.1) + childprocess (0.3.2) ffi (~> 1.0.6) coffee-rails (3.2.2) coffee-script (>= 2.2.0) @@ -49,12 +50,11 @@ GEM coffee-script-source execjs coffee-script-source (1.3.3) - cucumber (1.1.9) + cucumber (1.2.1) builder (>= 2.1.2) - diff-lcs (>= 1.1.2) - gherkin (~> 2.9.0) + diff-lcs (>= 1.1.3) + gherkin (~> 2.11.0) json (>= 1.4.6) - term-ansicolor (>= 1.0.6) cucumber-rails (1.3.0) capybara (>= 1.1.2) cucumber (>= 1.1.8) @@ -63,10 +63,10 @@ GEM erubis (2.7.0) execjs (1.4.0) multi_json (~> 1.0) - factory_girl (2.6.0) - activesupport (>= 2.3.9) + factory_girl (3.5.0) + activesupport (>= 3.0.0) ffi (1.0.11) - gherkin (2.9.0) + gherkin (2.11.0) json (>= 1.4.6) hike (1.2.1) i18n (0.6.0) @@ -75,23 +75,26 @@ GEM railties (>= 3.2.0, < 5.0) thor (~> 0.14) json (1.7.3) - json_pure (1.6.5) + libwebsocket (0.1.3) + addressable mail (2.4.4) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.19) - mongo (1.6.0) - bson (= 1.6.0) - mongoid (2.4.11) + mongoid (3.0.0.rc) activemodel (~> 3.1) - mongo (<= 1.6.2) + moped (~> 1.0.0.rc) + origin (~> 1.0.0.rc) tzinfo (~> 0.3.22) - mongoid-rspec (1.4.4) - mongoid (~> 2.0) - rspec (~> 2) + mongoid-rspec (1.4.6) + mongoid (>= 3.0.0.rc) + rake + rspec (>= 2.9) + moped (1.0.0.rc) multi_json (1.3.6) - nokogiri (1.5.2) + nokogiri (1.5.4) + origin (1.0.1) polyglot (0.3.3) rack (1.4.1) rack-cache (1.2) @@ -100,54 +103,53 @@ GEM rack rack-test (0.6.1) rack (>= 1.0) - rails (3.2.6) - actionmailer (= 3.2.6) - actionpack (= 3.2.6) - activerecord (= 3.2.6) - activeresource (= 3.2.6) - activesupport (= 3.2.6) + rails (3.2.3) + actionmailer (= 3.2.3) + actionpack (= 3.2.3) + activerecord (= 3.2.3) + activeresource (= 3.2.3) + activesupport (= 3.2.3) bundler (~> 1.0) - railties (= 3.2.6) - railties (3.2.6) - actionpack (= 3.2.6) - activesupport (= 3.2.6) + railties (= 3.2.3) + railties (3.2.3) + actionpack (= 3.2.3) + activesupport (= 3.2.3) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) - thor (>= 0.14.6, < 2.0) + thor (~> 0.14.6) rake (0.9.2.2) rdoc (3.12) json (~> 1.4) - rspec (2.8.0) - rspec-core (~> 2.8.0) - rspec-expectations (~> 2.8.0) - rspec-mocks (~> 2.8.0) - rspec-core (2.8.0) - rspec-expectations (2.8.0) - diff-lcs (~> 1.1.2) - rspec-mocks (2.8.0) - rspec-rails (2.8.1) + rspec (2.10.0) + rspec-core (~> 2.10.0) + rspec-expectations (~> 2.10.0) + rspec-mocks (~> 2.10.0) + rspec-core (2.10.1) + rspec-expectations (2.10.0) + diff-lcs (~> 1.1.3) + rspec-mocks (2.10.1) + rspec-rails (2.10.1) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec (~> 2.8.0) - rubyzip (0.9.6.1) + rspec (~> 2.10.0) + rubyzip (0.9.9) sass (3.1.19) sass-rails (3.2.5) railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) - selenium-webdriver (2.13.0) - childprocess (>= 0.2.1) - ffi (~> 1.0.9) - json_pure + selenium-webdriver (2.24.0) + childprocess (>= 0.2.5) + libwebsocket (~> 0.1.3) + multi_json (~> 1.0) rubyzip sprockets (2.1.3) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - term-ansicolor (1.0.7) - thor (0.15.3) + thor (0.14.6) tilt (1.3.3) treetop (1.4.10) polyglot @@ -171,7 +173,7 @@ DEPENDENCIES jquery-rails mongoid mongoid-rspec - rails (= 3.2.6) + rails (= 3.2.3) rspec-rails sass-rails (~> 3.2.3) uglifier (>= 1.0.3) diff --git a/app/assets/images/bg_fn_blog.png b/app/assets/images/bg_fn_blog.png new file mode 100644 index 0000000..13abf69 Binary files /dev/null and b/app/assets/images/bg_fn_blog.png differ diff --git a/app/assets/images/bg_fn_blog_corner.png b/app/assets/images/bg_fn_blog_corner.png new file mode 100644 index 0000000..fcda1f8 Binary files /dev/null and b/app/assets/images/bg_fn_blog_corner.png differ diff --git a/app/assets/javascripts/blogs.js.coffee b/app/assets/javascripts/blogs.js.coffee new file mode 100644 index 0000000..7615679 --- /dev/null +++ b/app/assets/javascripts/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://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 3192ec8..f2f4d6e 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -11,3 +11,52 @@ *= require_self *= require_tree . */ + +/* http://meyerweb.com/eric/tools/css/reset/ + v2.0 | 20110126 + License: none (public domain) +*/ + +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display: block; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} diff --git a/app/assets/stylesheets/blogs.css.scss b/app/assets/stylesheets/blogs.css.scss new file mode 100644 index 0000000..8c4f941 --- /dev/null +++ b/app/assets/stylesheets/blogs.css.scss @@ -0,0 +1,34 @@ +// Place all the styles related to the blogs controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ + +div.blog { + background: url('bg_fn_blog_corner.png') no-repeat; + padding: 2em 19px; + width: 641px; + border-radius: 5px; + border: 1px solid #E6E6E6; + h2 { + font-size: 40px; + margin-bottom: 19px; + a { + text-decoration: none; + &:hover { + strong { + display: inline; + } + } + strong { + font-size: 10px; + line-height: 40px; + margin-left: 1em; + display: none; + } + } + } +} +div.bottom { + background: url('bg_fn_blog.png') no-repeat; + height: 40px; + width: 679px; +} diff --git a/app/assets/stylesheets/global.css.scss b/app/assets/stylesheets/global.css.scss new file mode 100644 index 0000000..0f996c3 --- /dev/null +++ b/app/assets/stylesheets/global.css.scss @@ -0,0 +1,4 @@ +.container { + width: 1100px; + margin: 0 auto; +} diff --git a/app/assets/stylesheets/head.css.scss b/app/assets/stylesheets/head.css.scss new file mode 100644 index 0000000..59b3033 --- /dev/null +++ b/app/assets/stylesheets/head.css.scss @@ -0,0 +1,43 @@ +div.head { + margin-bottom: 2em; + background-color: #EFEFEF; + border-bottom: 1px solid #E6E6E6; + margin: 0 auto 1em; + div.container { + .descrip { + margin-left: 2em; + } + ul.nav { + list-style: none; + display: inline-block; + li { + display: inline-block; + margin-right: 0.3em; + width: 78px; + a { + display: block; + padding: 40px 0 10px 10px; + background-color: black; + color: white; + text-decoration: none; + strong { + display: block; + margin-top: 8px; + } + } + a#home { + background-color: #333; + } + a#tech { + background-color: #224b8f; + } + a#life { + background-color: #f15b6c; + } + a#creator { + background-color: #78cdd1; + } + } + } + } +} diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb new file mode 100644 index 0000000..a776700 --- /dev/null +++ b/app/controllers/blogs_controller.rb @@ -0,0 +1,8 @@ +class BlogsController < ApplicationController + def index + @posts = Post.all + end + + def show + end +end diff --git a/app/helpers/blogs_helper.rb b/app/helpers/blogs_helper.rb new file mode 100644 index 0000000..cc0dbd2 --- /dev/null +++ b/app/helpers/blogs_helper.rb @@ -0,0 +1,2 @@ +module BlogsHelper +end diff --git a/app/models/posts.rb b/app/models/post.rb similarity index 69% rename from app/models/posts.rb rename to app/models/post.rb index 27d2246..d13c755 100644 --- a/app/models/posts.rb +++ b/app/models/post.rb @@ -1,6 +1,5 @@ -class Posts +class Post include Mongoid::Document field :title, :type => String field :content, :type => String - field :type, :type => String end diff --git a/app/views/blogs/_post.html.erb b/app/views/blogs/_post.html.erb new file mode 100644 index 0000000..22e598a --- /dev/null +++ b/app/views/blogs/_post.html.erb @@ -0,0 +1,5 @@ +
+

<%= link_to (post.title + " >>").html_safe, blog_path(post) %>

+
<%= post.content %>
+
+
diff --git a/app/views/blogs/index.html.erb b/app/views/blogs/index.html.erb new file mode 100644 index 0000000..2d96a76 --- /dev/null +++ b/app/views/blogs/index.html.erb @@ -0,0 +1 @@ +<%= render :partial=> "post", :collection=> @posts %> diff --git a/app/views/blogs/show.html.erb b/app/views/blogs/show.html.erb new file mode 100644 index 0000000..a8701a8 --- /dev/null +++ b/app/views/blogs/show.html.erb @@ -0,0 +1,2 @@ +

Blogs#show

+

Find me in app/views/blogs/show.html.erb

diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index ecd53e4..e460d95 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,14 +1,29 @@ - WBlog + WinDy's Blog <%= stylesheet_link_tag "application", :media => "all" %> <%= javascript_include_tag "application" %> + <%= yield :js %> <%= csrf_meta_tags %> -<%= yield %> + +
+
+ + WinDy的个人中心 - 记录人生经历 - 技术 生活 And 创业 +
+
+
+ <%= yield %> +
diff --git a/config/application.rb b/config/application.rb index e4c75ef..0dba1ed 100644 --- a/config/application.rb +++ b/config/application.rb @@ -5,6 +5,7 @@ require File.expand_path('../boot', __FILE__) require "action_controller/railtie" require "action_mailer/railtie" require "active_resource/railtie" +require "sprockets/railtie" require "rails/test_unit/railtie" if defined?(Bundler) diff --git a/config/environments/development.rb b/config/environments/development.rb index fa6575a..0a3e7b5 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -23,11 +23,11 @@ WBlog::Application.configure do config.action_dispatch.best_standards_support = :builtin # Raise exception on mass assignment protection for Active Record models - config.active_record.mass_assignment_sanitizer = :strict + #config.active_record.mass_assignment_sanitizer = :strict # Log the query plan for queries taking more than this (works # with SQLite, MySQL, and PostgreSQL) - config.active_record.auto_explain_threshold_in_seconds = 0.5 + #config.active_record.auto_explain_threshold_in_seconds = 0.5 # Do not compress assets config.assets.compress = false diff --git a/config/mongoid.yml b/config/mongoid.yml index 57bbb37..888aeee 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -1,20 +1,60 @@ development: - host: localhost - database: w_blog_development + # Configure available database sessions. (required) + sessions: + # Defines the default session. (required) + default: + # Defines the name of the default database that Mongoid can connect to. + # (required). + database: w_blog_development + # Provides the hosts the default session can connect to. Must be an array + # of host:port pairs. (required) + hosts: + - localhost:27017 + options: + # Change whether the session persists in safe mode by default. + # (default: false) + # safe: false -test: - host: localhost - database: w_blog_test + # Change the default consistency model to :eventual or :strong. + # :eventual will send reads to secondaries, :strong sends everything + # to master. (default: :eventual) + consistency: :strong + # Configure Mongoid specific options. (optional) + options: + # Configuration for whether or not to allow access to fields that do + # not have a field definition on the model. (default: true) + # allow_dynamic_fields: true -# set these environment variables on your prod server -production: - host: <%= ENV['MONGOID_HOST'] %> - port: <%= ENV['MONGOID_PORT'] %> - username: <%= ENV['MONGOID_USERNAME'] %> - password: <%= ENV['MONGOID_PASSWORD'] %> - database: <%= ENV['MONGOID_DATABASE'] %> - # slaves: - # - host: slave1.local - # port: 27018 - # - host: slave2.local - # port: 27019 + # Enable the identity map, needed for eager loading. (default: false) + # identity_map_enabled: false + + # Includes the root model name in json serialization. (default: false) + # include_root_in_json: false + + # Include the _type field in serializaion. (default: false) + # include_type_for_serialization: false + + # Preload all models in development, needed when models use + # inheritance. (default: false) + # preload_models: false + + # Protect id and type from mass assignment. (default: true) + # protect_sensitive_fields: true + + # Raise an error when performing a #find and the document is not found. + # (default: true) + # raise_not_found_error: true + + # Raise an error when defining a scope with the same name as an + # existing method. (default: false) + # scope_overwrite_exception: false + + # Skip the database version check, used when connecting to a db without + # admin access. (default: false) + # skip_version_check: false + + # User Active Support's time zone in conversions. (default: true) + # use_activesupport_time_zone: true + + # Ensure all times are UTC in the app side. (default: false) + # use_utc: false diff --git a/config/routes.rb b/config/routes.rb index ea42f0d..db33895 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,58 +1,4 @@ WBlog::Application.routes.draw do - # The priority is based upon order of creation: - # first created -> highest priority. - - # Sample of regular route: - # match 'products/:id' => 'catalog#view' - # Keep in mind you can assign values other than :controller and :action - - # Sample of named route: - # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase - # This route can be invoked with purchase_url(:id => product.id) - - # Sample resource route (maps HTTP verbs to controller actions automatically): - # resources :products - - # Sample resource route with options: - # resources :products do - # member do - # get 'short' - # post 'toggle' - # end - # - # collection do - # get 'sold' - # end - # end - - # Sample resource route with sub-resources: - # resources :products do - # resources :comments, :sales - # resource :seller - # end - - # Sample resource route with more complex sub-resources - # resources :products do - # resources :comments - # resources :sales do - # get 'recent', :on => :collection - # end - # end - - # Sample resource route within a namespace: - # namespace :admin do - # # Directs /admin/products/* to Admin::ProductsController - # # (app/controllers/admin/products_controller.rb) - # resources :products - # end - - # You can have the root of your site routed with "root" - # just remember to delete public/index.html. - # root :to => 'welcome#index' - - # See how all your routes lay out with "rake routes" - - # This is a legacy wild controller route that's not recommended for RESTful applications. - # Note: This route will make all actions in every controller accessible via GET requests. - # match ':controller(/:action(/:id))(.:format)' + root :to => 'blogs#index' + resources :blogs, :only=>[:index, :show] end diff --git a/spec/.spec_helper.rb.swp b/spec/.spec_helper.rb.swp deleted file mode 100644 index b96ed66..0000000 Binary files a/spec/.spec_helper.rb.swp and /dev/null differ diff --git a/spec/controllers/blogs_controller_spec.rb b/spec/controllers/blogs_controller_spec.rb new file mode 100644 index 0000000..4199976 --- /dev/null +++ b/spec/controllers/blogs_controller_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe BlogsController do + + describe "GET 'index'" do + it "returns http success" do + get 'index' + response.should be_success + end + end + + describe "GET 'show'" do + it "returns http success" do + get 'show' + response.should be_success + end + end + +end diff --git a/spec/helpers/blogs_helper_spec.rb b/spec/helpers/blogs_helper_spec.rb new file mode 100644 index 0000000..df68143 --- /dev/null +++ b/spec/helpers/blogs_helper_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +# Specs in this file have access to a helper object that includes +# the BlogsHelper. For example: +# +# describe BlogsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# helper.concat_strings("this","that").should == "this that" +# end +# end +# end +describe BlogsHelper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/posts_spec.rb b/spec/models/post_spec.rb similarity index 82% rename from spec/models/posts_spec.rb rename to spec/models/post_spec.rb index b661743..98c3a24 100644 --- a/spec/models/posts_spec.rb +++ b/spec/models/post_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' -describe Posts do +describe Post do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/views/blogs/index.html.erb_spec.rb b/spec/views/blogs/index.html.erb_spec.rb new file mode 100644 index 0000000..c1f025d --- /dev/null +++ b/spec/views/blogs/index.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe "blogs/index.html.erb" do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/blogs/show.html.erb_spec.rb b/spec/views/blogs/show.html.erb_spec.rb new file mode 100644 index 0000000..49e8cc4 --- /dev/null +++ b/spec/views/blogs/show.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe "blogs/show.html.erb" do + pending "add some examples to (or delete) #{__FILE__}" +end