tb_blog 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +29 -0
- data/Readme.markdown +130 -0
- data/app/assets/images/spud/admin/news_thumb.png +0 -0
- data/app/assets/images/spud/admin/news_thumb@2x.png +0 -0
- data/app/assets/images/spud/admin/posts_thumb.png +0 -0
- data/app/assets/javascripts/spud/admin/post_categories.js +116 -0
- data/app/assets/javascripts/spud/admin/posts.js +71 -0
- data/app/assets/javascripts/spud/blog/sitemaps.js +2 -0
- data/app/assets/javascripts/spud/blog.js +41 -0
- data/app/assets/stylesheets/news.css +4 -0
- data/app/assets/stylesheets/spud/admin/posts.css +113 -0
- data/app/assets/stylesheets/spud/blog/sitemaps.css +4 -0
- data/app/assets/stylesheets/spud/blog/validity.css +3 -0
- data/app/controllers/blog_controller.rb +135 -0
- data/app/controllers/news_controller.rb +80 -0
- data/app/controllers/spud/admin/news_posts_controller.rb +62 -0
- data/app/controllers/spud/admin/post_categories_controller.rb +59 -0
- data/app/controllers/spud/admin/post_comments_controller.rb +68 -0
- data/app/controllers/spud/admin/posts_controller.rb +62 -0
- data/app/controllers/spud/blog/sitemaps_controller.rb +9 -0
- data/app/helpers/blog_helper.rb +25 -0
- data/app/helpers/news_helper.rb +2 -0
- data/app/helpers/spud/admin/news_posts_helper.rb +2 -0
- data/app/helpers/spud/admin/post_categories_helper.rb +2 -0
- data/app/helpers/spud/admin/post_comments_helper.rb +2 -0
- data/app/helpers/spud/admin/posts_helper.rb +22 -0
- data/app/helpers/spud/blog/sitemaps_helper.rb +2 -0
- data/app/models/spud_post.rb +171 -0
- data/app/models/spud_post_categories_post.rb +5 -0
- data/app/models/spud_post_category.rb +70 -0
- data/app/models/spud_post_category_sweeper.rb +41 -0
- data/app/models/spud_post_comment.rb +19 -0
- data/app/models/spud_post_comment_sweeper.rb +33 -0
- data/app/models/spud_post_site.rb +9 -0
- data/app/models/spud_post_sweeper.rb +47 -0
- data/app/views/blog/_comment.html.erb +4 -0
- data/app/views/blog/_comment_form.html.erb +20 -0
- data/app/views/blog/index.html.erb +35 -0
- data/app/views/blog/index.rss.builder +18 -0
- data/app/views/blog/show.html.erb +37 -0
- data/app/views/news/index.html.erb +35 -0
- data/app/views/news/index.rss.builder +18 -0
- data/app/views/news/show.html.erb +27 -0
- data/app/views/spud/admin/news_posts/edit.html.erb +3 -0
- data/app/views/spud/admin/news_posts/index.html.erb +44 -0
- data/app/views/spud/admin/news_posts/new.html.erb +3 -0
- data/app/views/spud/admin/post_categories/_category.html.erb +14 -0
- data/app/views/spud/admin/post_categories/_form.html.erb +23 -0
- data/app/views/spud/admin/post_categories/edit.html.erb +1 -0
- data/app/views/spud/admin/post_categories/index.html.erb +9 -0
- data/app/views/spud/admin/post_categories/new.html.erb +1 -0
- data/app/views/spud/admin/post_comments/index.html.erb +47 -0
- data/app/views/spud/admin/posts/_category.html.erb +9 -0
- data/app/views/spud/admin/posts/_form.html.erb +117 -0
- data/app/views/spud/admin/posts/edit.html.erb +3 -0
- data/app/views/spud/admin/posts/index.html.erb +50 -0
- data/app/views/spud/admin/posts/new.html.erb +3 -0
- data/app/views/spud/blog/sitemaps/show.xml.builder +16 -0
- data/config/routes.rb +94 -0
- data/db/migrate/20120125180945_create_spud_posts.rb +15 -0
- data/db/migrate/20120125181022_create_spud_post_categories.rb +13 -0
- data/db/migrate/20120125181359_create_spud_post_comments.rb +13 -0
- data/db/migrate/20120127143054_add_url_to_spud_posts.rb +6 -0
- data/db/migrate/20120127144942_add_url_to_spud_post_categories.rb +8 -0
- data/db/migrate/20120210165540_add_is_news_to_spud_posts.rb +6 -0
- data/db/migrate/20120309181917_add_meta_to_posts.rb +6 -0
- data/db/migrate/20120413020437_add_comments_counter_to_spud_posts.rb +12 -0
- data/db/migrate/20120713150446_create_spud_post_sites.rb +11 -0
- data/db/migrate/20120825142547_add_spam_fields_to_spud_post_comments.rb +8 -0
- data/db/migrate/20120825144506_add_permalink_to_spud_post_comments.rb +5 -0
- data/db/migrate/20121113135812_add_nested_set_to_post_categories.rb +21 -0
- data/db/migrate/20130120151857_add_content_format_to_spud_posts.rb +5 -0
- data/db/migrate/20130121130612_add_content_processed_to_spud_post.rb +5 -0
- data/lib/generators/spud/blog/random_posts_generator.rb +60 -0
- data/lib/generators/spud/blog/views_generator.rb +19 -0
- data/lib/spud_blog/configuration.rb +25 -0
- data/lib/spud_blog/engine.rb +64 -0
- data/lib/spud_blog/version.rb +5 -0
- data/lib/tasks/spud_blog_tasks.rake +4 -0
- data/lib/tb_blog.rb +6 -0
- data/test/fixtures/spud_post_sites.yml +9 -0
- data/test/unit/spud_post_site_test.rb +7 -0
- metadata +338 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZmQwODRlMmU0ZDkyM2U5OTU2NGZmNTJkODA2OGU0ZTJhNTVjNWQ0OQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YjA5ZGJhYzcwOTZiZDljNTM2Y2NkYjEzNjg0MDc3YTY1ZTA1Y2ExOA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MDM4NzFhYjEyOWQyOWY4YTEzNWJhM2VmYmIxOGQzYmM1NTgxMmExYjFkMmY5
|
10
|
+
YTFlM2I5ZTIxZWViZjE3ZTJlMmEwMDA0OTNjMmJmYmU1OTkyYWYwZTM4ZmFm
|
11
|
+
Y2JiNWIwMjc2YTI1MDE4YTZiN2QwYTlmMmY3NDdjZDFjYTI5Y2I=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MGEyMzQ5NDkxYjM1ZDMxYmY2MWQ3OWVmM2RmZGQyYWFlZjYzMmY3ZTg1ZDQ1
|
14
|
+
NThmM2VkMzYwMTYzOWYyMjNlOTBhYWIyODA0OThiZDdiZDY5OWQ1NTMxZGRi
|
15
|
+
ODRkZWFmOGFlMjY3YzFiYmZjMzI5OTdiNzMwYmE4MDNkOGI2NzQ=
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'SpudBlog'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
28
|
+
require 'rake'
|
29
|
+
|
data/Readme.markdown
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
Spud Blog
|
2
|
+
========
|
3
|
+
|
4
|
+
Spud Blog is a Blog Engine designed to be robust, easy to use, and light weight.
|
5
|
+
|
6
|
+
__NOTE:__ This project is still in its early infancy.
|
7
|
+
|
8
|
+
## Release Notes
|
9
|
+
|
10
|
+
* 0.8.15 - Increased Spam Protection and Akismet spam service support (Check further down in Readme for instructions)
|
11
|
+
|
12
|
+
## Installation/Usage
|
13
|
+
|
14
|
+
1. In your Gemfile add the following
|
15
|
+
|
16
|
+
gem 'spud_core'
|
17
|
+
gem 'spud_blog'
|
18
|
+
|
19
|
+
2. Run bundle install
|
20
|
+
3. Copy in database migrations to your new rails project
|
21
|
+
|
22
|
+
bundle exec rake railties:install:migrations
|
23
|
+
rake db:migrate
|
24
|
+
|
25
|
+
4. run a rails server instance and point your browser to /spud/admin
|
26
|
+
|
27
|
+
## Configuration
|
28
|
+
|
29
|
+
Spud Blog current accepts the following configuration options.
|
30
|
+
|
31
|
+
Spud::Blog.configure do |config|
|
32
|
+
config.base_layout = 'blog'
|
33
|
+
config.blog_enabled = true
|
34
|
+
config.news_enabled = true
|
35
|
+
config.blog_path = 'blog'
|
36
|
+
config.news_path = 'news'
|
37
|
+
config.posts_per_page = 5
|
38
|
+
config.has_custom_fields = true
|
39
|
+
config.caching_enabled = true
|
40
|
+
config.caching_expires_in = 1.hour
|
41
|
+
end
|
42
|
+
|
43
|
+
## Customizing Views
|
44
|
+
|
45
|
+
A number of built-in views have been provided to help you get started with the frontend display. Customzing these views will require you to copy them into your local application, which can be accomplished by using the views generator.
|
46
|
+
|
47
|
+
rails generate spud:blog:views
|
48
|
+
|
49
|
+
__NOTE:__ The built-in views are likely to undergo changes as features are added to the blogging engine. If a new version of Spud Blog does not play nicely with your customized views, try backing up your views to an alternate location and running the views generator again to see what has changed.
|
50
|
+
|
51
|
+
## Javascript Driver
|
52
|
+
|
53
|
+
Spud Blog includes a small, unobtrusive javascript driver that adds functionality to the built-in views. Including the driver is optional, as all client-side views and controllers are designed to work whether you include it or not.
|
54
|
+
|
55
|
+
<%= javascript_include_tag 'spud/blog' %>
|
56
|
+
|
57
|
+
## Custom Fields
|
58
|
+
|
59
|
+
You may find that your blog requires a field that isn't included in the default `spud_post` model. Adding custom fields is easy.
|
60
|
+
|
61
|
+
1. Set `has_custom_fields` to true in your Spud Blog configuration
|
62
|
+
2. Create a migration adding the necessary column(s) to your database
|
63
|
+
|
64
|
+
class AddCaptionToPosts < ActiveRecord::Migration
|
65
|
+
def change
|
66
|
+
add_column :spud_posts, :caption, :string
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
3. Save a view partial at `app/views/spud/admin/posts/_custom_fields.html.erb` with the desired inputs
|
71
|
+
|
72
|
+
|
73
|
+
<div class="control-group">
|
74
|
+
<%= f.label :caption, 'Caption',:class => "control-label" %>
|
75
|
+
<div class="controls">
|
76
|
+
<%= f.text_field :caption %>
|
77
|
+
</div>
|
78
|
+
</div>
|
79
|
+
|
80
|
+
## Extending the Post Model
|
81
|
+
|
82
|
+
Rails engines allow you to extend or even completely override classes by adding them to your local application. Source files found in your local app's path will take precedence over those found within the Spud Blog gem. Lets say you wanted to extend the SpudPost model.
|
83
|
+
|
84
|
+
1. Create a file at `app/models/spud_post.rb`
|
85
|
+
2. Add the following code:
|
86
|
+
|
87
|
+
# Use this helper method to pull in the SpudPost source code from the engine
|
88
|
+
Spud::Blog::Engine.require_model('spud_post')
|
89
|
+
|
90
|
+
# Add your own methods to SpudPost
|
91
|
+
class SpudPost
|
92
|
+
attr_accessible :caption
|
93
|
+
def byline
|
94
|
+
return "'#{self.title}' was posted by #{self.author.full_name} on #{self.display_date}"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
## Akismet Support
|
99
|
+
|
100
|
+
Spud Blog Engine now supports spam comment filtering using akismet. All you have to do is configure the rakismet gem and enable_rakismet in the spud_blog configuration. Add the following to your application.rb file
|
101
|
+
|
102
|
+
Spud::Blog.configure do |config|
|
103
|
+
config.enable_rakismet = true
|
104
|
+
end
|
105
|
+
config.rakismet.key = "your key here"
|
106
|
+
config.rakismet.url = 'http://yourdomain.com/'
|
107
|
+
|
108
|
+
Also make sure to add the rakismet gem to your gemfile
|
109
|
+
|
110
|
+
gem 'rakismet'
|
111
|
+
|
112
|
+
Testing
|
113
|
+
-----------------
|
114
|
+
|
115
|
+
Spud uses RSpec for testing. Get the tests running with a few short commands:
|
116
|
+
|
117
|
+
1. Create and migrate the databases:
|
118
|
+
|
119
|
+
rake db:create
|
120
|
+
rake db:migrate
|
121
|
+
|
122
|
+
2. Load the schema in to the test database:
|
123
|
+
|
124
|
+
rake app:db:test:prepare
|
125
|
+
|
126
|
+
3. Run the tests with RSpec
|
127
|
+
|
128
|
+
rspec spec
|
129
|
+
|
130
|
+
After the tests have completed the current code coverage stats is available by opening ```/coverage/index.html``` in a browser.
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,116 @@
|
|
1
|
+
spud = (typeof(spud) == 'undefined') ? {} : spud;
|
2
|
+
spud.admin = (typeof(spud.admin) == 'undefined') ? {} : spud.admin;
|
3
|
+
|
4
|
+
spud.admin.post_categories = new function(){
|
5
|
+
|
6
|
+
var self = this;
|
7
|
+
var _cachedCategoryIndex;
|
8
|
+
|
9
|
+
this.index = function(){
|
10
|
+
$('body').on('click', '.spud_blog_manage_categories', self.clickedManageCategories);
|
11
|
+
$('body').on('click', '.spud_blog_category_add_new', self.clickedAddNewCategory);
|
12
|
+
$('body').on('click', '.spud_blog_category_edit', self.clickedEditCategory);
|
13
|
+
$('body').on('click', '.spud_blog_manage_categories_back', self.clickedBackButton);
|
14
|
+
$('body').on('click', '.spud_blog_manage_categories_save', self.submittedPostCategoryForm);
|
15
|
+
$('body').on('submit', '.spud_post_category_form', self.submittedPostCategoryForm);
|
16
|
+
$('body').on('click', '.spud_blog_category_delete', self.clickedDeleteCategory);
|
17
|
+
};
|
18
|
+
|
19
|
+
this.clickedManageCategories = function(e){
|
20
|
+
e.preventDefault();
|
21
|
+
$.ajax({
|
22
|
+
url: $(this).attr('href'),
|
23
|
+
success: function(html, textStatus, jqXHR){
|
24
|
+
_cachedCategoryIndex = html;
|
25
|
+
displayModalDialogWithOptions({
|
26
|
+
title: 'Manage Categories',
|
27
|
+
html: html,
|
28
|
+
buttons: {
|
29
|
+
'spud_blog_manage_categories_back': 'Back',
|
30
|
+
'spud_blog_manage_categories_save btn-primary': 'Save'
|
31
|
+
}
|
32
|
+
});
|
33
|
+
}
|
34
|
+
});
|
35
|
+
};
|
36
|
+
|
37
|
+
this.clickedAddNewCategory = function(e){
|
38
|
+
e.preventDefault();
|
39
|
+
$.ajax({
|
40
|
+
url: $(this).attr('href'),
|
41
|
+
dataType: 'html',
|
42
|
+
success: function(html, textStatus, jqXHR){
|
43
|
+
$('.modal-footer button[data-dismiss="modal"]').hide();
|
44
|
+
$('.spud_blog_manage_categories_save, .spud_blog_manage_categories_back').show();
|
45
|
+
$('.spud_blog_category_manager').replaceWith(html);
|
46
|
+
}
|
47
|
+
});
|
48
|
+
};
|
49
|
+
|
50
|
+
this.clickedEditCategory = function(e){
|
51
|
+
e.preventDefault();
|
52
|
+
$.ajax({
|
53
|
+
url: $(this).attr('href'),
|
54
|
+
dataType: 'html',
|
55
|
+
success: function(html, textStatus, jqXHR){
|
56
|
+
$('.modal-footer button[data-dismiss="modal"]').hide();
|
57
|
+
$('.spud_blog_manage_categories_save, .spud_blog_manage_categories_back').show();
|
58
|
+
$('.spud_blog_category_manager').replaceWith(html);
|
59
|
+
}
|
60
|
+
});
|
61
|
+
};
|
62
|
+
|
63
|
+
this.clickedBackButton = function(e){
|
64
|
+
e.preventDefault();
|
65
|
+
$('.spud_post_category_form').replaceWith(_cachedCategoryIndex);
|
66
|
+
$('.modal-footer button[data-dismiss="modal"]').show();
|
67
|
+
$('.spud_blog_manage_categories_save, .spud_blog_manage_categories_back').hide();
|
68
|
+
};
|
69
|
+
|
70
|
+
this.clickedDeleteCategory = function(e){
|
71
|
+
e.preventDefault();
|
72
|
+
if(window.confirm('Are you sure you want to delete this category?')){
|
73
|
+
$.ajax({
|
74
|
+
url: $(this).attr('href'),
|
75
|
+
data: {_method: 'delete'},
|
76
|
+
type: 'delete',
|
77
|
+
dataType: 'html',
|
78
|
+
success: function(html, textStatus, jqXHR){
|
79
|
+
_cachedCategoryIndex = html;
|
80
|
+
$('.spud_blog_category_manager').replaceWith(html);
|
81
|
+
}
|
82
|
+
});
|
83
|
+
}
|
84
|
+
};
|
85
|
+
|
86
|
+
this.submittedPostCategoryForm = function(e){
|
87
|
+
e.preventDefault();
|
88
|
+
var form = $('.spud_post_category_form');
|
89
|
+
$.ajax({
|
90
|
+
url: form.attr('action'),
|
91
|
+
data: form.serialize(),
|
92
|
+
type: 'post',
|
93
|
+
dataType: 'html',
|
94
|
+
success: self.savedPostCategorySuccess,
|
95
|
+
error: self.savePostCategoryError
|
96
|
+
});
|
97
|
+
};
|
98
|
+
|
99
|
+
this.savedPostCategorySuccess = function(html, textStatus, jqXHR){
|
100
|
+
_cachedCategoryIndex = html;
|
101
|
+
$('.spud_blog_manage_categories_save, .spud_blog_manage_categories_back').hide();
|
102
|
+
$('.spud_post_category_form').replaceWith(html);
|
103
|
+
};
|
104
|
+
|
105
|
+
this.savePostCategoryError = function(jqXHR, textStatus, errorThrown){
|
106
|
+
if(jqXHR.status == 422){
|
107
|
+
var html = jqXHR.responseText;
|
108
|
+
$('.spud_post_category_form').replaceWith(html);
|
109
|
+
}
|
110
|
+
else{
|
111
|
+
if(window.console){
|
112
|
+
console.error('Oh Snap:', arguments);
|
113
|
+
}
|
114
|
+
}
|
115
|
+
};
|
116
|
+
};
|
@@ -0,0 +1,71 @@
|
|
1
|
+
//= require spud/admin/post_categories
|
2
|
+
|
3
|
+
spud = (typeof(spud) == 'undefined') ? {} : spud;
|
4
|
+
spud.admin = (typeof(spud.admin) == 'undefined') ? {} : spud.admin;
|
5
|
+
|
6
|
+
spud.admin.posts = new function(){
|
7
|
+
|
8
|
+
var self = this;
|
9
|
+
|
10
|
+
this.edit = function(){
|
11
|
+
initDatePicker();
|
12
|
+
|
13
|
+
$('body').on('click', '.spud_post_add_category', self.clickedPostAddCategory);
|
14
|
+
$('body').on('click', '.save_post_category_button', self.submittedPostCategoryForm);
|
15
|
+
$('body').on('submit', '.spud_post_category_form', self.submittedPostCategoryForm);
|
16
|
+
};
|
17
|
+
|
18
|
+
this.clickedPostAddCategory = function(e){
|
19
|
+
e.preventDefault();
|
20
|
+
$.ajax({
|
21
|
+
url: $(this).attr('href'),
|
22
|
+
dataType: 'html',
|
23
|
+
success: function(html, textStatus, jqXHR){
|
24
|
+
displayModalDialogWithOptions({
|
25
|
+
title: 'Add Category',
|
26
|
+
html: html
|
27
|
+
});
|
28
|
+
}
|
29
|
+
});
|
30
|
+
};
|
31
|
+
|
32
|
+
this.submittedPostCategoryForm = function(e){
|
33
|
+
e.preventDefault();
|
34
|
+
var form = $('.spud_post_category_form');
|
35
|
+
$.ajax({
|
36
|
+
url: form.attr('action'),
|
37
|
+
data: form.serialize(),
|
38
|
+
type: 'post',
|
39
|
+
dataType: 'json',
|
40
|
+
success: self.savedPostCategorySuccess,
|
41
|
+
error: self.savePostCategoryError
|
42
|
+
});
|
43
|
+
};
|
44
|
+
|
45
|
+
this.savedPostCategorySuccess = function(data, textStatus, jqXHR){
|
46
|
+
var checkbox = '';
|
47
|
+
checkbox += '<li class="spud_post_form_category" data-id="'+data.id+'">';
|
48
|
+
checkbox += '<input id="spud_post_category_'+data.id+'" name="spud_post[category_ids][]" type="checkbox" value="'+data.id+'" checked>' + "\n";
|
49
|
+
checkbox += '<label for="spud_post_category_'+data.id+'">'+data.name+'</label>';
|
50
|
+
checkbox += '<ul></ul></li>';
|
51
|
+
if(data.parent_id > 0){
|
52
|
+
$('.spud_post_form_category[data-id="'+data.parent_id+'"]>ul').append(checkbox);
|
53
|
+
}
|
54
|
+
else{
|
55
|
+
$('.spud_post_categories_form').append(checkbox);
|
56
|
+
}
|
57
|
+
hideModalDialog();
|
58
|
+
};
|
59
|
+
|
60
|
+
this.savePostCategoryError = function(jqXHR, textStatus, errorThrown){
|
61
|
+
if(jqXHR.status == 422){
|
62
|
+
var html = jqXHR.responseText;
|
63
|
+
$('.spud_post_category_form').replaceWith(html);
|
64
|
+
}
|
65
|
+
else{
|
66
|
+
if(window.console){
|
67
|
+
console.error('Oh Snap:', arguments);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
};
|
71
|
+
};
|
@@ -0,0 +1,41 @@
|
|
1
|
+
spud = (typeof(spud) == 'undefined') ? {} : spud;
|
2
|
+
|
3
|
+
spud.blog = new function(){
|
4
|
+
|
5
|
+
var self = this;
|
6
|
+
|
7
|
+
this.init = function(){
|
8
|
+
$('body').on('submit', '.spud_blog_filter_form', self.didSubmitFilterForm);
|
9
|
+
};
|
10
|
+
|
11
|
+
this.didSubmitFilterForm = function(event){
|
12
|
+
event.preventDefault();
|
13
|
+
var form = $(this);
|
14
|
+
var base = form.attr('action');
|
15
|
+
var url = '';
|
16
|
+
|
17
|
+
// find filter values
|
18
|
+
var category_select = $(this).find('select[rel=category]');
|
19
|
+
if(category_select){
|
20
|
+
var category = category_select.val();
|
21
|
+
}
|
22
|
+
var archive_select = $(this).find('select[rel=archive]');
|
23
|
+
if(archive_select){
|
24
|
+
var archive = archive_select.val();
|
25
|
+
}
|
26
|
+
|
27
|
+
// build url and redirect
|
28
|
+
if(category && archive){
|
29
|
+
url = '/category/' + category + '/' + archive;
|
30
|
+
}
|
31
|
+
else if(category){
|
32
|
+
url = '/category/' + category;
|
33
|
+
}
|
34
|
+
else if(archive){
|
35
|
+
url = '/archive/' + archive;
|
36
|
+
}
|
37
|
+
window.location = base + url;
|
38
|
+
};
|
39
|
+
};
|
40
|
+
|
41
|
+
$(document).ready(spud.blog.init);
|
@@ -0,0 +1,113 @@
|
|
1
|
+
/* Form Layout
|
2
|
+
---------------- */
|
3
|
+
.spud_post_form_fieldset{
|
4
|
+
margin: 30px 0;
|
5
|
+
}
|
6
|
+
.spud_post_form_col{
|
7
|
+
width: 400px;
|
8
|
+
float: left;
|
9
|
+
margin: 0 20px;
|
10
|
+
}
|
11
|
+
.spud_post_form_input_group{
|
12
|
+
border: 1px dashed #E5E5E5;
|
13
|
+
padding: 4px;
|
14
|
+
margin: 0 0 10px;
|
15
|
+
}
|
16
|
+
.spud_post_form_input_group input{
|
17
|
+
display: inline-block;
|
18
|
+
}
|
19
|
+
.spud_post_form_input_group select{
|
20
|
+
margin-bottom: 20px;
|
21
|
+
}
|
22
|
+
.spud_post_form_input_group label{
|
23
|
+
margin: 0 10px 0 0;
|
24
|
+
padding: 0;
|
25
|
+
}
|
26
|
+
.spud_post_form_row{
|
27
|
+
margin: 5px 0;
|
28
|
+
}
|
29
|
+
.spud_post_form_help_block{
|
30
|
+
font-size: 12px;
|
31
|
+
font-style: italic;
|
32
|
+
margin: 0 0 20px;
|
33
|
+
display: block;
|
34
|
+
}
|
35
|
+
#spud_post_meta_keywords, #spud_post_meta_description{
|
36
|
+
width: 380px;
|
37
|
+
}
|
38
|
+
#spud_post_meta_description{
|
39
|
+
height: 100px;
|
40
|
+
}
|
41
|
+
|
42
|
+
/* Categories
|
43
|
+
-------------- */
|
44
|
+
.spud_post_categories_form{
|
45
|
+
white-space: nowrap;
|
46
|
+
list-style-type: none;
|
47
|
+
margin: 15px 0;
|
48
|
+
max-height: 400px;
|
49
|
+
min-height: 200px;
|
50
|
+
background: white;
|
51
|
+
border: 1px solid #E5E5E5;
|
52
|
+
padding: 10px 0 10px 15px;
|
53
|
+
overflow: auto;
|
54
|
+
border-radius: 5px;
|
55
|
+
}
|
56
|
+
.spud_post_categories_form ul{
|
57
|
+
list-style-type: none;
|
58
|
+
margin: 0;
|
59
|
+
padding: 0 0 0 15px;
|
60
|
+
}
|
61
|
+
.spud_post_categories_form input{
|
62
|
+
display: inline-block;
|
63
|
+
margin: 0;
|
64
|
+
}
|
65
|
+
.spud_post_categories_form label{
|
66
|
+
display: inline;
|
67
|
+
}
|
68
|
+
.spud_post_form_category{
|
69
|
+
margin: 4px 0;
|
70
|
+
}
|
71
|
+
|
72
|
+
/* Category Manager
|
73
|
+
------------------- */
|
74
|
+
.spud_blog_category_add_new{
|
75
|
+
float: right;
|
76
|
+
}
|
77
|
+
.spud_blog_category_manager{
|
78
|
+
padding-right: 10px;
|
79
|
+
}
|
80
|
+
.spud_blog_category_manager ul{
|
81
|
+
|
82
|
+
}
|
83
|
+
.spud_blog_category_manager_list{
|
84
|
+
clear: right;
|
85
|
+
padding: 0 0 0 20px;
|
86
|
+
margin: 10px 0;
|
87
|
+
min-height: 100px;
|
88
|
+
max-height: 350px;
|
89
|
+
overflow: auto;
|
90
|
+
}
|
91
|
+
.spud_blog_category_manager_item{
|
92
|
+
position: relative;
|
93
|
+
margin: 10px 0;
|
94
|
+
/*border: 1px solid #E5E5E5;*/
|
95
|
+
}
|
96
|
+
.spud_blog_category_manager_item_children{
|
97
|
+
margin: 0;
|
98
|
+
padding: 0 0 0 15px;
|
99
|
+
}
|
100
|
+
.spud_blog_category_manager_item_actions{
|
101
|
+
position: absolute;
|
102
|
+
right: 0;
|
103
|
+
margin: 0 0 0 10px;
|
104
|
+
}
|
105
|
+
.spud_blog_manage_categories_save, .spud_blog_manage_categories_back{
|
106
|
+
display: none;
|
107
|
+
}
|
108
|
+
|
109
|
+
/*Comment Manager*/
|
110
|
+
.submitted-on {
|
111
|
+
display:block;
|
112
|
+
color:#555;
|
113
|
+
}
|