Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
<ul>Ruby on Discuz! </ul><ul>Ryudo in Ruby Tuesday 2010.05.18 </ul>用 Ruby 擴充論壇的社群功能
<ul>自我 介紹 </ul>
<ul>鄧慕凡 </ul><ul>Mu-Fan Teng </ul>
<ul>我的 工作 </ul>
<ul>遊戲 開發 </ul><ul>Ex-Game Developer </ul>
 
 
<ul>網站 開發 </ul><ul>WEB Developer </ul>
<ul>網站 維運 </ul><ul>WEB Operation </ul>
<ul>FREEBBS.TW </ul>
<ul>GAMECLUB.TW </ul>
<ul>網路社群型態 </ul>
<ul>論壇 </ul><ul>Forum </ul>
<ul>部落格 </ul><ul>Blog </ul>
<ul>Google Trends(TW) </ul>
<ul>最強的論壇系統 </ul>
<ul>DISCUZ! </ul>
<ul>唯一 華人製作 </ul><ul>180 多人的大公司 </ul>
<ul>華人地區市場獨佔 </ul>
<ul>還是 Google Trends </ul>
<ul>哪些網站使用 DZ? </ul>
<ul>YAHOO 網站排行榜前 10 名 </ul>
<ul>YAHOO 網站排行榜 11~20 名 </ul>
<ul>Rails 界也有 </ul>
RailsFUN.TW
<ul>受歡迎的原因 </ul>
<ul>符合華人使用習慣 </ul>
<ul>  </ul><ul>  </ul><ul>用戶組制度 + 積分制度 </ul>
<ul>論壇行為和積分掛勾 </ul>
<ul>積分可以讓 USER 升級 </ul>
<ul>會員間可以交易積分 </ul>
<ul>滿足資源論壇需求 </ul>
<ul>滿足 USER 升級的虛榮心 </ul>
<ul>插件 / 主題資源眾多 </ul>
<ul>效能 強大 </ul>
<ul>在 DZ 上開發功能 </ul>
 
