blogaze 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -7,7 +7,9 @@
7
7
  #
8
8
 
9
9
  module Blogaze
10
- class TagsRelationship < Sequel::Model
11
- many_to_one :tag
12
- end
13
- end
10
+ module Models
11
+ class TagsRelationship < Sequel::Model
12
+ many_to_one :tag
13
+ end # TagsRelationship
14
+ end # Models
15
+ end # Blogaze
@@ -0,0 +1,43 @@
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
+ module Models
11
+ class User < Sequel::Model
12
+ plugin :validation_helpers
13
+
14
+ one_to_many :post
15
+ many_to_one :group
16
+
17
+ def validate
18
+ super
19
+
20
+ # Username
21
+ validates_unique :username
22
+ validates_min_length 4, :username, :message => 'must be at least 4 characters' if new?
23
+ validates_presence :username, :message => 'can\'t be empty'
24
+
25
+ # Password
26
+ validates_presence :password, :message => 'cant be blank'
27
+ validates_min_length 6, :password, :message => 'must be at least 6 characters'
28
+
29
+ # Email
30
+ validates_unique :email
31
+ validates_format /(.*)@(.*)\.(.*)/, :email, :message => 'is not a valid email'
32
+ end
33
+
34
+ def before_create
35
+ self.password = Digest::SHA1.hexdigest(self.password)
36
+ self.group_id = 3
37
+ end
38
+
39
+ def before_save
40
+ end
41
+ end # User
42
+ end # Models
43
+ end # Blogaze
@@ -14,6 +14,10 @@ module Blogaze
14
14
  ::Ramaze::Route[/^\/[0-9]+\/[0-9]+\/([\w\.\-]+)$/] = '/posts/view/%s'
15
15
  ::Ramaze::Route[/\/page\/([0-9]+)/] = '/%d'
16
16
 
17
+ # Tag routes
18
+ ::Ramaze::Route[/^\/tags\/([\w]+)$/] = '/posts/tag/%s'
19
+ #::Ramaze::Route[/^\/tags\/([\w]+)\/page\/([0-9]+)$/] = '/posts/tag/%s/%d'
20
+
17
21
  # User routes
18
22
  ::Ramaze::Route['/login'] = '/sessions/new'
19
23
  ::Ramaze::Route['/logout'] = '/sessions/destroy'
data/lib/blogaze/theme.rb CHANGED
@@ -11,8 +11,12 @@ module Blogaze
11
11
  attr_accessor :name
12
12
  attr_accessor :templates
13
13
 
14
+ # Registered themes
14
15
  REGISTERED = {}
15
16
 
17
+ ##
18
+ # Sets the themes name as a symbol
19
+ #
16
20
  def name=(name)
17
21
  @name = name.to_sym
18
22
  end
@@ -20,24 +24,37 @@ module Blogaze
20
24
  class << self
21
25
  attr_accessor :current
22
26
 
27
+ ##
28
+ # Adds a new theme
29
+ #
23
30
  def add
24
31
  theme = self.new
25
32
  yield theme
26
33
  REGISTERED[theme.name] = theme
27
34
  end
28
35
 
36
+ ##
37
+ # Returns the with matching the supplied name.
38
+ #
29
39
  def [](name)
30
40
  name = name.to_sym
31
41
  raise("Invalid theme #{name}") unless REGISTERED.key?(name)
32
42
  return REGISTERED[name]
33
43
  end
34
44
 
45
+ ##
46
+ # Sets the supplied name as the
47
+ # current theme to be used.
48
+ #
35
49
  def use(name)
36
50
  name = name.to_sym
37
51
  raise("Unable to use theme #{name}: not registered") unless REGISTERED.key?(name)
38
52
  @current = REGISTERED[name]
39
53
  end
40
54
 
55
+ ##
56
+ # Returns the registered themes.
57
+ #
41
58
  def registered
42
59
  REGISTERED.to_a
43
60
  end
@@ -7,5 +7,5 @@
7
7
  #
8
8
 
9
9
  module Blogaze
10
- VERSION = "0.0.1"
10
+ VERSION = "0.0.2"
11
11
  end
