activeadmin-mongoid-blog 0.3.6 → 0.3.7
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 +5 -1
- data/activeadmin-mongoid-blog.gemspec +1 -1
- data/app/views/admin/categories/_form.html.erb +26 -0
- data/app/views/admin/posts/_categories.html.erb +16 -0
- data/lib/generators/active_admin/blog/templates/admin/blog_categories.rb +61 -40
- data/lib/generators/active_admin/blog/templates/admin/blog_posts.rb +5 -3
- data/vendor/assets/javascripts/activeadmin_mongoid_blog.js.coffee +39 -0
- data/vendor/assets/stylesheets/activeadmin_mongoid_blog.css.scss +27 -0
- metadata +5 -3
data/README.md
CHANGED
@@ -163,6 +163,10 @@ Add the following line to `config/environments/production.rb`:
|
|
163
163
|
config.assets.precompile += ["active_admin.js", "active_admin.css", "redactor-rails/css/style.css"]
|
164
164
|
|
165
165
|
|
166
|
-
|
166
|
+
## TODO
|
167
167
|
|
168
|
+
- Make sidebar category widget, so no nested menus for blog;
|
169
|
+
- Make settings and admin_user a different tabs on the same settings page;
|
170
|
+
- Admin blog post search;
|
168
171
|
|
172
|
+
### The End
|
@@ -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.7'
|
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'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<fieldset class="inputs"><legend><span>Details</span></legend><ol>
|
2
|
+
<%= f.input :name, :required => true %>
|
3
|
+
<%= f.input :permalink %>
|
4
|
+
</ol></fieldset>
|
5
|
+
|
6
|
+
<fieldset class="buttons">
|
7
|
+
<ol>
|
8
|
+
<li class="commit button">
|
9
|
+
<input class="update" id="proposal_submit" name="commit" type="submit"
|
10
|
+
value="<% if f.object.new? %>Create<% else %>Update<% end %> Category">
|
11
|
+
</li>
|
12
|
+
<li class="cancel">
|
13
|
+
<a href="<%= admin_posts_path %>">Cancel</a>
|
14
|
+
</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
|
+
</ol>
|
26
|
+
</fieldset>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<ul id="blog_categories_list">
|
2
|
+
<% categories.each do |c| %>
|
3
|
+
<li id="category_<%= c.id %>">
|
4
|
+
<span>
|
5
|
+
<%= link_to c.name, admin_category_path(c) %>
|
6
|
+
<% if c.blog_posts.size > 0 %>(<%= c.blog_posts.size %>)<% end %>
|
7
|
+
</span>
|
8
|
+
<span class="action-buttons">
|
9
|
+
<%= link_to "Edit", edit_admin_category_path(c) %>
|
10
|
+
</span>
|
11
|
+
</li>
|
12
|
+
<% end %>
|
13
|
+
</ul>
|
14
|
+
|
15
|
+
<br/>
|
16
|
+
<%= link_to "New Category", new_admin_category_path %>
|
@@ -1,62 +1,83 @@
|
|
1
1
|
ActiveAdmin.register BlogCategory, :as => "Category" do
|
2
|
-
menu
|
2
|
+
menu false
|
3
|
+
|
4
|
+
actions :show, :new, :edit, :create, :update, :destroy
|
3
5
|
|
4
6
|
controller do
|
5
|
-
|
6
|
-
|
7
|
+
def create
|
8
|
+
create! do |format|
|
9
|
+
format.html { redirect_to admin_posts_path }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def update
|
14
|
+
update! do |format|
|
15
|
+
format.html { redirect_to admin_posts_path }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def destroy
|
20
|
+
destroy! do |format|
|
21
|
+
format.html { redirect_to admin_posts_path }
|
22
|
+
end
|
23
|
+
end
|
7
24
|
|
8
|
-
|
9
|
-
column :name
|
10
|
-
default_actions
|
25
|
+
defaults :finder => :find_by_permalink
|
11
26
|
end
|
12
27
|
|
13
28
|
show :title => :name do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
29
|
+
ol :id => "category_posts_page" do
|
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")
|
22
43
|
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
44
|
|
29
|
-
|
30
|
-
html
|
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
|
31
56
|
end
|
32
57
|
|
33
|
-
|
34
|
-
|
58
|
+
t.column("Status") do |p|
|
59
|
+
"""#{p.date.to_s.gsub('-', '/')}<br/>
|
60
|
+
<i>#{p.draft ? 'Draft' : 'Published'}</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?")
|
35
66
|
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
67
|
end
|
68
|
+
else
|
69
|
+
p "No posts here yet."
|
48
70
|
end
|
49
71
|
end
|
50
72
|
end
|
51
73
|
end
|
52
74
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
f.input :permalink
|
57
|
-
end
|
75
|
+
sidebar :categories, :only => :show do
|
76
|
+
render :partial => "admin/posts/categories", :locals => { :categories => BlogCategory.all }
|
77
|
+
end
|
58
78
|
|
59
|
-
|
79
|
+
form do |f|
|
80
|
+
render :partial => "form", :locals => { :f => f }
|
60
81
|
end
|
61
82
|
|
62
83
|
collection_action :reorder, :method => :put do
|
@@ -1,7 +1,5 @@
|
|
1
1
|
ActiveAdmin.register BlogPost, :as => "Post" do
|
2
|
-
menu
|
3
|
-
:label => "All Posts",
|
4
|
-
:priority => 1
|
2
|
+
menu :label => "Blog"
|
5
3
|
|
6
4
|
actions :new, :create, :index, :update, :edit, :destroy
|
7
5
|
|
@@ -44,6 +42,10 @@ ActiveAdmin.register BlogPost, :as => "Post" do
|
|
44
42
|
default_actions
|
45
43
|
end
|
46
44
|
|
45
|
+
sidebar :categories, :only => :index do
|
46
|
+
render :partial => "categories", :locals => { :categories => BlogCategory.all }
|
47
|
+
end
|
48
|
+
|
47
49
|
form do |f|
|
48
50
|
f.inputs "Title" do
|
49
51
|
f.input :title, :required => true
|
@@ -2,7 +2,14 @@
|
|
2
2
|
#= require select2
|
3
3
|
#= require activeadmin_reorder_table
|
4
4
|
|
5
|
+
if !Array.prototype.last
|
6
|
+
Array.prototype.last = () -> return this[this.length - 1]
|
7
|
+
|
5
8
|
$ ->
|
9
|
+
# Fix header menu for category pages
|
10
|
+
if $('.admin_categories').length > 0
|
11
|
+
$('#header #blog').addClass("current")
|
12
|
+
|
6
13
|
# Enable redactor
|
7
14
|
$('.redactor').redactor
|
8
15
|
imageUpload: "/redactor_rails/pictures"
|
@@ -16,3 +23,35 @@ $ ->
|
|
16
23
|
if tags_input.length > 0
|
17
24
|
tags_url = tags_input.attr("data-url")
|
18
25
|
$.get tags_url, (tags) => tags_input.select2({tags: tags })
|
26
|
+
|
27
|
+
# Reorder functionality
|
28
|
+
$ ->
|
29
|
+
categories_sortable_options = (url) ->
|
30
|
+
options =
|
31
|
+
stop: (e, ui) ->
|
32
|
+
# Select object ids from the table rows
|
33
|
+
# -------------------------------------
|
34
|
+
ids = []
|
35
|
+
$(this).find('li').each ->
|
36
|
+
id_attr = $(this).attr('id')
|
37
|
+
if id_attr
|
38
|
+
id = id_attr.split("_").last()
|
39
|
+
ids.push(id)
|
40
|
+
|
41
|
+
params =
|
42
|
+
ids: ids
|
43
|
+
_method: "put"
|
44
|
+
authenticity_token: $('meta[name=csrf-token]').attr('content')
|
45
|
+
|
46
|
+
$.post url, params, (data) ->
|
47
|
+
if data != "ok"
|
48
|
+
alert 'Error happended. Please contact devs.'
|
49
|
+
return options
|
50
|
+
|
51
|
+
reorder_method_url = "/admin/categories/reorder"
|
52
|
+
$("#blog_categories_list")
|
53
|
+
.sortable(categories_sortable_options(reorder_method_url))
|
54
|
+
.disableSelection()
|
55
|
+
|
56
|
+
|
57
|
+
|
@@ -22,4 +22,31 @@
|
|
22
22
|
|
23
23
|
.admin_categories .category_posts {
|
24
24
|
tr th:first-child, tr th:last-child { width:118px; }
|
25
|
+
}
|
26
|
+
|
27
|
+
.admin_posts {
|
28
|
+
#categories_sidebar_section {
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
#categories_sidebar_section {
|
33
|
+
margin-top:36px;
|
34
|
+
ul {
|
35
|
+
margin:0px; padding:0px;
|
36
|
+
list-style:none;
|
37
|
+
}
|
38
|
+
.action-buttons {
|
39
|
+
float:right;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
#category_posts_page {
|
44
|
+
margin:0px;
|
45
|
+
padding:0px;
|
46
|
+
list-style:none;
|
47
|
+
|
48
|
+
.links {
|
49
|
+
height:22px;
|
50
|
+
margin-bottom:14px;
|
51
|
+
}
|
25
52
|
}
|
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.7
|
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-
|
12
|
+
date: 2012-08-01 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ''
|
15
15
|
email: santyor@gmail.com
|
@@ -21,6 +21,8 @@ files:
|
|
21
21
|
- README.md
|
22
22
|
- Rakefile
|
23
23
|
- activeadmin-mongoid-blog.gemspec
|
24
|
+
- app/views/admin/categories/_form.html.erb
|
25
|
+
- app/views/admin/posts/_categories.html.erb
|
24
26
|
- app/views/blog/_footer.html.erb
|
25
27
|
- app/views/blog/_header.html.erb
|
26
28
|
- app/views/blog/_post.html.erb
|
@@ -55,7 +57,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
55
57
|
version: '0'
|
56
58
|
segments:
|
57
59
|
- 0
|
58
|
-
hash:
|
60
|
+
hash: 1684917671557213397
|
59
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
62
|
none: false
|
61
63
|
requirements:
|