<ul>省事 ! </ul>
<ul><li>LAYOUT 元件 </li></ul><ul><ul><li>數千種佈景主題可供選用 </li></ul></ul><ul><li>討論區
討論區的管理
認證 / 會員
會員的管理 </li></ul>
<ul>跨語言的 DRY 實現 </ul>
<ul>開始進入 技術層面 </ul>
<ul>呈現的方式 </ul>
<ul>INSIDE of DISCUZ!(AJAX) </ul>
<ul><li>不用自行處理登入登出
不用 render 整頁
容易一體化
和頁面元素可互動 </li></ul><ul>優點 </ul>
<ul><li>REQUEST 次數多
須修改 DZ 的樣板來達到 AJAX
切頁問題
LAYOUT 會被污染 </li></ul><ul>缺點 </ul>
<ul>INSIDE of DISCUZ!(Iframe) </ul>
<ul><li>不用自行處理登入登出
LAYOUT 不會被污染 </li></ul><ul>優點 </ul>
<ul><ul><li>回應慢 (2 個完整頁 )
一樣得修改樣板
無法和頁面互動
自己處理認證 </li></ul></ul><ul>缺點 </ul>
<ul>OUTSIDE of DISCUZ! </ul>
<ul><ul><li>完全掌控頁面
回應快
不用更改 DZ 樣板 </li></ul></ul><ul>優點 </ul>
<ul><ul><li>得自己處理認證
花時間模仿 DZ 的 HTML </li></ul></ul><ul>缺點 </ul>
<ul>從共用 Host 開始 </ul>
<ul>WEB 伺服器的選擇 </ul>
<ul>+ </ul>
<ul>Rails APP as Sub-URI </ul>
<ul>Mixed together </ul>
<ul>PHP deploy on SUB-URI </ul>
<ul>Config file of Discuz! </ul>
<ul>Map DB to ARecord </ul><ul><li>Set Primary Key and Table Name
Set emulate_booleans to false
Set inheritance_column to nil. </li></ul><ul>class   Forum  <  ActiveRecord :: Base </ul><ul>set_table_name  'cdb_forums' ...
<ul>Session </ul>
<ul>Session Table </ul><ul><ul><li>Caches username
Update lastactivity to avoid session lost. </li></ul></ul>
<ul>Session Key(1) </ul><ul>cookies[:#{cookie_pre}_sid] </ul><ul><ul><li>Primary Key of session table
Auto generated when you enter any page of DZ!
Upcoming SlideShare
Loading in …5
×

Ruby on discuz

4,843 views

Published on

Published in: Technology
  • Be the first to comment

Ruby on discuz

  1. 1. <ul>Ruby on Discuz! </ul><ul>Ryudo in Ruby Tuesday 2010.05.18 </ul>用 Ruby 擴充論壇的社群功能
  2. 2. <ul>自我 介紹 </ul>
  3. 3. <ul>鄧慕凡 </ul><ul>Mu-Fan Teng </ul>
  4. 4. <ul>我的 工作 </ul>
  5. 5. <ul>遊戲 開發 </ul><ul>Ex-Game Developer </ul>
  6. 8. <ul>網站 開發 </ul><ul>WEB Developer </ul>
  7. 9. <ul>網站 維運 </ul><ul>WEB Operation </ul>
  8. 10. <ul>FREEBBS.TW </ul>
  9. 11. <ul>GAMECLUB.TW </ul>
  10. 12. <ul>網路社群型態 </ul>
  11. 13. <ul>論壇 </ul><ul>Forum </ul>
  12. 14. <ul>部落格 </ul><ul>Blog </ul>
  13. 15. <ul>Google Trends(TW) </ul>
  14. 16. <ul>最強的論壇系統 </ul>
  15. 17. <ul>DISCUZ! </ul>
  16. 18. <ul>唯一 華人製作 </ul><ul>180 多人的大公司 </ul>
  17. 19. <ul>華人地區市場獨佔 </ul>
  18. 20. <ul>還是 Google Trends </ul>
  19. 21. <ul>哪些網站使用 DZ? </ul>
  20. 22. <ul>YAHOO 網站排行榜前 10 名 </ul>
  21. 23. <ul>YAHOO 網站排行榜 11~20 名 </ul>
  22. 24. <ul>Rails 界也有 </ul>
  23. 25. RailsFUN.TW
  24. 26. <ul>受歡迎的原因 </ul>
  25. 27. <ul>符合華人使用習慣 </ul>
  26. 28. <ul>  </ul><ul>  </ul><ul>用戶組制度 + 積分制度 </ul>
  27. 29. <ul>論壇行為和積分掛勾 </ul>
  28. 30. <ul>積分可以讓 USER 升級 </ul>
  29. 31. <ul>會員間可以交易積分 </ul>
  30. 32. <ul>滿足資源論壇需求 </ul>
  31. 33. <ul>滿足 USER 升級的虛榮心 </ul>
  32. 34. <ul>插件 / 主題資源眾多 </ul>
  33. 35. <ul>效能 強大 </ul>
  34. 36. <ul>在 DZ 上開發功能 </ul>
  35. 38. <ul>省事 ! </ul>
  36. 39. <ul><li>LAYOUT 元件 </li></ul><ul><ul><li>數千種佈景主題可供選用 </li></ul></ul><ul><li>討論區
  37. 40. 討論區的管理
  38. 41. 認證 / 會員
  39. 42. 會員的管理 </li></ul>
  40. 43. <ul>跨語言的 DRY 實現 </ul>
  41. 44. <ul>開始進入 技術層面 </ul>
  42. 45. <ul>呈現的方式 </ul>
  43. 46. <ul>INSIDE of DISCUZ!(AJAX) </ul>
  44. 47. <ul><li>不用自行處理登入登出
  45. 48. 不用 render 整頁
  46. 49. 容易一體化
  47. 50. 和頁面元素可互動 </li></ul><ul>優點 </ul>
  48. 51. <ul><li>REQUEST 次數多
  49. 52. 須修改 DZ 的樣板來達到 AJAX
  50. 53. 切頁問題
  51. 54. LAYOUT 會被污染 </li></ul><ul>缺點 </ul>
  52. 55. <ul>INSIDE of DISCUZ!(Iframe) </ul>
  53. 56. <ul><li>不用自行處理登入登出
  54. 57. LAYOUT 不會被污染 </li></ul><ul>優點 </ul>
  55. 58. <ul><ul><li>回應慢 (2 個完整頁 )
  56. 59. 一樣得修改樣板
  57. 60. 無法和頁面互動
  58. 61. 自己處理認證 </li></ul></ul><ul>缺點 </ul>
  59. 62. <ul>OUTSIDE of DISCUZ! </ul>
  60. 63. <ul><ul><li>完全掌控頁面
  61. 64. 回應快
  62. 65. 不用更改 DZ 樣板 </li></ul></ul><ul>優點 </ul>
  63. 66. <ul><ul><li>得自己處理認證
  64. 67. 花時間模仿 DZ 的 HTML </li></ul></ul><ul>缺點 </ul>
  65. 68. <ul>從共用 Host 開始 </ul>
  66. 69. <ul>WEB 伺服器的選擇 </ul>
  67. 70. <ul>+ </ul>
  68. 71. <ul>Rails APP as Sub-URI </ul>
  69. 72. <ul>Mixed together </ul>
  70. 73. <ul>PHP deploy on SUB-URI </ul>
  71. 74. <ul>Config file of Discuz! </ul>
  72. 75. <ul>Map DB to ARecord </ul><ul><li>Set Primary Key and Table Name
  73. 76. Set emulate_booleans to false
  74. 77. Set inheritance_column to nil. </li></ul><ul>class Forum < ActiveRecord :: Base </ul><ul>set_table_name 'cdb_forums' set_inheritance_column nil set_primary_key 'fid' connection.emulate_booleans = false default_scope :conditions => [ &quot;type = ? &quot; , 'forum' ] belongs_to :group , :class_name => 'ForumGroup' , :foreign_key => :fup has_many :children , :class_name => 'SubForum' , :foreign_key => :fup </ul><ul>end </ul>
  75. 78. <ul>Session </ul>
  76. 79. <ul>Session Table </ul><ul><ul><li>Caches username
  77. 80. Update lastactivity to avoid session lost. </li></ul></ul>
  78. 81. <ul>Session Key(1) </ul><ul>cookies[:#{cookie_pre}_sid] </ul><ul><ul><li>Primary Key of session table
  79. 82. Auto generated when you enter any page of DZ!
  80. 83. Not persistent. </li></ul></ul>
  81. 84. <ul>Session key(2) </ul><ul>cookies[:#{cookie_pre}_auth] </ul><ul><ul><li>Include login information
  82. 85. Could recover login session by decoding it.
  83. 86. Persistent. </li></ul></ul>
  84. 87. <ul>Session of Admin </ul><ul>table: #{table_prefix}_adminsessions </ul><ul><ul><li>Primary Key is also foreign key
  85. 88. Have 1 to 1 relation with session table
  86. 89. Available only if administrator logged in backend. </li></ul></ul>
  87. 90. <ul>Log in/out Process </ul><ul><li>URI:/logging.php?action=(login/logout)
  88. 91. Log out request(get) must with the formhash param. </li></ul>
  89. 92. <ul>Auth. Flow of logon </ul>
  90. 93. <ul>Member(1) </ul><ul>table: #{table_prefix}_members </ul>
  91. 94. <ul>Member(2) </ul><ul><ul><li>MD5.hexdigest(username) = Password
  92. 95. Field 「 credits 」 means 積分
  93. 96. Field extcredits1..8 </li></ul></ul>
  94. 97. <ul>MemberField </ul><ul><li>Additional fields for member
  95. 98. Column can be added automatically in DISCUZ!.
  96. 99. Manually added field names are fields1..2~
  97. 100. Able to find column metadata from profilefields table. </li></ul><ul>table: #{table_prefix}_memberfields </ul>
  98. 101. <ul>Forum Models(1) </ul><ul><li>table: #{table_prefix}_forums
  99. 102. 3 models share one table. </li></ul>
  100. 103. <ul>Forum Models(2) </ul>
  101. 104. <ul>Forum Table </ul><ul><li>Fid: Primary Key
  102. 105. Fup: foreign_key for Forum and SubForum
  103. 106. Type: </li></ul><ul><ul><ul><li>group => 論壇分類
  104. 107. forum => 論壇
  105. 108. sub => 子論壇 </li></ul></ul></ul>
  106. 109. <ul>ForumGroup( 論壇分類 ) </ul><ul>class ForumGroup < ActiveRecord :: Base </ul><ul>set_table_name 'cdb_forums' set_inheritance_column nil set_primary_key 'fid' connection.emulate_booleans = false default_scope :conditions => [ &quot;type = ? &quot; , 'group' ] has_many :forums , :class_name => 'Forum' , :foreign_key => 'fup' </ul><ul>end </ul>
  107. 110. <ul>ForumGroup( 論壇 ) </ul><ul>class Forum < ActiveRecord :: Base </ul><ul>set_table_name 'cdb_forums' set_inheritance_column nil set_primary_key 'fid' connection.emulate_booleans = false default_scope :conditions => [ &quot;type = ? &quot; , 'forum' ] belongs_to :group , :class_name => 'ForumGroup' , :foreign_key => :fup has_many :children , :class_name => 'SubForum' , :foreign_key => :fup </ul><ul>end </ul>
  108. 111. <ul>SubForum ( 子論壇 ) </ul><ul>class SubForum < ActiveRecord :: Base </ul><ul>set_table_name 'cdb_forums' set_inheritance_column nil set_primary_key 'fid' connection.emulate_booleans = false default_scope :conditions => [ &quot;type = ? &quot; , 'sub' ] belongs_to :forum , :class_name => 'Forum' , :foreign_key => :fup </ul><ul>end </ul>
  109. 112. <ul>Topic Models </ul>
  110. 113. <ul>Topic( 主題 ) Table(1) </ul><ul><li>Table Name : #{prefix}_threads
  111. 114. Primary Key : tid
  112. 115. Class Name can’t be 「 Thread 」
  113. 116. Belongs to Forum and SubForum </li></ul>
  114. 117. <ul>Topic Table(2) </ul><ul>class Topic < ActiveRecord :: Base </ul><ul>set_table_name 'cdb_threads' set_primary_key 'tid' connection.emulate_booleans = false belongs_to :forum , :foreign_key => :fid belongs_to :sub_forum , :foreign_key => :fid has_many :posts , :foreign_key => :tid </ul><ul>end </ul>
  115. 118. <ul>Post( 帖 ) Table </ul><ul><li>Table Name : #{prefix}_posts
  116. 119. Primary Key : pid
  117. 120. Caches fid value from Topic.
  118. 121. Field 「 first 」 means first post(1) or not(0)
  119. 122. Each post can have its own subject
  120. 123. Field 「 htmlon 」 means escape HTML or not. </li></ul>
  121. 124. <ul>Topic Table(2) </ul><ul>class Post < ActiveRecord :: Base </ul><ul>set_table_name 'cdb_posts' set_primary_key 'pid' connection.emulate_booleans = false belongs_to :forum , :foreign_key => :fid belongs_to :sub_forum , :foreign_key => :fid belongs_to :topic , :foreign_key => :tid named_scope :html_escaped , :conditions => 'htmlon = 0' named_scope :html_not_escaped , :conditions => 'htmlon = 1' named_scope :first , :conditions => 'first = 1' named_scope :not_first , :conditions => 'first <> 1' </ul><ul>end </ul>
  122. 125. <ul>Build Layout by DZ styles </ul><ul><li>Get Session data row and styleid
  123. 126. Link 「 /forumdata/cache/style_#{styleid}.css 」
  124. 127. Customize Paginate Renderer for WillPaginate to make DZ-Style Paginate DIV. </li></ul><ul>class DiscuzLinkRenderer < WillPaginate :: LinkRenderer </ul><ul>... </ul><ul>end </ul>
  125. 128. <ul>END </ul>

×