@@ -33,35 +33,35 @@ body {
33
33
  color: #fff;
34
34
  padding: 8px;
35
35
  height: 36px;
36
-
36
+
37
37
  a {
38
38
  color: #fff;
39
39
  text-decoration: none;
40
40
  }
41
-
41
+
42
42
  h1 {
43
43
  font-weight: bold;
44
44
  color: #fff;
45
45
  margin: 0;
46
46
  float: left;
47
47
  }
48
-
48
+
49
49
  nav {
50
50
  margin-top: 7px;
51
51
  font-size: 15px;
52
52
  float: right;
53
-
53
+
54
54
  ul, li {
55
55
  margin: 0;
56
56
  padding: 0;
57
57
  list-style: none;
58
58
  display: inline;
59
59
  }
60
-
60
+
61
61
  li {
62
62
  margin: 0 2px;
63
63
  }
64
-
64
+
65
65
  a:hover {
66
66
  text-decoration: underline;
67
67
  }
@@ -69,6 +69,10 @@ body {
69
69
  }
70
70
 
71
71
  /* ==========# Posts and Content #==========*/
72
+ h2 {
73
+ margin: 0;
74
+ }
75
+
72
76
  .content, .post-body {
73
77
  padding: 5px;
74
78
  }
@@ -93,7 +97,7 @@ body {
93
97
  margin: 0;
94
98
  line-height: 1;
95
99
  font-size: 18px;
96
-
100
+
97
101
  a {
98
102
  color: #fff;
99
103
  text-decoration: none;
@@ -114,11 +118,11 @@ body {
114
118
 
115
119
  .pager_nav {
116
120
  height: 18px;
117
-
121
+
118
122
  .prev {
119
123
  float: left;
120
124
  }
121
-
125
+
122
126
  .next {
123
127
  float: right;
124
128
  }
@@ -128,7 +132,7 @@ body {
128
132
  h3 {
129
133
  margin-bottom: 4px;
130
134
  }
131
-
135
+
132
136
  h4 {
133
137
  font-size: 14px;
134
138
  }
@@ -166,7 +170,7 @@ body {
166
170
  text-align: left;
167
171
  width: 0;
168
172
  }
169
-
173
+
170
174
  input[type=checkbox] {
171
175
  margin-top: 10px;
172
176
  }
@@ -185,4 +189,4 @@ body {
185
189
 
186
190
  table.list {
187
191
  margin-bottom: 0;
188
- }
192
+ }
@@ -3,10 +3,10 @@
3
3
  <div class="content">
4
4
  What would you like to do today?
5
5
  <ul>
6
- <li>#{a 'Change Settings', Blogaze::Admin::Settings.r('/')}</li>
7
- <li>#{a 'Manage Posts', Blogaze::Admin::Posts.r('/')}</li>
8
- <li>#{a 'Manage Comments', Blogaze::Admin::Comments.r('/')}</li>
9
- <li>#{a 'Manage Pages', Blogaze::Admin::Pages.r('/')}</li>
6
+ <li>#{a 'Change Settings', Blogaze::Controllers::Admin::Settings.r('/')}</li>
7
+ <li>#{a 'Manage Posts', Blogaze::Controllers::Admin::Posts.r('/')}</li>
8
+ <li>#{a 'Manage Comments', Blogaze::Controllers::Admin::Comments.r('/')}</li>
9
+ <li>#{a 'Manage Pages', Blogaze::Controllers::Admin::Pages.r('/')}</li>
10
10
  </ul>
11
11
  </div>
12
12
  </div>
@@ -1,7 +1,7 @@
1
1
  <div id="page_content">
2
2
  <h2 id="page-title">Settings</h2>
3
3
  <div class="content">
4
- <form action="#{Blogaze::Admin::Settings.r('save')}" method="post" class="tabular">
4
+ <form action="#{Blogaze::Controllers::Admin::Settings.r('save')}" method="post" class="tabular">
5
5
  <p>
6
6
  <label>Blog Title</label>
7
7
  <input type="text" name="settings[title]" value="#{@settings[:title]}">
@@ -1,7 +1,10 @@
1
+ <?r if @tag ?>
2
+ <h2>Posts tagged #{@tag.name}</h2>
3
+ <?r end ?>
1
4
  <?r @posts.each do |post| ?>
2
5
  <article class="post">
3
6
  <header>
4
- <h2 class="title">#{a post.title, '/' + Time.at(post.created_at).year.to_s + '/' + Time.at(post.created_at).month.to_s + '/' + post.slug}</h2>
7
+ <h3 class="title"><a href="#{post.href}">#{post.title}</a></h3>
5
8
  </header>
6
9
  <div class="post-body">
7
10
  <?r if post.body == post.body_partial ?>
@@ -15,11 +18,11 @@
15
18
  <?r if post.tags.count > 0 ?>
16
19
  <div class="tags">
17
20
  <?r post.tags.each do |tag| ?>
18
- #{a tag.name, tag.href}
21
+ <a href="#{tag.href}">#{tag.name}</a>
19
22
  <?r end ?>
20
23
  </div>
21
24
  <?r end ?>
22
- By #{post.user.username}, <abbr title="#{Time.at(post.published_at)}">#{post.published_at.ago_in_words}</abbr>, <a href="#{post.href}#comments">#{post.comment.count} comments</a>
25
+ By #{post.user.username}, <abbr title="#{Time.at(post.published_at)}">#{post.published_at.ago_in_words}</abbr>, <a href="#{post.href}#comments">#{post.comments.count} comments</a>
23
26
  </footer>
24
27
  </article>
25
28
  <?r end ?>
@@ -13,10 +13,10 @@
13
13
  <body>
14
14
  <div id="wrapper">
15
15
  <header id="header">
16
- <h1>#{a 'AdminCP', Blogaze::Admin::Dashboard.r('/')}</h1>
16
+ <h1>#{a 'AdminCP', Blogaze::Controllers::Admin::Dashboard.r('/')}</h1>
17
17
  <nav>
18
18
  <ul>
19
- <li>#{a 'View Site', Blogaze::MainController.r('/')}</li>
19
+ <li>#{a 'View Site', Blogaze::Controllers::MainController.r('/')}</li>
20
20
  <li><a href="/logout">Logout</a></li>
21
21
  </ul>
22
22
  </nav>
@@ -16,7 +16,7 @@
16
16
  <h1><a href="/">#{@settings[:title]}</a></h1>
17
17
  <nav>
18
18
  <ul>
19
- <?r ::Blogaze::Page.filter(:on_menu => 1).all.each do |page| ?>
19
+ <?r ::Blogaze::Models::Page.filter(:on_menu => 1).all.each do |page| ?>
20
20
  <li><a href="/#{page.slug}">#{page.title}</a></li>
21
21
  <?r end ?>
22
22
  <?r if session[:logged_in] ?>
@@ -9,17 +9,17 @@
9
9
  <?r if @post.tags.count > 0 ?>
10
10
  <div class="tags">
11
11
  <?r @post.tags.each do |tag| ?>
12
- #{a tag.name, tag.href}
12
+ <a href="#{tag.href}">#{tag.name}</a>
13
13
  <?r end ?>
14
14
  </div>
15
15
  <?r end ?>
16
- By #{@post.user.username}, <abbr title="#{Time.at(@post.published_at)}">#{@post.published_at.ago_in_words}</abbr>, #{@post.comment.count} comments
16
+ By #{@post.user.username}, <abbr title="#{Time.at(@post.published_at)}">#{@post.published_at.ago_in_words}</abbr>, #{@post.comments.count} comments
17
17
  </footer>
18
18
  </article>
19
19
 
20
20
  <section id="comments">
21
21
  <h3><a name="comments" class="no-href">Comments</a></h3>
22
- <?r @post.comment.each do |comment| ?>
22
+ <?r @post.comments.each do |comment| ?>
23
23
  <div class="comment">
24
24
  <h4>#{comment.author}, #{comment.created_at.ago_in_words}</h4>
25
25
  <div class="content">
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blogaze
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -75,6 +75,22 @@ dependencies:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
77
  version: 0.2.5
78
+ - !ruby/object:Gem::Dependency
79
+ name: shebang
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '0.1'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '0.1'
78
94
  description: Blogaze is a simple blog powered by Ramaze and Sequel.
79
95
  email:
80
96
  - nrx@nirix.net
@@ -93,31 +109,31 @@ files:
93
109
  - lib/blogaze.rb
94
110
  - lib/blogaze/bin/create.rb
95
111
  - lib/blogaze/bin/default.rb
96
- - lib/blogaze/controller/admin/comments.rb
97
- - lib/blogaze/controller/admin/init.rb
98
- - lib/blogaze/controller/admin/main.rb
99
- - lib/blogaze/controller/admin/pages.rb
100
- - lib/blogaze/controller/admin/posts.rb
101
- - lib/blogaze/controller/admin/settings.rb
102
- - lib/blogaze/controller/init.rb
103
- - lib/blogaze/controller/main.rb
104
- - lib/blogaze/controller/pages.rb
105
- - lib/blogaze/controller/posts.rb
106
- - lib/blogaze/controller/sessions.rb
107
- - lib/blogaze/controller/users.rb
112
+ - lib/blogaze/controllers/admin/comments.rb
113
+ - lib/blogaze/controllers/admin/dashboard.rb
114
+ - lib/blogaze/controllers/admin/init.rb
115
+ - lib/blogaze/controllers/admin/pages.rb
116
+ - lib/blogaze/controllers/admin/posts.rb
117
+ - lib/blogaze/controllers/admin/settings.rb
118
+ - lib/blogaze/controllers/init.rb
119
+ - lib/blogaze/controllers/main_controller.rb
120
+ - lib/blogaze/controllers/pages.rb
121
+ - lib/blogaze/controllers/posts.rb
122
+ - lib/blogaze/controllers/sessions.rb
123
+ - lib/blogaze/controllers/users.rb
108
124
  - lib/blogaze/db/migration/001_start.rb
109
125
  - lib/blogaze/db/migration/002_pages.rb
110
126
  - lib/blogaze/db/migration/003_pages_on_menu.rb
111
127
  - lib/blogaze/db/migration/004_comments.rb
112
128
  - lib/blogaze/db/migration/005_tags.rb
113
- - lib/blogaze/model/comment.rb
114
- - lib/blogaze/model/group.rb
115
- - lib/blogaze/model/init.rb
116
- - lib/blogaze/model/page.rb
117
- - lib/blogaze/model/post.rb
118
- - lib/blogaze/model/tag.rb
119
- - lib/blogaze/model/tags_relationship.rb
120
- - lib/blogaze/model/user.rb
129
+ - lib/blogaze/models/comment.rb
130
+ - lib/blogaze/models/group.rb
131
+ - lib/blogaze/models/init.rb
132
+ - lib/blogaze/models/page.rb
133
+ - lib/blogaze/models/post.rb
134
+ - lib/blogaze/models/tag.rb
135
+ - lib/blogaze/models/tags_relationship.rb
136
+ - lib/blogaze/models/user.rb
121
137
  - lib/blogaze/routes.rb
122
138
  - lib/blogaze/tasks.rb
123
139
  - lib/blogaze/tasks/db.rake
@@ -1,32 +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
- module Admin
11
- class Comments < Controller
12
- map '/admin/comments'
13
-
14
- def index
15
- @comments = Comment.all
16
- respond(view_file('admin/comments/index'))
17
- end
18
-
19
- def approve(comment_id)
20
- Comment[comment_id].update(:in_moderation => 0).save
21
- flash[:success] = "Comment approved"
22
- redirect r('/')
23
- end
24
-
25
- def delete(comment_id)
26
- Comment[comment_id].delete
27
- flash[:success] = "Comment deleted"
28
- redirect r('/')
29
- end
30
- end
31
- end
32
- end
@@ -1,28 +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
- module Admin
11
- class Controller < ::Blogaze::Controller
12
- layout 'admin'
13
- helper :blue_form
14
-
15
- def initialize
16
- super
17
-
18
- if !@userinfo.respond_to?('group') or !@userinfo.group.is_admin
19
- redirect '/login'
20
- end
21
- end
22
- end
23
- end
24
-
25
- Dir.glob(File.dirname(__FILE__) + '/*.rb').each do |controller|
26
- require(controller)
27
- end
28
- end