Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update to Rails3 and created tables

  • Loading branch information...
commit 5520cba2d09b1758f43c60bbb7594239c0b948a2 0 parents
@huacnlee huacnlee authored
Showing with 11,910 additions and 0 deletions.
  1. +8 −0 .gitignore
  2. +30 −0 Gemfile
  3. +75 −0 Gemfile.lock
  4. +15 −0 README
  5. +7 −0 Rakefile
  6. +3 −0  app/controllers/application_controller.rb
  7. +83 −0 app/controllers/nodes_controller.rb
  8. +83 −0 app/controllers/replies_controller.rb
  9. +83 −0 app/controllers/sections_controller.rb
  10. +83 −0 app/controllers/topics_controller.rb
  11. +83 −0 app/controllers/users_controller.rb
  12. +2 −0  app/helpers/application_helper.rb
  13. +2 −0  app/helpers/nodes_helper.rb
  14. +2 −0  app/helpers/replies_helper.rb
  15. +2 −0  app/helpers/sections_helper.rb
  16. +2 −0  app/helpers/topics_helper.rb
  17. +2 −0  app/helpers/users_helper.rb
  18. +2 −0  app/models/counter.rb
  19. +2 −0  app/models/node.rb
  20. +2 −0  app/models/reply.rb
  21. +2 −0  app/models/section.rb
  22. +2 −0  app/models/topic.rb
  23. +2 −0  app/models/user.rb
  24. +14 −0 app/views/layouts/application.html.erb
  25. +33 −0 app/views/nodes/_form.html.erb
  26. +6 −0 app/views/nodes/edit.html.erb
  27. +29 −0 app/views/nodes/index.html.erb
  28. +5 −0 app/views/nodes/new.html.erb
  29. +25 −0 app/views/nodes/show.html.erb
  30. +37 −0 app/views/replies/_form.html.erb
  31. +6 −0 app/views/replies/edit.html.erb
  32. +31 −0 app/views/replies/index.html.erb
  33. +5 −0 app/views/replies/new.html.erb
  34. +30 −0 app/views/replies/show.html.erb
  35. +25 −0 app/views/sections/_form.html.erb
  36. +6 −0 app/views/sections/edit.html.erb
  37. +25 −0 app/views/sections/index.html.erb
  38. +5 −0 app/views/sections/new.html.erb
  39. +15 −0 app/views/sections/show.html.erb
  40. +49 −0 app/views/topics/_form.html.erb
  41. +6 −0 app/views/topics/edit.html.erb
  42. +37 −0 app/views/topics/index.html.erb
  43. +5 −0 app/views/topics/new.html.erb
  44. +45 −0 app/views/topics/show.html.erb
  45. +61 −0 app/views/users/_form.html.erb
  46. +6 −0 app/views/users/edit.html.erb
  47. +43 −0 app/views/users/index.html.erb
  48. +5 −0 app/views/users/new.html.erb
  49. +60 −0 app/views/users/show.html.erb
  50. +4 −0 config.ru
  51. +42 −0 config/application.rb
  52. +13 −0 config/boot.rb
  53. +26 −0 config/database.yml.default
  54. +5 −0 config/environment.rb
  55. +26 −0 config/environments/development.rb
  56. +49 −0 config/environments/production.rb
  57. +35 −0 config/environments/test.rb
  58. +7 −0 config/initializers/backtrace_silencers.rb
  59. +10 −0 config/initializers/inflections.rb
  60. +5 −0 config/initializers/mime_types.rb
  61. +7 −0 config/initializers/secret_token.rb
  62. +8 −0 config/initializers/session_store.rb
  63. +5 −0 config/locales/en.yml
  64. +147 −0 config/locales/zh-CN.yml
  65. +68 −0 config/routes.rb
  66. +25 −0 db/migrate/20100824055046_create_users.rb
  67. +14 −0 db/migrate/20100824055225_create_sections.rb
  68. +17 −0 db/migrate/20100824055320_create_nodes.rb
  69. +24 −0 db/migrate/20100824055700_create_topics.rb
  70. +20 −0 db/migrate/20100824055819_create_replies.rb
  71. +14 −0 db/migrate/20100824055944_create_counters.rb
  72. +86 −0 db/schema.rb
  73. +7 −0 db/seeds.rb
  74. +2 −0  doc/README_FOR_APP
  75. 0  lib/tasks/.gitkeep
  76. +26 −0 public/404.html
  77. +26 −0 public/422.html
  78. +26 −0 public/500.html
  79. 0  public/favicon.ico
  80. BIN  public/images/rails.png
  81. +239 −0 public/index.html
  82. +2 −0  public/javascripts/application.js
  83. +965 −0 public/javascripts/controls.js
  84. +974 −0 public/javascripts/dragdrop.js
  85. +1,123 −0 public/javascripts/effects.js
  86. +6,001 −0 public/javascripts/prototype.js
  87. +175 −0 public/javascripts/rails.js
  88. +5 −0 public/robots.txt
  89. 0  public/stylesheets/.gitkeep
  90. +56 −0 public/stylesheets/scaffold.css
  91. +6 −0 script/rails
  92. +9 −0 test/fixtures/counters.yml
  93. +13 −0 test/fixtures/nodes.yml
  94. +15 −0 test/fixtures/replies.yml
  95. +9 −0 test/fixtures/sections.yml
  96. +21 −0 test/fixtures/topics.yml
  97. +27 −0 test/fixtures/users.yml
  98. +49 −0 test/functional/nodes_controller_test.rb
  99. +49 −0 test/functional/replies_controller_test.rb
  100. +49 −0 test/functional/sections_controller_test.rb
  101. +49 −0 test/functional/topics_controller_test.rb
  102. +49 −0 test/functional/users_controller_test.rb
  103. +9 −0 test/performance/browsing_test.rb
  104. +13 −0 test/test_helper.rb
  105. +8 −0 test/unit/counter_test.rb
  106. +4 −0 test/unit/helpers/nodes_helper_test.rb
  107. +4 −0 test/unit/helpers/replies_helper_test.rb
  108. +4 −0 test/unit/helpers/sections_helper_test.rb
  109. +4 −0 test/unit/helpers/topics_helper_test.rb
  110. +4 −0 test/unit/helpers/users_helper_test.rb
  111. +8 −0 test/unit/node_test.rb
  112. +8 −0 test/unit/reply_test.rb
  113. +8 −0 test/unit/section_test.rb
  114. +8 −0 test/unit/topic_test.rb
  115. +8 −0 test/unit/user_test.rb
  116. 0  vendor/plugins/.gitkeep
