ruby on discuz

Download Ruby on discuz

If you can't read please download the document

Upload: mu-fan-teng

Post on 19-May-2015

4.308 views

Category:

Technology


2 download

TRANSCRIPT

  • 1.
    • Ruby on Discuz!
    • Ryudo in Ruby Tuesday 2010.05.18
    Ruby

2.

3.

  • Mu-Fan Teng

4.

5.

  • Ex-Game Developer

6. 7. 8.

  • WEB Developer

9.

  • WEB Operation

10.

  • FREEBBS.TW

11.

  • GAMECLUB.TW

12.

13.

  • Forum

14.

  • Blog

15.

  • Google Trends(TW)

16.

17.

  • DISCUZ!

18.

  • 180

19.

20.

  • Google Trends

21.

  • DZ?

22.

  • YAHOO 10

23.

  • YAHOO 11~20

24.

  • Rails

25. RailsFUN.TW 26.

27.

28.

  • +

29.

30.

  • USER

31.

32.

33.

  • USER

34.

  • /

35.

36.

  • DZ

37. 38.

  • !

39.

  • LAYOUT

40. 41. / 42. 43.

  • DRY

44.

45.

46.

  • INSIDE of DISCUZ!(AJAX)

47.

48. render 49. 50.

51.

  • REQUEST

52. DZ AJAX 53. 54. LAYOUT

55.

  • INSIDE of DISCUZ!(Iframe)

56.

57. LAYOUT

58.

    • (2 )
  • 59.

60. 61.

62.

  • OUTSIDE of DISCUZ!

63.

  • 64.

65. DZ

66.

  • 67. DZ HTML

68.

  • Host

69.

  • WEB

70.

71.

  • Rails APP as Sub-URI

72.

  • Mixed together

73.

  • PHP deploy on SUB-URI

74.

  • Config file of Discuz!

75.

  • Map DB to ARecord
  • Set Primary Key and Table Name

76. Set emulate_booleans to false 77. Set inheritance_column to nil.

  • class Forum
  • set_table_name'cdb_forums' set_inheritance_columnnil set_primary_key'fid' connection.emulate_booleans =false default_scope:conditions=> [ "type = ? " ,'forum' ] belongs_to:group ,:class_name=>'ForumGroup' ,:foreign_key=>:fup has_many:children ,:class_name=>'SubForum' ,:foreign_key=>:fup
  • end

78.

  • Session

79.

  • Session Table
    • Caches username
  • 80. Update lastactivity to avoid session lost.

81.

  • Session Key(1)
  • cookies[:#{cookie_pre}_sid]
    • Primary Key of session table
  • 82. Auto generated when you enter any page of DZ!

83. Notpersistent. 84.

  • Session key(2)
  • cookies[:#{cookie_pre}_auth]
    • Include login information
  • 85. Could recover login session by decoding it.

86. Persistent. 87.

  • Session of Admin
  • table: #{table_prefix}_adminsessions
    • Primary Key is also foreign key
  • 88. Have 1 to 1 relation with session table

89. Available only if administrator logged in backend. 90.

  • Log in/out Process
  • URI:/logging.php?action=(login/logout)

91. Log out request(get) must with the formhash param. 92.

  • Auth. Flow of logon

93.

  • Member(1)
  • table: #{table_prefix}_members

94.

  • Member(2)
    • MD5.hexdigest(username) = Password
  • 95. Field creditsmeans

96. Field extcredits1..8 97.

  • MemberField
  • Additional fields for member

98. Column can be added automatically in DISCUZ!. 99. Manually added field names are fields1..2~ 100. Able to find column metadata from profilefields table.

  • table: #{table_prefix}_memberfields

101.

  • Forum Models(1)
  • table: #{table_prefix}_forums

102. 3 models share one table. 103.

  • Forum Models(2)

104.

  • Forum Table
  • Fid: Primary Key

105. Fup: foreign_key for Forum and SubForum 106. Type:

      • group =>
    • 107. forum =>
  • 108. sub =>

109.

  • ForumGroup( )
  • class ForumGroup
  • set_table_name'cdb_forums' set_inheritance_columnnil set_primary_key'fid' connection.emulate_booleans =false default_scope:conditions=> [ "type = ? " ,'group' ] has_many:forums ,:class_name=>'Forum' ,:foreign_key=>'fup'
  • end

110.

  • ForumGroup( )
  • class Forum
  • set_table_name'cdb_forums' set_inheritance_columnnil set_primary_key'fid' connection.emulate_booleans =false default_scope:conditions=> [ "type = ? " ,'forum' ] belongs_to:group ,:class_name=>'ForumGroup' ,:foreign_key=>:fup has_many:children ,:class_name=>'SubForum' ,:foreign_key=>:fup
  • end

111.

  • SubForum ( )
  • class SubForum
  • set_table_name'cdb_forums' set_inheritance_columnnil set_primary_key'fid' connection.emulate_booleans =false default_scope:conditions=> [ "type = ? " ,'sub' ] belongs_to:forum ,:class_name=>'Forum' ,:foreign_key=>:fup
  • end

112.

  • Topic Models

113.

  • Topic( ) Table(1)
  • Table Name : #{prefix}_threads

114. Primary Key : tid 115. Class Name cant be Thread 116. Belongs to Forum and SubForum 117.

  • Topic Table(2)
  • class Topic
  • 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
  • end

118.

  • Post( ) Table
  • Table Name : #{prefix}_posts

119. Primary Key : pid 120. Caches fid value from Topic. 121. Field first means first post(1) or not(0) 122. Each post can have its own subject 123. Field htmlon means escape HTML or not. 124.

  • Topic Table(2)
  • class Post
  • 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'
  • end

125.

  • Build Layout by DZ styles
  • Get Session data row and styleid

126. Link /forumdata/cache/style_#{styleid}.css 127. Customize Paginate Renderer for WillPaginate to make DZ-Style Paginate DIV.

  • class DiscuzLinkRenderer
  • ...
  • end

128.

  • END