activeadmin-mongoid-blog 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -0
- data/activeadmin-mongoid-blog.gemspec +1 -1
- data/app/views/blog/_footer.html.erb +3 -0
- data/app/views/blog/_post.html.erb +6 -4
- data/install.sh +8 -7
- data/lib/generators/active_admin/blog/templates/admin/blog_categories.rb +40 -9
- data/lib/generators/active_admin/blog/templates/admin/blog_posts.rb +28 -21
- data/lib/generators/active_admin/blog/templates/models/blog_post.rb +2 -7
- data/vendor/assets/stylesheets/activeadmin_mongoid_blog.css.scss +13 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -21,6 +21,9 @@ Add these gems to Gemfile and run `bundle` command:
|
|
21
21
|
gem 'devise'
|
22
22
|
gem 'activeadmin-mongoid'
|
23
23
|
gem 'activeadmin-mongoid-blog'
|
24
|
+
gem 'therubyracer'
|
25
|
+
gem 'twitter-bootstrap-rails'
|
26
|
+
|
24
27
|
|
25
28
|
Run generators to and check settings in `/config/mongoid.yml`, `/config/initializers/active_admin.rb`:
|
26
29
|
|
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.name = 'activeadmin-mongoid-blog'
|
6
|
-
gem.version = '0.3.
|
6
|
+
gem.version = '0.3.4'
|
7
7
|
gem.summary = 'Blog app on the top of activeadmin and mongoid, using redactor and select2 plugins.'
|
8
8
|
gem.description = ''
|
9
9
|
gem.license = 'MIT'
|
@@ -14,11 +14,13 @@
|
|
14
14
|
<% end %>
|
15
15
|
</p>
|
16
16
|
|
17
|
-
<!-- FEATURED IMAGE LINK
|
17
|
+
<!-- FEATURED IMAGE LINK -->
|
18
18
|
<% if post.has_featured_image? %>
|
19
|
-
<
|
20
|
-
<%=
|
21
|
-
|
19
|
+
<p>
|
20
|
+
<a href="<%= blog_post_path(post) %>" title="Read More">
|
21
|
+
<%= image_tag post.featured_image_url, :alt=>post.title %>
|
22
|
+
</a>
|
23
|
+
</p>
|
22
24
|
<% end %>
|
23
25
|
|
24
26
|
<!-- EXCERPT -->
|
data/install.sh
CHANGED
@@ -20,12 +20,13 @@ cd $project_name
|
|
20
20
|
|
21
21
|
# Gems
|
22
22
|
echo '
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
gem "bson_ext"
|
24
|
+
gem "mongoid"
|
25
|
+
gem "devise"
|
26
|
+
gem "activeadmin-mongoid"
|
27
|
+
gem "activeadmin-mongoid-blog"
|
28
|
+
gem "therubyracer"
|
29
|
+
gem "twitter-bootstrap-rails"' >> Gemfile
|
29
30
|
|
30
31
|
|
31
32
|
bundle
|
@@ -77,7 +78,7 @@ echo '//= require jquery
|
|
77
78
|
//= require jquery_ujs
|
78
79
|
//= require twitter/bootstrap
|
79
80
|
//= require bootstrap
|
80
|
-
' > app/assets/
|
81
|
+
' > app/assets/javascripts/application.js
|
81
82
|
|
82
83
|
|
83
84
|
echo "\n\n\n"
|
@@ -10,19 +10,50 @@ ActiveAdmin.register BlogCategory, :as => "Category" do
|
|
10
10
|
default_actions
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
13
|
+
show :title => :name do
|
14
|
+
panel "Posts" do
|
15
|
+
if category.blog_posts.size > 0
|
16
|
+
table_for(category.blog_posts, {:class => "index_table category_posts"}) do |t|
|
17
|
+
|
18
|
+
t.column("") do |p| # Blog post featured image thumbnail
|
19
|
+
url = p.featured_image.thumb.url
|
20
|
+
if url.nil?
|
21
|
+
url = "http://placehold.it/118x100&text=NO+IMAGE"
|
22
|
+
end
|
23
|
+
image_tag(url, :alt => p.title, :size=>"118x100")
|
24
|
+
end
|
25
|
+
|
26
|
+
t.column("Title") do |p|
|
27
|
+
html = "<p><strong>#{p.title}</strong><br/><em>#{truncate(p.excerpt, :length => 90)}</em></p>"
|
28
|
+
|
29
|
+
if not p.tags.empty?
|
30
|
+
html << "Tags: <em>" + p.tags.gsub(',', ', ') + "</em><br/>"
|
31
|
+
end
|
32
|
+
|
33
|
+
if p.categories.size > 0
|
34
|
+
html << "Published in: " + p.categories.collect{|c| link_to(c.name, admin_category_path(c))}.join(", ")
|
35
|
+
end
|
36
|
+
html.html_safe
|
37
|
+
end
|
38
|
+
|
39
|
+
t.column("Status") do |p|
|
40
|
+
"""#{p.date.to_s.gsub('-', '/')}<br/>
|
41
|
+
<i>#{p.draft ? 'Draft' : 'Published'}</i>""".html_safe
|
42
|
+
end
|
43
|
+
|
44
|
+
t.column "" do |p|
|
45
|
+
link_to("Edit", edit_admin_post_path(p), :class => "member_link") +
|
46
|
+
link_to("Delete", admin_post_path(p), :class => "member_link", :method => :delete, :confirm => "Are you sure?")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
22
52
|
|
23
53
|
form do |f|
|
24
54
|
f.inputs "Details" do
|
25
55
|
f.input :name, :required => true
|
56
|
+
f.input :permalink
|
26
57
|
end
|
27
58
|
|
28
59
|
f.buttons
|
@@ -15,33 +15,28 @@ ActiveAdmin.register BlogPost, :as => "Post" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
index do
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
# image_tag(url, :alt => p.title, :size=>"60x40")
|
25
|
-
#end
|
26
|
-
|
27
|
-
column("Title") do |p|
|
28
|
-
html = "<strong>#{p.title}</strong>"
|
29
|
-
html.html_safe
|
18
|
+
column("") do |p| # Blog post featured image thumbnail
|
19
|
+
url = p.featured_image.thumb.url
|
20
|
+
if url.nil?
|
21
|
+
url = "http://placehold.it/118x100&text=NO+IMAGE"
|
22
|
+
end
|
23
|
+
image_tag(url, :alt => p.title, :size=>"118x100")
|
30
24
|
end
|
31
25
|
|
32
|
-
column("
|
33
|
-
html = ""
|
26
|
+
column("Title") do |p|
|
27
|
+
html = "<p><strong>#{p.title}</strong><br/><em>#{truncate(p.excerpt, :length => 90)}</em></p>"
|
28
|
+
|
29
|
+
if not p.tags.empty?
|
30
|
+
html << "Tags: <em>" + p.tags.gsub(',', ', ') + "</em><br/>"
|
31
|
+
end
|
32
|
+
|
34
33
|
if p.categories.size > 0
|
35
34
|
html << "Published in: " + p.categories.collect{|c| link_to(c.name, admin_category_path(c))}.join(", ")
|
36
|
-
html << "<br/>"
|
37
|
-
end
|
38
|
-
if not p.tags.empty?
|
39
|
-
html << "Tags: <em>" + p.tags.gsub(',', ', ') + "</em>"
|
40
35
|
end
|
41
36
|
html.html_safe
|
42
37
|
end
|
43
38
|
|
44
|
-
column("
|
39
|
+
column("Status") do |p|
|
45
40
|
"""#{p.date.to_s.gsub('-', '/')}<br/>
|
46
41
|
<i>#{p.draft ? 'Draft' : 'Published'}</i>""".html_safe
|
47
42
|
end
|
@@ -58,18 +53,30 @@ ActiveAdmin.register BlogPost, :as => "Post" do
|
|
58
53
|
:input_html => { :class => "redactor" }
|
59
54
|
end
|
60
55
|
f.inputs "Details" do
|
56
|
+
|
57
|
+
if f.object.has_featured_image?
|
58
|
+
featured_image_hint = image_tag f.object.featured_image.thumb.url, :size => "118x100"
|
59
|
+
else
|
60
|
+
featured_image_hint = ""
|
61
|
+
end
|
62
|
+
f.input :featured_image, :hint => featured_image_hint
|
63
|
+
|
64
|
+
if f.object.has_featured_image?
|
65
|
+
f.input :remove_featured_image, :as => :boolean
|
66
|
+
end
|
67
|
+
|
61
68
|
unless f.object.new?
|
62
69
|
f.input :permalink
|
63
70
|
end
|
64
71
|
|
65
|
-
f.input :date, :input_html => { :class => "datepicker" }
|
66
|
-
|
67
72
|
f.input :draft, :as => :select,
|
68
73
|
:label => "State",
|
69
74
|
:collection => [["draft", "true"], ["published", "false"]],
|
70
75
|
:include_blank => false,
|
71
76
|
:input_html => { :class => "select2" }
|
72
77
|
|
78
|
+
f.input :date, :input_html => { :class => "datepicker", :placeholder => "Click field to pick date" }
|
79
|
+
|
73
80
|
categories = BlogCategory.all
|
74
81
|
if categories.size > 0
|
75
82
|
f.input :categories, :as => :select,
|
@@ -14,8 +14,6 @@ class BlogPost
|
|
14
14
|
field :draft, :type => Boolean, :default => true
|
15
15
|
field :date, :type => Date
|
16
16
|
|
17
|
-
field :featured_image # This is temporary value until redactor with file uploading functionality is off
|
18
|
-
|
19
17
|
# Validations
|
20
18
|
validates_presence_of :title
|
21
19
|
validates_uniqueness_of :title
|
@@ -23,6 +21,7 @@ class BlogPost
|
|
23
21
|
# Features
|
24
22
|
slug :title, :as => :permalink, :permanent => true
|
25
23
|
search_in :title, :content, :tags
|
24
|
+
mount_uploader :featured_image, RedactorRailsPictureUploader
|
26
25
|
paginates_per 6
|
27
26
|
|
28
27
|
# Relations
|
@@ -35,11 +34,7 @@ class BlogPost
|
|
35
34
|
|
36
35
|
# Helpers
|
37
36
|
def has_featured_image?
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
def tags?
|
42
|
-
tags.size > 0
|
37
|
+
not featured_image.to_s.empty?
|
43
38
|
end
|
44
39
|
|
45
40
|
def excerpt
|
@@ -10,4 +10,16 @@
|
|
10
10
|
#post_category_ids { width:76%; }
|
11
11
|
#post_draft { width:160px; }
|
12
12
|
#post_date { width:138px; }
|
13
|
-
}
|
13
|
+
}
|
14
|
+
|
15
|
+
#posts.index_table {
|
16
|
+
tr th:first-child, tr th:last-child { width:118px; }
|
17
|
+
}
|
18
|
+
|
19
|
+
#categories.index_table {
|
20
|
+
tr th:last-child { width:118px; }
|
21
|
+
}
|
22
|
+
|
23
|
+
.admin_categories .category_posts {
|
24
|
+
tr th:first-child, tr th:last-child { width:118px; }
|
25
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeadmin-mongoid-blog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -55,7 +55,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
55
55
|
version: '0'
|
56
56
|
segments:
|
57
57
|
- 0
|
58
|
-
hash: -
|
58
|
+
hash: -3072008541518925790
|
59
59
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
60
|
none: false
|
61
61
|
requirements:
|