wpb 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ wiki/
data/Changelog.md CHANGED
@@ -1,4 +1,17 @@
1
- ## Changelog
1
+ # Changelog
2
+
3
+ ### Release 0.0.3
4
+ * 1 major feature
5
+ * Added comments support
6
+ * 3 minor features
7
+ * Saving a Page or Post now updates the post_modified and post_modified_gmt columns to the current time and date
8
+ * When creating a page some values are now filled in for you
9
+ * Checks to see if post has an author
10
+ * 2 minor bug fixes
11
+ * Shortcuts to columns in PagePost and User (e.g. title= or name=) were not setting the value
12
+ * Having a post type other than post and page would break app
13
+ * 1 depreciated
14
+ * `body` and `body=` in Page/Post models use `content` and `content=` instead (method removed completeley)
2
15
 
3
16
  ### Release 0.0.2
4
17
  * 1 minor feature
@@ -0,0 +1,27 @@
1
+ require "active_record"
2
+
3
+ class Comment < ActiveRecord::Base
4
+ set_table_name :wp_comments
5
+ set_primary_key :comment_ID
6
+
7
+ belongs_to :page_post
8
+ belongs_to :user
9
+
10
+ validates_presence_of :comment_post_ID
11
+
12
+ before_create :set_default_values
13
+
14
+ def set_default_values
15
+ t = Time.now
16
+ self.comment_date = t
17
+ self.comment_date_gmt = t.gmtime
18
+ end
19
+
20
+ def content
21
+ comment_content
22
+ end
23
+
24
+ def content= new_content
25
+ self.comment_content = new_content
26
+ end
27
+ end
data/lib/wpb/pagepost.rb CHANGED
@@ -5,9 +5,33 @@ class PagePost < ActiveRecord::Base
5
5
  set_primary_key :ID
6
6
 
7
7
  before_save :update_date
8
+ before_create :set_default_values
9
+
10
+ validates_presence_of :post_author
11
+
12
+ has_many :comments, :foreign_key => :comment_post_ID
13
+
14
+ def set_default_values
15
+ t = Time.now
16
+ self.post_date = t
17
+ self.post_date_gmt = t.gmtime
18
+
19
+ # Ready for when Site model is added
20
+ # site_url = Site.find_by_option_name "siteurl"
21
+ # type = 'p'
22
+ # if self.type == "Page"
23
+ # type << 'age_id'
24
+ # end
25
+ # self.guid = "#{site_url}/?#{type}=#{self.id}"
26
+
27
+ urlify = self.post_title.dup.downcase.gsub(' ', '-')
28
+ self.post_name = urlify
29
+ end
8
30
 
9
31
  def update_date
10
- #TODO: update date_modified column
32
+ t = Time.now
33
+ self.post_modified = t
34
+ self.post_modified_gmt = t.gmtime
11
35
  end
12
36
 
13
37
  def title
@@ -15,14 +39,14 @@ class PagePost < ActiveRecord::Base
15
39
  end
16
40
 
17
41
  def title= new_title
18
- post_title = new_title
42
+ self.post_title = new_title
19
43
  end
20
44
 
21
- def body
45
+ def content
22
46
  post_content
23
47
  end
24
48
 
25
- def body= new_content
26
- post_content = new_content
49
+ def content= new_content
50
+ self.post_content = new_content
27
51
  end
28
52
  end
data/lib/wpb/user.rb CHANGED
@@ -7,13 +7,14 @@ class User < ActiveRecord::Base
7
7
  has_many :settings
8
8
  has_many :pages, :foreign_key => :post_author
9
9
  has_many :posts, :foreign_key => :post_author
10
+ has_many :comments, :foreign_key => :user_id
10
11
 
11
12
  def name
12
13
  display_name
13
14
  end
14
15
 
15
16
  def name= name
16
- display_name = name
17
+ self.display_name = name
17
18
  end
18
19
 
19
20
  def username
@@ -21,7 +22,7 @@ class User < ActiveRecord::Base
21
22
  end
22
23
 
23
24
  def username= username
24
- user_login = username
25
+ self.user_login = username
25
26
  end
26
27
 
27
28
  def email
@@ -29,6 +30,6 @@ class User < ActiveRecord::Base
29
30
  end
30
31
 
31
32
  def email= email
32
- user_email = email
33
+ self.user_email = email
33
34
  end
34
35
  end
data/lib/wpb/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module WPB
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/wpb.rb CHANGED
@@ -4,6 +4,7 @@ require "wpb/setting"
4
4
  require "wpb/pagepost"
5
5
  require "wpb/page"
6
6
  require "wpb/post"
7
+ require "wpb/comment"
7
8
  require "active_record"
8
9
 
9
10
  config = {
@@ -24,10 +25,6 @@ class AddType < ActiveRecord::Migration
24
25
  add_column :wp_posts, :type, :string
25
26
  PagePost.reset_column_information
26
27
  end
27
- PagePost.all.each do |p|
28
- p.type = p.post_type.capitalize
29
- p.save
30
- end
31
28
  end
32
29
  end
33
30
 
@@ -37,6 +34,13 @@ class AddType < ActiveRecord::Migration
37
34
  end
38
35
 
39
36
  AddType::up
37
+ PagePost.all.each do |p|
38
+ p.type = p.post_type.capitalize
39
+ if p.post_type != "post" && p.post_type != "page"
40
+ p.type = "Post"
41
+ end
42
+ p.save
43
+ end
40
44
 
41
45
  module WPB
42
46
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: wpb
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - James Birtles
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-17 00:00:00 +01:00
13
+ date: 2011-05-18 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -41,6 +41,7 @@ files:
41
41
  - Rakefile
42
42
  - bin/wpb
43
43
  - lib/wpb.rb
44
+ - lib/wpb/comment.rb
44
45
  - lib/wpb/page.rb
45
46
  - lib/wpb/pagepost.rb
46
47
  - lib/wpb/post.rb