activeadmin-blog 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -2
- data/app/models/activeadmin_blog/blog_post.rb +1 -2
- data/app/views/admin/categories/_form.html.erb +4 -12
- data/app/views/admin/categories/_show.html.erb +5 -0
- data/app/views/admin/posts/_categories.html.erb +2 -0
- data/app/views/admin/posts/_form.html.erb +57 -0
- data/app/views/admin/posts/_table.html.erb +51 -0
- data/app/views/admin/posts/all.html.erb +5 -0
- data/lib/activeadmin-blog/version.rb +1 -1
- data/lib/generators/activeadmin_blog/templates/admin/blog_categories.rb +1 -44
- data/lib/generators/activeadmin_blog/templates/admin/blog_posts.rb +13 -83
- data/vendor/assets/javascripts/activeadmin_blog.js.coffee +22 -11
- data/vendor/assets/stylesheets/activeadmin_blog.css.scss +25 -4
- metadata +8 -4
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
activeadmin-blog (0.4.
|
4
|
+
activeadmin-blog (0.4.2)
|
5
5
|
activeadmin-mongoid
|
6
6
|
activeadmin-mongoid-reorder
|
7
7
|
activeadmin-settings
|
@@ -198,7 +198,7 @@ GEM
|
|
198
198
|
tilt (~> 1.1, != 1.3.0)
|
199
199
|
stringex (1.4.0)
|
200
200
|
subexec (0.2.2)
|
201
|
-
thor (0.
|
201
|
+
thor (0.16.0)
|
202
202
|
tilt (1.3.3)
|
203
203
|
treetop (1.4.10)
|
204
204
|
polyglot
|
@@ -27,8 +27,7 @@ class ActiveadminBlog::BlogPost
|
|
27
27
|
has_and_belongs_to_many :categories, :class_name => "ActiveadminBlog::BlogCategory"
|
28
28
|
|
29
29
|
# Scopes
|
30
|
-
default_scope order_by(:date => :desc)
|
31
|
-
scope :ideas, where(published: false)
|
30
|
+
default_scope order_by(:published => :asc).order_by({:date => :desc})
|
32
31
|
scope :published, where(published: true)
|
33
32
|
|
34
33
|
# Helpers
|
@@ -1,26 +1,18 @@
|
|
1
1
|
<fieldset class="inputs"><legend><span>Details</span></legend><ol>
|
2
2
|
<%= f.input :name, :required => true %>
|
3
|
-
|
3
|
+
<% if not f.object.new? %>
|
4
|
+
<%= f.input :permalink %>
|
5
|
+
<% end %>
|
4
6
|
</ol></fieldset>
|
5
7
|
|
6
8
|
<fieldset class="buttons">
|
7
9
|
<ol>
|
8
10
|
<li class="commit button">
|
9
|
-
<input class="update"
|
11
|
+
<input class="update" name="commit" type="submit"
|
10
12
|
value="<% if f.object.new? %>Create<% else %>Update<% end %> Category">
|
11
13
|
</li>
|
12
14
|
<li class="cancel">
|
13
15
|
<a href="<%= admin_posts_path %>">Cancel</a>
|
14
16
|
</li>
|
15
|
-
<!--
|
16
|
-
<% if not f.object.new? %>
|
17
|
-
<li style="float:right;">
|
18
|
-
<%= link_to "Delete Category", resource_path(f.object),
|
19
|
-
:method => :delete,
|
20
|
-
:confirm => "Are you sure, you want to delte this category?",
|
21
|
-
:class => "delete button" %>
|
22
|
-
</li>
|
23
|
-
<% end %>
|
24
|
-
-->
|
25
17
|
</ol>
|
26
18
|
</fieldset>
|
@@ -0,0 +1,57 @@
|
|
1
|
+
<fieldset class="inputs"><legend><span>Title</span></legend><ol>
|
2
|
+
<%= f.input :title, :required => true %>
|
3
|
+
</ol></fieldset>
|
4
|
+
|
5
|
+
<fieldset class="inputs<% if f.object.new? %> collapsed<% end %>">
|
6
|
+
<legend>
|
7
|
+
<span>Details
|
8
|
+
<a class="collapse-button-hide" href="#" title="Hide details">Hide</a>
|
9
|
+
<a class="collapse-button-show" href="#" title="Show details">Show</a>
|
10
|
+
</span>
|
11
|
+
</legend>
|
12
|
+
<ol>
|
13
|
+
<%= f.input :featured_image, :hint => f.object.has_featured_image? ? image_tag(f.object.featured_image.thumb.url, :size => "118x100") : "" %>
|
14
|
+
|
15
|
+
<% if f.object.has_featured_image? %>
|
16
|
+
<%= f.input :remove_featured_image, :as => :boolean %>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<% if not f.object.new? %>
|
20
|
+
<%= f.input :permalink %>
|
21
|
+
<% end %>
|
22
|
+
|
23
|
+
<%= f.input :date, :input_html => { :class => "datepicker", :placeholder => "Click field to pick date" } %>
|
24
|
+
|
25
|
+
<% categories = ActiveadminBlog::BlogCategory.all
|
26
|
+
if categories.size > 0 %>
|
27
|
+
|
28
|
+
<%= f.input :categories, :as => :select,
|
29
|
+
:label => "Published in",
|
30
|
+
:input_html => { :multiple => true, :class => "select2" },
|
31
|
+
:collection => categories,
|
32
|
+
:include_blank => false,
|
33
|
+
:hint => "Select one or several categories" %>
|
34
|
+
<% end %>
|
35
|
+
|
36
|
+
<%= f.input :tags, :hint => "Tags separted by comma",
|
37
|
+
:input_html => { "data-url" => "/admin/posts/tags" } %>
|
38
|
+
|
39
|
+
<%= f.input :published, :as => :boolean, :label => "Published" %>
|
40
|
+
|
41
|
+
</ol></fieldset>
|
42
|
+
|
43
|
+
<fieldset class="inputs"><legend><span>Content</span></legend><ol>
|
44
|
+
<%= f.input :content, :as => :text, :input_html => { :class => "redactor" }%>
|
45
|
+
</ol></fieldset>
|
46
|
+
|
47
|
+
<fieldset class="buttons">
|
48
|
+
<ol>
|
49
|
+
<li class="commit button">
|
50
|
+
<input class="update" name="commit" type="submit"
|
51
|
+
value="<% if f.object.new? %>Create<% else %>Update<% end %> Post">
|
52
|
+
</li>
|
53
|
+
<li class="cancel">
|
54
|
+
<a href="<%= admin_posts_path %>">Cancel</a>
|
55
|
+
</li>
|
56
|
+
</ol>
|
57
|
+
</fieldset>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
<table border="0" cellspacing="0" cellpadding="0" id="posts" class="index_table">
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<th class=""></th>
|
5
|
+
<th class="">Post</th>
|
6
|
+
<th class="">Status</th>
|
7
|
+
<th class=""></th>
|
8
|
+
</tr>
|
9
|
+
</thead>
|
10
|
+
<tbody>
|
11
|
+
<% posts.each do |p| %>
|
12
|
+
<tr>
|
13
|
+
<td class="featured-image">
|
14
|
+
<% if p.featured_image.thumb.url.nil? %>
|
15
|
+
<%= image_tag("http://placehold.it/118x100&text=NO+IMAGE", :alt=>p.title, :size=>"118x100") %>
|
16
|
+
<% else %>
|
17
|
+
<%= image_tag(p.featured_image.thumb.url, :alt=>p.title, :size=>"118x100") %>
|
18
|
+
<% end %>
|
19
|
+
</td>
|
20
|
+
|
21
|
+
<td class="post-details">
|
22
|
+
<p>
|
23
|
+
<strong><%= p.title %></strong>
|
24
|
+
<br/>
|
25
|
+
<em><%= truncate(p.excerpt, :length => 90) %></em>
|
26
|
+
</p>
|
27
|
+
|
28
|
+
<% if not p.tags.empty? %>
|
29
|
+
Tags: <em><%= p.tags.gsub(',', ', ') %></em>
|
30
|
+
<br/>
|
31
|
+
<% end %>
|
32
|
+
|
33
|
+
<% if p.categories.size > 0 %>
|
34
|
+
Published in: <%= p.categories.collect{ |c| link_to(c.name, admin_category_path(c)) }.join(", ").html_safe %>
|
35
|
+
<% end %>
|
36
|
+
</td>
|
37
|
+
|
38
|
+
<td class="post-status">
|
39
|
+
<%= p.date.to_s.gsub('-', '/') %>
|
40
|
+
<br/>
|
41
|
+
<i><%= p.published ? 'Published' : 'Not Published' %></i>
|
42
|
+
</td>
|
43
|
+
|
44
|
+
<td class="actions">
|
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
|
+
</td>
|
48
|
+
</tr>
|
49
|
+
<% end %>
|
50
|
+
</tbody>
|
51
|
+
</table>
|
@@ -26,50 +26,7 @@ ActiveAdmin.register ActiveadminBlog::BlogCategory, :as => "Category" do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
show :title => :name do
|
29
|
-
|
30
|
-
li :class => "links" do
|
31
|
-
link_to "All Posts", admin_posts_path, :class => "all-posts-button"
|
32
|
-
end
|
33
|
-
li do
|
34
|
-
if category.blog_posts.size > 0
|
35
|
-
table_for(category.blog_posts, {:class => "index_table category_posts"}) do |t|
|
36
|
-
|
37
|
-
t.column("") do |p| # Blog post featured image thumbnail
|
38
|
-
url = p.featured_image.thumb.url
|
39
|
-
if url.nil?
|
40
|
-
url = "http://placehold.it/118x100&text=NO+IMAGE"
|
41
|
-
end
|
42
|
-
image_tag(url, :alt => p.title, :size=>"118x100")
|
43
|
-
end
|
44
|
-
|
45
|
-
t.column("Title") do |p|
|
46
|
-
html = "<p><strong>#{p.title}</strong><br/><em>#{truncate(p.excerpt, :length => 90)}</em></p>"
|
47
|
-
|
48
|
-
if not p.tags.empty?
|
49
|
-
html << "Tags: <em>" + p.tags.gsub(',', ', ') + "</em><br/>"
|
50
|
-
end
|
51
|
-
|
52
|
-
if p.categories.size > 0
|
53
|
-
html << "Published in: " + p.categories.collect{|c| link_to(c.name, admin_category_path(c))}.join(", ")
|
54
|
-
end
|
55
|
-
html.html_safe
|
56
|
-
end
|
57
|
-
|
58
|
-
t.column("Status") do |p|
|
59
|
-
"""#{p.date.to_s.gsub('-', '/')}<br/>
|
60
|
-
<i>#{p.published ? 'Published' : 'Not Finished'}</i>""".html_safe
|
61
|
-
end
|
62
|
-
|
63
|
-
t.column "" do |p|
|
64
|
-
link_to("Edit", edit_admin_post_path(p), :class => "member_link") +
|
65
|
-
link_to("Delete", admin_post_path(p), :class => "member_link", :method => :delete, :confirm => "Are you sure?")
|
66
|
-
end
|
67
|
-
end
|
68
|
-
else
|
69
|
-
p "No posts here yet."
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
29
|
+
render :partial => "show", :locals => { :category => category }
|
73
30
|
end
|
74
31
|
|
75
32
|
sidebar :categories, :only => :show do
|
@@ -3,99 +3,29 @@ ActiveAdmin.register ActiveadminBlog::BlogPost, :as => "Post" do
|
|
3
3
|
|
4
4
|
actions :all, :except => [:show]
|
5
5
|
|
6
|
-
# Scopes
|
7
|
-
scope :published, :default => true
|
8
|
-
scope :ideas
|
9
|
-
|
10
6
|
controller do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
index do
|
15
|
-
column("") do |p| # Blog post featured image thumbnail
|
16
|
-
url = p.featured_image.thumb.url
|
17
|
-
if url.nil?
|
18
|
-
url = "http://placehold.it/118x100&text=NO+IMAGE"
|
19
|
-
end
|
20
|
-
image_tag(url, :alt => p.title, :size=>"118x100")
|
21
|
-
end
|
22
|
-
|
23
|
-
column("Title") do |p|
|
24
|
-
html = "<p><strong>#{p.title}</strong><br/><em>#{truncate(p.excerpt, :length => 90)}</em></p>"
|
25
|
-
|
26
|
-
if not p.tags.empty?
|
27
|
-
html << "Tags: <em>" + p.tags.gsub(',', ', ') + "</em><br/>"
|
28
|
-
end
|
29
|
-
|
30
|
-
if p.categories.size > 0
|
31
|
-
html << "Published in: " + p.categories.collect{|c| link_to(c.name, admin_category_path(c))}.join(", ")
|
32
|
-
end
|
33
|
-
html.html_safe
|
34
|
-
end
|
35
|
-
|
36
|
-
column("Status") do |p|
|
37
|
-
"""#{p.date.to_s.gsub('-', '/')}<br/>
|
38
|
-
<i>#{p.published ? 'Published' : 'Not Finished'}</i>""".html_safe
|
7
|
+
def index
|
8
|
+
redirect_to all_admin_posts_path
|
39
9
|
end
|
40
10
|
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
sidebar :categories, :only => :index do
|
45
|
-
render :partial => "categories", :locals => { :categories => ActiveadminBlog::BlogCategory.all }
|
11
|
+
defaults :finder => :find_by_permalink
|
46
12
|
end
|
47
13
|
|
48
14
|
form do |f|
|
49
|
-
|
50
|
-
f.input :title, :required => true
|
51
|
-
end
|
52
|
-
f.inputs "Content" do
|
53
|
-
f.input :content, :as => :text,
|
54
|
-
:input_html => { :class => "redactor" }
|
55
|
-
end
|
56
|
-
f.inputs "Details" do
|
57
|
-
|
58
|
-
if f.object.has_featured_image?
|
59
|
-
featured_image_hint = image_tag f.object.featured_image.thumb.url, :size => "118x100"
|
60
|
-
else
|
61
|
-
featured_image_hint = ""
|
62
|
-
end
|
63
|
-
f.input :featured_image, :hint => featured_image_hint
|
64
|
-
|
65
|
-
if f.object.has_featured_image?
|
66
|
-
f.input :remove_featured_image, :as => :boolean
|
67
|
-
end
|
68
|
-
|
69
|
-
unless f.object.new?
|
70
|
-
f.input :permalink
|
71
|
-
end
|
72
|
-
|
73
|
-
f.input :published, :as => :select,
|
74
|
-
:label => "State",
|
75
|
-
:collection => [["published", "true"], ["not finished", "false"]],
|
76
|
-
:include_blank => false,
|
77
|
-
:input_html => { :class => "select2" }
|
78
|
-
|
79
|
-
f.input :date, :input_html => { :class => "datepicker", :placeholder => "Click field to pick date" }
|
80
|
-
|
81
|
-
categories = ActiveadminBlog::BlogCategory.all
|
82
|
-
if categories.size > 0
|
83
|
-
f.input :categories, :as => :select,
|
84
|
-
:label => "Published in",
|
85
|
-
:input_html => { :multiple => true, :class => "select2" },
|
86
|
-
:collection => categories,
|
87
|
-
:include_blank => false,
|
88
|
-
:hint => "Click on field and select category from dropdown"
|
89
|
-
end
|
90
|
-
|
91
|
-
f.input :tags, :hint => "Select from the list or type a new one and press ENTER",
|
92
|
-
:input_html => { "data-url" => "/admin/posts/tags" }
|
93
|
-
end
|
94
|
-
f.buttons
|
15
|
+
render :partial => "form", :locals => { :f => f }
|
95
16
|
end
|
96
17
|
|
97
18
|
collection_action :tags, :method => :get do
|
98
19
|
tags = ActiveadminBlog::BlogPost.all.collect{ |p| p.tags }.join(",").split(',').uniq
|
99
20
|
render :json => tags
|
100
21
|
end
|
22
|
+
|
23
|
+
collection_action :all do
|
24
|
+
@page_title = "All Posts"
|
25
|
+
@posts = ActiveadminBlog::BlogPost.all
|
26
|
+
end
|
27
|
+
|
28
|
+
sidebar :categories, :only => :all do
|
29
|
+
render :partial => "categories", :locals => { :categories => ActiveadminBlog::BlogCategory.all }
|
30
|
+
end
|
101
31
|
end
|
@@ -4,27 +4,33 @@
|
|
4
4
|
if !Array.prototype.last
|
5
5
|
Array.prototype.last = () -> return this[this.length - 1]
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
enable_collapsable_details = ->
|
8
|
+
$('.collapsed .collapse-button-show').live 'click', (e) ->
|
9
|
+
e.preventDefault()
|
10
|
+
$(this).closest('.collapsed').removeClass('collapsed')
|
11
|
+
|
12
|
+
$('form .collapse-button-hide').click (e) ->
|
13
|
+
e.preventDefault()
|
14
|
+
$(this).closest('fieldset').addClass('collapsed')
|
15
|
+
|
16
|
+
enable_header_link_highlight = ->
|
9
17
|
if $('.admin_categories').length > 0
|
10
18
|
$('#header #blog').addClass("current")
|
11
|
-
|
12
|
-
# Enable redactor
|
13
|
-
$('.redactor').redactor
|
14
|
-
imageUpload: "/redactor_rails/pictures"
|
15
|
-
imageGetJson: "/redactor_rails/pictures"
|
16
19
|
|
17
|
-
|
20
|
+
enable_redactor = ->
|
21
|
+
$('.redactor').redactor()
|
22
|
+
|
23
|
+
enable_select2 = ->
|
18
24
|
$('.select2').select2
|
19
25
|
minimumResultsForSearch: 10
|
20
26
|
|
21
27
|
tags_input = $("#post_tags")
|
28
|
+
|
22
29
|
if tags_input.length > 0
|
23
30
|
tags_url = tags_input.attr("data-url")
|
24
31
|
$.get tags_url, (tags) => tags_input.select2({tags: tags })
|
25
32
|
|
26
|
-
|
27
|
-
$ ->
|
33
|
+
categories_reorder = ->
|
28
34
|
categories_sortable_options = (url) ->
|
29
35
|
options =
|
30
36
|
stop: (e, ui) ->
|
@@ -53,4 +59,9 @@ $ ->
|
|
53
59
|
.disableSelection()
|
54
60
|
|
55
61
|
|
56
|
-
|
62
|
+
$ ->
|
63
|
+
enable_collapsable_details()
|
64
|
+
enable_header_link_highlight()
|
65
|
+
enable_redactor()
|
66
|
+
#enable_select2()
|
67
|
+
categories_reorder()
|
@@ -6,8 +6,8 @@
|
|
6
6
|
|
7
7
|
#post_title { font-size:2em; }
|
8
8
|
|
9
|
-
|
10
|
-
#
|
9
|
+
//#post_category_ids { width:76%; }
|
10
|
+
#post_category_ids { width:160px; }
|
11
11
|
#post_date { width:138px; }
|
12
12
|
}
|
13
13
|
|
@@ -29,7 +29,6 @@
|
|
29
29
|
}
|
30
30
|
|
31
31
|
#categories_sidebar_section {
|
32
|
-
margin-top:36px;
|
33
32
|
ul {
|
34
33
|
margin:0px; padding:0px;
|
35
34
|
list-style:none;
|
@@ -48,4 +47,26 @@
|
|
48
47
|
height:22px;
|
49
48
|
margin-bottom:14px;
|
50
49
|
}
|
51
|
-
}
|
50
|
+
}
|
51
|
+
|
52
|
+
.admin_posts, .admin_categories {
|
53
|
+
.breadcrumb { display:none; }
|
54
|
+
}
|
55
|
+
|
56
|
+
// Collapse blog post details
|
57
|
+
.admin_posts form {
|
58
|
+
.inputs.collapsed {
|
59
|
+
padding:0;
|
60
|
+
|
61
|
+
.collapse-button-hide { display: none; }
|
62
|
+
.collapse-button-show { display: inline; }
|
63
|
+
|
64
|
+
ol { display:none; }
|
65
|
+
}
|
66
|
+
|
67
|
+
.collapse-button-hide, .collapse-button-show { float:right; }
|
68
|
+
|
69
|
+
.collapse-button-show {
|
70
|
+
display:none;
|
71
|
+
}
|
72
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeadmin-blog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -133,7 +133,11 @@ files:
|
|
133
133
|
- app/views/activeadmin_blog/posts/show.html.erb
|
134
134
|
- app/views/activeadmin_blog/posts/tag.html.erb
|
135
135
|
- app/views/admin/categories/_form.html.erb
|
136
|
+
- app/views/admin/categories/_show.html.erb
|
136
137
|
- app/views/admin/posts/_categories.html.erb
|
138
|
+
- app/views/admin/posts/_form.html.erb
|
139
|
+
- app/views/admin/posts/_table.html.erb
|
140
|
+
- app/views/admin/posts/all.html.erb
|
137
141
|
- config/routes.rb
|
138
142
|
- install.sh
|
139
143
|
- lib/activeadmin-blog.rb
|
@@ -161,7 +165,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
161
165
|
version: '0'
|
162
166
|
segments:
|
163
167
|
- 0
|
164
|
-
hash:
|
168
|
+
hash: -3963232444574075549
|
165
169
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
170
|
none: false
|
167
171
|
requirements:
|
@@ -170,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
174
|
version: '0'
|
171
175
|
segments:
|
172
176
|
- 0
|
173
|
-
hash:
|
177
|
+
hash: -3963232444574075549
|
174
178
|
requirements: []
|
175
179
|
rubyforge_project: nowarning
|
176
180
|
rubygems_version: 1.8.24
|