8 .gitignore
@@ -0,0 +1,8 @@
+.bundle
+db/*.sqlite3
+log/*.log
+tmp/**/*
+config/database.yml
+public/javascripts/cached_*
+public/stylesheets/cached_*
+
30 Gemfile
@@ -0,0 +1,30 @@
+source 'http://rubygems.org'
+
+gem 'rails', '3.0.0.rc2'
+
+# Bundle edge Rails instead:
+# gem 'rails', :git => 'git://github.com/rails/rails.git'
+
+gem 'mysql2'
+
+# Use unicorn as the web server
+# gem 'unicorn'
+
+# Deploy with Capistrano
+# gem 'capistrano'
+
+# To use debugger
+# gem 'ruby-debug'
+
+# Bundle the extra gems:
+# gem 'bj'
+# gem 'nokogiri'
+gem 'sqlite3-ruby', :require => 'sqlite3'
+# gem 'aws-s3', :require => 'aws/s3'
+
+# Bundle gems for the local environment. Make sure to
+# put test-only gems in this group so their generators
+# and rake tasks are available in development mode:
+# group :development, :test do
+# gem 'webrat'
+# end
75 Gemfile.lock
@@ -0,0 +1,75 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ abstract (1.0.0)
+ actionmailer (3.0.0.rc2)
+ actionpack (= 3.0.0.rc2)
+ mail (~> 2.2.5)
+ actionpack (3.0.0.rc2)
+ activemodel (= 3.0.0.rc2)
+ activesupport (= 3.0.0.rc2)
+ builder (~> 2.1.2)
+ erubis (~> 2.6.6)
+ i18n (~> 0.4.1)
+ rack (~> 1.2.1)
+ rack-mount (~> 0.6.12)
+ rack-test (~> 0.5.4)
+ tzinfo (~> 0.3.23)
+ activemodel (3.0.0.rc2)
+ activesupport (= 3.0.0.rc2)
+ builder (~> 2.1.2)
+ i18n (~> 0.4.1)
+ activerecord (3.0.0.rc2)
+ activemodel (= 3.0.0.rc2)
+ activesupport (= 3.0.0.rc2)
+ arel (~> 1.0.0.rc1)
+ tzinfo (~> 0.3.23)
+ activeresource (3.0.0.rc2)
+ activemodel (= 3.0.0.rc2)
+ activesupport (= 3.0.0.rc2)
+ activesupport (3.0.0.rc2)
+ arel (1.0.0.rc1)
+ activesupport (>= 3.0.0.beta)
+ builder (2.1.2)
+ erubis (2.6.6)
+ abstract (>= 1.0.0)
+ i18n (0.4.1)
+ mail (2.2.5)
+ activesupport (>= 2.3.6)
+ mime-types
+ treetop (>= 1.4.5)
+ mime-types (1.16)
+ mysql2 (0.2.3)
+ polyglot (0.3.1)
+ rack (1.2.1)
+ rack-mount (0.6.12)
+ rack (>= 1.0.0)
+ rack-test (0.5.4)
+ rack (>= 1.0)
+ rails (3.0.0.rc2)
+ actionmailer (= 3.0.0.rc2)
+ actionpack (= 3.0.0.rc2)
+ activerecord (= 3.0.0.rc2)
+ activeresource (= 3.0.0.rc2)
+ activesupport (= 3.0.0.rc2)
+ bundler (>= 1.0.0.rc.6)
+ railties (= 3.0.0.rc2)
+ railties (3.0.0.rc2)
+ actionpack (= 3.0.0.rc2)
+ activesupport (= 3.0.0.rc2)
+ rake (>= 0.8.3)
+ thor (~> 0.14.0)
+ rake (0.8.7)
+ sqlite3-ruby (1.3.1)
+ thor (0.14.0)
+ treetop (1.4.8)
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.23)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ mysql2
+ rails (= 3.0.0.rc2)
+ sqlite3-ruby
15 README
@@ -0,0 +1,15 @@
+== 介绍
+
+我起名为“家园”,正如这个名字,这是一个为快速搭建小区论坛而做的开源项目。
+
+== 特色
+
+ 1. 简洁高效的论坛程序;
+ 2. 使用 Ruby on Rails 开发,具有良好的架构以便于后期维护和改进;
+ 3. Mobile 支持;
+
+
+== 演示
+
+ http://lanxs.com (楠香山,我住的小区)
+
7 Rakefile
@@ -0,0 +1,7 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require File.expand_path('../config/application', __FILE__)
+require 'rake'
+
+Homeland::Application.load_tasks
3  app/controllers/application_controller.rb
@@ -0,0 +1,3 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+end
83 app/controllers/nodes_controller.rb
@@ -0,0 +1,83 @@
+class NodesController < ApplicationController
+ # GET /nodes
+ # GET /nodes.xml
+ def index
+ @nodes = Node.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @nodes }
+ end
+ end
+
+ # GET /nodes/1
+ # GET /nodes/1.xml
+ def show
+ @node = Node.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @node }
+ end
+ end
+
+ # GET /nodes/new
+ # GET /nodes/new.xml
+ def new
+ @node = Node.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @node }
+ end
+ end
+
+ # GET /nodes/1/edit
+ def edit
+ @node = Node.find(params[:id])
+ end
+
+ # POST /nodes
+ # POST /nodes.xml
+ def create
+ @node = Node.new(params[:node])
+
+ respond_to do |format|
+ if @node.save
+ format.html { redirect_to(@node, :notice => 'Node was successfully created.') }
+ format.xml { render :xml => @node, :status => :created, :location => @node }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @node.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /nodes/1
+ # PUT /nodes/1.xml
+ def update
+ @node = Node.find(params[:id])
+
+ respond_to do |format|
+ if @node.update_attributes(params[:node])
+ format.html { redirect_to(@node, :notice => 'Node was successfully updated.') }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @node.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /nodes/1
+ # DELETE /nodes/1.xml
+ def destroy
+ @node = Node.find(params[:id])
+ @node.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(nodes_url) }
+ format.xml { head :ok }
+ end
+ end
+end
83 app/controllers/replies_controller.rb
@@ -0,0 +1,83 @@
+class RepliesController < ApplicationController
+ # GET /replies
+ # GET /replies.xml
+ def index
+ @replies = Reply.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @replies }
+ end
+ end
+
+ # GET /replies/1
+ # GET /replies/1.xml
+ def show
+ @reply = Reply.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @reply }
+ end
+ end
+
+ # GET /replies/new
+ # GET /replies/new.xml
+ def new
+ @reply = Reply.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @reply }
+ end
+ end
+
+ # GET /replies/1/edit
+ def edit
+ @reply = Reply.find(params[:id])
+ end
+
+ # POST /replies
+ # POST /replies.xml
+ def create
+ @reply = Reply.new(params[:reply])
+
+ respond_to do |format|
+ if @reply.save
+ format.html { redirect_to(@reply, :notice => 'Reply was successfully created.') }
+ format.xml { render :xml => @reply, :status => :created, :location => @reply }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @reply.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /replies/1
+ # PUT /replies/1.xml
+ def update
+ @reply = Reply.find(params[:id])
+
+ respond_to do |format|
+ if @reply.update_attributes(params[:reply])
+ format.html { redirect_to(@reply, :notice => 'Reply was successfully updated.') }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @reply.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /replies/1
+ # DELETE /replies/1.xml
+ def destroy
+ @reply = Reply.find(params[:id])
+ @reply.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(replies_url) }
+ format.xml { head :ok }
+ end
+ end
+end
83 app/controllers/sections_controller.rb
@@ -0,0 +1,83 @@
+class SectionsController < ApplicationController
+ # GET /sections
+ # GET /sections.xml
+ def index
+ @sections = Section.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @sections }
+ end
+ end
+
+ # GET /sections/1
+ # GET /sections/1.xml
+ def show
+ @section = Section.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @section }
+ end
+ end
+
+ # GET /sections/new
+ # GET /sections/new.xml
+ def new
+ @section = Section.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @section }
+ end
+ end
+
+ # GET /sections/1/edit
+ def edit
+ @section = Section.find(params[:id])
+ end
+
+ # POST /sections
+ # POST /sections.xml
+ def create
+ @section = Section.new(params[:section])
+
+ respond_to do |format|
+ if @section.save
+ format.html { redirect_to(@section, :notice => 'Section was successfully created.') }
+ format.xml { render :xml => @section, :status => :created, :location => @section }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @section.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /sections/1
+ # PUT /sections/1.xml
+ def update
+ @section = Section.find(params[:id])
+
+ respond_to do |format|
+ if @section.update_attributes(params[:section])
+ format.html { redirect_to(@section, :notice => 'Section was successfully updated.') }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @section.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /sections/1
+ # DELETE /sections/1.xml
+ def destroy
+ @section = Section.find(params[:id])
+ @section.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(sections_url) }
+ format.xml { head :ok }
+ end
+ end
+end
83 app/controllers/topics_controller.rb
@@ -0,0 +1,83 @@
+class TopicsController < ApplicationController
+ # GET /topics
+ # GET /topics.xml
+ def index
+ @topics = Topic.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @topics }
+ end
+ end
+
+ # GET /topics/1
+ # GET /topics/1.xml
+ def show
+ @topic = Topic.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @topic }
+ end
+ end
+
+ # GET /topics/new
+ # GET /topics/new.xml
+ def new
+ @topic = Topic.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @topic }
+ end
+ end
+
+ # GET /topics/1/edit
+ def edit
+ @topic = Topic.find(params[:id])
+ end
+
+ # POST /topics
+ # POST /topics.xml
+ def create
+ @topic = Topic.new(params[:topic])
+
+ respond_to do |format|
+ if @topic.save
+ format.html { redirect_to(@topic, :notice => 'Topic was successfully created.') }
+ format.xml { render :xml => @topic, :status => :created, :location => @topic }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /topics/1
+ # PUT /topics/1.xml
+ def update
+ @topic = Topic.find(params[:id])
+
+ respond_to do |format|
+ if @topic.update_attributes(params[:topic])
+ format.html { redirect_to(@topic, :notice => 'Topic was successfully updated.') }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /topics/1
+ # DELETE /topics/1.xml
+ def destroy
+ @topic = Topic.find(params[:id])
+ @topic.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(topics_url) }
+ format.xml { head :ok }
+ end
+ end
+end
83 app/controllers/users_controller.rb
@@ -0,0 +1,83 @@
+class UsersController < ApplicationController
+ # GET /users
+ # GET /users.xml
+ def index
+ @users = User.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @users }
+ end
+ end
+
+ # GET /users/1
+ # GET /users/1.xml
+ def show
+ @user = User.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @user }
+ end
+ end
+
+ # GET /users/new
+ # GET /users/new.xml
+ def new
+ @user = User.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @user }
+ end
+ end
+
+ # GET /users/1/edit
+ def edit
+ @user = User.find(params[:id])
+ end
+
+ # POST /users
+ # POST /users.xml
+ def create
+ @user = User.new(params[:user])
+
+ respond_to do |format|
+ if @user.save
+ format.html { redirect_to(@user, :notice => 'User was successfully created.') }
+ format.xml { render :xml => @user, :status => :created, :location => @user }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /users/1
+ # PUT /users/1.xml
+ def update
+ @user = User.find(params[:id])
+
+ respond_to do |format|
+ if @user.update_attributes(params[:user])
+ format.html { redirect_to(@user, :notice => 'User was successfully updated.') }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /users/1
+ # DELETE /users/1.xml
+ def destroy
+ @user = User.find(params[:id])
+ @user.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(users_url) }
+ format.xml { head :ok }
+ end
+ end
+end
2  app/helpers/application_helper.rb
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
2  app/helpers/nodes_helper.rb
@@ -0,0 +1,2 @@
+module NodesHelper
+end
2  app/helpers/replies_helper.rb
@@ -0,0 +1,2 @@
+module RepliesHelper
+end
2  app/helpers/sections_helper.rb
@@ -0,0 +1,2 @@
+module SectionsHelper
+end
2  app/helpers/topics_helper.rb
@@ -0,0 +1,2 @@
+module TopicsHelper
+end
2  app/helpers/users_helper.rb
@@ -0,0 +1,2 @@
+module UsersHelper
+end
2  app/models/counter.rb
@@ -0,0 +1,2 @@
+class Counter < ActiveRecord::Base
+end
2  app/models/node.rb
@@ -0,0 +1,2 @@
+class Node < ActiveRecord::Base
+end
2  app/models/reply.rb
@@ -0,0 +1,2 @@
+class Reply < ActiveRecord::Base
+end
2  app/models/section.rb
@@ -0,0 +1,2 @@
+class Section < ActiveRecord::Base
+end
2  app/models/topic.rb
@@ -0,0 +1,2 @@
+class Topic < ActiveRecord::Base
+end
2  app/models/user.rb
@@ -0,0 +1,2 @@
+class User < ActiveRecord::Base
+end
14 app/views/layouts/application.html.erb
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Homeland</title>
+ <%= stylesheet_link_tag :all %>
+ <%= javascript_include_tag :defaults %>
+ <%= csrf_meta_tag %>
+</head>
+<body>
+
+<%= yield %>
+
+</body>
+</html>
33 app/views/nodes/_form.html.erb
@@ -0,0 +1,33 @@
+<%= form_for(@node) do |f| %>
+ <% if @node.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@node.errors.count, "error") %> prohibited this node from being saved:</h2>
+
+ <ul>
+ <% @node.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="field">
+ <%= f.label :name %><br />
+ <%= f.text_field :name %>
+ </div>
+ <div class="field">
+ <%= f.label :sort %><br />
+ <%= f.text_field :sort %>
+ </div>
+ <div class="field">
+ <%= f.label :topics_count %><br />
+ <%= f.text_field :topics_count %>
+ </div>
+ <div class="field">
+ <%= f.label :summary %><br />
+ <%= f.text_field :summary %>
+ </div>
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
6 app/views/nodes/edit.html.erb
@@ -0,0 +1,6 @@
+<h1>Editing node</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @node %> |
+<%= link_to 'Back', nodes_path %>
29 app/views/nodes/index.html.erb
@@ -0,0 +1,29 @@
+<h1>Listing nodes</h1>
+
+<table>
+ <tr>
+ <th>Name</th>
+ <th>Sort</th>
+ <th>Topics count</th>
+ <th>Summary</th>
+ <th></th>
+ <th></th>
+ <th></th>
+ </tr>
+
+<% @nodes.each do |node| %>
+ <tr>
+ <td><%= node.name %></td>
+ <td><%= node.sort %></td>
+ <td><%= node.topics_count %></td>
+ <td><%= node.summary %></td>
+ <td><%= link_to 'Show', node %></td>
+ <td><%= link_to 'Edit', edit_node_path(node) %></td>
+ <td><%= link_to 'Destroy', node, :confirm => 'Are you sure?', :method => :delete %></td>
+ </tr>
+<% end %>
+</table>
+
+<br />
+
+<%= link_to 'New Node', new_node_path %>
5 app/views/nodes/new.html.erb
@@ -0,0 +1,5 @@
+<h1>New node</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Back', nodes_path %>
25 app/views/nodes/show.html.erb
@@ -0,0 +1,25 @@
+<p id="notice"><%= notice %></p>
+
+<p>
+ <b>Name:</b>
+ <%= @node.name %>
+</p>
+
+<p>
+ <b>Sort:</b>
+ <%= @node.sort %>
+</p>
+
+<p>
+ <b>Topics count:</b>
+ <%= @node.topics_count %>
+</p>
+
+<p>
+ <b>Summary:</b>
+ <%= @node.summary %>
+</p>
+
+
+<%= link_to 'Edit', edit_node_path(@node) %> |
+<%= link_to 'Back', nodes_path %>
37 app/views/replies/_form.html.erb
@@ -0,0 +1,37 @@
+<%= form_for(@reply) do |f| %>
+ <% if @reply.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@reply.errors.count, "error") %> prohibited this reply from being saved:</h2>
+
+ <ul>
+ <% @reply.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="field">
+ <%= f.label :topic_id %><br />
+ <%= f.text_field :topic_id %>
+ </div>
+ <div class="field">
+ <%= f.label :body %><br />
+ <%= f.text_area :body %>
+ </div>
+ <div class="field">
+ <%= f.label :user_id %><br />
+ <%= f.text_field :user_id %>
+ </div>
+ <div class="field">
+ <%= f.label :state %><br />
+ <%= f.text_field :state %>
+ </div>
+ <div class="field">
+ <%= f.label :source %><br />
+ <%= f.text_field :source %>
+ </div>
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
6 app/views/replies/edit.html.erb
@@ -0,0 +1,6 @@
+<h1>Editing reply</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @reply %> |
+<%= link_to 'Back', replies_path %>
31 app/views/replies/index.html.erb
@@ -0,0 +1,31 @@
+<h1>Listing replies</h1>
+
+<table>
+ <tr>
+ <th>Topic</th>
+ <th>Body</th>
+ <th>User</th>
+ <th>State</th>
+ <th>Source</th>
+ <th></th>
+ <th></th>
+ <th></th>
+ </tr>
+
+<% @replies.each do |reply| %>
+ <tr>
+ <td><%= reply.topic_id %></td>
+ <td><%= reply.body %></td>
+ <td><%= reply.user_id %></td>
+ <td><%= reply.state %></td>
+ <td><%= reply.source %></td>
+ <td><%= link_to 'Show', reply %></td>
+ <td><%= link_to 'Edit', edit_reply_path(reply) %></td>
+ <td><%= link_to 'Destroy', reply, :confirm => 'Are you sure?', :method => :delete %></td>
+ </tr>
+<% end %>
+</table>
+
+<br />
+
+<%= link_to 'New Reply', new_reply_path %>
5 app/views/replies/new.html.erb
@@ -0,0 +1,5 @@
+<h1>New reply</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Back', replies_path %>
30 app/views/replies/show.html.erb
@@ -0,0 +1,30 @@
+<p id="notice"><%= notice %></p>
+
+<p>
+ <b>Topic:</b>
+ <%= @reply.topic_id %>
+</p>
+
+<p>
+ <b>Body:</b>
+ <%= @reply.body %>
+</p>
+
+<p>
+ <b>User:</b>
+ <%= @reply.user_id %>
+</p>
+
+<p>
+ <b>State:</b>
+ <%= @reply.state %>
+</p>
+
+<p>
+ <b>Source:</b>
+ <%= @reply.source %>
+</p>
+
+
+<%= link_to 'Edit', edit_reply_path(@reply) %> |
+<%= link_to 'Back', replies_path %>
25 app/views/sections/_form.html.erb
@@ -0,0 +1,25 @@
+<%= form_for(@section) do |f| %>
+ <% if @section.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@section.errors.count, "error") %> prohibited this section from being saved:</h2>
+
+ <ul>
+ <% @section.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="field">
+ <%= f.label :name %><br />
+ <%= f.text_field :name %>
+ </div>
+ <div class="field">
+ <%= f.label :sort %><br />
+ <%= f.text_field :sort %>
+ </div>
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
6 app/views/sections/edit.html.erb
@@ -0,0 +1,6 @@
+<h1>Editing section</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @section %> |
+<%= link_to 'Back', sections_path %>
25 app/views/sections/index.html.erb
@@ -0,0 +1,25 @@
+<h1>Listing sections</h1>
+
+<table>
+ <tr>
+ <th>Name</th>
+ <th>Sort</th>
+ <th></th>
+ <th></th>
+ <th></th>
+ </tr>
+
+<% @sections.each do |section| %>
+ <tr>
+ <td><%= section.name %></td>
+ <td><%= section.sort %></td>
+ <td><%= link_to 'Show', section %></td>
+ <td><%= link_to 'Edit', edit_section_path(section) %></td>
+ <td><%= link_to 'Destroy', section, :confirm => 'Are you sure?', :method => :delete %></td>
+ </tr>
+<% end %>
+</table>
+
+<br />
+
+<%= link_to 'New Section', new_section_path %>
5 app/views/sections/new.html.erb
@@ -0,0 +1,5 @@
+<h1>New section</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Back', sections_path %>
15 app/views/sections/show.html.erb
@@ -0,0 +1,15 @@
+<p id="notice"><%= notice %></p>
+
+<p>
+ <b>Name:</b>
+ <%= @section.name %>
+</p>
+
+<p>
+ <b>Sort:</b>
+ <%= @section.sort %>
+</p>
+
+
+<%= link_to 'Edit', edit_section_path(@section) %> |
+<%= link_to 'Back', sections_path %>
49 app/views/topics/_form.html.erb
@@ -0,0 +1,49 @@
+<%= form_for(@topic) do |f| %>
+ <% if @topic.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@topic.errors.count, "error") %> prohibited this topic from being saved:</h2>
+
+ <ul>
+ <% @topic.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="field">
+ <%= f.label :title %><br />
+ <%= f.text_field :title %>
+ </div>
+ <div class="field">
+ <%= f.label :node_id %><br />
+ <%= f.text_field :node_id %>
+ </div>
+ <div class="field">
+ <%= f.label :body %><br />
+ <%= f.text_area :body %>
+ </div>
+ <div class="field">
+ <%= f.label :user_id %><br />
+ <%= f.text_field :user_id %>
+ </div>
+ <div class="field">
+ <%= f.label :replies_count %><br />
+ <%= f.text_field :replies_count %>
+ </div>
+ <div class="field">
+ <%= f.label :last_reply_user_id %><br />
+ <%= f.text_field :last_reply_user_id %>
+ </div>
+ <div class="field">
+ <%= f.label :replied_at %><br />
+ <%= f.datetime_select :replied_at %>
+ </div>
+ <div class="field">
+ <%= f.label :source %><br />
+ <%= f.text_field :source %>
+ </div>
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
6 app/views/topics/edit.html.erb
@@ -0,0 +1,6 @@
+<h1>Editing topic</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @topic %> |
+<%= link_to 'Back', topics_path %>
37 app/views/topics/index.html.erb
@@ -0,0 +1,37 @@
+<h1>Listing topics</h1>
+
+<table>
+ <tr>
+ <th>Title</th>
+ <th>Node</th>
+ <th>Body</th>
+ <th>User</th>
+ <th>Replies count</th>
+ <th>Last reply user</th>
+ <th>Replied at</th>
+ <th>Source</th>
+ <th></th>
+ <th></th>
+ <th></th>
+ </tr>
+
+<% @topics.each do |topic| %>
+ <tr>
+ <td><%= topic.title %></td>
+ <td><%= topic.node_id %></td>
+ <td><%= topic.body %></td>
+ <td><%= topic.user_id %></td>
+ <td><%= topic.replies_count %></td>
+ <td><%= topic.last_reply_user_id %></td>
+ <td><%= topic.replied_at %></td>
+ <td><%= topic.source %></td>
+ <td><%= link_to 'Show', topic %></td>
+ <td><%= link_to 'Edit', edit_topic_path(topic) %></td>
+ <td><%= link_to 'Destroy', topic, :confirm => 'Are you sure?', :method => :delete %></td>
+ </tr>
+<% end %>
+</table>
+
+<br />
+
+<%= link_to 'New Topic', new_topic_path %>
5 app/views/topics/new.html.erb
@@ -0,0 +1,5 @@
+<h1>New topic</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Back', topics_path %>
45 app/views/topics/show.html.erb
@@ -0,0 +1,45 @@
+<p id="notice"><%= notice %></p>
+
+<p>
+ <b>Title:</b>
+ <%= @topic.title %>
+</p>
+
+<p>
+ <b>Node:</b>
+ <%= @topic.node_id %>
+</p>
+
+<p>
+ <b>Body:</b>
+ <%= @topic.body %>
+</p>
+
+<p>
+ <b>User:</b>
+ <%= @topic.user_id %>
+</p>
+
+<p>
+ <b>Replies count:</b>
+ <%= @topic.replies_count %>
+</p>
+
+<p>
+ <b>Last reply user:</b>
+ <%= @topic.last_reply_user_id %>
+</p>
+
+<p>
+ <b>Replied at:</b>
+ <%= @topic.replied_at %>
+</p>
+
+<p>
+ <b>Source:</b>
+ <%= @topic.source %>
+</p>
+
+
+<%= link_to 'Edit', edit_topic_path(@topic) %> |
+<%= link_to 'Back', topics_path %>
61 app/views/users/_form.html.erb
@@ -0,0 +1,61 @@
+<%= form_for(@user) do |f| %>
+ <% if @user.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
+
+ <ul>
+ <% @user.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="field">
+ <%= f.label :email %><br />
+ <%= f.text_field :email %>
+ </div>
+ <div class="field">
+ <%= f.label :passwd %><br />
+ <%= f.text_field :passwd %>
+ </div>
+ <div class="field">
+ <%= f.label :name %><br />
+ <%= f.text_field :name %>
+ </div>
+ <div class="field">
+ <%= f.label :location %><br />
+ <%= f.text_field :location %>
+ </div>
+ <div class="field">
+ <%= f.label :bio %><br />
+ <%= f.text_field :bio %>
+ </div>
+ <div class="field">
+ <%= f.label :website %><br />
+ <%= f.text_field :website %>
+ </div>
+ <div class="field">
+ <%= f.label :avatar_file_name %><br />
+ <%= f.text_field :avatar_file_name %>
+ </div>
+ <div class="field">
+ <%= f.label :state %><br />
+ <%= f.text_field :state %>
+ </div>
+ <div class="field">
+ <%= f.label :qq %><br />
+ <%= f.text_field :qq %>
+ </div>
+ <div class="field">
+ <%= f.label :last_logined_at %><br />
+ <%= f.datetime_select :last_logined_at %>
+ </div>
+ <div class="field">
+ <%= f.label :tagline %><br />
+ <%= f.text_field :tagline %>
+ </div>
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
6 app/views/users/edit.html.erb
@@ -0,0 +1,6 @@
+<h1>Editing user</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @user %> |
+<%= link_to 'Back', users_path %>
43 app/views/users/index.html.erb
@@ -0,0 +1,43 @@
+<h1>Listing users</h1>
+
+<table>
+ <tr>
+ <th>Email</th>
+ <th>Passwd</th>
+ <th>Name</th>
+ <th>Location</th>
+ <th>Bio</th>
+ <th>Website</th>
+ <th>Avatar file name</th>
+ <th>State</th>
+ <th>Qq</th>
+ <th>Last logined at</th>
+ <th>Tagline</th>
+ <th></th>
+ <th></th>
+ <th></th>
+ </tr>
+
+<% @users.each do |user| %>
+ <tr>
+ <td><%= user.email %></td>
+ <td><%= user.passwd %></td>
+ <td><%= user.name %></td>
+ <td><%= user.location %></td>
+ <td><%= user.bio %></td>
+ <td><%= user.website %></td>
+ <td><%= user.avatar_file_name %></td>
+ <td><%= user.state %></td>
+ <td><%= user.qq %></td>
+ <td><%= user.last_logined_at %></td>
+ <td><%= user.tagline %></td>
+ <td><%= link_to 'Show', user %></td>
+ <td><%= link_to 'Edit', edit_user_path(user) %></td>
+ <td><%= link_to 'Destroy', user, :confirm => 'Are you sure?', :method => :delete %></td>
+ </tr>
+<% end %>
+</table>
+
+<br />
+
+<%= link_to 'New User', new_user_path %>
5 app/views/users/new.html.erb
@@ -0,0 +1,5 @@
+<h1>New user</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Back', users_path %>
60 app/views/users/show.html.erb
@@ -0,0 +1,60 @@
+<p id="notice"><%= notice %></p>
+
+<p>
+ <b>Email:</b>
+ <%= @user.email %>
+</p>
+
+<p>
+ <b>Passwd:</b>
+ <%= @user.passwd %>
+</p>
+
+<p>
+ <b>Name:</b>
+ <%= @user.name %>
+</p>
+
+<p>
+ <b>Location:</b>
+ <%= @user.location %>
+</p>
+
+<p>
+ <b>Bio:</b>
+ <%= @user.bio %>
+</p>
+
+<p>
+ <b>Website:</b>
+ <%= @user.website %>
+</p>
+
+<p>
+ <b>Avatar file name:</b>
+ <%= @user.avatar_file_name %>
+</p>
+
+<p>
+ <b>State:</b>
+ <%= @user.state %>
+</p>
+
+<p>
+ <b>Qq:</b>
+ <%= @user.qq %>
+</p>
+
+<p>
+ <b>Last logined at:</b>
+ <%= @user.last_logined_at %>
+</p>
+
+<p>
+ <b>Tagline:</b>
+ <%= @user.tagline %>
+</p>
+
+
+<%= link_to 'Edit', edit_user_path(@user) %> |
+<%= link_to 'Back', users_path %>
4 config.ru
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment', __FILE__)
+run Homeland::Application
42 config/application.rb
@@ -0,0 +1,42 @@
+require File.expand_path('../boot', __FILE__)
+
+require 'rails/all'
+
+# If you have a Gemfile, require the gems listed there, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(:default, Rails.env) if defined?(Bundler)
+
+module Homeland
+ class Application < Rails::Application
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+
+ # Custom directories with classes and modules you want to be autoloadable.
+ # config.autoload_paths += %W(#{config.root}/extras)
+
+ # Only load the plugins named here, in the order given (default is alphabetical).
+ # :all can be used as a placeholder for all plugins not explicitly named.
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+
+ # Activate observers that should always be running.
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
+
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
+ # config.time_zone = 'Central Time (US & Canada)'
+
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
+ # config.i18n.default_locale = :de
+
+ # JavaScript files you want as :defaults (application.js is always included).
+ # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
+
+ # Configure the default encoding used in templates for Ruby 1.9.
+ config.encoding = "utf-8"
+
+ # Configure sensitive parameters which will be filtered from the log file.
+ config.filter_parameters += [:passwd]
+ end
+end
13 config/boot.rb
@@ -0,0 +1,13 @@
+require 'rubygems'
+
+# Set up gems listed in the Gemfile.
+gemfile = File.expand_path('../../Gemfile', __FILE__)
+begin
+ ENV['BUNDLE_GEMFILE'] = gemfile
+ require 'bundler'
+ Bundler.setup
+rescue Bundler::GemNotFound => e
+ STDERR.puts e.message
+ STDERR.puts "Try running `bundle install`."
+ exit!
+end if File.exist?(gemfile)
26 config/database.yml.default
@@ -0,0 +1,26 @@
+# SQLite version 3.x
+# gem install sqlite3-ruby (not necessary on OS X Leopard)
+development:
+ adapter: "mysql2"
+ database: "homeland_development"
+ pool: 5
+ username: "monster"
+ password: "123123"
+ host: "172.28.150.23"
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ adapter: sqlite3
+ database: db/test.sqlite3
+ pool: 5
+ timeout: 5000
+
+production:
+ adapter: "mysql2"
+ database: "homeland"
+ pool: 5
+ username: "monster"
+ password: "123456"
+ host: "127.0.0.1"
5 config/environment.rb
@@ -0,0 +1,5 @@
+# Load the rails application
+require File.expand_path('../application', __FILE__)
+
+# Initialize the rails application
+Homeland::Application.initialize!
26 config/environments/development.rb
@@ -0,0 +1,26 @@
+Homeland::Application.configure do
+ # Settings specified here will take precedence over those in config/environment.rb
+
+ # In the development environment your application's code is reloaded on
+ # every request. This slows down response time but is perfect for development
+ # since you don't have to restart the webserver when you make code changes.
+ config.cache_classes = false
+
+ # Log error messages when you accidentally call methods on nil.
+ config.whiny_nils = true
+
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_view.debug_rjs = true
+ config.action_controller.perform_caching = false
+
+ # Don't care if the mailer can't send
+ config.action_mailer.raise_delivery_errors = false
+
+ # Print deprecation notices to the Rails logger
+ config.active_support.deprecation = :log
+
+ # Only use best-standards-support built into browsers
+ config.action_dispatch.best_standards_support = :builtin
+end
+
49 config/environments/production.rb
@@ -0,0 +1,49 @@
+Homeland::Application.configure do
+ # Settings specified here will take precedence over those in config/environment.rb
+
+ # The production environment is meant for finished, "live" apps.
+ # Code is not reloaded between requests
+ config.cache_classes = true
+
+ # Full error reports are disabled and caching is turned on
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
+
+ # Specifies the header that your server uses for sending files
+ config.action_dispatch.x_sendfile_header = "X-Sendfile"
+
+ # For nginx:
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
+
+ # If you have no front-end server that supports something like X-Sendfile,
+ # just comment this out and Rails will serve the files
+
+ # See everything in the log (default is :info)
+ # config.log_level = :debug
+
+ # Use a different logger for distributed setups
+ # config.logger = SyslogLogger.new
+
+ # Use a different cache store in production
+ # config.cache_store = :mem_cache_store
+
+ # Disable Rails's static asset server
+ # In production, Apache or nginx will already do this
+ config.serve_static_assets = false
+
+ # Enable serving of images, stylesheets, and javascripts from an asset server
+ # config.action_controller.asset_host = "http://assets.example.com"
+
+ # Disable delivery errors, bad email addresses will be ignored
+ # config.action_mailer.raise_delivery_errors = false
+
+ # Enable threaded mode
+ # config.threadsafe!
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation can not be found)
+ config.i18n.fallbacks = true
+
+ # Send deprecation notices to registered listeners
+ config.active_support.deprecation = :notify
+end
35 config/environments/test.rb
@@ -0,0 +1,35 @@
+Homeland::Application.configure do
+ # Settings specified here will take precedence over those in config/environment.rb
+
+ # The test environment is used exclusively to run your application's
+ # test suite. You never need to work with it otherwise. Remember that
+ # your test database is "scratch space" for the test suite and is wiped
+ # and recreated between test runs. Don't rely on the data there!
+ config.cache_classes = true
+
+ # Log error messages when you accidentally call methods on nil.
+ config.whiny_nils = true
+
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Raise exceptions instead of rendering exception templates
+ config.action_dispatch.show_exceptions = false
+
+ # Disable request forgery protection in test environment
+ config.action_controller.allow_forgery_protection = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
+ # like if you have constraints or database-specific column types
+ # config.active_record.schema_format = :sql
+
+ # Print deprecation notices to the stderr
+ config.active_support.deprecation = :stderr
+end
7 config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
10 config/initializers/inflections.rb
@@ -0,0 +1,10 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format
+# (all these examples are active by default):
+# ActiveSupport::Inflector.inflections do |inflect|
+# inflect.plural /^(ox)$/i, '\1en'
+# inflect.singular /^(ox)en/i, '\1'
+# inflect.irregular 'person', 'people'
+# inflect.uncountable %w( fish sheep )
+# end
5 config/initializers/mime_types.rb
@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new mime types for use in respond_to blocks:
+# Mime::Type.register "text/richtext", :rtf
+# Mime::Type.register_alias "text/html", :iphone
7 config/initializers/secret_token.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies will become invalid!
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+Homeland::Application.config.secret_token = '5070365ffe9d3ad7ed04e0ce080fe7ae9da2bd8497297a695118f91519a4c7b26fce69a024a888e768bacf2e376395921b557ea5cc50999b0e1d86993b908225'
8 config/initializers/session_store.rb
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+Homeland::Application.config.session_store :cookie_store, :key => '_homeland_session'
+
+# Use the database for sessions instead of the cookie-based default,
+# which shouldn't be used to store highly confidential information
+# (create the session table with "rake db:sessions:create")
+# Homeland::Application.config.session_store :active_record_store
5 config/locales/en.yml
@@ -0,0 +1,5 @@
+# Sample localization file for English. Add more files in this directory for other locales.
+# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
+
+en:
+ hello: "Hello world"
147 config/locales/zh-CN.yml
@@ -0,0 +1,147 @@
+# Chinese (China) translations for Ruby on Rails
+# by tsechingho (http://github.com/tsechingho)
+
+"zh-CN":
+ date:
+ formats:
+ default: "%Y-%m-%d"
+ short: "%b%d日"
+ long: "%Y年%b%d日"
+ day_names: [星期日, 星期一, 星期二, 星期三, 星期四, 星期五, 星期六]
+ abbr_day_names: [日, 一, 二, 三, 四, 五, 六]
+ month_names: [~, 一月, 二月, 三月, 四月, 五月, 六月, 七月, 八月, 九月, 十月, 十一月, 十二月]
+ abbr_month_names: [~, 1月, 2月, 3月, 4月, 5月, 6月, 7月, 8月, 9月, 10月, 11月, 12月]
+ order: [ :year, :month, :day ]
+
+ time:
+ formats:
+ default: "%Y年%b%d日 %A %H:%M:%S %Z"
+ short: "%b%d日 %H:%M"
+ long: "%Y年%b%d日 %H:%M"
+ am: "上午"
+ pm: "下午"
+
+ datetime:
+ distance_in_words:
+ half_a_minute: "半分钟"
+ less_than_x_seconds:
+ one: "不到一秒"
+ other: "不到 %{count} 秒"
+ x_seconds:
+ one: "一秒"
+ other: "%{count} 秒"
+ less_than_x_minutes:
+ one: "不到一分钟"
+ other: "不到 %{count} 分钟"
+ x_minutes:
+ one: "一分钟"
+ other: "%{count} 分钟"
+ about_x_hours:
+ one: "大约一小时"
+ other: "大约 %{count} 小时"
+ x_days:
+ one: "一天"
+ other: "%{count} 天"
+ about_x_months:
+ one: "大约一个月"
+ other: "大约 %{count} 个月"
+ x_months:
+ one: "一个月"
+ other: "%{count} 个月"
+ about_x_years:
+ one: "大约一年"
+ other: "大约 %{count} 年"
+ over_x_years:
+ one: "一年多"
+ other: "%{count} 年多"
+ almost_x_years:
+ one: "接近一年"
+ other: "接近 %{count} 年"
+ prompts:
+ year: ""
+ month: ""
+ day: ""
+ hour: ""
+ minute: ""
+ second: ""
+
+ number:
+ format:
+ separator: "."
+ delimiter: ","
+ precision: 3
+ currency:
+ format:
+ format: "%u %n"
+ unit: "CN¥"
+ separator: "."
+ delimiter: ","
+ precision: 2
+ percentage:
+ format:
+ delimiter: ""
+ precision:
+ format:
+ delimiter: ""
+ human:
+ format:
+ delimiter: ""
+ precision: 1
+ storage_units:
+ format: "%n %u"
+ units:
+ byte:
+ one: "Byte"
+ other: "Bytes"
+ kb: "KB"
+ mb: "MB"
+ gb: "GB"
+ tb: "TB"
+
+ support:
+ array:
+ words_connector: ", "
+ two_words_connector: ""
+ last_word_connector: ", 和 "
+ select:
+ prompt: "请选择"
+
+ activerecord:
+ errors:
+ template: # ~ 2.3.5 backward compatible
+ header:
+ one: "有 1 个错误发生导致「%{model}」无法被保存。"
+ other: "有 %{count} 个错误发生导致「%{model}」无法被保存。"
+ body: "如下字段出现错误:"
+ messages:
+ inclusion: "不包含于列表中"
+ exclusion: "是保留关键字"
+ invalid: "是无效的"
+ confirmation: "与确认值不匹配"
+ accepted: "必须是可被接受的"
+ empty: "不能留空"
+ blank: "不能为空字符"
+ too_long: "过长(最长为 %{count} 个字符)"
+ too_short: "过短(最短为 %{count} 个字符)"
+ wrong_length: "长度非法(必须为 %{count} 个字符)"
+ taken: "已经被使用"
+ not_a_number: "不是数字"
+ not_an_integer: "必须是整数"
+ greater_than: "必须大于 %{count}"
+ greater_than_or_equal_to: "必须大于或等于 %{count}"
+ equal_to: "必须等于 %{count}"
+ less_than: "必须小于 %{count}"
+ less_than_or_equal_to: "必须小于或等于 %{count}"
+ odd: "必须为单数"
+ even: "必须为双数"
+ record_invalid: "校验失败: %{errors}"
+
+ activemodel:
+ errors:
+ template:
+ header:
+ one: "有 1 个错误发生导致「%{model}」无法被保存。"
+ other: "有 %{count} 个错误发生导致「%{model}」无法被保存。"
+ body: "如下字段出现错误:"
+
+
68 config/routes.rb
@@ -0,0 +1,68 @@
+Homeland::Application.routes.draw do
+ resources :replies
+
+ resources :topics
+
+ resources :nodes
+
+ resources :sections
+
+ resources :users
+
+ # 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)))'
+end
25 db/migrate/20100824055046_create_users.rb
@@ -0,0 +1,25 @@
+class CreateUsers < ActiveRecord::Migration
+ def self.up
+ create_table :users do |t|
+ t.string :email, :null => false
+ t.string :passwd, :null => false
+ t.string :name, :null => false
+ t.string :location
+ t.string :bio
+ t.string :website
+ t.string :avatar_file_name
+ t.integer :state, :null => false, :default => 1
+ t.string :qq
+ t.datetime :last_logined_at
+ t.string :tagline
+
+ t.timestamps
+ end
+
+ add_index :users, :email
+ end
+
+ def self.down
+ drop_table :users
+ end
+end
14 db/migrate/20100824055225_create_sections.rb
@@ -0,0 +1,14 @@
+class CreateSections < ActiveRecord::Migration
+ def self.up
+ create_table :sections do |t|
+ t.string :name, :null => false
+ t.integer :sort, :null => false, :default => 0
+ end
+
+ add_index :sections, :sort
+ end
+
+ def self.down
+ drop_table :sections
+ end
+end
17 db/migrate/20100824055320_create_nodes.rb
@@ -0,0 +1,17 @@
+class CreateNodes < ActiveRecord::Migration
+ def self.up
+ create_table :nodes do |t|
+ t.string :name, :null => false
+ t.references :section, :null => false
+ t.integer :sort, :null => false, :default => 0
+ t.integer :topics_count, :null => false, :default => 0
+ t.string :summary
+
+ end
+ add_index :nodes, :section_id
+ end
+
+ def self.down
+ drop_table :nodes
+ end
+end
24 db/migrate/20100824055700_create_topics.rb
@@ -0,0 +1,24 @@
+class CreateTopics < ActiveRecord::Migration
+ def self.up
+ create_table :topics do |t|
+ t.string :title, :null => false
+ t.references :node, :null => false
+ t.text :body, :null => false
+ t.references :user, :null => false
+ t.integer :replies_count, :null => false, :default => 0
+ t.integer :last_reply_user_id
+ t.datetime :replied_at
+ t.string :source
+
+ t.timestamps
+
+ end
+
+ add_index :topics, :node_id
+ add_index :topics, :user_id
+ end
+
+ def self.down
+ drop_table :topics
+ end
+end
20 db/migrate/20100824055819_create_replies.rb
@@ -0,0 +1,20 @@
+class CreateReplies < ActiveRecord::Migration
+ def self.up
+ create_table :replies do |t|
+ t.references :topic, :null => false
+ t.text :body, :null => false
+ t.references :user, :null => false
+ t.integer :state, :null => false, :default => 1
+ t.string :source
+
+ t.timestamps
+ end
+
+ add_index :replies, :user_id
+ add_index :replies, :topic_id
+ end
+
+ def self.down
+ drop_table :replies
+ end
+end
14 db/migrate/20100824055944_create_counters.rb
@@ -0,0 +1,14 @@
+class CreateCounters < ActiveRecord::Migration
+ def self.up
+ create_table :counters do |t|
+ t.string :key, :null => false
+ t.string :value, :null => false
+ end
+
+ add_index :counters, :key
+ end
+
+ def self.down
+ drop_table :counters
+ end
+end
86 db/schema.rb
@@ -0,0 +1,86 @@
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 20100824055944) do
+
+ create_table "counters", :force => true do |t|
+ t.string "key", :null => false
+ t.string "value", :null => false
+ end
+
+ add_index "counters", ["key"], :name => "index_counters_on_key"
+
+ create_table "nodes", :force => true do |t|
+ t.string "name", :null => false
+ t.integer "section_id", :null => false
+ t.integer "sort", :default => 0, :null => false
+ t.integer "topics_count", :default => 0, :null => false
+ t.string "summary"
+ end
+
+ add_index "nodes", ["section_id"], :name => "index_nodes_on_section_id"
+
+ create_table "replies", :force => true do |t|
+ t.integer "topic_id", :null => false
+ t.text "body", :null => false
+ t.integer "user_id", :null => false
+ t.integer "state", :default => 1, :null => false
+ t.string "source"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "replies", ["topic_id"], :name => "index_replies_on_topic_id"
+ add_index "replies", ["user_id"], :name => "index_replies_on_user_id"
+
+ create_table "sections", :force => true do |t|
+ t.string "name", :null => false
+ t.integer "sort", :default => 0, :null => false
+ end
+
+ add_index "sections", ["sort"], :name => "index_sections_on_sort"
+
+ create_table "topics", :force => true do |t|
+ t.string "title", :null => false
+ t.integer "node_id", :null => false
+ t.text "body", :null => false
+ t.integer "user_id", :null => false
+ t.integer "replies_count", :default => 0, :null => false
+ t.integer "last_reply_user_id"
+ t.datetime "replied_at"
+ t.string "source"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "topics", ["node_id"], :name => "index_topics_on_node_id"
+ add_index "topics", ["user_id"], :name => "index_topics_on_user_id"
+
+ create_table "users", :force => true do |t|
+ t.string "email", :null => false
+ t.string "passwd", :null => false
+ t.string "name", :null => false
+ t.string "location"
+ t.string "bio"
+ t.string "website"
+ t.string "avatar_file_name"
+ t.integer "state", :default => 1, :null => false
+ t.string "qq"
+ t.datetime "last_logined_at"
+ t.string "tagline"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "users", ["email"], :name => "index_users_on_email"
+
+end
7 db/seeds.rb
@@ -0,0 +1,7 @@
+# This file should contain all the record creation needed to seed the database with its default values.
+# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
+#
+# Examples:
+#
+# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
+# Mayor.create(:name => 'Daley', :city => cities.first)
2  doc/README_FOR_APP
@@ -0,0 +1,2 @@
+Use this README file to introduce your application and point to useful places in the API for learning more.
+Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
0  lib/tasks/.gitkeep
No changes.
26 public/404.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>The page you were looking for doesn't exist (404)</title>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/404.html -->
+ <div class="dialog">
+ <h1>The page you were looking for doesn't exist.</h1>
+ <p>You may have mistyped the address or the page may have moved.</p>
+ </div>
+</body>
+</html>
26 public/422.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>The change you wanted was rejected (422)</title>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/422.html -->
+ <div class="dialog">
+ <h1>The change you wanted was rejected.</h1>
+ <p>Maybe you tried to change something you didn't have access to.</p>
+ </div>
+</body>
+</html>
26 public/500.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>We're sorry, but something went wrong (500)</title>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/500.html -->
+ <div class="dialog">
+ <h1>We're sorry, but something went wrong.</h1>
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
+ </div>
+</body>
+</html>
0  public/favicon.ico
No changes.
BIN  public/images/rails.png