blogaze 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. data/README.md +12 -13
  2. data/blogaze.gemspec +1 -0
  3. data/lib/blogaze.rb +2 -2
  4. data/lib/blogaze/bin/create.rb +6 -0
  5. data/lib/blogaze/controllers/admin/comments.rb +43 -0
  6. data/lib/blogaze/controllers/admin/dashboard.rb +25 -0
  7. data/lib/blogaze/controllers/admin/init.rb +30 -0
  8. data/lib/blogaze/controllers/admin/pages.rb +95 -0
  9. data/lib/blogaze/controllers/admin/posts.rb +125 -0
  10. data/lib/blogaze/controllers/admin/settings.rb +41 -0
  11. data/lib/blogaze/{controller → controllers}/init.rb +1 -1
  12. data/lib/blogaze/controllers/main_controller.rb +35 -0
  13. data/lib/blogaze/controllers/pages.rb +39 -0
  14. data/lib/blogaze/controllers/posts.rb +77 -0
  15. data/lib/blogaze/controllers/sessions.rb +50 -0
  16. data/lib/blogaze/controllers/users.rb +41 -0
  17. data/lib/blogaze/models/comment.rb +28 -0
  18. data/lib/blogaze/{model → models}/group.rb +6 -4
  19. data/lib/blogaze/{model → models}/init.rb +0 -0
  20. data/lib/blogaze/models/page.rb +29 -0
  21. data/lib/blogaze/models/post.rb +95 -0
  22. data/lib/blogaze/models/tag.rb +25 -0
  23. data/lib/blogaze/{model → models}/tags_relationship.rb +6 -4
  24. data/lib/blogaze/models/user.rb +43 -0
  25. data/lib/blogaze/routes.rb +4 -0
  26. data/lib/blogaze/theme.rb +17 -0
  27. data/lib/blogaze/version.rb +1 -1
  28. data/proto/public/css/master.less +16 -12
  29. data/proto/themes/default/admin/index.xhtml +4 -4
  30. data/proto/themes/default/admin/settings/index.xhtml +1 -1
  31. data/proto/themes/default/index.xhtml +6 -3
  32. data/proto/themes/default/layouts/admin.xhtml +2 -2
  33. data/proto/themes/default/layouts/default.xhtml +1 -1
  34. data/proto/themes/default/posts/view.xhtml +3 -3
  35. metadata +37 -21
  36. data/lib/blogaze/controller/admin/comments.rb +0 -32
  37. data/lib/blogaze/controller/admin/init.rb +0 -28
  38. data/lib/blogaze/controller/admin/main.rb +0 -20
  39. data/lib/blogaze/controller/admin/pages.rb +0 -75
  40. data/lib/blogaze/controller/admin/posts.rb +0 -103
  41. data/lib/blogaze/controller/admin/settings.rb +0 -33
  42. data/lib/blogaze/controller/main.rb +0 -30
  43. data/lib/blogaze/controller/pages.rb +0 -34
  44. data/lib/blogaze/controller/posts.rb +0 -43
  45. data/lib/blogaze/controller/sessions.rb +0 -39
  46. data/lib/blogaze/controller/users.rb +0 -39
  47. data/lib/blogaze/model/comment.rb +0 -26
  48. data/lib/blogaze/model/page.rb +0 -27
  49. data/lib/blogaze/model/post.rb +0 -79
  50. data/lib/blogaze/model/tag.rb +0 -19
  51. data/lib/blogaze/model/user.rb +0 -41
