Permalink
Browse files

Update to Rails3 support

  • Loading branch information...
1 parent daaae12 commit 9c93e79334f37cdea3828f94bc2893d34cd7bd26 @huacnlee committed Aug 27, 2010
Showing with 1,146 additions and 3,601 deletions.
  1. +2 −0 .bundle/config
  2. +19 −0 Gemfile
  3. +87 −0 Gemfile.lock
  4. +7 −9 Rakefile
  5. +1 −0 app/controllers/application_controller.rb
  6. +1 −0 app/controllers/cpanel/application_controller.rb
  7. +1 −0 app/controllers/cpanel/categories_controller.rb
  8. +1 −0 app/controllers/cpanel/comments_controller.rb
  9. +2 −1 app/controllers/cpanel/home_controller.rb
  10. +1 −0 app/controllers/cpanel/menus_controller.rb
  11. +1 −0 app/controllers/cpanel/pages_controller.rb
  12. +1 −0 app/controllers/cpanel/posts_controller.rb
  13. +1 −0 app/controllers/cpanel/settings_controller.rb
  14. +1 −0 app/controllers/home_controller.rb
  15. +2 −5 app/controllers/posts_controller.rb
  16. +10 −9 app/helpers/application_helper.rb
  17. +1 −0 app/helpers/comments_helper.rb
  18. +1 −0 app/helpers/home_helper.rb
  19. +1 −0 app/helpers/menus_helper.rb
  20. +1 −0 app/helpers/pages_helper.rb
  21. +1 −0 app/helpers/posts_helper.rb
  22. +1 −0 app/helpers/settings_helper.rb
  23. +1 −0 app/{models → mailers}/notice_mailer.rb
  24. +5 −3 app/models/category.rb
  25. +6 −5 app/models/comment.rb
  26. +0 −30 app/models/comment_observer.rb
  27. +2 −1 app/models/fanfou.rb
  28. +1 −0 app/models/menu.rb
  29. +3 −7 app/models/page.rb
  30. +7 −7 app/models/post.rb
  31. +0 −20 app/models/post_observer.rb
  32. +1 −0 app/models/setting.rb
  33. +1 −1 app/models/share.rb
  34. +1 −0 app/models/tag.rb
  35. +1 −0 app/models/tweet.rb
  36. +1 −0 app/models/unfollower.rb
  37. +2 −1 app/models/user.rb
  38. +2 −2 app/views/cpanel/categories/edit.html.erb
  39. +7 −6 app/views/cpanel/comments/index.html.erb
  40. +2 −2 app/views/cpanel/menus/edit.html.erb
  41. +3 −3 app/views/cpanel/pages/edit.html.erb
  42. +0 −1 app/views/cpanel/posts/_submenu.html.erb
  43. +2 −2 app/views/cpanel/posts/edit.html.erb
  44. +0 −30 app/views/cpanel/posts/importblogbus.html.erb
  45. +2 −2 app/views/cpanel/settings/index.html.erb
  46. +3 −3 app/views/cpanel/settings/password.html.erb
  47. +0 −9 app/views/home/_recent_posts.html.erb
  48. +0 −22 app/views/home/_tweet.html.erb
  49. +2 −2 app/views/home/_webicons.html.erb
  50. +31 −4 app/views/home/index.html.erb
  51. +6 −4 app/views/layouts/application.html.erb
  52. +5 −4 app/views/layouts/cpanel.html.erb
  53. +1 −1 app/views/pages/show.html.erb
  54. +2 −2 app/views/posts/_posts.html.erb
  55. +3 −3 app/views/posts/show.html.erb
  56. +10 −0 app/views/shared/_error_messages.html.erb
  57. +4 −0 config.ru
  58. +61 −0 config/application.rb
  59. +13 −110 config/boot.rb
  60. +17 −13 config/database.yml.default
  61. +5 −86 config/environment.rb
  62. +22 −15 config/environments/development.rb
  63. +51 −28 config/environments/production.rb
  64. +17 −0 config/initializers/setup_mailer.rb
  65. +0 −6 db/import/index.html
  66. +7 −6 db/schema.rb
  67. +2 −0 db/seeds.rb
  68. +2 −1 lib/encoder.rb
  69. +2 −2 lib/fanfou_moulde.rb
  70. +0 −281 lib/guid.rb
  71. +6 −5 lib/{string.rb → string_extensions.rb}
  72. +151 −29 public/javascripts/src/lib/jquery.js
  73. +132 −0 public/javascripts/src/rails.js
  74. 0 vendor/plugins/scrooge/README → public/stylesheets/src/cpanel/categories.css
  75. +0 −4 script/about
  76. +0 −3 script/console
  77. +0 −3 script/dbconsole
  78. +0 −3 script/destroy
  79. +0 −3 script/generate
  80. +0 −3 script/performance/benchmarker
  81. +0 −3 script/performance/profiler
  82. +0 −3 script/plugin
  83. +6 −0 script/rails
  84. +0 −3 script/runner
  85. +0 −3 script/server
  86. +388 −0 tags
  87. +0 −2 vendor/plugins/acts-as-taggable-on/.gitignore
  88. +0 −18 vendor/plugins/acts-as-taggable-on/CHANGELOG
  89. +0 −20 vendor/plugins/acts-as-taggable-on/MIT-LICENSE
  90. +0 −196 vendor/plugins/acts-as-taggable-on/README
  91. +0 −7 vendor/plugins/acts-as-taggable-on/Rakefile
  92. +0 −42 vendor/plugins/acts-as-taggable-on/acts-as-taggable-on.gemspec
  93. +0 −7 ...s-taggable-on/generators/acts_as_taggable_on_migration/acts_as_taggable_on_migration_generator.rb
  94. +0 −29 vendor/plugins/acts-as-taggable-on/generators/acts_as_taggable_on_migration/templates/migration.rb
  95. +0 −1 vendor/plugins/acts-as-taggable-on/init.rb
  96. +0 −6 vendor/plugins/acts-as-taggable-on/lib/acts-as-taggable-on.rb
  97. +0 −326 vendor/plugins/acts-as-taggable-on/lib/acts_as_taggable_on/acts_as_taggable_on.rb
  98. +0 −52 vendor/plugins/acts-as-taggable-on/lib/acts_as_taggable_on/acts_as_tagger.rb
  99. +0 −23 vendor/plugins/acts-as-taggable-on/lib/acts_as_taggable_on/tag.rb
  100. +0 −93 vendor/plugins/acts-as-taggable-on/lib/acts_as_taggable_on/tag_list.rb
  101. +0 −6 vendor/plugins/acts-as-taggable-on/lib/acts_as_taggable_on/tagging.rb
  102. +0 −11 vendor/plugins/acts-as-taggable-on/lib/acts_as_taggable_on/tags_helper.rb
  103. +0 −6 vendor/plugins/acts-as-taggable-on/rails/init.rb
  104. +0 −165 vendor/plugins/acts-as-taggable-on/spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb
  105. +0 −72 vendor/plugins/acts-as-taggable-on/spec/acts_as_taggable_on/acts_as_tagger_spec.rb
  106. +0 −41 vendor/plugins/acts-as-taggable-on/spec/acts_as_taggable_on/tag_list_spec.rb
  107. +0 −27 vendor/plugins/acts-as-taggable-on/spec/acts_as_taggable_on/tag_spec.rb
  108. +0 −147 vendor/plugins/acts-as-taggable-on/spec/acts_as_taggable_on/taggable_spec.rb
  109. +0 −23 vendor/plugins/acts-as-taggable-on/spec/acts_as_taggable_on/tagger_spec.rb
  110. +0 −7 vendor/plugins/acts-as-taggable-on/spec/acts_as_taggable_on/tagging_spec.rb
  111. +0 −32 vendor/plugins/acts-as-taggable-on/spec/schema.rb
  112. +0 −7 vendor/plugins/acts-as-taggable-on/spec/spec.opts
  113. +0 −46 vendor/plugins/acts-as-taggable-on/spec/spec_helper.rb
  114. +0 −1 vendor/plugins/acts-as-taggable-on/uninstall.rb
  115. +3 −3 vendor/plugins/captcha/lib/captcha_image_generator.rb
  116. +0 −234 vendor/plugins/scrooge/README.textile
  117. +0 −39 vendor/plugins/scrooge/Rakefile
  118. +0 −4 vendor/plugins/scrooge/VERSION.yml
  119. +0 −1 vendor/plugins/scrooge/init.rb
  120. +0 −5 vendor/plugins/scrooge/install.rb
  121. +0 −106 vendor/plugins/scrooge/lib/callsite.rb
  122. +0 −92 vendor/plugins/scrooge/lib/optimizations/associations/macro.rb
  123. +0 −148 vendor/plugins/scrooge/lib/optimizations/columns/attributes_proxy.rb
  124. +0 −227 vendor/plugins/scrooge/lib/optimizations/columns/macro.rb
  125. +0 −9 vendor/plugins/scrooge/lib/optimizations/result_sets/result_array.rb
  126. +0 −105 vendor/plugins/scrooge/lib/optimizations/result_sets/updateable_result_set.rb
  127. +0 −82 vendor/plugins/scrooge/lib/scrooge.rb
  128. +0 −1 vendor/plugins/scrooge/rails/init.rb
  129. +0 −29 vendor/plugins/scrooge/scrooge.gemspec
  130. +0 −41 vendor/plugins/scrooge/test/callsite_test.rb
  131. +0 −90 vendor/plugins/scrooge/test/helper.rb
  132. +0 −7 vendor/plugins/scrooge/test/models/mysql_column_privilege.rb
  133. +0 −5 vendor/plugins/scrooge/test/models/mysql_host.rb
  134. +0 −8 vendor/plugins/scrooge/test/models/mysql_table_privilege.rb
  135. +0 −13 vendor/plugins/scrooge/test/models/mysql_user.rb
  136. +0 −27 vendor/plugins/scrooge/test/optimizations/associations/macro_test.rb
  137. +0 −12 vendor/plugins/scrooge/test/scrooge_helper.rb
  138. +0 −83 vendor/plugins/scrooge/test/scrooge_test.rb
  139. +0 −3 vendor/plugins/scrooge/test/setup.rb
