blogaze 0.1.0 → 0.2.0
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.
- data/README.md +0 -12
- data/lib/blogaze.rb +14 -1
- data/lib/blogaze/bin/create.rb +1 -1
- data/lib/blogaze/bin/default.rb +4 -1
- data/lib/blogaze/controllers/admin/comments.rb +6 -1
- data/lib/blogaze/controllers/admin/dashboard.rb +1 -2
- data/lib/blogaze/controllers/admin/init.rb +5 -1
- data/lib/blogaze/controllers/admin/pages.rb +18 -6
- data/lib/blogaze/controllers/admin/posts.rb +19 -6
- data/lib/blogaze/controllers/admin/settings.rb +4 -1
- data/lib/blogaze/controllers/admin/users.rb +20 -9
- data/lib/blogaze/controllers/init.rb +22 -1
- data/lib/blogaze/controllers/main_controller.rb +2 -4
- data/lib/blogaze/controllers/pages.rb +8 -6
- data/lib/blogaze/controllers/posts.rb +10 -2
- data/lib/blogaze/controllers/sessions.rb +3 -3
- data/lib/blogaze/controllers/users.rb +7 -3
- data/lib/blogaze/models/comment.rb +7 -1
- data/lib/blogaze/models/group.rb +4 -1
- data/lib/blogaze/models/init.rb +1 -1
- data/lib/blogaze/models/page.rb +7 -1
- data/lib/blogaze/models/post.rb +17 -1
- data/lib/blogaze/models/tag.rb +6 -1
- data/lib/blogaze/models/tags_relationship.rb +4 -1
- data/lib/blogaze/models/user.rb +11 -4
- data/lib/blogaze/routes.rb +3 -3
- data/lib/blogaze/tasks/db.rake +1 -1
- data/lib/blogaze/theme.rb +15 -2
- data/lib/blogaze/themes/default/admin/pages/edit.xhtml +2 -2
- data/lib/blogaze/themes/default/admin/pages/new.xhtml +2 -2
- data/lib/blogaze/themes/default/admin/posts/new.xhtml +1 -1
- data/lib/blogaze/themes/default/admin/users/edit.xhtml +1 -1
- data/lib/blogaze/themes/default/index.xhtml +2 -2
- data/lib/blogaze/themes/default/layouts/admin.xhtml +1 -1
- data/lib/blogaze/themes/default/layouts/default.xhtml +1 -1
- data/lib/blogaze/themes/default/sessions/new.xhtml +2 -2
- data/lib/blogaze/themes/default/users/new.xhtml +2 -2
- data/lib/blogaze/themes/default/users/profile.xhtml +1 -1
- data/lib/blogaze/version.rb +2 -2
- data/proto/public/css/master.less +1 -1
- metadata +2 -1
data/README.md
CHANGED
@@ -3,11 +3,6 @@ Blogaze
|
|
3
3
|
|
4
4
|
Simple blog powered by the Ramaze framework.
|
5
5
|
|
6
|
-
WARNING
|
7
|
-
-------
|
8
|
-
|
9
|
-
Blogaze is currently in development, use at your own risk.
|
10
|
-
|
11
6
|
Setup
|
12
7
|
------
|
13
8
|
|
@@ -22,10 +17,3 @@ Or install from the repository
|
|
22
17
|
Create a new installation
|
23
18
|
|
24
19
|
blogaze create my_blog
|
25
|
-
|
26
|
-
Todo
|
27
|
-
------
|
28
|
-
|
29
|
-
Things that still need to be done.
|
30
|
-
|
31
|
-
1. Profile manager
|
data/lib/blogaze.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
require 'ramaze'
|
@@ -19,19 +19,29 @@ module Blogaze
|
|
19
19
|
attr_accessor :root
|
20
20
|
attr_accessor :database
|
21
21
|
|
22
|
+
##
|
22
23
|
# Sets root and pushes it to Ramaze roots
|
24
|
+
#
|
25
|
+
# @param [String] path Path to Blogaze root
|
26
|
+
#
|
23
27
|
def root=(path)
|
24
28
|
@root = path
|
25
29
|
Ramaze.options.roots.push(path) if !Ramze.options.roots.include(path)
|
26
30
|
end
|
27
31
|
|
32
|
+
##
|
28
33
|
# Sets database and loads models
|
34
|
+
#
|
35
|
+
# @param [Object] database Database connection
|
36
|
+
#
|
29
37
|
def database=(database)
|
30
38
|
@database = database
|
31
39
|
require 'blogaze/models/init'
|
32
40
|
end
|
33
41
|
|
42
|
+
##
|
34
43
|
# Loads routes and controllers
|
44
|
+
#
|
35
45
|
def start
|
36
46
|
require 'blogaze/themes/default'
|
37
47
|
require 'blogaze/routes'
|
@@ -42,6 +52,9 @@ end
|
|
42
52
|
|
43
53
|
# wat
|
44
54
|
class Fixnum
|
55
|
+
##
|
56
|
+
# Shortcut for Time.at(...).ago_in_words
|
57
|
+
#
|
45
58
|
def ago_in_words
|
46
59
|
Time.at(self).ago_in_words
|
47
60
|
end
|
data/lib/blogaze/bin/create.rb
CHANGED
data/lib/blogaze/bin/default.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
@@ -30,6 +30,9 @@ module Blogaze
|
|
30
30
|
help
|
31
31
|
end
|
32
32
|
|
33
|
+
##
|
34
|
+
# Help message
|
35
|
+
#
|
33
36
|
def help
|
34
37
|
puts @option_parser
|
35
38
|
puts
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
@@ -16,6 +16,7 @@ module Blogaze
|
|
16
16
|
# List comments
|
17
17
|
#
|
18
18
|
def index
|
19
|
+
title "Comments"
|
19
20
|
@comments = ::Blogaze::Models::Comment.all
|
20
21
|
respond(view_file('admin/comments/index'))
|
21
22
|
end
|
@@ -23,6 +24,8 @@ module Blogaze
|
|
23
24
|
##
|
24
25
|
# Approve comment
|
25
26
|
#
|
27
|
+
# @param [Integer] comment_id
|
28
|
+
#
|
26
29
|
def approve(comment_id)
|
27
30
|
::Blogaze::Models::Comment[comment_id].update(:in_moderation => 0).save
|
28
31
|
flash[:success] = "Comment approved"
|
@@ -32,6 +35,8 @@ module Blogaze
|
|
32
35
|
##
|
33
36
|
# Delete comment
|
34
37
|
#
|
38
|
+
# @param [Integer] comment_id
|
39
|
+
#
|
35
40
|
def delete(comment_id)
|
36
41
|
::Blogaze::Models::Comment[comment_id].delete
|
37
42
|
flash[:success] = "Comment deleted"
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
@@ -16,7 +16,6 @@ module Blogaze
|
|
16
16
|
# Admin index
|
17
17
|
#
|
18
18
|
def index
|
19
|
-
@title = "Admin - #{@settings[:title]}"
|
20
19
|
respond(view_file('admin/index'))
|
21
20
|
end
|
22
21
|
end # Dashboard
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
@@ -16,6 +16,10 @@ module Blogaze
|
|
16
16
|
def initialize
|
17
17
|
super
|
18
18
|
|
19
|
+
# Set AdminCP title
|
20
|
+
title "Admin"
|
21
|
+
|
22
|
+
# Make sure the user is logged in and has permission
|
19
23
|
if !@userinfo.respond_to?('group') or @userinfo.group.is_admin != 1
|
20
24
|
redirect '/login'
|
21
25
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
@@ -12,11 +12,17 @@ module Blogaze
|
|
12
12
|
class Pages < Controller
|
13
13
|
map '/admin/pages'
|
14
14
|
|
15
|
+
def initialize
|
16
|
+
super
|
17
|
+
|
18
|
+
# Set title
|
19
|
+
title "Pages"
|
20
|
+
end
|
21
|
+
|
15
22
|
##
|
16
23
|
# Page listing
|
17
24
|
#
|
18
25
|
def index
|
19
|
-
@title = "Pages - Admin - #{@settings[:title]}"
|
20
26
|
@pages = ::Blogaze::Models::Page.order(:title.asc).all
|
21
27
|
respond(view_file('admin/pages/index'))
|
22
28
|
end
|
@@ -25,7 +31,7 @@ module Blogaze
|
|
25
31
|
# New page form
|
26
32
|
#
|
27
33
|
def new
|
28
|
-
|
34
|
+
title "New Page"
|
29
35
|
@page = ::Blogaze::Models::Page.new
|
30
36
|
respond(view_file('admin/pages/new'))
|
31
37
|
end
|
@@ -34,7 +40,7 @@ module Blogaze
|
|
34
40
|
# Create page
|
35
41
|
#
|
36
42
|
def create
|
37
|
-
|
43
|
+
title "New Page"
|
38
44
|
data = {
|
39
45
|
:title => request[:title],
|
40
46
|
:slug => request[:slug],
|
@@ -56,8 +62,10 @@ module Blogaze
|
|
56
62
|
##
|
57
63
|
# Edit page
|
58
64
|
#
|
65
|
+
# @param [Integer] page_id
|
66
|
+
#
|
59
67
|
def edit(page_id)
|
60
|
-
|
68
|
+
title "Edit Page"
|
61
69
|
@page = ::Blogaze::Models::Page[page_id]
|
62
70
|
respond(view_file('admin/pages/edit'))
|
63
71
|
end
|
@@ -65,8 +73,10 @@ module Blogaze
|
|
65
73
|
##
|
66
74
|
# Save page
|
67
75
|
#
|
76
|
+
# @param [Integer] page_id
|
77
|
+
#
|
68
78
|
def save(page_id)
|
69
|
-
|
79
|
+
title "Edit Page"
|
70
80
|
@page = ::Blogaze::Models::Page[page_id]
|
71
81
|
@page.title = request[:title]
|
72
82
|
@page.slug = request[:slug]
|
@@ -85,6 +95,8 @@ module Blogaze
|
|
85
95
|
##
|
86
96
|
# Delete page
|
87
97
|
#
|
98
|
+
# @param [Integer] page_id
|
99
|
+
#
|
88
100
|
def delete(page_id)
|
89
101
|
P::Blogaze::Models::age[page_id].delete
|
90
102
|
flash[:success] = "Page deleted successfully"
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
@@ -12,20 +12,32 @@ module Blogaze
|
|
12
12
|
class Posts < Controller
|
13
13
|
map '/admin/posts'
|
14
14
|
|
15
|
+
def initialize
|
16
|
+
super
|
17
|
+
|
18
|
+
# Set title
|
19
|
+
title "Posts"
|
20
|
+
end
|
21
|
+
|
22
|
+
# Make sure the user has permission to create posts
|
15
23
|
before :new, :create do
|
24
|
+
title "New Post"
|
16
25
|
if !@userinfo.group.create_posts
|
17
26
|
flash[:error] = "You don't have permission to do that."
|
18
27
|
redirect '/login'
|
19
28
|
end
|
20
29
|
end
|
21
30
|
|
31
|
+
# Make sure the user has permission to edit posts
|
22
32
|
before :edit, :save do
|
33
|
+
title "Edit Page"
|
23
34
|
if !@userinfo.group.edit_posts
|
24
35
|
flash[:error] = "You don't have permission to do that."
|
25
36
|
redirect '/login'
|
26
37
|
end
|
27
38
|
end
|
28
39
|
|
40
|
+
# Make sure the user has permission to delete posts
|
29
41
|
before :delete do
|
30
42
|
if !@userinfo.group.delete_posts
|
31
43
|
flash[:error] = "You don't have permission to do that."
|
@@ -37,7 +49,6 @@ module Blogaze
|
|
37
49
|
# Post listing
|
38
50
|
#
|
39
51
|
def index
|
40
|
-
@title = "Posts - Admin - #{@settings[:title]}"
|
41
52
|
@posts = ::Blogaze::Models::Post.order(:id.desc).all
|
42
53
|
respond(view_file('admin/posts/index'))
|
43
54
|
end
|
@@ -46,7 +57,6 @@ module Blogaze
|
|
46
57
|
# New post form
|
47
58
|
#
|
48
59
|
def new
|
49
|
-
@title = "New Post - Posts - Admin - #{@settings[:title]}"
|
50
60
|
@post = ::Blogaze::Models::Post.new
|
51
61
|
respond(view_file('admin/posts/new'))
|
52
62
|
end
|
@@ -55,7 +65,6 @@ module Blogaze
|
|
55
65
|
# Create post
|
56
66
|
#
|
57
67
|
def create
|
58
|
-
@title = "New Post - Posts - Admin - #{@settings[:title]}"
|
59
68
|
data = {
|
60
69
|
:title => request[:title],
|
61
70
|
:body => request[:body],
|
@@ -77,8 +86,9 @@ module Blogaze
|
|
77
86
|
##
|
78
87
|
# Edit post
|
79
88
|
#
|
89
|
+
# @param [Integer] post_id
|
90
|
+
#
|
80
91
|
def edit(post_id)
|
81
|
-
@title = "Edit Post - Posts - Admin - #{@settings[:title]}"
|
82
92
|
@post = ::Blogaze::Models::Post[post_id]
|
83
93
|
|
84
94
|
post_tags = []
|
@@ -93,8 +103,9 @@ module Blogaze
|
|
93
103
|
##
|
94
104
|
# Save post
|
95
105
|
#
|
106
|
+
# @param [Integer] post_id
|
107
|
+
#
|
96
108
|
def save(post_id)
|
97
|
-
@title = "Edit Post - Posts - Admin - #{@settings[:title]}"
|
98
109
|
@post = ::Blogaze::Models::Post[post_id]
|
99
110
|
@post.title = request[:title]
|
100
111
|
@post.body = request[:body]
|
@@ -112,6 +123,8 @@ module Blogaze
|
|
112
123
|
##
|
113
124
|
# Delete post
|
114
125
|
#
|
126
|
+
# @param [Integer] post_id
|
127
|
+
#
|
115
128
|
def delete(post_id)
|
116
129
|
post = ::Blogaze::Models::Post[post_id]
|
117
130
|
post.delete
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
@@ -16,6 +16,9 @@ module Blogaze
|
|
16
16
|
# Settings form
|
17
17
|
#
|
18
18
|
def index
|
19
|
+
# Set title
|
20
|
+
title "Settings"
|
21
|
+
|
19
22
|
# Get themes
|
20
23
|
@themes = []
|
21
24
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
@@ -13,18 +13,22 @@ module Blogaze
|
|
13
13
|
map '/admin/users'
|
14
14
|
|
15
15
|
before :edit, :save do
|
16
|
-
|
16
|
+
title "Edit User"
|
17
17
|
@groups = {}
|
18
18
|
::Blogaze::Models::Group.all.each do |group|
|
19
19
|
@groups[group.id] = group.name
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
def initialize
|
24
|
+
super
|
25
|
+
title "Users"
|
26
|
+
end
|
27
|
+
|
23
28
|
##
|
24
29
|
# Lists users
|
25
30
|
#
|
26
31
|
def index
|
27
|
-
@title = "Users - Admin - #{@settings[:title]}"
|
28
32
|
@users = ::Blogaze::Models::User.all
|
29
33
|
respond(view_file('admin/users/index'))
|
30
34
|
end
|
@@ -32,20 +36,25 @@ module Blogaze
|
|
32
36
|
##
|
33
37
|
# Edit user form
|
34
38
|
#
|
35
|
-
|
36
|
-
|
39
|
+
# @param [Integer] user_id
|
40
|
+
#
|
41
|
+
def edit(user_id)
|
42
|
+
@user = ::Blogaze::Models::User[user_id]
|
37
43
|
respond(view_file('admin/users/edit'))
|
38
44
|
end
|
39
45
|
|
40
46
|
##
|
41
47
|
# Save user
|
42
48
|
#
|
43
|
-
|
44
|
-
|
49
|
+
# @param [Integer] user_id
|
50
|
+
#
|
51
|
+
def save(user_id)
|
52
|
+
@user = ::Blogaze::Models::User[user_id]
|
45
53
|
@user.username = request[:username]
|
46
54
|
@user.email = request[:email]
|
47
55
|
@user.group_id = request[:group_id]
|
48
56
|
|
57
|
+
# Validate data
|
49
58
|
if @user.valid?
|
50
59
|
@user.save
|
51
60
|
flash[:success] = "User saved successfully"
|
@@ -58,8 +67,10 @@ module Blogaze
|
|
58
67
|
##
|
59
68
|
# Delete user
|
60
69
|
#
|
61
|
-
|
62
|
-
|
70
|
+
# @param [Integer] user_id
|
71
|
+
#
|
72
|
+
def delete(user_id)
|
73
|
+
::Blogaze::Models::User[user_id].delete
|
63
74
|
flash[:success] = "User deleted successfully"
|
64
75
|
redirect Users.r('/')
|
65
76
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
@@ -13,6 +13,10 @@ module Blogaze
|
|
13
13
|
helper :xhtml, :maruku, :blue_form, :formatting
|
14
14
|
engine :etanni
|
15
15
|
|
16
|
+
##
|
17
|
+
# Sherlock: Initializer
|
18
|
+
# Watson: No shit, Sherlock.
|
19
|
+
#
|
16
20
|
def initialize
|
17
21
|
super
|
18
22
|
|
@@ -26,11 +30,25 @@ module Blogaze
|
|
26
30
|
|
27
31
|
# Set theme
|
28
32
|
Theme.use @settings[:theme]
|
33
|
+
|
34
|
+
# Page title
|
35
|
+
@title = [@settings[:title]]
|
36
|
+
end
|
37
|
+
|
38
|
+
##
|
39
|
+
# Adds the passed title to be added to the page title.
|
40
|
+
#
|
41
|
+
# @param [String] title
|
42
|
+
#
|
43
|
+
def title(title)
|
44
|
+
@title.push title
|
29
45
|
end
|
30
46
|
|
31
47
|
##
|
32
48
|
# Renders the view with the set layout
|
33
49
|
#
|
50
|
+
# @param [String] path Path to view
|
51
|
+
#
|
34
52
|
def view_file(path)
|
35
53
|
path = path.to_s if not path.is_a?(String)
|
36
54
|
view_path = File.join(Theme.current.templates, "#{path}.xhtml")
|
@@ -38,6 +56,9 @@ module Blogaze
|
|
38
56
|
return render_file(layout_path, :content => render_file(view_path))
|
39
57
|
end
|
40
58
|
|
59
|
+
##
|
60
|
+
# Load settings from the database.
|
61
|
+
#
|
41
62
|
def get_settings
|
42
63
|
@settings = {}
|
43
64
|
Blogaze.database[:settings].all.each do |setting|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
@@ -19,9 +19,7 @@ module Blogaze
|
|
19
19
|
# Check if we should change the title to include
|
20
20
|
# what page we're on.
|
21
21
|
if page.to_i > 1
|
22
|
-
|
23
|
-
else
|
24
|
-
@title = @settings[:title]
|
22
|
+
title "Page #{page}"
|
25
23
|
end
|
26
24
|
|
27
25
|
# Get the data and paginate it.
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
@@ -14,23 +14,25 @@ module Blogaze
|
|
14
14
|
##
|
15
15
|
# View page
|
16
16
|
#
|
17
|
+
# @param [String] slug Page slug
|
18
|
+
#
|
17
19
|
def view(slug = nil)
|
18
|
-
if slug
|
19
|
-
slug = request.env["REQUEST_PATH"]
|
20
|
-
end
|
20
|
+
slug = request.env["REQUEST_PATH"] if slug.nil?
|
21
21
|
|
22
22
|
# Chomp chomp chomp, let's trim any unwanted
|
23
23
|
# forward slashes from the begning and end of the url.
|
24
24
|
slug = slug.chomp("/").reverse.chomp("/").reverse
|
25
25
|
|
26
|
+
# Get page
|
26
27
|
@page = ::Blogaze::Models::Page[:slug => slug]
|
27
28
|
|
28
29
|
# Check if the page exists, if not render the
|
29
30
|
# not found page.
|
30
|
-
if
|
31
|
+
if @page.nil?
|
32
|
+
title "Not Found"
|
31
33
|
respond(view_file('pages/notfound'))
|
32
34
|
else
|
33
|
-
|
35
|
+
title @page.title
|
34
36
|
respond(view_file('pages/page'))
|
35
37
|
end
|
36
38
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
@@ -15,12 +15,14 @@ module Blogaze
|
|
15
15
|
##
|
16
16
|
# View post
|
17
17
|
#
|
18
|
+
# @param [String] slug Post slug
|
19
|
+
#
|
18
20
|
def view(slug)
|
19
21
|
@post = ::Blogaze::Models::Post.filter(:slug => slug).first
|
20
22
|
return respond(view_file('pages/notfound')) if @post.nil?
|
21
23
|
|
22
24
|
# Set title
|
23
|
-
|
25
|
+
title @post.title
|
24
26
|
|
25
27
|
# Instead of a controller just for comment creation
|
26
28
|
# let's just put it here, that way we can display
|
@@ -48,10 +50,16 @@ module Blogaze
|
|
48
50
|
##
|
49
51
|
# Lists posts belonging to the tag.
|
50
52
|
#
|
53
|
+
# @param [String] slug Tag slug
|
54
|
+
# @param [Integer] page Page number
|
55
|
+
#
|
51
56
|
def tag(slug, page = 1)
|
52
57
|
@tag = ::Blogaze::Models::Tag[:slug => slug]
|
53
58
|
return respond(view_file('pages/notfound')) if @tag.nil?
|
54
59
|
|
60
|
+
# Set title
|
61
|
+
title "Posts tagged #{@tag.name}"
|
62
|
+
|
55
63
|
# Get relationships with posts and put the post IDs
|
56
64
|
# into an array for use when selecting posts to be
|
57
65
|
# paginated.
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
@@ -15,7 +15,7 @@ module Blogaze
|
|
15
15
|
# Login page
|
16
16
|
#
|
17
17
|
def new
|
18
|
-
|
18
|
+
title "Login"
|
19
19
|
respond(view_file('sessions/new'))
|
20
20
|
end
|
21
21
|
|
@@ -23,7 +23,7 @@ module Blogaze
|
|
23
23
|
# Create session
|
24
24
|
#
|
25
25
|
def create
|
26
|
-
|
26
|
+
title "Login"
|
27
27
|
@get_user = ::Blogaze::Models::User.where(:username => request[:username]).first
|
28
28
|
|
29
29
|
if @get_user and @get_user.check_password(request[:password])
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
@@ -15,7 +15,7 @@ module Blogaze
|
|
15
15
|
# Register form
|
16
16
|
#
|
17
17
|
def new
|
18
|
-
|
18
|
+
title "Register"
|
19
19
|
@user = ::Blogaze::Models::User.new
|
20
20
|
respond(view_file('users/new'))
|
21
21
|
end
|
@@ -26,7 +26,7 @@ module Blogaze
|
|
26
26
|
def create
|
27
27
|
return redirect('/') unless request.post?
|
28
28
|
|
29
|
-
|
29
|
+
title "Register"
|
30
30
|
data = {
|
31
31
|
:username => request[:username],
|
32
32
|
:password => request[:password],
|
@@ -51,6 +51,7 @@ module Blogaze
|
|
51
51
|
#
|
52
52
|
def profile
|
53
53
|
return respond(view_file('sessions/new')) unless session[:logged_in]
|
54
|
+
title "Profile"
|
54
55
|
respond(view_file('users/profile'))
|
55
56
|
end
|
56
57
|
|
@@ -60,6 +61,9 @@ module Blogaze
|
|
60
61
|
def save
|
61
62
|
return redirect('/') unless request.post?
|
62
63
|
|
64
|
+
# Set title
|
65
|
+
title "Profile"
|
66
|
+
|
63
67
|
# Set email
|
64
68
|
@userinfo.email = request[:email]
|
65
69
|
|
@@ -3,16 +3,22 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
10
10
|
module Models
|
11
|
+
##
|
12
|
+
# Post comments model
|
13
|
+
#
|
11
14
|
class Comment < Sequel::Model
|
12
15
|
plugin :validation_helpers
|
13
16
|
|
14
17
|
many_to_one :post
|
15
18
|
|
19
|
+
##
|
20
|
+
# Validations
|
21
|
+
#
|
16
22
|
def validate
|
17
23
|
validates_presence [:post_id, :author, :body]
|
18
24
|
validates_integer :post_id
|
data/lib/blogaze/models/group.rb
CHANGED
@@ -3,11 +3,14 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
10
10
|
module Models
|
11
|
+
##
|
12
|
+
# User group model
|
13
|
+
#
|
11
14
|
class Group < Sequel::Model
|
12
15
|
one_to_many :user
|
13
16
|
end # Group
|
data/lib/blogaze/models/init.rb
CHANGED
data/lib/blogaze/models/page.rb
CHANGED
@@ -3,14 +3,20 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
10
10
|
module Models
|
11
|
+
##
|
12
|
+
# Custom page model
|
13
|
+
#
|
11
14
|
class Page < Sequel::Model
|
12
15
|
plugin :validation_helpers
|
13
16
|
|
17
|
+
##
|
18
|
+
# Validations
|
19
|
+
#
|
14
20
|
def validate
|
15
21
|
validates_presence [:title, :slug, :body]
|
16
22
|
end
|
data/lib/blogaze/models/post.rb
CHANGED
@@ -3,11 +3,14 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
10
10
|
module Models
|
11
|
+
##
|
12
|
+
# Post model
|
13
|
+
#
|
11
14
|
class Post < Sequel::Model
|
12
15
|
attr_accessor :post_tags
|
13
16
|
plugin :validation_helpers
|
@@ -20,6 +23,8 @@ module Blogaze
|
|
20
23
|
##
|
21
24
|
# Returns the URI to the post.
|
22
25
|
#
|
26
|
+
# @return [String]
|
27
|
+
#
|
23
28
|
def href
|
24
29
|
return '/' + Time.at(self.published_at).year.to_s + '/' + Time.at(self.published_at).month.to_s + '/' + self.slug
|
25
30
|
end
|
@@ -27,6 +32,8 @@ module Blogaze
|
|
27
32
|
##
|
28
33
|
# Returns an array of the posts tags.
|
29
34
|
#
|
35
|
+
# @return [Array]
|
36
|
+
#
|
30
37
|
def tags
|
31
38
|
tags = []
|
32
39
|
relationships = ::Blogaze::Models::TagsRelationship.where(:object_id => self.id, :object_type => 'post')
|
@@ -40,11 +47,16 @@ module Blogaze
|
|
40
47
|
##
|
41
48
|
# Returns the partial body of the post.
|
42
49
|
#
|
50
|
+
# @return [String]
|
51
|
+
#
|
43
52
|
def body_partial
|
44
53
|
body = self.body.split('<!-- MORE -->')
|
45
54
|
return body[0]
|
46
55
|
end
|
47
56
|
|
57
|
+
##
|
58
|
+
# Validations
|
59
|
+
#
|
48
60
|
def validate
|
49
61
|
validates_presence [:title, :body, :user_id]
|
50
62
|
validates_integer :user_id
|
@@ -69,6 +81,10 @@ module Blogaze
|
|
69
81
|
|
70
82
|
private
|
71
83
|
|
84
|
+
##
|
85
|
+
# Creates, updates and removes tags
|
86
|
+
# from the post.
|
87
|
+
#
|
72
88
|
def process_tags
|
73
89
|
# Names of tags, obviously
|
74
90
|
tag_names = []
|
data/lib/blogaze/models/tag.rb
CHANGED
@@ -3,16 +3,21 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
10
10
|
module Models
|
11
|
+
##
|
12
|
+
# Tags model
|
13
|
+
#
|
11
14
|
class Tag < Sequel::Model
|
12
15
|
##
|
13
16
|
# Returns the URI to the page
|
14
17
|
# listing posts belonging to the tag.
|
15
18
|
#
|
19
|
+
# @return [String]
|
20
|
+
#
|
16
21
|
def href
|
17
22
|
"/tags/#{slug}"
|
18
23
|
end
|
@@ -3,11 +3,14 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
10
10
|
module Models
|
11
|
+
##
|
12
|
+
# Tag relationships model
|
13
|
+
#
|
11
14
|
class TagsRelationship < Sequel::Model
|
12
15
|
many_to_one :tag
|
13
16
|
end # TagsRelationship
|
data/lib/blogaze/models/user.rb
CHANGED
@@ -3,11 +3,14 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
10
10
|
module Models
|
11
|
+
##
|
12
|
+
# User model
|
13
|
+
#
|
11
14
|
class User < Sequel::Model
|
12
15
|
plugin :validation_helpers
|
13
16
|
|
@@ -18,6 +21,8 @@ module Blogaze
|
|
18
21
|
# Check if the users password matches
|
19
22
|
# the supplied password.
|
20
23
|
#
|
24
|
+
# @param [String] password
|
25
|
+
#
|
21
26
|
def check_password(password)
|
22
27
|
BCrypt::Password.new(self.password) == password
|
23
28
|
end
|
@@ -25,10 +30,15 @@ module Blogaze
|
|
25
30
|
##
|
26
31
|
# Changes the users password.
|
27
32
|
#
|
33
|
+
# @param [String] new_password
|
34
|
+
#
|
28
35
|
def change_password(new_password)
|
29
36
|
self.password = BCrypt::Password.create(new_password)
|
30
37
|
end
|
31
38
|
|
39
|
+
##
|
40
|
+
# Validations
|
41
|
+
#
|
32
42
|
def validate
|
33
43
|
super
|
34
44
|
|
@@ -50,9 +60,6 @@ module Blogaze
|
|
50
60
|
self.password = BCrypt::Password.create(self.password)
|
51
61
|
self.group_id = 3
|
52
62
|
end
|
53
|
-
|
54
|
-
def before_save
|
55
|
-
end
|
56
63
|
end # User
|
57
64
|
end # Models
|
58
65
|
end # Blogaze
|
data/lib/blogaze/routes.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
@@ -12,11 +12,11 @@ module Blogaze
|
|
12
12
|
|
13
13
|
# Post routes
|
14
14
|
::Ramaze::Route[/^\/[0-9]+\/[0-9]+\/([\w\.\-]+)$/] = '/posts/view/%s'
|
15
|
-
::Ramaze::Route[
|
15
|
+
::Ramaze::Route[/^\/page\/([0-9]+)$/] = '/%d'
|
16
16
|
|
17
17
|
# Tag routes
|
18
18
|
::Ramaze::Route[/^\/tags\/([\w]+)$/] = '/posts/tag/%s'
|
19
|
-
|
19
|
+
::Ramaze::Route[/^\/tags\/([\w]+)\/page\/([0-9]+)$/] = '/posts/tag/%s/%d'
|
20
20
|
|
21
21
|
# User routes
|
22
22
|
::Ramaze::Route['/login'] = '/sessions/new'
|
data/lib/blogaze/tasks/db.rake
CHANGED
data/lib/blogaze/theme.rb
CHANGED
@@ -3,10 +3,13 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
10
|
+
##
|
11
|
+
# Theme class
|
12
|
+
#
|
10
13
|
class Theme
|
11
14
|
attr_accessor :name
|
12
15
|
attr_accessor :templates
|
@@ -17,6 +20,8 @@ module Blogaze
|
|
17
20
|
##
|
18
21
|
# Sets the themes name as a symbol
|
19
22
|
#
|
23
|
+
# @param [String] name Themes name
|
24
|
+
#
|
20
25
|
def name=(name)
|
21
26
|
@name = name.to_sym
|
22
27
|
end
|
@@ -27,6 +32,8 @@ module Blogaze
|
|
27
32
|
##
|
28
33
|
# Adds a new theme
|
29
34
|
#
|
35
|
+
# @yield theme
|
36
|
+
#
|
30
37
|
def add
|
31
38
|
theme = self.new
|
32
39
|
yield theme
|
@@ -34,7 +41,9 @@ module Blogaze
|
|
34
41
|
end
|
35
42
|
|
36
43
|
##
|
37
|
-
# Returns the
|
44
|
+
# Returns the theme matching the supplied name.
|
45
|
+
#
|
46
|
+
# @param [String] name Themes name
|
38
47
|
#
|
39
48
|
def [](name)
|
40
49
|
name = name.to_sym
|
@@ -46,6 +55,8 @@ module Blogaze
|
|
46
55
|
# Sets the supplied name as the
|
47
56
|
# current theme to be used.
|
48
57
|
#
|
58
|
+
# @param [String] name Themes name
|
59
|
+
#
|
49
60
|
def use(name)
|
50
61
|
name = name.to_sym
|
51
62
|
raise("Unable to use theme #{name}: not registered") unless REGISTERED.key?(name)
|
@@ -55,6 +66,8 @@ module Blogaze
|
|
55
66
|
##
|
56
67
|
# Returns the registered themes.
|
57
68
|
#
|
69
|
+
# @return [Array]
|
70
|
+
#
|
58
71
|
def registered
|
59
72
|
REGISTERED.to_a
|
60
73
|
end
|
@@ -8,7 +8,7 @@
|
|
8
8
|
<?r end ?>
|
9
9
|
</div>
|
10
10
|
<?r end ?>
|
11
|
-
<div class="new-
|
11
|
+
<div class="new-page-form tabular">
|
12
12
|
#{
|
13
13
|
form_for(@page, :method => :post, :action => '/admin/pages/save/' + @page.id.to_s) do |f|
|
14
14
|
f.input_text 'Title', :title
|
@@ -27,4 +27,4 @@
|
|
27
27
|
}
|
28
28
|
</div>
|
29
29
|
</div>
|
30
|
-
</div>
|
30
|
+
</div>
|
@@ -8,7 +8,7 @@
|
|
8
8
|
<?r end ?>
|
9
9
|
</div>
|
10
10
|
<?r end ?>
|
11
|
-
<div class="new-
|
11
|
+
<div class="new-page-form tabular">
|
12
12
|
#{
|
13
13
|
form_for(@page, :method => :post, :action => '/admin/pages/create') do |f|
|
14
14
|
f.input_text 'Title', :title
|
@@ -23,4 +23,4 @@
|
|
23
23
|
}
|
24
24
|
</div>
|
25
25
|
</div>
|
26
|
-
</div>
|
26
|
+
</div>
|
@@ -29,10 +29,10 @@
|
|
29
29
|
<?r if @posts.page_count > 1 ?>
|
30
30
|
<div class="pager_nav">
|
31
31
|
<?r if @posts.prev_page ?>
|
32
|
-
<a href="/page/#{@posts.prev_page}" class="prev">< Previous</a>
|
32
|
+
<a href="#{!@tag.nil? ? "/tags/#{@tag.slug}" :''}/page/#{@posts.prev_page}" class="prev">< Previous</a>
|
33
33
|
<?r end ?>
|
34
34
|
<?r if @posts.next_page ?>
|
35
|
-
<a href="/page/#{@posts.next_page}" class="next">Next > </a>
|
35
|
+
<a href="#{!@tag.nil? ? "/tags/#{@tag.slug}" :''}/page/#{@posts.next_page}" class="next">Next > </a>
|
36
36
|
<?r end ?>
|
37
37
|
</div>
|
38
38
|
<?r end ?>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
3
|
<head>
|
4
|
-
<title>#{@title}</title>
|
4
|
+
<title>#{@title.reverse.join(" - ")}</title>
|
5
5
|
<link href="#{Ramaze.options.prefix}css/master.less" rel="stylesheet/less" type="text/css">
|
6
6
|
<link href="/css/print.css" media="print" rel="stylesheet" type="text/css" />
|
7
7
|
<!--[if lt IE 8]>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
3
|
<head>
|
4
|
-
<title>#{@title}</title>
|
4
|
+
<title>#{@title.reverse.join(" - ")}</title>
|
5
5
|
<link href="#{Ramaze.options.prefix}css/master.less" rel="stylesheet/less" type="text/css">
|
6
6
|
<link href="/css/print.css" media="print" rel="stylesheet" type="text/css" />
|
7
7
|
<!--[if lt IE 8]>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
Invalid username and/or password.
|
7
7
|
</div>
|
8
8
|
<?r end ?>
|
9
|
-
<div class="
|
9
|
+
<div class="centered-form tabular">
|
10
10
|
<form action="#{Ramaze.options.prefix}sessions/create" method="post">
|
11
11
|
<p>
|
12
12
|
<label for="username">Username</label>
|
@@ -22,4 +22,4 @@
|
|
22
22
|
</form>
|
23
23
|
</div>
|
24
24
|
</div>
|
25
|
-
</div>
|
25
|
+
</div>
|
@@ -8,7 +8,7 @@
|
|
8
8
|
<?r end ?>
|
9
9
|
</div>
|
10
10
|
<?r end ?>
|
11
|
-
<div class="
|
11
|
+
<div class="centered-form tabular">
|
12
12
|
#{
|
13
13
|
form_for(@user, :method => :post, :action => '/users/create') do |f|
|
14
14
|
f.input_text 'Username', :username
|
@@ -19,4 +19,4 @@
|
|
19
19
|
}
|
20
20
|
</div>
|
21
21
|
</div>
|
22
|
-
</div>
|
22
|
+
</div>
|
data/lib/blogaze/version.rb
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
# Copyright (C) 2011-2013 Jack Polgar
|
4
4
|
#
|
5
5
|
# Blogaze is released under the BSD 3-clause license.
|
6
|
-
#
|
6
|
+
# http://opensource.org/licenses/BSD-3-Clause
|
7
7
|
#
|
8
8
|
|
9
9
|
module Blogaze
|
10
|
-
VERSION = "0.
|
10
|
+
VERSION = "0.2.0"
|
11
11
|
end
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -214,3 +214,4 @@ signing_key:
|
|
214
214
|
specification_version: 3
|
215
215
|
summary: Blogaze is a simple blog.
|
216
216
|
test_files: []
|
217
|
+
has_rdoc:
|