blogaze 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +12 -13
- data/blogaze.gemspec +1 -0
- data/lib/blogaze.rb +2 -2
- data/lib/blogaze/bin/create.rb +6 -0
- data/lib/blogaze/controllers/admin/comments.rb +43 -0
- data/lib/blogaze/controllers/admin/dashboard.rb +25 -0
- data/lib/blogaze/controllers/admin/init.rb +30 -0
- data/lib/blogaze/controllers/admin/pages.rb +95 -0
- data/lib/blogaze/controllers/admin/posts.rb +125 -0
- data/lib/blogaze/controllers/admin/settings.rb +41 -0
- data/lib/blogaze/{controller → controllers}/init.rb +1 -1
- data/lib/blogaze/controllers/main_controller.rb +35 -0
- data/lib/blogaze/controllers/pages.rb +39 -0
- data/lib/blogaze/controllers/posts.rb +77 -0
- data/lib/blogaze/controllers/sessions.rb +50 -0
- data/lib/blogaze/controllers/users.rb +41 -0
- data/lib/blogaze/models/comment.rb +28 -0
- data/lib/blogaze/{model → models}/group.rb +6 -4
- data/lib/blogaze/{model → models}/init.rb +0 -0
- data/lib/blogaze/models/page.rb +29 -0
- data/lib/blogaze/models/post.rb +95 -0
- data/lib/blogaze/models/tag.rb +25 -0
- data/lib/blogaze/{model → models}/tags_relationship.rb +6 -4
- data/lib/blogaze/models/user.rb +43 -0
- data/lib/blogaze/routes.rb +4 -0
- data/lib/blogaze/theme.rb +17 -0
- data/lib/blogaze/version.rb +1 -1
- data/proto/public/css/master.less +16 -12
- data/proto/themes/default/admin/index.xhtml +4 -4
- data/proto/themes/default/admin/settings/index.xhtml +1 -1
- data/proto/themes/default/index.xhtml +6 -3
- data/proto/themes/default/layouts/admin.xhtml +2 -2
- data/proto/themes/default/layouts/default.xhtml +1 -1
- data/proto/themes/default/posts/view.xhtml +3 -3
- metadata +37 -21
- data/lib/blogaze/controller/admin/comments.rb +0 -32
- data/lib/blogaze/controller/admin/init.rb +0 -28
- data/lib/blogaze/controller/admin/main.rb +0 -20
- data/lib/blogaze/controller/admin/pages.rb +0 -75
- data/lib/blogaze/controller/admin/posts.rb +0 -103
- data/lib/blogaze/controller/admin/settings.rb +0 -33
- data/lib/blogaze/controller/main.rb +0 -30
- data/lib/blogaze/controller/pages.rb +0 -34
- data/lib/blogaze/controller/posts.rb +0 -43
- data/lib/blogaze/controller/sessions.rb +0 -39
- data/lib/blogaze/controller/users.rb +0 -39
- data/lib/blogaze/model/comment.rb +0 -26
- data/lib/blogaze/model/page.rb +0 -27
- data/lib/blogaze/model/post.rb +0 -79
- data/lib/blogaze/model/tag.rb +0 -19
- data/lib/blogaze/model/user.rb +0 -41
data/README.md
CHANGED
@@ -11,23 +11,22 @@ Blogaze is currently in development, use at your own risk.
|
|
11
11
|
Setup
|
12
12
|
------
|
13
13
|
|
14
|
-
|
15
|
-
2. Enter your database information in the `config/database.rb` file.
|
16
|
-
3. Run `rake db:migrate` and `rake db:defaults`
|
17
|
-
4. Run `ruby start.rb` or `thin start` or whatever your preferred way is.
|
14
|
+
Install the gem:
|
18
15
|
|
19
|
-
|
16
|
+
gem install blogaze
|
20
17
|
|
21
|
-
|
22
|
-
------
|
18
|
+
Or install from the repository
|
23
19
|
|
24
|
-
|
20
|
+
rake install
|
21
|
+
|
22
|
+
Create a new installation
|
25
23
|
|
26
|
-
|
27
|
-
2. User manager
|
28
|
-
3. Profile manager
|
24
|
+
blogaze create my_blog
|
29
25
|
|
30
|
-
|
26
|
+
Todo
|
31
27
|
------
|
32
28
|
|
33
|
-
|
29
|
+
Things that still need to be done.
|
30
|
+
|
31
|
+
1. User manager
|
32
|
+
2. Profile manager
|
data/blogaze.gemspec
CHANGED
data/lib/blogaze.rb
CHANGED
@@ -27,13 +27,13 @@ module Blogaze
|
|
27
27
|
# Sets database and loads models
|
28
28
|
def database=(database)
|
29
29
|
@database = database
|
30
|
-
require 'blogaze/
|
30
|
+
require 'blogaze/models/init'
|
31
31
|
end
|
32
32
|
|
33
33
|
# Loads routes and controllers
|
34
34
|
def start
|
35
35
|
require 'blogaze/routes'
|
36
|
-
require 'blogaze/
|
36
|
+
require 'blogaze/controllers/init'
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
data/lib/blogaze/bin/create.rb
CHANGED
@@ -17,24 +17,30 @@ module Blogaze
|
|
17
17
|
PROTOTYPE = __DIR__('../../../proto')
|
18
18
|
|
19
19
|
def index
|
20
|
+
# Require the name argument
|
20
21
|
if ARGV[0] == '' or ARGV[0].nil?
|
21
22
|
puts "Missing argument [NAME]"
|
22
23
|
return
|
23
24
|
end
|
24
25
|
|
26
|
+
# Destination to copy files
|
25
27
|
destination = File.join(Dir.pwd, ARGV[0])
|
26
28
|
|
29
|
+
# Make sure the destination doesn't exist
|
27
30
|
if File.directory?(destination) and !option(:f)
|
28
31
|
puts "Directory already exists with name: #{ARGV[0]}"
|
29
32
|
return
|
30
33
|
else
|
34
|
+
# Copy files
|
31
35
|
puts 'Copying files...'
|
32
36
|
FileUtils.cp_r(PROTOTYPE, destination)
|
33
37
|
|
38
|
+
# Rename config files
|
34
39
|
['config.default.rb', 'database.default.rb'].each do |config|
|
35
40
|
FileUtils.mv(destination + "/config/#{config}", destination + "/config/" + config.gsub('.default', ''))
|
36
41
|
end
|
37
42
|
|
43
|
+
# Tell the user what to do next
|
38
44
|
puts 'Done.'
|
39
45
|
puts
|
40
46
|
puts "You will need to enter your database information"
|
@@ -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 Controllers
|
11
|
+
module Admin
|
12
|
+
class Comments < Controller
|
13
|
+
map '/admin/comments'
|
14
|
+
|
15
|
+
##
|
16
|
+
# List comments
|
17
|
+
#
|
18
|
+
def index
|
19
|
+
@comments = ::Blogaze::Models::Comment.all
|
20
|
+
respond(view_file('admin/comments/index'))
|
21
|
+
end
|
22
|
+
|
23
|
+
##
|
24
|
+
# Approve comment
|
25
|
+
#
|
26
|
+
def approve(comment_id)
|
27
|
+
::Blogaze::Models::Comment[comment_id].update(:in_moderation => 0).save
|
28
|
+
flash[:success] = "Comment approved"
|
29
|
+
redirect r('/')
|
30
|
+
end
|
31
|
+
|
32
|
+
##
|
33
|
+
# Delete comment
|
34
|
+
#
|
35
|
+
def delete(comment_id)
|
36
|
+
::Blogaze::Models::Comment[comment_id].delete
|
37
|
+
flash[:success] = "Comment deleted"
|
38
|
+
redirect r('/')
|
39
|
+
end
|
40
|
+
end # Comments
|
41
|
+
end # Admin
|
42
|
+
end # Controllers
|
43
|
+
end # Blogaze
|
@@ -0,0 +1,25 @@
|
|
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 Controllers
|
11
|
+
module Admin
|
12
|
+
class Dashboard < Controller
|
13
|
+
map '/admin'
|
14
|
+
|
15
|
+
##
|
16
|
+
# Admin index
|
17
|
+
#
|
18
|
+
def index
|
19
|
+
@title = "Admin - #{@settings[:title]}"
|
20
|
+
respond(view_file('admin/index'))
|
21
|
+
end
|
22
|
+
end # Dashboard
|
23
|
+
end # Admin
|
24
|
+
end # Controllers
|
25
|
+
end # Blogaze
|
@@ -0,0 +1,30 @@
|
|
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 Controllers
|
11
|
+
module Admin
|
12
|
+
class Controller < ::Blogaze::Controller
|
13
|
+
layout 'admin'
|
14
|
+
helper :blue_form
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
super
|
18
|
+
|
19
|
+
if !@userinfo.respond_to?('group') or !@userinfo.group.is_admin
|
20
|
+
redirect '/login'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end # Controller
|
24
|
+
end # Admin
|
25
|
+
end # Controllers
|
26
|
+
end # Blogaze
|
27
|
+
|
28
|
+
Dir.glob(File.dirname(__FILE__) + '/*.rb').each do |controller|
|
29
|
+
require(controller)
|
30
|
+
end
|
@@ -0,0 +1,95 @@
|
|
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 Controllers
|
11
|
+
module Admin
|
12
|
+
class Pages < Controller
|
13
|
+
map '/admin/pages'
|
14
|
+
|
15
|
+
##
|
16
|
+
# Page listing
|
17
|
+
#
|
18
|
+
def index
|
19
|
+
@pages = ::Blogaze::Models::Page.order(:title.asc).all
|
20
|
+
respond(view_file('admin/pages/index'))
|
21
|
+
end
|
22
|
+
|
23
|
+
##
|
24
|
+
# New page form
|
25
|
+
#
|
26
|
+
def new
|
27
|
+
@title = "New Page - Pages - Admin - #{@settings[:title]}"
|
28
|
+
@page = ::Blogaze::Models::Page.new
|
29
|
+
respond(view_file('admin/pages/new'))
|
30
|
+
end
|
31
|
+
|
32
|
+
##
|
33
|
+
# Create page
|
34
|
+
#
|
35
|
+
def create
|
36
|
+
@title = "New Page - Pages - Admin - #{@settings[:title]}"
|
37
|
+
data = {
|
38
|
+
:title => request[:title],
|
39
|
+
:slug => request[:slug],
|
40
|
+
:body => request[:body],
|
41
|
+
:on_menu => request[:on_menu]
|
42
|
+
}
|
43
|
+
|
44
|
+
@page = ::Blogaze::Models::Page.new(data)
|
45
|
+
|
46
|
+
if @page.valid?
|
47
|
+
@page.save
|
48
|
+
flash[:success] = "Page created successfully"
|
49
|
+
redirect Pages.r('/')
|
50
|
+
else
|
51
|
+
respond(view_file('admin/pages/new'))
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
##
|
56
|
+
# Edit page
|
57
|
+
#
|
58
|
+
def edit(page_id)
|
59
|
+
@title = "Edit Page - Pages - Admin - #{@settings[:title]}"
|
60
|
+
@page = ::Blogaze::Models::Page[page_id]
|
61
|
+
respond(view_file('admin/pages/edit'))
|
62
|
+
end
|
63
|
+
|
64
|
+
##
|
65
|
+
# Save page
|
66
|
+
#
|
67
|
+
def save(page_id)
|
68
|
+
@title = "Edit Page - Pages - Admin - #{@settings[:title]}"
|
69
|
+
@page = ::Blogaze::Models::Page[page_id]
|
70
|
+
@page.title = request[:title]
|
71
|
+
@page.slug = request[:slug]
|
72
|
+
@page.body = request[:body]
|
73
|
+
@page.on_menu = request[:on_menu]
|
74
|
+
|
75
|
+
if @page.valid?
|
76
|
+
@page.save
|
77
|
+
flash[:success] = "Page saved successfully"
|
78
|
+
redirect Pages.r('/')
|
79
|
+
else
|
80
|
+
respond(view_file('admin/pages/edit'))
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
##
|
85
|
+
# Delete page
|
86
|
+
#
|
87
|
+
def delete(page_id)
|
88
|
+
P::Blogaze::Models::age[page_id].delete
|
89
|
+
flash[:success] = "Page deleted successfully"
|
90
|
+
redirect Pages.r('/')
|
91
|
+
end
|
92
|
+
end # Pages
|
93
|
+
end # Admin
|
94
|
+
end # Controllers
|
95
|
+
end # Blogaze
|
@@ -0,0 +1,125 @@
|
|
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 Controllers
|
11
|
+
module Admin
|
12
|
+
class Posts < Controller
|
13
|
+
map '/admin/posts'
|
14
|
+
|
15
|
+
before :new, :create do
|
16
|
+
if !@userinfo.group.create_posts
|
17
|
+
flash[:error] = "You don't have permission to do that."
|
18
|
+
redirect '/login'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
before :edit, :save do
|
23
|
+
if !@userinfo.group.edit_posts
|
24
|
+
flash[:error] = "You don't have permission to do that."
|
25
|
+
redirect '/login'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
before :delete do
|
30
|
+
if !@userinfo.group.delete_posts
|
31
|
+
flash[:error] = "You don't have permission to do that."
|
32
|
+
redirect '/login'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
##
|
37
|
+
# Post listing
|
38
|
+
#
|
39
|
+
def index
|
40
|
+
@title = "Posts - Admin - #{@settings[:title]}"
|
41
|
+
@posts = ::Blogaze::Models::Post.order(:id.desc).all
|
42
|
+
respond(view_file('admin/posts/index'))
|
43
|
+
end
|
44
|
+
|
45
|
+
##
|
46
|
+
# New post form
|
47
|
+
#
|
48
|
+
def new
|
49
|
+
@title = "New Post - Posts - Admin - #{@settings[:title]}"
|
50
|
+
@post = ::Blogaze::Models::Post.new
|
51
|
+
respond(view_file('admin/posts/new'))
|
52
|
+
end
|
53
|
+
|
54
|
+
##
|
55
|
+
# Create post
|
56
|
+
#
|
57
|
+
def create
|
58
|
+
@title = "New Post - Posts - Admin - #{@settings[:title]}"
|
59
|
+
data = {
|
60
|
+
:title => request[:title],
|
61
|
+
:body => request[:body],
|
62
|
+
:user_id => @userinfo.id,
|
63
|
+
:post_tags => request[:post_tags].is_a?(String) ? request[:post_tags].gsub(', ', ',').split(',') : []
|
64
|
+
}
|
65
|
+
@post = ::Blogaze::Models::Post.new(data)
|
66
|
+
|
67
|
+
if @post.valid?
|
68
|
+
@post.save
|
69
|
+
flash[:success] = "Post created successfully"
|
70
|
+
redirect Posts.r('/')
|
71
|
+
else
|
72
|
+
@post.post_tags = @post.post_tags.join(', ')
|
73
|
+
respond(view_file('admin/posts/new'))
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
##
|
78
|
+
# Edit post
|
79
|
+
#
|
80
|
+
def edit(post_id)
|
81
|
+
@title = "Edit Post - Posts - Admin - #{@settings[:title]}"
|
82
|
+
@post = ::Blogaze::Models::Post[post_id]
|
83
|
+
|
84
|
+
post_tags = []
|
85
|
+
@post.tags.each do |tag|
|
86
|
+
post_tags.push tag.name
|
87
|
+
end
|
88
|
+
@post.post_tags = post_tags.join(', ')
|
89
|
+
|
90
|
+
respond(view_file('admin/posts/edit'))
|
91
|
+
end
|
92
|
+
|
93
|
+
##
|
94
|
+
# Save post
|
95
|
+
#
|
96
|
+
def save(post_id)
|
97
|
+
@title = "Edit Post - Posts - Admin - #{@settings[:title]}"
|
98
|
+
@post = ::Blogaze::Models::Post[post_id]
|
99
|
+
@post.title = request[:title]
|
100
|
+
@post.body = request[:body]
|
101
|
+
@post.post_tags = request[:post_tags].is_a?(String) ? request[:post_tags].gsub(', ', ',').split(',') : []
|
102
|
+
|
103
|
+
if @post.valid?
|
104
|
+
@post.save
|
105
|
+
flash[:success] = "Post saved successfully"
|
106
|
+
redirect Posts.r('/')
|
107
|
+
else
|
108
|
+
respond(view_file('admin/posts/edit'))
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
##
|
113
|
+
# Delete post
|
114
|
+
#
|
115
|
+
def delete(post_id)
|
116
|
+
post = ::Blogaze::Models::Post[post_id]
|
117
|
+
post.delete
|
118
|
+
::Blogaze::Models::TagsRelationship.where(:object_type => 'post', :object_id => post.id).delete
|
119
|
+
flash[:success] = "Post deleted successfully"
|
120
|
+
redirect Posts.r('/')
|
121
|
+
end
|
122
|
+
end # Posts
|
123
|
+
end # Admin
|
124
|
+
end # Controllers
|
125
|
+
end # Blogaze
|
@@ -0,0 +1,41 @@
|
|
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 Controllers
|
11
|
+
module Admin
|
12
|
+
class Settings < Controller
|
13
|
+
map '/admin/settings'
|
14
|
+
|
15
|
+
##
|
16
|
+
# Settings form
|
17
|
+
#
|
18
|
+
def index
|
19
|
+
# Get themes
|
20
|
+
@themes = []
|
21
|
+
|
22
|
+
::Blogaze::Theme.registered.each do |theme|
|
23
|
+
@themes.push theme[0].to_s
|
24
|
+
end
|
25
|
+
|
26
|
+
respond(view_file('admin/settings/index'))
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
# Save settings
|
31
|
+
#
|
32
|
+
def save
|
33
|
+
request[:settings].each do |setting, value|
|
34
|
+
::Blogaze.database[:settings].where(:setting => setting).update(:value => value)
|
35
|
+
end
|
36
|
+
redirect Settings.r('/')
|
37
|
+
end
|
38
|
+
end # Settings
|
39
|
+
end # Admin
|
40
|
+
end # Controllers
|
41
|
+
end # Blogaze
|