@@ -1,27 +0,0 @@
1
- #
2
- # Blogaze
3
- # Copyright (C) 2011-2013 Jack Polgar
4
- #
5
- # Blogaze is released under the BSD 3-clause license.
6
- # @license http://opensource.org/licenses/BSD-3-Clause
7
- #
8
-
9
- module Blogaze
10
- class Page < Sequel::Model
11
- plugin :validation_helpers
12
-
13
- def validate
14
- validates_presence [:title, :slug, :body]
15
- end
16
-
17
- def before_create
18
- super
19
- self.created_at = Time.now.to_i
20
- self.updated_at = 0
21
- end
22
-
23
- def before_save
24
- self.updated_at = Time.now.to_i
25
- end
26
- end
27
- end
@@ -1,79 +0,0 @@
1
- #
2
- # Blogaze
3
- # Copyright (C) 2011-2013 Jack Polgar
4
- #
5
- # Blogaze is released under the BSD 3-clause license.
6
- # @license http://opensource.org/licenses/BSD-3-Clause
7
- #
8
-
9
- module Blogaze
10
- class Post < Sequel::Model
11
- attr_accessor :post_tags
12
- plugin :validation_helpers
13
-
14
- many_to_one :user
15
- one_to_many :comment do |cmt|
16
- cmt.filter{in_moderation < 1}
17
- end
18
-
19
- def href
20
- return '/' + Time.at(self.published_at).year.to_s + '/' + Time.at(self.published_at).month.to_s + '/' + self.slug
21
- end
22
-
23
- def tags
24
- tags = []
25
- relationships = TagsRelationship.where(:object_id => self.id, :object_type => 'post')
26
- relationships.each do |rel|
27
- tags.push rel.tag
28
- end
29
-
30
- return tags
31
- end
32
-
33
- def body_partial
34
- body = self.body.split('<!-- MORE -->')
35
- return body[0]
36
- end
37
-
38
- def validate
39
- validates_presence [:title, :body, :user_id]
40
- validates_integer :user_id
41
- end
42
-
43
- def before_create
44
- super
45
- self.slug = Innate::Helper::CGI.u(self.title.scan(/\w+/).join('-')).downcase
46
- self.created_at = Time.now.to_i
47
- self.published_at = Time.now.to_i
48
- self.updated_at = 0
49
- end
50
-
51
- def before_save
52
- self.slug = Innate::Helper::CGI.u(self.title.scan(/\w+/).join('-')).downcase
53
- self.updated_at = Time.now.to_i
54
- end
55
-
56
- def after_save
57
- process_tags
58
- end
59
-
60
- private
61
-
62
- def process_tags
63
- tag_names = []
64
- post_tags.each do |tag|
65
- t = Tag.find_or_create(:name => tag.strip)
66
- tag_names.push t.name
67
- if t and !TagsRelationship.where(:object_id => id, :object_type => 'post', :tag_id => t.id).first
68
- TagsRelationship.new({ :object_id => id, :object_type => 'post', :tag_id => t.id }).save
69
- end
70
- end
71
-
72
- tags.each do |tag|
73
- if not tag_names.include?(tag.name)
74
- TagsRelationship.where({ :object_id => id, :object_type => 'post', :tag_id => tag.id }).delete
75
- end
76
- end
77
- end
78
- end
79
- end
@@ -1,19 +0,0 @@
1
- #
2
- # Blogaze
3
- # Copyright (C) 2011-2013 Jack Polgar
4
- #
5
- # Blogaze is released under the BSD 3-clause license.
6
- # @license http://opensource.org/licenses/BSD-3-Clause
7
- #
8
-
9
- module Blogaze
10
- class Tag < Sequel::Model
11
- def href
12
- "/tags/#{slug}"
13
- end
14
-
15
- def before_save
16
- self.slug = Innate::Helper::CGI.u(self.name.scan(/\w+/).join('-')).downcase
17
- end
18
- end
19
- end
@@ -1,41 +0,0 @@
1
- #
2
- # Blogaze
3
- # Copyright (C) 2011-2013 Jack Polgar
4
- #
5
- # Blogaze is released under the BSD 3-clause license.
6
- # @license http://opensource.org/licenses/BSD-3-Clause
7
- #
8
-
9
- module Blogaze
10
- class User < Sequel::Model
11
- plugin :validation_helpers
12
-
13
- one_to_many :post
14
- many_to_one :group
15
-
16
- def validate
17
- super
18
-
19
- # Username
20
- validates_unique :username
21
- validates_min_length 4, :username, :message => 'must be at least 4 characters' if new?
22
- validates_presence :username, :message => 'can\'t be empty'
23
-
24
- # Password
25
- validates_presence :password, :message => 'cant be blank'
26
- validates_min_length 6, :password, :message => 'must be at least 6 characters'
27
-
28
- # Email
29
- validates_unique :email
30
- validates_format /(.*)@(.*)\.(.*)/, :email, :message => 'is not a valid email'
31
- end
32
-
33
- def before_create
34
- self.password = Digest::SHA1.hexdigest(self.password)
35
- self.group_id = 3
36
- end
37
-
38
- def before_save
39
- end
40
- end
41
- end