View
@@ -0,0 +1,2 @@
+---
+BUNDLE_DISABLE_SHARED_GEMS: "1"
View
19 Gemfile
@@ -0,0 +1,19 @@
+source 'http://rubygems.org'
+
+gem 'rails', '3.0.0.rc2'
+gem 'mysql2'
+gem 'RedCloth'
+gem 'simple-rss'
+gem 'will_paginate', '3.0.pre'
+gem 'twitter4r'
+gem 'acts-as-taggable-on'
+gem 'rmagick'
+gem 'jquery-ujs'
+# 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
View
@@ -0,0 +1,87 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ RedCloth (4.2.3)
+ 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)
+ acts-as-taggable-on (2.0.6)
+ 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)
+ json (1.4.6)
+ 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)
+ rmagick (2.13.1)
+ simple-rss (1.2.3)
+ thor (0.14.0)
+ treetop (1.4.8)
+ polyglot (>= 0.3.1)
+ twitter4r (0.3.2)
+ json (>= 1.1.1)
+ tzinfo (0.3.23)
+ will_paginate (3.0.pre)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ RedCloth
+ acts-as-taggable-on
+ mysql2
+ rails (= 3.0.0.rc2)
+ rmagick
+ simple-rss
+ twitter4r
+ will_paginate (= 3.0.pre)
View
@@ -1,17 +1,15 @@
# 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.join(File.dirname(__FILE__), 'config', 'boot'))
-
+require File.expand_path('../config/application', __FILE__)
require 'rake'
-require 'rake/testtask'
-require 'rake/rdoctask'
-require 'tasks/rails'
+
+Personlab::Application.load_tasks
# Twitter
-namespace :tweet do
+namespace :tweet do
desc "Twitter reload."
- task :update => :environment do
+ task :update => :environment do
require 'app/models/setting'
require 'app/models/tweet'
setting = Setting.find_create
@@ -25,9 +23,9 @@ namespace :tweet do
end
# Google Reader
-namespace :reader_share do
+namespace :reader_share do
desc "Google Reader reload shere items."
- task :update => :environment do
+ task :update => :environment do
require 'app/models/setting'
require 'app/models/share'
setting = Setting.find_create
@@ -1,3 +1,4 @@
+# coding: utf-8
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
@@ -1,3 +1,4 @@
+# coding: utf-8
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
@@ -1,3 +1,4 @@
+# coding: utf-8
# ----------------------------------------------------
# name: menus_controller.rb
# authors: Jason Lee<huacnlee@gmail.com>,
@@ -1,3 +1,4 @@
+# coding: utf-8
# ----------------------------------------------------
# name: comments_controller.rb
# authors: Jason Lee<huacnlee@gmail.com>,
@@ -1,3 +1,4 @@
+# coding: utf-8
# admin home controller
class Cpanel::HomeController < Cpanel::ApplicationController
before_filter :require_login,:only => [:index,:logout]
@@ -38,4 +39,4 @@ def login
render :action => "login", :layout => false
end
-end
+end
@@ -1,3 +1,4 @@
+# coding: utf-8
# ----------------------------------------------------
# name: menus_controller.rb
# authors: Jason Lee<huacnlee@gmail.com>,
@@ -1,3 +1,4 @@
+# coding: utf-8
# ----------------------------------------------------
# name: pages_controller.rb
# authors: Jason Lee<huacnlee@gmail.com>,
@@ -1,3 +1,4 @@
+# coding: utf-8
class Cpanel::PostsController < Cpanel::ApplicationController
cache_sweeper :post_sweeper,:only => [:create,:update,:destroy]
# GET /posts
@@ -1,3 +1,4 @@
+# coding: utf-8
class Cpanel::SettingsController < Cpanel::ApplicationController
cache_sweeper :setting_sweeper,:page_sweeper, :only => [:update]
@@ -1,3 +1,4 @@
+# coding: utf-8
class HomeController < ApplicationController
caches_action :show
@@ -1,3 +1,4 @@
+# coding: utf-8
class PostsController < ApplicationController
cache_sweeper :comment_sweeper,:only => [:show]
validates_captcha
@@ -107,23 +108,19 @@ def show
@view_count = Post.update_view_count(params[:slug])
- @post = Rails.cache.read(@post_key)
if (not @post) or (@view_count == 0)
@post = Post.find_slug(params[:slug])
if not @post
return render_404
end
-
- Rails.cache.write(@post_key,@post)
end
if request.post?
@pcomment = params[:comment]
- @comment = Comment.new(params[:comment])
+ @comment = @post.comments.build(params[:comment])
set_guest(@comment.author,@comment.url,@comment.email)
if captcha_validated?
- @comment.post_id = @post.id
if @comment.save
NoticeMailer.new_comment_notice(@post,@comment)
if @comment.status == 2
@@ -1,30 +1,31 @@
-require "md5"
+# coding: utf-8
+require "digest/md5"
require "encoder"
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
# return the formatted flash[:notice] html
def success_messages
+ msg = ''
if flash[:notice]
- '
+ msg = '
<div id="successMessage" class="successMessage">
'+flash[:notice]+'
</div>
'
- else
- ''
end
+ raw msg
end
# form auth token
def auth_token
- "<input name=\"authenticity_token\" type=\"hidden\" value=\"#{form_authenticity_token}\" />"
+ raw "<input name=\"authenticity_token\" type=\"hidden\" value=\"#{form_authenticity_token}\" />"
end
# return the Gravatar face by Email
def face_url(email)
- hash = MD5::md5(email)
- "http://www.gravatar.com/avatar/#{hash}?s=32"
+ hash = Digest::MD5.hexdigest(email)
+ raw "http://www.gravatar.com/avatar/#{hash}?s=32"
end
# close html tag when truncated
@@ -33,7 +34,7 @@ def close_tags(text)
text.scan(/\<([^\>\s\/]+)[^\>\/]*?\>/).each { |t| open_tags.unshift(t) }
text.scan(/\<\/([^\>\s\/]+)[^\>]*?\>/).each { |t| open_tags.slice!(open_tags.index(t)) }
open_tags.each {|t| text += "</#{t}>" }
- return text
+ return raw text
end
def truncate_html(html, options={})
@@ -62,7 +63,7 @@ def truncate_html(html, options={})
end
end
end
- return result.join(" ") + options[:omission].to_s
+ return raw(result.join(" ") + options[:omission].to_s)
end
# 退定连接
@@ -1,2 +1,3 @@
+# coding: utf-8
module CommentsHelper
end
@@ -1,2 +1,3 @@
+# coding: utf-8
module HomeHelper
end
@@ -1,2 +1,3 @@
+# coding: utf-8
module MenusHelper
end
@@ -1,3 +1,4 @@
+# coding: utf-8
require "RedCloth"
module PagesHelper
def textile(body)
@@ -1,2 +1,3 @@
+# coding: utf-8
module PostsHelper
end
@@ -1,2 +1,3 @@
+# coding: utf-8
module SettingsHelper
end
@@ -1,3 +1,4 @@
+# coding: utf-8
class NoticeMailer < ActionMailer::Base
helper :application
layout "mailer"
View
@@ -1,11 +1,13 @@
+# coding: utf-8
+require "string_extensions"
class Category < ActiveRecord::Base
validates_presence_of :name
has_many :posts
- before_update :before_update
+ before_update :recount_posts_count
- def before_update
+ def recount_posts_count
self.posts_count = self.posts.count
end
-end
+end
View
@@ -1,16 +1,17 @@
+# coding: utf-8
class Comment < ActiveRecord::Base
- belongs_to :post
+ belongs_to :post,:counter_cache => "comment_count"
- validates_presence_of :author,:email,:body, :message => "还未填写."
+ validates_presence_of :author,:email,:body
default_scope :order => 'id ASC'
- before_create :before_create
- def before_create
+ before_create :default_value
+ def default_value
self.status = 1 if self.status.blank?
end
def created_at_s
- created_at.to_s(:short_time_string)
+ I18n.l created_at
end
def self.find_list(page = 1, per_page = 20,options = {})
@@ -1,30 +0,0 @@
-# ----------------------------------------------------
-# name: comment_observer.rb
-# authors: Jason Lee<huacnlee@gmail.com>,
-# create at: 2009-04-20
-# summary:
-# this comment_observer.rb summary
-# ----------------------------------------------------
-require "sweepers/comment_sweeper"
-class CommentObserver < ActiveRecord::Observer
-
- def after_create(m)
- total_comment_count(m)
- end
-
- def after_destroy(m)
- total_comment_count(m)
- end
-
- private
- # tatal the comments count of this post and save it.
- def total_comment_count(m)
- post = m.post
- if post
- count = post.comments.length
- post.comment_count = count
- post.save
- end
- CommentSweeper.instance.after_create(m)
- end
-end
Oops, something went wrong.

0 comments on commit 9c93e79

Please sign in to comment.