Compare commits
36 commits
master
...
1-x-stable
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0d9394dacd | ||
![]() |
2d4e9085eb | ||
![]() |
0f4d976f34 | ||
![]() |
dda07a7fab | ||
![]() |
e26d53bee4 | ||
![]() |
a0ec115272 | ||
![]() |
31bb972db9 | ||
![]() |
09d919d1b7 | ||
![]() |
6884642093 | ||
![]() |
58b87c9e1a | ||
![]() |
01a10f5266 | ||
![]() |
7ad876b8a5 | ||
![]() |
d3a914261a | ||
![]() |
6a5afeaa19 | ||
![]() |
2bff0b207f | ||
![]() |
5efcadcc80 | ||
![]() |
5c78c38e98 | ||
![]() |
57619d6993 | ||
![]() |
9840c56b40 | ||
![]() |
7d8588dfd2 | ||
![]() |
f3d32c1ac5 | ||
![]() |
8ca270774f | ||
![]() |
2ed293f74a | ||
![]() |
5ab4ef464b | ||
![]() |
92ed22cce2 | ||
![]() |
22f398c724 | ||
![]() |
b1d05554d6 | ||
![]() |
8b4be5638b | ||
![]() |
d9387e32c3 | ||
![]() |
81bf46cd7a | ||
![]() |
62c525e424 | ||
![]() |
eb160aa354 | ||
![]() |
d5fadb4523 | ||
![]() |
c761572593 | ||
![]() |
329d54bdf0 | ||
![]() |
49404806ab |
219 changed files with 4101 additions and 4936 deletions
10
.gitignore
vendored
10
.gitignore
vendored
|
@ -14,7 +14,6 @@ doc/*
|
|||
*.autobackupbyrefinery.*
|
||||
/refinerycms-blog*.gem
|
||||
.autotest
|
||||
spec/dummy
|
||||
|
||||
# Mac
|
||||
.DS_Store
|
||||
|
@ -44,11 +43,6 @@ nbproject
|
|||
# Capybara Bug
|
||||
capybara-*html
|
||||
|
||||
# rvm
|
||||
.rvmrc
|
||||
|
||||
#rbenv
|
||||
.rbenv-version
|
||||
|
||||
# Future stuff
|
||||
Gemfile.lock
|
||||
.rbx
|
||||
spec/dummy
|
1
.rspec
1
.rspec
|
@ -1 +0,0 @@
|
|||
--colour
|
23
.travis.yml
23
.travis.yml
|
@ -1,20 +1,5 @@
|
|||
before_script:
|
||||
- "bundle exec rake refinery:testing:dummy_app > /dev/null"
|
||||
script: "bundle exec rake spec"
|
||||
notifications:
|
||||
email:
|
||||
- parndt@gmail.com
|
||||
- ugis.ozolss@gmail.com
|
||||
- joe@joesak.com
|
||||
- jamie@enmasse.com
|
||||
env:
|
||||
- DB=postgresql
|
||||
- DB=mysql
|
||||
matrix:
|
||||
allow_failures:
|
||||
- rvm: rbx-19mode
|
||||
rvm:
|
||||
- 1.8.7
|
||||
- 1.9.3
|
||||
- rbx-19mode
|
||||
- jruby
|
||||
- 1.9.2
|
||||
branches:
|
||||
only:
|
||||
- rails-3-1
|
73
Gemfile
73
Gemfile
|
@ -1,70 +1,7 @@
|
|||
source "http://rubygems.org"
|
||||
|
||||
gemspec
|
||||
|
||||
gem 'refinerycms', :git => 'git://github.com/resolve/refinerycms.git'
|
||||
gem 'refinerycms-i18n', :git => 'git://github.com/parndt/refinerycms-i18n.git'
|
||||
gem 'refinerycms-settings', :git => 'git://github.com/parndt/refinerycms-settings.git'
|
||||
source 'http://rubygems.org'
|
||||
|
||||
group :development, :test do
|
||||
require 'rbconfig'
|
||||
|
||||
gem 'refinerycms-testing', :git => 'git://github.com/resolve/refinerycms.git'
|
||||
|
||||
platforms :jruby do
|
||||
gem 'activerecord-jdbcsqlite3-adapter'
|
||||
gem 'activerecord-jdbcmysql-adapter'
|
||||
gem 'activerecord-jdbcpostgresql-adapter'
|
||||
gem 'jruby-openssl'
|
||||
end
|
||||
|
||||
unless defined?(JRUBY_VERSION)
|
||||
gem 'sqlite3'
|
||||
gem 'mysql2'
|
||||
gem 'pg'
|
||||
end
|
||||
|
||||
platforms :mswin, :mingw do
|
||||
gem 'win32console'
|
||||
gem 'rb-fchange', '~> 0.0.5'
|
||||
gem 'rb-notifu', '~> 0.0.4'
|
||||
end
|
||||
|
||||
platforms :ruby do
|
||||
gem 'spork', '0.9.0.rc9'
|
||||
gem 'guard-spork'
|
||||
|
||||
unless ENV['TRAVIS']
|
||||
if RbConfig::CONFIG['target_os'] =~ /darwin/i
|
||||
gem 'rb-fsevent', '>= 0.3.9'
|
||||
gem 'growl', '~> 1.0.3'
|
||||
end
|
||||
if RbConfig::CONFIG['target_os'] =~ /linux/i
|
||||
gem 'rb-inotify', '>= 0.5.1'
|
||||
gem 'libnotify', '~> 0.1.3'
|
||||
gem 'therubyracer', '~> 0.9.9'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
platforms :jruby do
|
||||
unless ENV['TRAVIS']
|
||||
if RbConfig::CONFIG['target_os'] =~ /darwin/i
|
||||
gem 'growl', '~> 1.0.3'
|
||||
end
|
||||
if RbConfig::CONFIG['target_os'] =~ /linux/i
|
||||
gem 'rb-inotify', '>= 0.5.1'
|
||||
gem 'libnotify', '~> 0.1.3'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Refinery/rails should pull in the proper versions of these
|
||||
group :assets do
|
||||
gem 'sass-rails'
|
||||
gem 'coffee-rails'
|
||||
gem 'uglifier'
|
||||
end
|
||||
|
||||
gem 'jquery-rails'
|
||||
gem 'sqlite3'
|
||||
gem 'mysql2'
|
||||
gem 'pg'
|
||||
end
|
20
Guardfile
20
Guardfile
|
@ -1,20 +0,0 @@
|
|||
guard 'rspec', :version => 2, :cli => "--format Fuubar --color --drb" do
|
||||
watch(%r{^spec/.+_spec\.rb$})
|
||||
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
||||
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
||||
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/controllers/#{m[1]}_#{m[2]}_spec.rb", "spec/requests/#{m[1]}_spec.rb"] }
|
||||
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
||||
watch('spec/spec_helper.rb') { "spec" }
|
||||
watch('config/routes.rb') { "spec/routing" }
|
||||
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
||||
# Capybara request specs
|
||||
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
|
||||
end
|
||||
|
||||
guard 'spork', :wait => 60, :cucumber => false, :rspec_env => { 'RAILS_ENV' => 'test' } do
|
||||
watch('config/application.rb')
|
||||
watch('config/environment.rb')
|
||||
watch(%r{^config/environments/.+\.rb$})
|
||||
watch(%r{^config/initializers/.+\.rb$})
|
||||
watch('spec/spec_helper.rb')
|
||||
end
|
19
Rakefile
19
Rakefile
|
@ -1,19 +0,0 @@
|
|||
#!/usr/bin/env rake
|
||||
begin
|
||||
require 'bundler/setup'
|
||||
rescue LoadError
|
||||
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
||||
end
|
||||
|
||||
ENGINE_PATH = File.dirname(__FILE__)
|
||||
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
||||
|
||||
if File.exists?(APP_RAKEFILE)
|
||||
load 'rails/tasks/engine.rake'
|
||||
end
|
||||
|
||||
require "refinerycms-testing"
|
||||
Refinery::Testing::Railtie.load_tasks
|
||||
Refinery::Testing::Railtie.load_dummy_tasks(ENGINE_PATH)
|
||||
|
||||
load File.expand_path('../tasks/rspec.rake', __FILE__)
|
|
@ -1,73 +0,0 @@
|
|||
.comments_icon {
|
||||
background-image: image_url('refinery/blog/icons/comments.png');
|
||||
}
|
||||
.comment_icon {
|
||||
background-image: image_url('refinery/blog/icons/comment.png');
|
||||
}
|
||||
.comment_cross_icon {
|
||||
background-image: image_url('refinery/blog/icons/comment_cross.png');
|
||||
}
|
||||
.comment_tick_icon {
|
||||
background-image: image_url('refinery/blog/icons/comment_tick.png');
|
||||
}
|
||||
.folder_icon {
|
||||
background-image: image_url('refinery/blog/icons/folder.png');
|
||||
}
|
||||
.folder_add_icon {
|
||||
background-image: image_url('refinery/blog/icons/folder_add.png');
|
||||
}
|
||||
.folder_edit_icon {
|
||||
background-image: image_url('refinery/blog/icons/folder_edit.png');
|
||||
}
|
||||
.settings_icon {
|
||||
background-image: image_url('refinery/blog/icons/cog.png');
|
||||
}
|
||||
.page_icon {
|
||||
background-image: image_url('refinery/blog/icons/page.png');
|
||||
}
|
||||
.page_copy_icon {
|
||||
background-image: image_url('refinery/blog/icons/page_copy.png');
|
||||
}
|
||||
.page_add_icon {
|
||||
background-image: image_url('refinery/blog/icons/page_add.png');
|
||||
}
|
||||
ul.collapsible_menu li {
|
||||
position: relative;
|
||||
}
|
||||
ul.collapsible_menu li span.arrow {
|
||||
background-repeat: no-repeat;
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 13px;
|
||||
width: 11px;
|
||||
height: 7px;
|
||||
cursor: pointer;
|
||||
}
|
||||
ul.collapsible_menu li span.arrow {
|
||||
background-image: image_url('refinery/blog/icons/up.gif');
|
||||
}
|
||||
ul.collapsible_menu li.closed span.arrow {
|
||||
background-image: image_url('refinery/blog/icons/down.gif');
|
||||
}
|
||||
ul.collapsible_menu > div {
|
||||
width: 93%;
|
||||
margin: 0px auto;
|
||||
}
|
||||
ul.blog_categories{
|
||||
height:200px;
|
||||
overflow:auto;
|
||||
border:1px solid #ccc;
|
||||
padding:5px;
|
||||
}
|
||||
ul.blog_categories, ul.blog_categories li {
|
||||
list-style: none;
|
||||
margin:5px 0;
|
||||
}
|
||||
a#copy_body_link {
|
||||
background: image_url('refinery/blog/icons/add.png') no-repeat scroll 0 6px transparent;
|
||||
border-bottom: 0 none;
|
||||
display: inline;
|
||||
line-height: 29px;
|
||||
margin-top: 0;
|
||||
padding-left: 20px;
|
||||
}
|
11
app/controllers/admin/blog/categories_controller.rb
Normal file
11
app/controllers/admin/blog/categories_controller.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
module Admin
|
||||
module Blog
|
||||
class CategoriesController < Admin::BaseController
|
||||
|
||||
crudify :blog_category,
|
||||
:title_attribute => :title,
|
||||
:order => 'title ASC'
|
||||
|
||||
end
|
||||
end
|
||||
end
|
40
app/controllers/admin/blog/comments_controller.rb
Normal file
40
app/controllers/admin/blog/comments_controller.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
module Admin
|
||||
module Blog
|
||||
class CommentsController < Admin::BaseController
|
||||
|
||||
crudify :blog_comment,
|
||||
:title_attribute => :name,
|
||||
:order => 'published_at DESC'
|
||||
|
||||
def index
|
||||
@blog_comments = BlogComment.unmoderated
|
||||
render :action => 'index'
|
||||
end
|
||||
|
||||
def approved
|
||||
unless params[:id].present?
|
||||
@blog_comments = BlogComment.approved
|
||||
render :action => 'index'
|
||||
else
|
||||
@blog_comment = BlogComment.find(params[:id])
|
||||
@blog_comment.approve!
|
||||
flash[:notice] = t('approved', :scope => 'admin.blog.comments', :author => @blog_comment.name)
|
||||
redirect_to :action => params[:return_to] || 'index'
|
||||
end
|
||||
end
|
||||
|
||||
def rejected
|
||||
unless params[:id].present?
|
||||
@blog_comments = BlogComment.rejected
|
||||
render :action => 'index'
|
||||
else
|
||||
@blog_comment = BlogComment.find(params[:id])
|
||||
@blog_comment.reject!
|
||||
flash[:notice] = t('rejected', :scope => 'admin.blog.comments', :author => @blog_comment.name)
|
||||
redirect_to :action => params[:return_to] || 'index'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
97
app/controllers/admin/blog/posts_controller.rb
Normal file
97
app/controllers/admin/blog/posts_controller.rb
Normal file
|
@ -0,0 +1,97 @@
|
|||
module Admin
|
||||
module Blog
|
||||
class PostsController < Admin::BaseController
|
||||
require 'will_paginate/array'
|
||||
|
||||
crudify :blog_post,
|
||||
:title_attribute => :title,
|
||||
:order => 'published_at DESC'
|
||||
|
||||
def uncategorized
|
||||
@blog_posts = BlogPost.uncategorized.paginate({
|
||||
:page => params[:page],
|
||||
:per_page => BlogPost.per_page
|
||||
})
|
||||
end
|
||||
|
||||
def tags
|
||||
op = case ActiveRecord::Base.connection.adapter_name.downcase
|
||||
when 'postgresql'
|
||||
'~*'
|
||||
else
|
||||
'LIKE'
|
||||
end
|
||||
wildcard = case ActiveRecord::Base.connection.adapter_name.downcase
|
||||
when 'postgresql'
|
||||
'.*'
|
||||
else
|
||||
'%'
|
||||
end
|
||||
@tags = BlogPost.tag_counts_on(:tags).where(
|
||||
["tags.name #{op} ?", "#{wildcard}#{params[:term].to_s.downcase}#{wildcard}"]
|
||||
).map { |tag| {:id => tag.id, :value => tag.name}}
|
||||
render :json => @tags.flatten
|
||||
end
|
||||
|
||||
def create
|
||||
# if the position field exists, set this object as last object, given the conditions of this class.
|
||||
if BlogPost.column_names.include?("position")
|
||||
params[:blog_post].merge!({
|
||||
:position => ((BlogPost.maximum(:position, :conditions => "")||-1) + 1)
|
||||
})
|
||||
end
|
||||
|
||||
if BlogPost.column_names.include?("user_id")
|
||||
params[:blog_post].merge!({
|
||||
:user_id => current_user.id
|
||||
})
|
||||
end
|
||||
|
||||
if (@blog_post = BlogPost.create(params[:blog_post])).valid?
|
||||
(request.xhr? ? flash.now : flash).notice = t(
|
||||
'refinery.crudify.created',
|
||||
:what => "'#{@blog_post.title}'"
|
||||
)
|
||||
|
||||
unless from_dialog?
|
||||
unless params[:continue_editing] =~ /true|on|1/
|
||||
redirect_back_or_default(admin_blog_posts_url)
|
||||
else
|
||||
unless request.xhr?
|
||||
redirect_to :back
|
||||
else
|
||||
render :partial => "/shared/message"
|
||||
end
|
||||
end
|
||||
else
|
||||
render :text => "<script>parent.window.location = '#{admin_blog_posts_url}';</script>"
|
||||
end
|
||||
else
|
||||
unless request.xhr?
|
||||
render :action => 'new'
|
||||
else
|
||||
render :partial => "/shared/admin/error_messages",
|
||||
:locals => {
|
||||
:object => @blog_post,
|
||||
:include_object_name => true
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
before_filter :find_all_categories,
|
||||
:only => [:new, :edit, :create, :update]
|
||||
|
||||
before_filter :check_category_ids, :only => :update
|
||||
|
||||
protected
|
||||
def find_all_categories
|
||||
@blog_categories = BlogCategory.find(:all)
|
||||
end
|
||||
|
||||
def check_category_ids
|
||||
params[:blog_post][:category_ids] ||= []
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
53
app/controllers/admin/blog/settings_controller.rb
Normal file
53
app/controllers/admin/blog/settings_controller.rb
Normal file
|
@ -0,0 +1,53 @@
|
|||
module Admin
|
||||
module Blog
|
||||
class SettingsController < Admin::BaseController
|
||||
|
||||
def notification_recipients
|
||||
@recipients = BlogComment::Notification.recipients
|
||||
|
||||
if request.post?
|
||||
BlogComment::Notification.recipients = params[:recipients]
|
||||
flash[:notice] = t('updated', :scope => 'admin.blog.settings.notification_recipients',
|
||||
:recipients => BlogComment::Notification.recipients)
|
||||
unless request.xhr? or from_dialog?
|
||||
redirect_back_or_default(admin_blog_posts_path)
|
||||
else
|
||||
render :text => "<script type='text/javascript'>parent.window.location = '#{admin_blog_posts_path}';</script>",
|
||||
:layout => false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def moderation
|
||||
enabled = BlogComment::Moderation.toggle!
|
||||
unless request.xhr?
|
||||
redirect_back_or_default(admin_blog_posts_path)
|
||||
else
|
||||
render :json => {:enabled => enabled},
|
||||
:layout => false
|
||||
end
|
||||
end
|
||||
|
||||
def comments
|
||||
enabled = BlogComment.toggle!
|
||||
unless request.xhr?
|
||||
redirect_back_or_default(admin_blog_posts_path)
|
||||
else
|
||||
render :json => {:enabled => enabled},
|
||||
:layout => false
|
||||
end
|
||||
end
|
||||
|
||||
def teasers
|
||||
enabled = BlogPost.teaser_enabled_toggle!
|
||||
unless request.xhr?
|
||||
redirect_back_or_default(admin_blog_posts_path)
|
||||
else
|
||||
render :json => {:enabled => enabled},
|
||||
:layout => false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
13
app/controllers/blog/categories_controller.rb
Normal file
13
app/controllers/blog/categories_controller.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
module Blog
|
||||
class CategoriesController < BlogController
|
||||
|
||||
def show
|
||||
@category = BlogCategory.find(params[:id])
|
||||
@blog_posts = @category.posts.live.includes(:comments, :categories).paginate({
|
||||
:page => params[:page],
|
||||
:per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
109
app/controllers/blog/posts_controller.rb
Normal file
109
app/controllers/blog/posts_controller.rb
Normal file
|
@ -0,0 +1,109 @@
|
|||
module Blog
|
||||
class PostsController < BlogController
|
||||
|
||||
before_filter :find_all_blog_posts, :except => [:archive]
|
||||
before_filter :find_blog_post, :only => [:show, :comment, :update_nav]
|
||||
before_filter :find_tags
|
||||
|
||||
respond_to :html, :js, :rss
|
||||
|
||||
def index
|
||||
# Rss feeders are greedy. Let's give them every blog post instead of paginating.
|
||||
(@blog_posts = BlogPost.live.includes(:comments, :categories).all) if request.format.rss?
|
||||
respond_with (@blog_posts) do |format|
|
||||
format.html
|
||||
format.rss
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@blog_comment = BlogComment.new
|
||||
@canonical = url_for(:locale => ::Refinery::I18n.default_frontend_locale) if canonical?
|
||||
|
||||
respond_with (@blog_post) do |format|
|
||||
format.html { present(@blog_post) }
|
||||
format.js { render :partial => 'post', :layout => false }
|
||||
end
|
||||
end
|
||||
|
||||
def comment
|
||||
if (@blog_comment = @blog_post.comments.create(params[:blog_comment])).valid?
|
||||
if BlogComment::Moderation.enabled? or @blog_comment.ham?
|
||||
begin
|
||||
Blog::CommentMailer.notification(@blog_comment, request).deliver
|
||||
rescue
|
||||
logger.warn "There was an error delivering a blog comment notification.\n#{$!}\n"
|
||||
end
|
||||
end
|
||||
|
||||
if BlogComment::Moderation.enabled?
|
||||
flash[:notice] = t('thank_you_moderated', :scope => 'blog.posts.comments')
|
||||
redirect_to blog_post_url(params[:id])
|
||||
else
|
||||
flash[:notice] = t('thank_you', :scope => 'blog.posts.comments')
|
||||
redirect_to blog_post_url(params[:id],
|
||||
:anchor => "comment-#{@blog_comment.to_param}")
|
||||
end
|
||||
else
|
||||
render :action => 'show'
|
||||
end
|
||||
end
|
||||
|
||||
def archive
|
||||
if params[:month].present?
|
||||
date = "#{params[:month]}/#{params[:year]}"
|
||||
@archive_date = Time.parse(date)
|
||||
@date_title = @archive_date.strftime('%B %Y')
|
||||
@blog_posts = BlogPost.live.by_archive(@archive_date).paginate({
|
||||
:page => params[:page],
|
||||
:per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
|
||||
})
|
||||
else
|
||||
date = "01/#{params[:year]}"
|
||||
@archive_date = Time.parse(date)
|
||||
@date_title = @archive_date.strftime('%Y')
|
||||
@blog_posts = BlogPost.live.by_year(@archive_date).paginate({
|
||||
:page => params[:page],
|
||||
:per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
|
||||
})
|
||||
end
|
||||
respond_with (@blog_posts)
|
||||
end
|
||||
|
||||
def tagged
|
||||
@tag = ActsAsTaggableOn::Tag.find(params[:tag_id])
|
||||
@tag_name = @tag.name
|
||||
@blog_posts = BlogPost.tagged_with(@tag_name).paginate({
|
||||
:page => params[:page],
|
||||
:per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
|
||||
})
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def find_blog_post
|
||||
unless (@blog_post = BlogPost.find(params[:id])).try(:live?)
|
||||
if refinery_user? and current_user.authorized_plugins.include?("refinerycms_blog")
|
||||
@blog_post = BlogPost.find(params[:id])
|
||||
else
|
||||
error_404
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def find_all_blog_posts
|
||||
@blog_posts = BlogPost.live.includes(:comments, :categories).paginate({
|
||||
:page => params[:page],
|
||||
:per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
|
||||
})
|
||||
end
|
||||
|
||||
def find_tags
|
||||
@tags = BlogPost.tag_counts_on(:tags)
|
||||
end
|
||||
|
||||
def canonical?
|
||||
::Refinery.i18n_enabled? && ::Refinery::I18n.default_frontend_locale != ::Refinery::I18n.current_frontend_locale
|
||||
end
|
||||
end
|
||||
end
|
16
app/controllers/blog_controller.rb
Normal file
16
app/controllers/blog_controller.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
class BlogController < ApplicationController
|
||||
|
||||
helper :blog_posts
|
||||
before_filter :find_page, :find_all_blog_categories
|
||||
|
||||
protected
|
||||
|
||||
def find_page
|
||||
@page = Page.find_by_link_url("/blog")
|
||||
end
|
||||
|
||||
def find_all_blog_categories
|
||||
@blog_categories = BlogCategory.all
|
||||
end
|
||||
|
||||
end
|
|
@ -1,12 +0,0 @@
|
|||
module Refinery
|
||||
module Blog
|
||||
module Admin
|
||||
class CategoriesController < ::Refinery::AdminController
|
||||
|
||||
crudify :'refinery/blog/category',
|
||||
:order => 'title ASC'
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,49 +0,0 @@
|
|||
module Refinery
|
||||
module Blog
|
||||
module Admin
|
||||
class CommentsController < ::Refinery::AdminController
|
||||
|
||||
cache_sweeper Refinery::BlogSweeper
|
||||
|
||||
crudify :'refinery/blog/comment',
|
||||
:title_attribute => :name,
|
||||
:order => 'published_at DESC'
|
||||
|
||||
def index
|
||||
@comments = Refinery::Blog::Comment.unmoderated.page(params[:page])
|
||||
|
||||
render :action => 'index'
|
||||
end
|
||||
|
||||
def approved
|
||||
unless params[:id].present?
|
||||
@comments = Refinery::Blog::Comment.approved.page(params[:page])
|
||||
|
||||
render :action => 'index'
|
||||
else
|
||||
@comment = Refinery::Blog::Comment.find(params[:id])
|
||||
@comment.approve!
|
||||
flash[:notice] = t('approved', :scope => 'refinery.blog.admin.comments', :author => @comment.name)
|
||||
|
||||
redirect_to refinery.url_for(:action => params[:return_to] || 'index', :id => nil)
|
||||
end
|
||||
end
|
||||
|
||||
def rejected
|
||||
unless params[:id].present?
|
||||
@comments = Refinery::Blog::Comment.rejected.page(params[:page])
|
||||
|
||||
render :action => 'index'
|
||||
else
|
||||
@comment = Refinery::Blog::Comment.find(params[:id])
|
||||
@comment.reject!
|
||||
flash[:notice] = t('rejected', :scope => 'refinery.blog.admin.comments', :author => @comment.name)
|
||||
|
||||
redirect_to refinery.url_for(:action => params[:return_to] || 'index', :id => nil)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,90 +0,0 @@
|
|||
module Refinery
|
||||
module Blog
|
||||
module Admin
|
||||
class PostsController < ::Refinery::AdminController
|
||||
|
||||
cache_sweeper Refinery::BlogSweeper
|
||||
|
||||
crudify :'refinery/blog/post',
|
||||
:order => 'published_at DESC'
|
||||
|
||||
before_filter :find_all_categories,
|
||||
:only => [:new, :edit, :create, :update]
|
||||
|
||||
before_filter :check_category_ids, :only => :update
|
||||
|
||||
def uncategorized
|
||||
@posts = Refinery::Blog::Post.uncategorized.page(params[:page])
|
||||
end
|
||||
|
||||
def tags
|
||||
if ActiveRecord::Base.connection.adapter_name.downcase == 'postgresql'
|
||||
op = '~*'
|
||||
wildcard = '.*'
|
||||
else
|
||||
op = 'LIKE'
|
||||
wildcard = '%'
|
||||
end
|
||||
|
||||
@tags = Refinery::Blog::Post.tag_counts_on(:tags).where(
|
||||
["tags.name #{op} ?", "#{wildcard}#{params[:term].to_s.downcase}#{wildcard}"]
|
||||
).map { |tag| {:id => tag.id, :value => tag.name}}
|
||||
render :json => @tags.flatten
|
||||
end
|
||||
|
||||
def new
|
||||
@post = ::Refinery::Blog::Post.new(:author => current_refinery_user)
|
||||
end
|
||||
|
||||
def create
|
||||
# if the position field exists, set this object as last object, given the conditions of this class.
|
||||
if Refinery::Blog::Post.column_names.include?("position")
|
||||
params[:post].merge!({
|
||||
:position => ((Refinery::Blog::Post.maximum(:position, :conditions => "")||-1) + 1)
|
||||
})
|
||||
end
|
||||
|
||||
if (@post = Refinery::Blog::Post.create(params[:post])).valid?
|
||||
(request.xhr? ? flash.now : flash).notice = t(
|
||||
'refinery.crudify.created',
|
||||
:what => "'#{@post.title}'"
|
||||
)
|
||||
|
||||
unless from_dialog?
|
||||
unless params[:continue_editing] =~ /true|on|1/
|
||||
redirect_back_or_default(refinery.blog_admin_posts_path)
|
||||
else
|
||||
unless request.xhr?
|
||||
redirect_to :back
|
||||
else
|
||||
render "/shared/message"
|
||||
end
|
||||
end
|
||||
else
|
||||
render :text => "<script>parent.window.location = '#{refinery.blog_admin_posts_url}';</script>"
|
||||
end
|
||||
else
|
||||
unless request.xhr?
|
||||
render :action => 'new'
|
||||
else
|
||||
render :partial => "/refinery/admin/error_messages",
|
||||
:locals => {
|
||||
:object => @post,
|
||||
:include_object_name => true
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
def find_all_categories
|
||||
@categories = Refinery::Blog::Category.find(:all)
|
||||
end
|
||||
|
||||
def check_category_ids
|
||||
params[:post][:category_ids] ||= []
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,55 +0,0 @@
|
|||
module Refinery
|
||||
module Blog
|
||||
module Admin
|
||||
class SettingsController < ::Refinery::AdminController
|
||||
|
||||
def notification_recipients
|
||||
@recipients = Refinery::Blog::Comment::Notification.recipients
|
||||
|
||||
if request.post?
|
||||
Refinery::Blog::Comment::Notification.recipients = params[:recipients]
|
||||
flash[:notice] = t('updated', :scope => 'refinery.blog.admin.settings.notification_recipients',
|
||||
:recipients => Refinery::Blog::Comment::Notification.recipients)
|
||||
unless request.xhr? or from_dialog?
|
||||
redirect_back_or_default(refinery.blog_admin_posts_path)
|
||||
else
|
||||
render :text => "<script type='text/javascript'>parent.window.location = '#{refinery.blog_admin_posts_path}';</script>",
|
||||
:layout => false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def moderation
|
||||
enabled = Refinery::Blog::Comment::Moderation.toggle!
|
||||
unless request.xhr?
|
||||
redirect_back_or_default(refinery.blog_admin_posts_path)
|
||||
else
|
||||
render :json => {:enabled => enabled},
|
||||
:layout => false
|
||||
end
|
||||
end
|
||||
|
||||
def comments
|
||||
enabled = Refinery::Blog::Comment.toggle!
|
||||
unless request.xhr?
|
||||
redirect_back_or_default(refinery.blog_admin_posts_path)
|
||||
else
|
||||
render :json => {:enabled => enabled},
|
||||
:layout => false
|
||||
end
|
||||
end
|
||||
|
||||
def teasers
|
||||
enabled = Refinery::Blog::Post.teaser_enabled_toggle!
|
||||
unless request.xhr?
|
||||
redirect_back_or_default(refinery.blog_admin_posts_path)
|
||||
else
|
||||
render :json => {:enabled => enabled},
|
||||
:layout => false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,17 +0,0 @@
|
|||
module Refinery
|
||||
module Blog
|
||||
class BlogController < ::ApplicationController
|
||||
|
||||
include ControllerHelper
|
||||
|
||||
helper :'refinery/blog/posts'
|
||||
before_filter :find_page, :find_all_blog_categories
|
||||
|
||||
protected
|
||||
|
||||
def find_page
|
||||
@page = Refinery::Page.find_by_link_url("/blog")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,12 +0,0 @@
|
|||
module Refinery
|
||||
module Blog
|
||||
class CategoriesController < BlogController
|
||||
|
||||
def show
|
||||
@category = Refinery::Blog::Category.find(params[:id])
|
||||
@posts = @category.posts.live.includes(:comments, :categories).page(params[:page])
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,85 +0,0 @@
|
|||
module Refinery
|
||||
module Blog
|
||||
class PostsController < BlogController
|
||||
|
||||
caches_page :index, :unless => proc {|c| c.refinery_user_signed_in? || c.flash.any? || params[:page].present? }
|
||||
|
||||
before_filter :find_all_blog_posts, :except => [:archive]
|
||||
before_filter :find_blog_post, :only => [:show, :comment, :update_nav]
|
||||
before_filter :find_tags
|
||||
|
||||
respond_to :html, :js, :rss
|
||||
|
||||
def index
|
||||
# Rss feeders are greedy. Let's give them every blog post instead of paginating.
|
||||
(@posts = Post.live.includes(:comments, :categories).all) if request.format.rss?
|
||||
respond_with (@posts) do |format|
|
||||
format.html
|
||||
format.rss
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@comment = Comment.new
|
||||
|
||||
@canonical = url_for(:locale => ::Refinery::I18n.default_frontend_locale) if canonical?
|
||||
|
||||
@post.increment!(:access_count, 1)
|
||||
|
||||
respond_with (@post) do |format|
|
||||
format.html { present(@post) }
|
||||
format.js { render :partial => 'post', :layout => false }
|
||||
end
|
||||
end
|
||||
|
||||
def comment
|
||||
if (@comment = @post.comments.create(params[:comment])).valid?
|
||||
if Comment::Moderation.enabled? or @comment.ham?
|
||||
begin
|
||||
CommentMailer.notification(@comment, request).deliver
|
||||
rescue
|
||||
logger.warn "There was an error delivering a blog comment notification.\n#{$!}\n"
|
||||
end
|
||||
end
|
||||
|
||||
if Comment::Moderation.enabled?
|
||||
flash[:notice] = t('thank_you_moderated', :scope => 'refinery.blog.posts.comments')
|
||||
redirect_to refinery.blog_post_url(params[:id])
|
||||
else
|
||||
flash[:notice] = t('thank_you', :scope => 'refinery.blog.posts.comments')
|
||||
redirect_to refinery.blog_post_url(params[:id],
|
||||
:anchor => "comment-#{@comment.to_param}")
|
||||
end
|
||||
else
|
||||
render :action => 'show'
|
||||
end
|
||||
end
|
||||
|
||||
def archive
|
||||
if params[:month].present?
|
||||
date = "#{params[:month]}/#{params[:year]}"
|
||||
@archive_date = Time.parse(date)
|
||||
@date_title = @archive_date.strftime('%B %Y')
|
||||
@posts = Post.live.by_month(@archive_date).page(params[:page])
|
||||
else
|
||||
date = "01/#{params[:year]}"
|
||||
@archive_date = Time.parse(date)
|
||||
@date_title = @archive_date.strftime('%Y')
|
||||
@posts = Post.live.by_year(@archive_date).page(params[:page])
|
||||
end
|
||||
respond_with (@posts)
|
||||
end
|
||||
|
||||
def tagged
|
||||
@tag = ActsAsTaggableOn::Tag.find(params[:tag_id])
|
||||
@tag_name = @tag.name
|
||||
@posts = Post.tagged_with(@tag_name).page(params[:page])
|
||||
end
|
||||
|
||||
protected
|
||||
def canonical?
|
||||
::Refinery.i18n_enabled? && ::Refinery::I18n.default_frontend_locale != ::Refinery::I18n.current_frontend_locale
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
56
app/helpers/blog_posts_helper.rb
Normal file
56
app/helpers/blog_posts_helper.rb
Normal file
|
@ -0,0 +1,56 @@
|
|||
module BlogPostsHelper
|
||||
def blog_archive_list
|
||||
posts = BlogPost.live.select('published_at').all_previous
|
||||
return nil if posts.blank?
|
||||
html = ''
|
||||
links = []
|
||||
super_old_links = []
|
||||
|
||||
posts.each do |e|
|
||||
if e.published_at >= Time.now.end_of_year.advance(:years => -3)
|
||||
links << e.published_at.strftime('%m/%Y')
|
||||
else
|
||||
super_old_links << e.published_at.strftime('01/%Y')
|
||||
end
|
||||
end
|
||||
links.uniq!
|
||||
super_old_links.uniq!
|
||||
links.each do |l|
|
||||
year = l.split('/')[1]
|
||||
month = l.split('/')[0]
|
||||
count = BlogPost.live.by_archive(Time.parse(l)).size
|
||||
text = t("date.month_names")[month.to_i] + " #{year} (#{count})"
|
||||
html << "<li>"
|
||||
html << link_to(text, archive_blog_posts_path(:year => year, :month => month))
|
||||
html << "</li>"
|
||||
end
|
||||
super_old_links.each do |l|
|
||||
year = l.split('/')[1]
|
||||
count = BlogPost.live.by_year(Time.parse(l)).size
|
||||
text = "#{year} (#{count})"
|
||||
html << "<li>"
|
||||
html << link_to(text, archive_blog_posts_path(:year => year))
|
||||
html << "</li>"
|
||||
end
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
def next_or_previous?(post)
|
||||
post.next.present? or post.prev.present?
|
||||
end
|
||||
|
||||
def blog_post_teaser_enabled?
|
||||
BlogPost.teasers_enabled?
|
||||
end
|
||||
|
||||
def blog_post_teaser(post)
|
||||
if post.respond_to?(:custom_teaser) && post.custom_teaser.present?
|
||||
post.custom_teaser.html_safe
|
||||
else
|
||||
truncate(post.body, {
|
||||
:length => RefinerySetting.find_or_set(:blog_post_teaser_length, 250),
|
||||
:preserve_html_tags => true
|
||||
}).html_safe
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,29 +0,0 @@
|
|||
module Refinery
|
||||
module Blog
|
||||
module ControllerHelper
|
||||
|
||||
protected
|
||||
|
||||
def find_blog_post
|
||||
unless (@post = Refinery::Blog::Post.find(params[:id])).try(:live?)
|
||||
if refinery_user? and current_refinery_user.authorized_plugins.include?("refinerycms_blog")
|
||||
@post = Refinery::Blog::Post.find(params[:id])
|
||||
else
|
||||
error_404
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def find_all_blog_posts
|
||||
@posts = Refinery::Blog::Post.live.includes(:comments, :categories).page(params[:page])
|
||||
end
|
||||
|
||||
def find_tags
|
||||
@tags = Refinery::Blog::Post.tag_counts_on(:tags)
|
||||
end
|
||||
def find_all_blog_categories
|
||||
@categories = Refinery::Blog::Category.all
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,72 +0,0 @@
|
|||
module Refinery
|
||||
module Blog
|
||||
module PostsHelper
|
||||
def next_or_previous?(post)
|
||||
post.next.present? or post.prev.present?
|
||||
end
|
||||
|
||||
def blog_post_teaser_enabled?
|
||||
Refinery::Blog::Post.teasers_enabled?
|
||||
end
|
||||
|
||||
def blog_post_teaser(post)
|
||||
if post.respond_to?(:custom_teaser) && post.custom_teaser.present?
|
||||
post.custom_teaser.html_safe
|
||||
else
|
||||
truncate(post.body, {
|
||||
:length => Refinery::Blog.post_teaser_length,
|
||||
:preserve_html_tags => true
|
||||
}).html_safe
|
||||
end
|
||||
end
|
||||
|
||||
def blog_archive_widget(dates=blog_archive_dates)
|
||||
ArchiveWidget.new(dates, self).display
|
||||
end
|
||||
|
||||
def blog_archive_dates(cutoff=Time.now.beginning_of_month)
|
||||
Refinery::Blog::Post.published_dates_older_than(cutoff)
|
||||
end
|
||||
|
||||
class ArchiveWidget
|
||||
delegate :t, :link_to, :refinery, :render, :to => :view_context
|
||||
attr_reader :view_context
|
||||
|
||||
def initialize(dates, view_context, cutoff=3.years.ago.end_of_year)
|
||||
@recent_dates, @old_dates = dates.sort_by {|date| -date.to_i }.
|
||||
partition {|date| date > cutoff }
|
||||
|
||||
@view_context = view_context
|
||||
end
|
||||
|
||||
def recent_links
|
||||
@recent_dates.group_by {|date| [date.year, date.month] }.
|
||||
map {|(year, month), dates| recent_link(year, month, dates.count) }
|
||||
end
|
||||
|
||||
def recent_link(year, month, count)
|
||||
link_to "#{t("date.month_names")[month]} #{year} (#{count})",
|
||||
refinery.blog_archive_posts_path(:year => year, :month => month)
|
||||
end
|
||||
|
||||
def old_links
|
||||
@old_dates.group_by {|date| date.year }.
|
||||
map {|year, dates| old_link(year, dates.size) }
|
||||
end
|
||||
|
||||
def old_link(year, count)
|
||||
link_to "#{year} (#{count})", refinery.blog_archive_posts_path(:year => year)
|
||||
end
|
||||
|
||||
def links
|
||||
recent_links + old_links
|
||||
end
|
||||
|
||||
def display
|
||||
return "" if links.empty?
|
||||
render "refinery/blog/widgets/blog_archive", :links => links
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
13
app/mailers/blog/comment_mailer.rb
Normal file
13
app/mailers/blog/comment_mailer.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
module Blog
|
||||
class CommentMailer < ActionMailer::Base
|
||||
|
||||
def notification(comment, request)
|
||||
subject BlogComment::Notification.subject
|
||||
recipients BlogComment::Notification.recipients
|
||||
from "\"#{RefinerySetting[:site_name]}\" <no-reply@#{request.domain(RefinerySetting.find_or_set(:tld_length, 1))}>"
|
||||
sent_on Time.now
|
||||
@comment = comment
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -1,14 +0,0 @@
|
|||
module Refinery
|
||||
module Blog
|
||||
class CommentMailer < ActionMailer::Base
|
||||
|
||||
def notification(comment, request)
|
||||
@comment = comment
|
||||
mail :subject => Blog::Comment::Notification.subject,
|
||||
:to => Blog::Comment::Notification.recipients,
|
||||
:from => "\"#{Refinery::Core.site_name}\" <no-reply@#{request.domain}>"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
1
app/models/blog/comment_mailer.rb
Normal file
1
app/models/blog/comment_mailer.rb
Normal file
|
@ -0,0 +1 @@
|
|||
require File.expand_path('../../../mailers/blog/comment_mailer', __FILE__)
|
19
app/models/blog_category.rb
Normal file
19
app/models/blog_category.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
class BlogCategory < ActiveRecord::Base
|
||||
|
||||
has_many :categorizations, :dependent => :destroy
|
||||
has_many :posts, :through => :categorizations, :source => :blog_post
|
||||
|
||||
acts_as_indexed :fields => [:title]
|
||||
|
||||
validates :title, :presence => true, :uniqueness => true
|
||||
|
||||
has_friendly_id :title, :use_slug => true,
|
||||
:default_locale => (::Refinery::I18n.default_frontend_locale rescue :en),
|
||||
:approximate_ascii => RefinerySetting.find_or_set(:approximate_ascii, false, :scoping => 'blog'),
|
||||
:strip_non_ascii => RefinerySetting.find_or_set(:strip_non_ascii, false, :scoping => 'blog')
|
||||
|
||||
def post_count
|
||||
posts.select(&:live?).count
|
||||
end
|
||||
|
||||
end
|
137
app/models/blog_comment.rb
Normal file
137
app/models/blog_comment.rb
Normal file
|
@ -0,0 +1,137 @@
|
|||
class BlogComment < ActiveRecord::Base
|
||||
|
||||
attr_accessible :name, :email, :message
|
||||
|
||||
filters_spam :author_field => :name,
|
||||
:email_field => :email,
|
||||
:message_field => :body
|
||||
|
||||
belongs_to :post, :class_name => 'BlogPost', :foreign_key => 'blog_post_id'
|
||||
|
||||
acts_as_indexed :fields => [:name, :email, :message]
|
||||
|
||||
alias_attribute :message, :body
|
||||
|
||||
validates :name, :message, :presence => true
|
||||
validates :email, :format => { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i }
|
||||
|
||||
scope :unmoderated, :conditions => {:state => nil}
|
||||
scope :approved, :conditions => {:state => 'approved'}
|
||||
scope :rejected, :conditions => {:state => 'rejected'}
|
||||
|
||||
def avatar_url(options = {})
|
||||
require 'digest/md5'
|
||||
params = {
|
||||
:s => options[:size] || 60,
|
||||
:d => options[:default_image]
|
||||
}
|
||||
query_string = params.map do |k,v|
|
||||
[k,v].map { |s| CGI::escape(s.to_s) }.join('=')
|
||||
end.join('&')
|
||||
email_md5 = Digest::MD5.hexdigest(self.email.to_s.strip.downcase)
|
||||
"http://gravatar.com/avatar/#{email_md5}?#{query_string}"
|
||||
end
|
||||
|
||||
def approve!
|
||||
self.update_attribute(:state, 'approved')
|
||||
end
|
||||
|
||||
def reject!
|
||||
self.update_attribute(:state, 'rejected')
|
||||
end
|
||||
|
||||
def rejected?
|
||||
self.state == 'rejected'
|
||||
end
|
||||
|
||||
def approved?
|
||||
self.state == 'approved'
|
||||
end
|
||||
|
||||
def unmoderated?
|
||||
self.state.nil?
|
||||
end
|
||||
|
||||
def self.toggle!
|
||||
currently = RefinerySetting.find_or_set(:comments_allowed, true, {
|
||||
:scoping => 'blog'
|
||||
})
|
||||
RefinerySetting.set(:comments_allowed, {:value => !currently, :scoping => 'blog'})
|
||||
end
|
||||
|
||||
before_create do |comment|
|
||||
unless BlogComment::Moderation.enabled?
|
||||
comment.state = comment.ham? ? 'approved' : 'rejected'
|
||||
end
|
||||
end
|
||||
|
||||
module Moderation
|
||||
class << self
|
||||
def enabled?
|
||||
RefinerySetting.find_or_set(:comment_moderation, true, {
|
||||
:scoping => 'blog',
|
||||
:restricted => false
|
||||
})
|
||||
end
|
||||
|
||||
def toggle!
|
||||
new_value = {
|
||||
:value => !BlogComment::Moderation.enabled?,
|
||||
:scoping => 'blog',
|
||||
:restricted => false
|
||||
}
|
||||
if RefinerySetting.respond_to?(:set)
|
||||
RefinerySetting.set(:comment_moderation, new_value)
|
||||
else
|
||||
RefinerySetting[:comment_moderation] = new_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module Notification
|
||||
class << self
|
||||
def recipients
|
||||
RefinerySetting.find_or_set(:comment_notification_recipients, (Role[:refinery].users.first.email rescue ''),
|
||||
{
|
||||
:scoping => 'blog',
|
||||
:restricted => false
|
||||
})
|
||||
end
|
||||
|
||||
def recipients=(emails)
|
||||
new_value = {
|
||||
:value => emails,
|
||||
:scoping => 'blog',
|
||||
:restricted => false
|
||||
}
|
||||
if RefinerySetting.respond_to?(:set)
|
||||
RefinerySetting.set(:comment_notification_recipients, new_value)
|
||||
else
|
||||
RefinerySetting[:comment_notification_recipients] = new_value
|
||||
end
|
||||
end
|
||||
|
||||
def subject
|
||||
RefinerySetting.find_or_set(:comment_notification_subject, "New inquiry from your website", {
|
||||
:scoping => 'blog',
|
||||
:restricted => false
|
||||
})
|
||||
end
|
||||
|
||||
def subject=(subject_line)
|
||||
new_value = {
|
||||
:value => subject_line,
|
||||
:scoping => 'blog',
|
||||
:restricted => false
|
||||
}
|
||||
if RefinerySetting.respond_to?(:set)
|
||||
RefinerySetting.set(:comment_notification_subject, new_value)
|
||||
else
|
||||
RefinerySetting[:comment_notification_subject] = new_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
114
app/models/blog_post.rb
Normal file
114
app/models/blog_post.rb
Normal file
|
@ -0,0 +1,114 @@
|
|||
require 'acts-as-taggable-on'
|
||||
require 'seo_meta'
|
||||
|
||||
class BlogPost < ActiveRecord::Base
|
||||
|
||||
is_seo_meta if self.table_exists?
|
||||
|
||||
default_scope :order => 'published_at DESC'
|
||||
#.first & .last will be reversed -- consider a with_exclusive_scope on these?
|
||||
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => :user_id, :readonly => true
|
||||
|
||||
has_many :comments, :class_name => 'BlogComment', :dependent => :destroy
|
||||
acts_as_taggable
|
||||
|
||||
has_many :categorizations, :dependent => :destroy
|
||||
has_many :categories, :through => :categorizations, :source => :blog_category
|
||||
|
||||
acts_as_indexed :fields => [:title, :body]
|
||||
|
||||
validates :title, :presence => true, :uniqueness => true
|
||||
validates :body, :presence => true
|
||||
|
||||
has_friendly_id :friendly_id_source, :use_slug => true,
|
||||
:default_locale => (::Refinery::I18n.default_frontend_locale rescue :en),
|
||||
:approximate_ascii => RefinerySetting.find_or_set(:approximate_ascii, false, :scoping => 'blog'),
|
||||
:strip_non_ascii => RefinerySetting.find_or_set(:strip_non_ascii, false, :scoping => 'blog')
|
||||
|
||||
scope :by_archive, lambda { |archive_date|
|
||||
where(['published_at between ? and ?', archive_date.beginning_of_month, archive_date.end_of_month])
|
||||
}
|
||||
|
||||
scope :by_year, lambda { |archive_year|
|
||||
where(['published_at between ? and ?', archive_year.beginning_of_year, archive_year.end_of_year])
|
||||
}
|
||||
|
||||
scope :all_previous, lambda { where(['published_at <= ?', Time.now.beginning_of_month]) }
|
||||
|
||||
scope :live, lambda { where( "published_at <= ? and draft = ?", Time.now, false) }
|
||||
|
||||
scope :previous, lambda { |i| where(["published_at < ? and draft = ?", i.published_at, false]).limit(1) }
|
||||
# next is now in << self
|
||||
|
||||
def next
|
||||
BlogPost.next(self).first
|
||||
end
|
||||
|
||||
def prev
|
||||
BlogPost.previous(self).first
|
||||
end
|
||||
|
||||
def live?
|
||||
!draft and published_at <= Time.now
|
||||
end
|
||||
|
||||
def category_ids=(ids)
|
||||
self.categories = ids.reject{|id| id.blank?}.collect {|c_id|
|
||||
BlogCategory.find(c_id.to_i) rescue nil
|
||||
}.compact
|
||||
end
|
||||
|
||||
def friendly_id_source
|
||||
custom_url.present? ? custom_url : title
|
||||
end
|
||||
|
||||
class << self
|
||||
def next current_record
|
||||
self.send(:with_exclusive_scope) do
|
||||
where(["published_at > ? and draft = ?", current_record.published_at, false]).order("published_at ASC")
|
||||
end
|
||||
end
|
||||
|
||||
def comments_allowed?
|
||||
RefinerySetting.find_or_set(:comments_allowed, true, {
|
||||
:scoping => 'blog'
|
||||
})
|
||||
end
|
||||
|
||||
def teasers_enabled?
|
||||
RefinerySetting.find_or_set(:teasers_enabled, true, {
|
||||
:scoping => 'blog'
|
||||
})
|
||||
end
|
||||
|
||||
def teaser_enabled_toggle!
|
||||
currently = RefinerySetting.find_or_set(:teasers_enabled, true, {
|
||||
:scoping => 'blog'
|
||||
})
|
||||
RefinerySetting.set(:teasers_enabled, {:value => !currently, :scoping => 'blog'})
|
||||
end
|
||||
|
||||
def uncategorized
|
||||
BlogPost.live.reject { |p| p.categories.any? }
|
||||
end
|
||||
end
|
||||
|
||||
module ShareThis
|
||||
DEFAULT_KEY = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
|
||||
class << self
|
||||
def key
|
||||
RefinerySetting.find_or_set(:share_this_key, BlogPost::ShareThis::DEFAULT_KEY, {
|
||||
:scoping => 'blog'
|
||||
})
|
||||
end
|
||||
|
||||
def enabled?
|
||||
key = BlogPost::ShareThis.key
|
||||
key.present? and key != BlogPost::ShareThis::DEFAULT_KEY
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
7
app/models/categorization.rb
Normal file
7
app/models/categorization.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class Categorization < ActiveRecord::Base
|
||||
|
||||
set_table_name 'blog_categories_blog_posts'
|
||||
belongs_to :blog_post
|
||||
belongs_to :blog_category
|
||||
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
module Refinery
|
||||
module Blog
|
||||
class Category < ActiveRecord::Base
|
||||
extend FriendlyId
|
||||
friendly_id :title, :use => [:slugged]
|
||||
|
||||
has_many :categorizations, :dependent => :destroy, :foreign_key => :blog_category_id
|
||||
has_many :posts, :through => :categorizations, :source => :blog_post
|
||||
|
||||
acts_as_indexed :fields => [:title]
|
||||
|
||||
validates :title, :presence => true, :uniqueness => true
|
||||
|
||||
attr_accessible :title
|
||||
|
||||
def post_count
|
||||
posts.live.count
|
||||
end
|
||||
|
||||
# how many items to show per page
|
||||
self.per_page = Refinery::Blog.posts_per_page
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,135 +0,0 @@
|
|||
module Refinery
|
||||
module Blog
|
||||
class Comment < ActiveRecord::Base
|
||||
|
||||
attr_accessible :name, :email, :message
|
||||
|
||||
filters_spam :author_field => :name,
|
||||
:email_field => :email,
|
||||
:message_field => :body
|
||||
|
||||
belongs_to :post, :foreign_key => 'blog_post_id'
|
||||
|
||||
acts_as_indexed :fields => [:name, :email, :message]
|
||||
|
||||
alias_attribute :message, :body
|
||||
|
||||
validates :name, :message, :presence => true
|
||||
validates :email, :format => { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i }
|
||||
|
||||
class << self
|
||||
def unmoderated
|
||||
where(:state => nil)
|
||||
end
|
||||
|
||||
def approved
|
||||
where(:state => 'approved')
|
||||
end
|
||||
|
||||
def rejected
|
||||
where(:state => 'rejected')
|
||||
end
|
||||
end
|
||||
|
||||
self.per_page = Refinery::Blog.comments_per_page
|
||||
|
||||
def avatar_url(options = {})
|
||||
options = {:size => 60}
|
||||
require 'digest/md5'
|
||||
size = ("?s=#{options[:size]}" if options[:size])
|
||||
"http://gravatar.com/avatar/#{Digest::MD5.hexdigest(self.email.to_s.strip.downcase)}#{size}.jpg"
|
||||
end
|
||||
|
||||
def approve!
|
||||
self.update_attribute(:state, 'approved')
|
||||
end
|
||||
|
||||
def reject!
|
||||
self.update_attribute(:state, 'rejected')
|
||||
end
|
||||
|
||||
def rejected?
|
||||
self.state == 'rejected'
|
||||
end
|
||||
|
||||
def approved?
|
||||
self.state == 'approved'
|
||||
end
|
||||
|
||||
def unmoderated?
|
||||
self.state.nil?
|
||||
end
|
||||
|
||||
def self.toggle!
|
||||
currently = Refinery::Setting.find_or_set(:comments_allowed, true, {
|
||||
:scoping => 'blog'
|
||||
})
|
||||
Refinery::Setting.set(:comments_allowed, {:value => !currently, :scoping => 'blog'})
|
||||
end
|
||||
|
||||
before_create do |comment|
|
||||
unless Moderation.enabled?
|
||||
comment.state = comment.ham? ? 'approved' : 'rejected'
|
||||
end
|
||||
end
|
||||
|
||||
module Moderation
|
||||
class << self
|
||||
def enabled?
|
||||
Refinery::Setting.find_or_set(:comment_moderation, true, {
|
||||
:scoping => 'blog',
|
||||
:restricted => false
|
||||
})
|
||||
end
|
||||
|
||||
def toggle!
|
||||
new_value = {
|
||||
:value => !Blog::Comment::Moderation.enabled?,
|
||||
:scoping => 'blog',
|
||||
:restricted => false
|
||||
}
|
||||
Refinery::Setting.set(:comment_moderation, new_value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module Notification
|
||||
class << self
|
||||
def recipients
|
||||
Refinery::Setting.find_or_set(:comment_notification_recipients, (Refinery::Role[:refinery].users.first.email rescue ''),
|
||||
{
|
||||
:scoping => 'blog',
|
||||
:restricted => false
|
||||
})
|
||||
end
|
||||
|
||||
def recipients=(emails)
|
||||
new_value = {
|
||||
:value => emails,
|
||||
:scoping => 'blog',
|
||||
:restricted => false
|
||||
}
|
||||
Refinery::Setting.set(:comment_notification_recipients, new_value)
|
||||
end
|
||||
|
||||
def subject
|
||||
Refinery::Setting.find_or_set(:comment_notification_subject, "New inquiry from your website", {
|
||||
:scoping => 'blog',
|
||||
:restricted => false
|
||||
})
|
||||
end
|
||||
|
||||
def subject=(subject_line)
|
||||
new_value = {
|
||||
:value => subject_line,
|
||||
:scoping => 'blog',
|
||||
:restricted => false
|
||||
}
|
||||
Refinery::Setting.set(:comment_notification_subject, new_value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,120 +0,0 @@
|
|||
require 'acts-as-taggable-on'
|
||||
require 'seo_meta'
|
||||
|
||||
module Refinery
|
||||
module Blog
|
||||
class Post < ActiveRecord::Base
|
||||
extend FriendlyId
|
||||
friendly_id :friendly_id_source, :use => [:slugged]
|
||||
|
||||
is_seo_meta if self.table_exists?
|
||||
|
||||
default_scope :order => 'published_at DESC'
|
||||
|
||||
belongs_to :author, :class_name => 'Refinery::User', :foreign_key => :user_id, :readonly => true
|
||||
|
||||
has_many :comments, :dependent => :destroy, :foreign_key => :blog_post_id
|
||||
acts_as_taggable
|
||||
|
||||
has_many :categorizations, :dependent => :destroy, :foreign_key => :blog_post_id
|
||||
has_many :categories, :through => :categorizations, :source => :blog_category
|
||||
|
||||
acts_as_indexed :fields => [:title, :body]
|
||||
|
||||
validates :title, :presence => true, :uniqueness => true
|
||||
validates :body, :presence => true
|
||||
|
||||
validates :source_url, :url => { :if => 'Refinery::Blog.validate_source_url',
|
||||
:update => true,
|
||||
:allow_nil => true,
|
||||
:allow_blank => true,
|
||||
:verify => [:resolve_redirects]}
|
||||
|
||||
attr_accessible :title, :body, :custom_teaser, :tag_list, :draft, :published_at, :custom_url, :author
|
||||
attr_accessible :browser_title, :meta_keywords, :meta_description, :user_id, :category_ids
|
||||
attr_accessible :source_url, :source_url_title
|
||||
|
||||
self.per_page = Refinery::Blog.posts_per_page
|
||||
|
||||
def next
|
||||
self.class.next(self)
|
||||
end
|
||||
|
||||
def prev
|
||||
self.class.previous(self)
|
||||
end
|
||||
|
||||
def live?
|
||||
!draft and published_at <= Time.now
|
||||
end
|
||||
|
||||
def friendly_id_source
|
||||
custom_url.presence || title
|
||||
end
|
||||
|
||||
class << self
|
||||
def by_month(date)
|
||||
where(:published_at => date.beginning_of_month..date.end_of_month)
|
||||
end
|
||||
|
||||
def by_archive(date)
|
||||
Refinery.deprecate("Refinery::Blog::Post.by_archive(date)", {:replacement => "Refinery::Blog::Post.by_month(date)", :when => 2.2 })
|
||||
by_month(date)
|
||||
end
|
||||
|
||||
def by_year(date)
|
||||
where(:published_at => date.beginning_of_year..date.end_of_year)
|
||||
end
|
||||
|
||||
def published_dates_older_than(date)
|
||||
published_before(date).pluck(:published_at)
|
||||
end
|
||||
|
||||
def recent(count)
|
||||
live.limit(count)
|
||||
end
|
||||
|
||||
def popular(count)
|
||||
unscoped.order("access_count DESC").limit(count)
|
||||
end
|
||||
|
||||
def previous(item)
|
||||
published_before(item.published_at).first
|
||||
end
|
||||
|
||||
def uncategorized
|
||||
live.includes(:categories).where(:categories => { Refinery::Categorization.table_name => { :blog_category_id => nil } })
|
||||
end
|
||||
|
||||
def next(current_record)
|
||||
where(["published_at > ? and draft = ?", current_record.published_at, false]).first
|
||||
end
|
||||
|
||||
def published_before(date=Time.now)
|
||||
where("published_at < ? and draft = ?", date, false)
|
||||
end
|
||||
alias_method :live, :published_before
|
||||
|
||||
def comments_allowed?
|
||||
Refinery::Setting.find_or_set(:comments_allowed, true, :scoping => 'blog')
|
||||
end
|
||||
|
||||
def teasers_enabled?
|
||||
Refinery::Setting.find_or_set(:teasers_enabled, true, :scoping => 'blog')
|
||||
end
|
||||
|
||||
def teaser_enabled_toggle!
|
||||
currently = Refinery::Setting.find_or_set(:teasers_enabled, true, :scoping => 'blog')
|
||||
Refinery::Setting.set(:teasers_enabled, :value => !currently, :scoping => 'blog')
|
||||
end
|
||||
end
|
||||
|
||||
module ShareThis
|
||||
def self.enabled?
|
||||
Refinery::Blog.share_this_key != "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,10 +0,0 @@
|
|||
module Refinery
|
||||
class Categorization < ActiveRecord::Base
|
||||
|
||||
self.table_name = 'refinery_blog_categories_blog_posts'
|
||||
belongs_to :blog_post, :class_name => 'Refinery::Blog::Post', :foreign_key => :blog_post_id
|
||||
belongs_to :blog_category, :class_name => 'Refinery::Blog::Category', :foreign_key => :blog_category_id
|
||||
|
||||
attr_accessible :blog_category_id, :blog_post_id
|
||||
end
|
||||
end
|
|
@ -1,26 +0,0 @@
|
|||
module Refinery
|
||||
class BlogSweeper < ActionController::Caching::Sweeper
|
||||
observe Blog::Post, Blog::Comment
|
||||
|
||||
def after_create(record)
|
||||
expire_cache_for(record)
|
||||
end
|
||||
|
||||
def after_update(record)
|
||||
expire_cache_for(record)
|
||||
end
|
||||
|
||||
def after_destroy(record)
|
||||
expire_cache_for(record)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def expire_cache_for(record)
|
||||
# TODO: Convert these to url helpers
|
||||
expire_page '/blog'
|
||||
expire_page '/blog/feed.rss'
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -1,9 +1,9 @@
|
|||
<nav id='actions' class='multilist'>
|
||||
<ul class='search_list'>
|
||||
<li class='not_a_link'>
|
||||
<%= render :partial => "/refinery/admin/search",
|
||||
<%= render :partial => "/shared/admin/search",
|
||||
:locals => {
|
||||
:url => refinery.blog_admin_posts_path
|
||||
:url => admin_blog_posts_url
|
||||
} %>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -14,23 +14,23 @@
|
|||
:class => 'page_copy_icon' %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.posts.manage'), refinery.blog_admin_posts_path,
|
||||
<%= link_to t('.posts.manage'), admin_blog_posts_path,
|
||||
:class => 'page_icon' %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.posts.uncategorized'), refinery.uncategorized_blog_admin_posts_path,
|
||||
<%= link_to t('.posts.uncategorized'), uncategorized_admin_blog_posts_url,
|
||||
:class => 'page_icon' %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.posts.new'), refinery.new_blog_admin_post_path,
|
||||
<%= link_to t('.posts.new'), new_admin_blog_post_url,
|
||||
:class => 'page_add_icon' %>
|
||||
</li>
|
||||
</ul>
|
||||
<% if Refinery::Blog::Post.comments_allowed? %>
|
||||
<% if BlogPost.comments_allowed? %>
|
||||
<ul class='collapsible_menu'>
|
||||
<li class='not_a_link'>
|
||||
<% if Refinery::Blog::Comment.unmoderated.any? %>
|
||||
<% title = t('.comments.title_with_count', :new_count => Refinery::Blog::Comment.unmoderated.size) %>
|
||||
<% if BlogComment.unmoderated.any? %>
|
||||
<% title = t('.comments.title_with_count', :new_count => BlogComment.unmoderated.size) %>
|
||||
<% else %>
|
||||
<% title = t('.comments.title') %>
|
||||
<% end %>
|
||||
|
@ -38,15 +38,15 @@
|
|||
:class => 'comments_icon' %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.comments.new'), refinery.blog_admin_comments_path,
|
||||
<%= link_to t('.comments.new'), admin_blog_comments_path,
|
||||
:class => 'comment_icon' %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.comments.approved'), refinery.approved_blog_admin_comments_path,
|
||||
<%= link_to t('.comments.approved'), approved_admin_blog_comments_path,
|
||||
:class => 'comment_tick_icon' %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.comments.rejected'), refinery.rejected_blog_admin_comments_path,
|
||||
<%= link_to t('.comments.rejected'), rejected_admin_blog_comments_path,
|
||||
:class => 'comment_cross_icon' %>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -58,39 +58,39 @@
|
|||
:class => 'folder_icon' %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.categories.manage'), refinery.blog_admin_categories_path,
|
||||
<%= link_to t('.categories.manage'), admin_blog_categories_url,
|
||||
:class => 'folder_edit_icon' %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.categories.new'), refinery.new_blog_admin_category_path,
|
||||
<%= link_to t('.categories.new'), new_admin_blog_category_url(:dialog => true, :height => 325),
|
||||
:class => 'folder_add_icon' %>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class='collapsible_menu'>
|
||||
<li class='not_a_link'>
|
||||
<%= link_to t('.settings.title'), refinery.blog_admin_settings_path,
|
||||
<%= link_to t('.settings.title'), admin_blog_settings_path,
|
||||
:class => 'settings_icon' %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.settings.comments'), refinery.comments_blog_admin_settings_path,
|
||||
:class => "#{Refinery::Blog::Post.comments_allowed? ? 'success' : 'failure'}_icon" %>
|
||||
<%= link_to t('.settings.comments'), comments_admin_blog_settings_url,
|
||||
:class => "#{BlogPost.comments_allowed? ? 'success' : 'failure'}_icon" %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.settings.moderation'), refinery.moderation_blog_admin_settings_path,
|
||||
:class => "#{Refinery::Blog::Comment::Moderation.enabled? ? 'success' : 'failure'}_icon" %>
|
||||
<%= link_to t('.settings.moderation'), moderation_admin_blog_settings_url,
|
||||
:class => "#{BlogComment::Moderation.enabled? ? 'success' : 'failure'}_icon" %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.settings.update_notified'),
|
||||
refinery.notification_recipients_blog_admin_settings_path(:dialog => true, :height => 400),
|
||||
notification_recipients_admin_blog_settings_url(:dialog => true, :height => 400),
|
||||
:class => 'user_comment_icon' %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.settings.teasers'),
|
||||
refinery.teasers_blog_admin_settings_path, :class => "#{Refinery::Blog::Post.teasers_enabled? ? 'success' : 'failure'}_icon" %>
|
||||
teasers_admin_blog_settings_url, :class => "#{BlogPost.teasers_enabled? ? 'success' : 'failure'}_icon" %>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</nav>
|
||||
|
||||
<% content_for :stylesheets, stylesheet_link_tag('refinery/blog/backend') %>
|
||||
<% content_for :stylesheets, stylesheet_link_tag('refinery/refinerycms-blog')%>
|
|
@ -5,12 +5,12 @@
|
|||
</span>
|
||||
<span class='actions'>
|
||||
<%= link_to refinery_icon_tag("application_edit.png"),
|
||||
refinery.edit_blog_admin_category_path(category, :dialog => true, :height => 325),
|
||||
edit_admin_blog_category_path(category, :dialog => true, :height => 325),
|
||||
:title => t('.edit') %>
|
||||
<%= link_to refinery_icon_tag("delete.png"), refinery.blog_admin_category_path(category),
|
||||
<%= link_to refinery_icon_tag("delete.png"), admin_blog_category_path(category),
|
||||
:class => "cancel confirm-delete",
|
||||
:title => t('.delete'),
|
||||
:method => :delete,
|
||||
:confirm => t('message', :scope => 'refinery.admin.delete', :title => category.title) %>
|
||||
:confirm => t('message', :scope => 'shared.admin.delete', :title => category.title) %>
|
||||
</span>
|
||||
</li>
|
|
@ -1,5 +1,5 @@
|
|||
<%= form_for [refinery, :blog_admin, @category] do |f| -%>
|
||||
<%= render :partial => "/refinery/admin/error_messages",
|
||||
<%= form_for [:admin, @blog_category] do |f| -%>
|
||||
<%= render :partial => "/shared/admin/error_messages",
|
||||
:locals => {
|
||||
:object => f.object,
|
||||
:include_object_name => true
|
||||
|
@ -10,10 +10,10 @@
|
|||
<%= f.text_field :title, :class => 'larger widest' -%>
|
||||
</div>
|
||||
|
||||
<%= render :partial => "/refinery/admin/form_actions",
|
||||
<%= render :partial => "/shared/admin/form_actions",
|
||||
:locals => {
|
||||
:f => f,
|
||||
:continue_editing => false,
|
||||
:delete_title => t('delete', :scope => 'refinery.blog.admin.categories.category')
|
||||
:delete_title => t('delete', :scope => 'admin.blog.categories.category')
|
||||
} %>
|
||||
<% end %>
|
|
@ -1,7 +1,7 @@
|
|||
<ul id='sortable_list'>
|
||||
<%= render :partial => 'comment', :collection => @comments %>
|
||||
<%= render :partial => 'category', :collection => @blog_categories %>
|
||||
</ul>
|
||||
<%= render :partial => "/refinery/admin/sortable_list",
|
||||
<%= render :partial => "/shared/admin/sortable_list",
|
||||
:locals => {
|
||||
:continue_reordering => (defined?(continue_reordering) ? continue_reordering : true)
|
||||
} %>
|
1
app/views/admin/blog/categories/edit.html.erb
Normal file
1
app/views/admin/blog/categories/edit.html.erb
Normal file
|
@ -0,0 +1 @@
|
|||
<%= render :partial => "form" %>
|
26
app/views/admin/blog/categories/index.html.erb
Normal file
26
app/views/admin/blog/categories/index.html.erb
Normal file
|
@ -0,0 +1,26 @@
|
|||
<%= render :partial => '/admin/blog/submenu' %>
|
||||
<div id='records'>
|
||||
<% if searching? %>
|
||||
<h2><%= t('results_for', :scope => 'shared.admin.search', :query => params[:search]) %></h2>
|
||||
<% if @blog_categories.any? %>
|
||||
<%= render :partial => "blog_categories",
|
||||
:collection => @blog_categories %>
|
||||
<% else %>
|
||||
<p><%= t('search_no_results', :scope => 'admin') %></p>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if @blog_categories.any? %>
|
||||
<%= will_paginate @blog_categories %>
|
||||
|
||||
<%= render :partial => "sortable_list" %>
|
||||
|
||||
<%= will_paginate @blog_categories %>
|
||||
<% else %>
|
||||
<p>
|
||||
<strong>
|
||||
<%= t('.no_items_yet', :create => t('new', :scope => 'admin.blog.submenu.categories')) %>
|
||||
</strong>
|
||||
</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
1
app/views/admin/blog/categories/new.html.erb
Normal file
1
app/views/admin/blog/categories/new.html.erb
Normal file
|
@ -0,0 +1 @@
|
|||
<%= render :partial => "form" %>
|
|
@ -5,16 +5,16 @@
|
|||
</span>
|
||||
<span class='actions'>
|
||||
<%= link_to refinery_icon_tag("application_go.png"),
|
||||
refinery.blog_post_path(comment.post, :anchor => "comment-#{comment.to_param}"),
|
||||
blog_post_url(comment.post, :anchor => "comment-#{comment.to_param}"),
|
||||
:title => t('.view_live_html'),
|
||||
:target => "_blank" unless comment.unmoderated? %>
|
||||
<%= link_to refinery_icon_tag('zoom.png'), refinery.blog_admin_comment_path(comment),
|
||||
<%= link_to refinery_icon_tag('zoom.png'), admin_blog_comment_path(comment),
|
||||
:title => t('.read') %>
|
||||
<%= link_to refinery_icon_tag("cross.png"),
|
||||
refinery.rejected_blog_admin_comment_path(comment, :return_to => request.path.split('/').last.gsub(/^comments$/, 'index')),
|
||||
rejected_admin_blog_comment_path(comment, :return_to => request.path.split('/').last.gsub(/^comments$/, 'index')),
|
||||
:title => t('.reject') unless comment.rejected? %>
|
||||
<%= link_to refinery_icon_tag("tick.png"),
|
||||
refinery.approved_blog_admin_comment_path(comment, :return_to => request.path.split('/').last.gsub(/^comments$/, 'index')),
|
||||
approved_admin_blog_comment_path(comment, :return_to => request.path.split('/').last.gsub(/^comments$/, 'index')),
|
||||
:title => t('.approve') unless comment.approved? %>
|
||||
</span>
|
||||
</li>
|
|
@ -1,7 +1,7 @@
|
|||
<ul id='sortable_list'>
|
||||
<%= render :partial => 'category', :collection => @categories %>
|
||||
<%= render :partial => 'comment', :collection => @blog_comments %>
|
||||
</ul>
|
||||
<%= render :partial => "/refinery/admin/sortable_list",
|
||||
<%= render :partial => "/shared/admin/sortable_list",
|
||||
:locals => {
|
||||
:continue_reordering => (defined?(continue_reordering) ? continue_reordering : true)
|
||||
} %>
|
35
app/views/admin/blog/comments/index.html.erb
Normal file
35
app/views/admin/blog/comments/index.html.erb
Normal file
|
@ -0,0 +1,35 @@
|
|||
<%= render :partial => '/admin/blog/submenu' %>
|
||||
<div id='records'>
|
||||
<% if searching? %>
|
||||
<h2><%= t('results_for', :scope => 'shared.admin.search', :query => params[:search]) %></h2>
|
||||
<% if @blog_comments.any? %>
|
||||
<%=# will_paginate @blog_comments
|
||||
%>
|
||||
|
||||
<ul>
|
||||
<%= render :partial => "blog_comments",
|
||||
:collection => @blog_comments %>
|
||||
</ul>
|
||||
|
||||
<%=# will_paginate @blog_comments
|
||||
%>
|
||||
<% else %>
|
||||
<p><%= t('search_no_results', :scope => 'admin') %></p>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if @blog_comments.any? %>
|
||||
<%=# will_paginate @blog_comments
|
||||
%>
|
||||
|
||||
<%= render :partial => "sortable_list" %>
|
||||
|
||||
<%=# will_paginate @blog_comments
|
||||
%>
|
||||
<% else %>
|
||||
<h3>
|
||||
<%= t('.no_items_yet',
|
||||
:type => t(action_name.gsub('index', 'new'), :scope => 'admin.blog.submenu.comments').downcase) %>
|
||||
</h3>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
63
app/views/admin/blog/comments/show.html.erb
Normal file
63
app/views/admin/blog/comments/show.html.erb
Normal file
|
@ -0,0 +1,63 @@
|
|||
<div id='actions'>
|
||||
<h2><%= t('.details')%></h2>
|
||||
<p>
|
||||
<strong><%= t('.age') %>:</strong> <%= time_ago_in_words(@blog_comment.created_at) %>
|
||||
</p>
|
||||
<h2><%= t('.actions') %></h2>
|
||||
<ul>
|
||||
<li>
|
||||
<%= link_to t('.back'), {:action => 'index'}, :class => "back_icon" %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.reject'), rejected_admin_blog_comment_path(@blog_comment, :return_to => 'rejected'),
|
||||
:class => 'comment_cross_icon' unless @blog_comment.rejected? %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.approve'), approved_admin_blog_comment_path(@blog_comment, :return_to => 'approved'),
|
||||
:class => 'comment_tick_icon' unless @blog_comment.approved? %>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id='records'>
|
||||
<h2><%= t('.comment') %></h2>
|
||||
<table id='inquiry'>
|
||||
<tr>
|
||||
<td>
|
||||
<strong><%= t('.blog_post') %></strong>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to @blog_comment.post.title,
|
||||
blog_post_url(@blog_comment.post, :anchor => "comment-#{@blog_comment.to_param}"),
|
||||
:target => '_blank' %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<strong><%= t('.from') %></strong>
|
||||
</td>
|
||||
<td>
|
||||
<%= @blog_comment.name %> [<%= mail_to @blog_comment.email, @blog_comment.email, {:title => t('.click_to_email')} %>]
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<strong><%= t('.date') %></strong>
|
||||
</td>
|
||||
<td>
|
||||
<%= l(Date.parse(@blog_comment.created_at.to_s), :format => :long) %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign='top'>
|
||||
<strong><%= t('.message') %></strong>
|
||||
</td>
|
||||
<td>
|
||||
<p style='margin-top: 0px'>
|
||||
<%= @blog_comment.message.gsub("\r\n\r\n", "\r\n").gsub("\r\n", "</p><p>") %>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<% content_for :stylesheets, stylesheet_link_tag('refinery/refinerycms-blog') %>
|
20
app/views/admin/blog/posts/_form.css.erb
Normal file
20
app/views/admin/blog/posts/_form.css.erb
Normal file
|
@ -0,0 +1,20 @@
|
|||
<style type='text/css'>
|
||||
ul.blog_categories{
|
||||
height:200px;
|
||||
overflow:auto;
|
||||
border:1px solid #ccc;
|
||||
padding:5px;
|
||||
}
|
||||
ul.blog_categories, ul.blog_categories li {
|
||||
list-style: none;
|
||||
margin:5px 0;
|
||||
}
|
||||
a#copy_body_link {
|
||||
background: url("/images/refinery/icons/add.png") no-repeat scroll 0 6px transparent;
|
||||
border-bottom: 0 none;
|
||||
display: inline;
|
||||
line-height: 29px;
|
||||
margin-top: 0;
|
||||
padding-left: 20px;
|
||||
}
|
||||
</style>
|
|
@ -1,5 +1,5 @@
|
|||
<%= form_for [refinery, :blog_admin, @post] do |f| -%>
|
||||
<%= render :partial => "/refinery/admin/error_messages",
|
||||
<%= form_for [:admin, @blog_post] do |f| -%>
|
||||
<%= render :partial => "/shared/admin/error_messages",
|
||||
:locals => {
|
||||
:object => f.object,
|
||||
:include_object_name => true
|
||||
|
@ -9,22 +9,20 @@
|
|||
<%= f.label :title -%>
|
||||
<%= f.text_field :title, :class => 'larger widest' -%>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<p>
|
||||
<%= f.check_box :draft %>
|
||||
<%= f.label :draft, t('.save_as_draft'), :class => "stripped" %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class='field'>
|
||||
<div id='page-tabs' class='clearfix ui-tabs ui-widget ui-widget-content ui-corner-all'>
|
||||
<ul id='page_parts'>
|
||||
<li class='ui-state-default ui-state-active'>
|
||||
<%= link_to t('body', :scope => 'activerecord.attributes.refinery/blog_post'), "#page_part_body" %>
|
||||
<%= link_to t('body', :scope => 'activerecord.attributes.blog_post'), "#page_part_body" %>
|
||||
</li>
|
||||
<li class='ui-state-default'>
|
||||
<%= link_to t('teaser', :scope => 'activerecord.attributes.refinery/blog_post'), "#page_part_teaser" %>
|
||||
<%= link_to t('teaser', :scope => 'activerecord.attributes.blog_post'), "#page_part_teaser" %>
|
||||
</li>
|
||||
<% Refinery::Blog.tabs.each_with_index do |tab, tab_index| %>
|
||||
<li class='ui-state-default' id="custom_<%= tab.name %>_tab">
|
||||
|
@ -32,42 +30,52 @@
|
|||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
|
||||
<div id='page_part_editors'>
|
||||
|
||||
<% part_index = -1 %>
|
||||
<%= render 'form_part', :f => f, :part_index => (part_index += 1) -%>
|
||||
<%= render 'teaser_part', :f => f, :part_index => (part_index += 1) if f.object.respond_to?(:custom_teaser) -%>
|
||||
<%= render :partial => 'form_part',
|
||||
:locals => {
|
||||
:f => f,
|
||||
:part_index => (part_index += 1),
|
||||
} -%>
|
||||
<%= render :partial => 'teaser_part',
|
||||
:locals => {
|
||||
:f => f,
|
||||
:part_index => (part_index += 1),
|
||||
} if f.object.respond_to?(:custom_teaser) -%>
|
||||
<% Refinery::Blog.tabs.each_with_index do |tab, tab_index| %>
|
||||
<div class='page_part' id='<%= "custom_tab_#{tab_index}" %>'>
|
||||
<%= render tab.partial, :f => f %>
|
||||
<%= render :partial => tab.partial, :locals => {:f => f} %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class='field'>
|
||||
<%= f.label :tag_list, t('refinery.blog.shared.tags.title') -%>
|
||||
<%= f.label :tag_list, t('blog.shared.tags.title') -%>
|
||||
<%= f.text_field :tag_list, :class => 'larger' -%>
|
||||
</div>
|
||||
|
||||
|
||||
<div id='more_options_field'>
|
||||
<p>
|
||||
<%= link_to t('.advanced_options'), "#",
|
||||
:id => 'toggle_advanced_options',
|
||||
:title => t('.toggle_advanced_options') %>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
<div id='more_options' style="display:none;">
|
||||
<div class="hemisquare">
|
||||
<h3><%= t('title', :scope => 'refinery.blog.admin.submenu.categories') %></h3>
|
||||
<h3><%= t('title', :scope => 'admin.blog.submenu.categories') %></h3>
|
||||
<ul class='blog_categories'>
|
||||
<% @categories.each do |category| %>
|
||||
<% @blog_categories.each do |category| %>
|
||||
<li>
|
||||
<%= check_box_tag 'post[category_ids][]', category.id,
|
||||
@post.categories.include?(category),
|
||||
:id => (id="post_category_ids_#{category.id}") %>
|
||||
<%= label_tag 'post[category_ids][]', category.title,
|
||||
<%= check_box_tag 'blog_post[category_ids][]', category.id,
|
||||
@blog_post.categories.include?(category),
|
||||
:id => (id="blog_post_category_ids_#{category.id}") %>
|
||||
<%= label_tag 'blog_post[category_ids][]', category.title,
|
||||
:class => 'stripped',
|
||||
:for => id %>
|
||||
</li>
|
||||
|
@ -84,44 +92,19 @@
|
|||
<%= f.text_field :custom_url, :class => "widest" %>
|
||||
</div>
|
||||
|
||||
<div class='field'>
|
||||
<span class='label_with_help'>
|
||||
<%= f.label :source_url_title, t('.source_url_title') %>
|
||||
<%= refinery_help_tag t('.source_url_title_help') %>
|
||||
</span>
|
||||
<%= f.text_field :source_url_title, :class => "widest" %>
|
||||
</div>
|
||||
|
||||
<div class='field'>
|
||||
<span class='label_with_help'>
|
||||
<%= f.label :source_url, t('.source_url') %>
|
||||
<%= refinery_help_tag t('.source_url_help') %>
|
||||
</span>
|
||||
<%= f.text_field :source_url, :class => "widest" %>
|
||||
</div>
|
||||
|
||||
<div class='field'>
|
||||
<span class='label_with_help'>
|
||||
<%= f.label :user_id, t('.author') %>
|
||||
<%= refinery_help_tag t('.author_help') %>
|
||||
<br/>
|
||||
<%= f.collection_select :user_id, ::Refinery::User.all, :id, :username %>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class='hemisquare right_side'>
|
||||
<%= render '/seo_meta/form', :form => f %>
|
||||
<%= render :partial => '/seo_meta/form', :locals => {:form => f} %>
|
||||
</div>
|
||||
</div>
|
||||
<%= render :partial => "/refinery/admin/form_actions",
|
||||
<%= render :partial => "/shared/admin/form_actions",
|
||||
:locals => {
|
||||
:f => f,
|
||||
:continue_editing => true,
|
||||
:delete_title => t('delete', :scope => 'refinery.blog.admin.posts.post')
|
||||
:delete_title => t('delete', :scope => 'admin.blog.posts.post')
|
||||
} %>
|
||||
<% end -%>
|
||||
|
||||
<% content_for :stylesheets, stylesheet_link_tag('refinery/blog/backend') %>
|
||||
<% content_for :javascripts, javascript_include_tag('refinery/blog/backend') %>
|
||||
<%= render 'refinery/shared/admin/autocomplete', :dom_id => '#blog_post_tag_list', :url => refinery.tags_blog_admin_posts_url %>
|
||||
<% content_for :stylesheets, render(:partial => 'form.css') -%>
|
||||
<% content_for :javascripts, render(:partial => 'form.js') -%>
|
||||
<%= render 'shared/admin/autocomplete', :dom_id => '#blog_post_tag_list', :url => tags_admin_blog_posts_url %>
|
23
app/views/admin/blog/posts/_form.js.erb
Normal file
23
app/views/admin/blog/posts/_form.js.erb
Normal file
|
@ -0,0 +1,23 @@
|
|||
<script>
|
||||
(function($) {
|
||||
$(function() {
|
||||
$('#page-tabs').tabs();
|
||||
$('#copy_body_link').click(function(event) {
|
||||
// Find the WYMEditor that maps to the custom_teaser field
|
||||
var teaserTextArea = $('#blog_post_custom_teaser')[0];
|
||||
var teaserEditor = null;
|
||||
$.each(WYMeditor.INSTANCES, function(index, editor) {
|
||||
if (editor._element[0] == teaserTextArea) {
|
||||
teaserEditor = editor;
|
||||
}
|
||||
});
|
||||
|
||||
if (teaserEditor) {
|
||||
teaserEditor.html($('#blog_post_body').attr('value'));
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
</script>
|
24
app/views/admin/blog/posts/_post.html.erb
Normal file
24
app/views/admin/blog/posts/_post.html.erb
Normal file
|
@ -0,0 +1,24 @@
|
|||
<li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(post) -%>">
|
||||
<span class='title'>
|
||||
<%= post.title %>
|
||||
<span class="preview">
|
||||
<%= post.published_at.try(:strftime, '%b %d, %Y') || 'draft' %>
|
||||
<%= " by #{post.author.username}" if post.author.present? %>
|
||||
</span>
|
||||
</span>
|
||||
<% if post.draft? %>
|
||||
<span class="label notice">Draft</span>
|
||||
<% end %>
|
||||
<span class='actions'>
|
||||
<%= link_to refinery_icon_tag("application_go.png"), blog_post_url(post),
|
||||
:title => t('.view_live_html'),
|
||||
:target => "_blank" %>
|
||||
<%= link_to refinery_icon_tag("application_edit.png"), edit_admin_blog_post_path(post),
|
||||
:title => t('.edit') %>
|
||||
<%= link_to refinery_icon_tag("delete.png"), admin_blog_post_path(post),
|
||||
:class => "cancel confirm-delete",
|
||||
:title => t('.delete'),
|
||||
:method => :delete,
|
||||
:confirm => t('message', :scope => 'shared.admin.delete', :title => post.title) %>
|
||||
</span>
|
||||
</li>
|
|
@ -1,7 +1,7 @@
|
|||
<ul id='sortable_list'>
|
||||
<%= render :partial => 'post', :collection => @posts %>
|
||||
<%= render :partial => 'post', :collection => @blog_posts %>
|
||||
</ul>
|
||||
<%= render :partial => "/refinery/admin/sortable_list",
|
||||
<%= render :partial => "/shared/admin/sortable_list",
|
||||
:locals => {
|
||||
:continue_reordering => (defined?(continue_reordering) ? continue_reordering : true)
|
||||
} %>
|
|
@ -2,9 +2,9 @@
|
|||
<%= f.text_area :custom_teaser, :rows => 20, :class => 'wymeditor widest' -%>
|
||||
<p>
|
||||
<span class='clearfix label_inline_with_link'>
|
||||
<%= link_to t('copy_body', :scope => 'refinery.blog.admin.posts.form'), "#",
|
||||
<%= link_to t('copy_body', :scope => 'admin.blog.posts.form'), "#",
|
||||
:id => 'copy_body_link',
|
||||
:title => t('copy_body_help', :scope => 'refinery.blog.admin.posts.form') %>
|
||||
:title => t('copy_body_help', :scope => 'admin.blog.posts.form') %>
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
1
app/views/admin/blog/posts/edit.html.erb
Normal file
1
app/views/admin/blog/posts/edit.html.erb
Normal file
|
@ -0,0 +1 @@
|
|||
<%= render :partial => "form" %>
|
28
app/views/admin/blog/posts/index.html.erb
Normal file
28
app/views/admin/blog/posts/index.html.erb
Normal file
|
@ -0,0 +1,28 @@
|
|||
<%= render :partial => '/admin/blog/submenu' %>
|
||||
<div id='records'>
|
||||
<% if searching? %>
|
||||
<h2><%= t('results_for', :scope => 'shared.admin.search', :query => params[:search]) %></h2>
|
||||
<% if @blog_posts.any? %>
|
||||
<ul>
|
||||
<%= render :partial => "post",
|
||||
:collection => @blog_posts %>
|
||||
</ul>
|
||||
<% else %>
|
||||
<p><%= t('no_results', :scope => 'shared.admin.search') %></p>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if @blog_posts.any? %>
|
||||
<%= will_paginate @blog_posts %>
|
||||
|
||||
<%= render :partial => "sortable_list" %>
|
||||
|
||||
<%= will_paginate @blog_posts %>
|
||||
<% else %>
|
||||
<p>
|
||||
<strong>
|
||||
<%= t('.no_items_yet', :create => t('new', :scope => 'admin.blog.submenu.posts')) %>
|
||||
</strong>
|
||||
</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
1
app/views/admin/blog/posts/new.html.erb
Normal file
1
app/views/admin/blog/posts/new.html.erb
Normal file
|
@ -0,0 +1 @@
|
|||
<%= render :partial => "form" %>
|
26
app/views/admin/blog/posts/uncategorized.html.erb
Normal file
26
app/views/admin/blog/posts/uncategorized.html.erb
Normal file
|
@ -0,0 +1,26 @@
|
|||
<%= render :partial => '/admin/blog/submenu' %>
|
||||
<div id='records'>
|
||||
<% if searching? %>
|
||||
<h2><%= t('results_for', :scope => 'shared.admin.search', :query => params[:search]) %></h2>
|
||||
<% if @blog_posts.any? %>
|
||||
<%= render :partial => "blog_posts",
|
||||
:collection => @blog_posts %>
|
||||
<% else %>
|
||||
<p><%= t('search_no_results', :scope => 'admin') %></p>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if @blog_posts.any? %>
|
||||
<%= will_paginate @blog_posts %>
|
||||
|
||||
<%= render :partial => "sortable_list" %>
|
||||
|
||||
<%= will_paginate @blog_posts %>
|
||||
<% else %>
|
||||
<p>
|
||||
<strong>
|
||||
<%= t('.no_items_yet', :create => t('new', :scope => 'admin.blog.submenu.posts')) %>
|
||||
</strong>
|
||||
</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
|
@ -1,4 +1,4 @@
|
|||
<%= form_tag refinery.notification_recipients_blog_admin_settings_path do %>
|
||||
<%= form_tag do %>
|
||||
|
||||
<div class='field'>
|
||||
<span class='label_with_help'>
|
||||
|
@ -14,11 +14,11 @@
|
|||
<%= t('.example') %>
|
||||
</p>
|
||||
|
||||
<%= render :partial => "/refinery/admin/form_actions",
|
||||
<%= render :partial => "/shared/admin/form_actions",
|
||||
:locals => {
|
||||
:f => nil,
|
||||
:continue_editing => false,
|
||||
:cancel_url => refinery.blog_admin_posts_url,
|
||||
:cancel_url => admin_blog_posts_url,
|
||||
:hide_delete => true
|
||||
} %>
|
||||
<% end %>
|
21
app/views/blog/categories/show.html.erb
Normal file
21
app/views/blog/categories/show.html.erb
Normal file
|
@ -0,0 +1,21 @@
|
|||
<% content_for :body_content_title, @category.title %>
|
||||
|
||||
<% content_for :body_content_left do %>
|
||||
<% if @blog_posts.any? %>
|
||||
<section id="blog_posts">
|
||||
<%= render :partial => "/blog/shared/post", :collection => @blog_posts %>
|
||||
<%= will_paginate @blog_posts %>
|
||||
</section>
|
||||
<% else %>
|
||||
<p>
|
||||
<%= t('.no_posts') %>
|
||||
</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% content_for :body_content_right do %>
|
||||
<%= render :partial => "/blog/shared/categories" %>
|
||||
<% end %>
|
||||
|
||||
<%= render :partial => "/shared/content_page" %>
|
||||
<% content_for :stylesheets, stylesheet_link_tag('refinerycms-blog') %>
|
|
@ -12,6 +12,6 @@
|
|||
<%=raw t('.comment_ends') %>
|
||||
|
||||
<%=raw t('.closing_line') %>,
|
||||
<%=raw Refinery::Core.site_name %>
|
||||
<%=raw RefinerySetting[:site_name] %>
|
||||
|
||||
<%=raw t('.ps') %>
|
|
@ -3,8 +3,8 @@
|
|||
<%= simple_format auto_link(comment.message.to_s) %>
|
||||
<footer class='blog_comment_author'>
|
||||
<p>
|
||||
<%= t('by', :scope => 'refinery.blog.posts.comments', :who => comment.name) %>,
|
||||
<%= t('time_ago', :scope => 'refinery.blog.posts.comments', :time => time_ago_in_words(comment.created_at)) %>
|
||||
<%= t('by', :scope => 'blog.posts.comments', :who => comment.name) %>,
|
||||
<%= t('time_ago', :scope => 'blog.posts.comments', :time => time_ago_in_words(comment.created_at)) %>
|
||||
</p>
|
||||
</footer>
|
||||
</article>
|
11
app/views/blog/posts/_nav.html.erb
Normal file
11
app/views/blog/posts/_nav.html.erb
Normal file
|
@ -0,0 +1,11 @@
|
|||
<nav id="next_prev_article">
|
||||
<% if @blog_post.next.present? -%>
|
||||
<%= link_to (truncate(@blog_post.next.title) + " »").html_safe, @blog_post.next, :class => 'next' %>
|
||||
<% end -%>
|
||||
|
||||
<%= link_to t('blog_home', :scope => 'blog.posts.show'), blog_root_path, :class => 'home' %>
|
||||
|
||||
<% if @blog_post.prev.present? -%>
|
||||
<%= link_to ("« " + truncate(@blog_post.prev.title)).html_safe, @blog_post.prev, :class => 'prev' %>
|
||||
<% end -%>
|
||||
</nav><!-- /next_prev_article -->
|
20
app/views/blog/posts/archive.html.erb
Normal file
20
app/views/blog/posts/archive.html.erb
Normal file
|
@ -0,0 +1,20 @@
|
|||
<% content_for :body_content_left do %>
|
||||
<h1><%= t('.blog_archive_for', :date => @archive_date.strftime('%B %Y')) %></h1>
|
||||
<% if @blog_posts.any? %>
|
||||
<section id="blog_posts">
|
||||
<%= render :partial => "/blog/shared/post", :collection => @blog_posts %>
|
||||
</section>
|
||||
<% else %>
|
||||
<p><%= t('.no_blog_articles_posted', :date => @archive_date.strftime('%B %Y')) %></p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% content_for :body_content_right do %>
|
||||
<%= render :partial => "/blog/shared/categories" %>
|
||||
<%= render :partial => "/blog/shared/tags" %>
|
||||
<%= render :partial => "/blog/shared/rss_feed" %>
|
||||
<%= render :partial => "/blog/shared/archive_list" %>
|
||||
<% end %>
|
||||
|
||||
<%= render :partial => "/shared/content_page" %>
|
||||
<% content_for :stylesheets, stylesheet_link_tag('refinerycms-blog') %>
|
24
app/views/blog/posts/index.html.erb
Normal file
24
app/views/blog/posts/index.html.erb
Normal file
|
@ -0,0 +1,24 @@
|
|||
<% content_for :body_content_left do %>
|
||||
<%=raw @page[Page.default_parts.first.to_sym] if Page.default_parts.any? %>
|
||||
|
||||
<% if @blog_posts.any? %>
|
||||
<section id="blog_posts">
|
||||
<%= render :partial => "/blog/shared/post", :collection => @blog_posts %>
|
||||
<%= will_paginate @blog_posts %>
|
||||
</section>
|
||||
<% else %>
|
||||
<p><%= t('.no_blog_articles_yet') %></p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% content_for :body_content_right do %>
|
||||
<%=raw @page[Page.default_parts.second.to_sym] if Page.default_parts.many? %>
|
||||
|
||||
<%= render :partial => "/blog/shared/categories" %>
|
||||
<%= render :partial => "/blog/shared/tags" %>
|
||||
<%= render :partial => "/blog/shared/rss_feed" %>
|
||||
<%= render :partial => "/blog/shared/archive_list" %>
|
||||
<% end %>
|
||||
|
||||
<%= render :partial => "/shared/content_page" %>
|
||||
<% content_for :stylesheets, stylesheet_link_tag('refinerycms-blog') %>
|
17
app/views/blog/posts/index.rss.builder
Normal file
17
app/views/blog/posts/index.rss.builder
Normal file
|
@ -0,0 +1,17 @@
|
|||
xml.instruct! :xml, :version => "1.0"
|
||||
xml.rss :version => "2.0" do
|
||||
xml.channel do
|
||||
xml.title RefinerySetting.find_or_set(:site_name, "Company Name")
|
||||
xml.description RefinerySetting.find_or_set(:site_name, "Company Name") + " Blog Posts"
|
||||
xml.link blog_root_url
|
||||
|
||||
@blog_posts.each do |post|
|
||||
xml.item do
|
||||
xml.title post.title
|
||||
xml.description post.body
|
||||
xml.pubDate post.published_at.to_s(:rfc822)
|
||||
xml.link blog_post_url(post)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
98
app/views/blog/posts/show.html.erb
Normal file
98
app/views/blog/posts/show.html.erb
Normal file
|
@ -0,0 +1,98 @@
|
|||
<% content_for :body_content_left do %>
|
||||
<div id="show_blog_post">
|
||||
<% flash.each do |key, value| %>
|
||||
<div id='flash' class="flash flash_<%= key %>">
|
||||
<%= value %>
|
||||
</div>
|
||||
<% end %>
|
||||
<article id="blog_post">
|
||||
<header>
|
||||
<h1><%= @blog_post.title %></h1>
|
||||
<section class='details'>
|
||||
<time datetime="<%=l @blog_post.published_at.to_date, :format => :default %>" class='posted_at'>
|
||||
<%= t('created_at', :scope => 'blog.shared.posts', :when => l(@blog_post.published_at.to_date, :format => :short)) %>
|
||||
</time>
|
||||
<%= "#{t('by', :scope => 'blog.posts.show')} #{@blog_post.author.username}" if @blog_post.author.present? %>.
|
||||
<% if (categories = @blog_post.categories).any? %>
|
||||
<aside class='filed_in'>
|
||||
<%= t('filed_in', :scope => 'blog.posts.show') %>
|
||||
<% categories.each_with_index do |category, index| %>
|
||||
<%= link_to category.title, blog_category_url(category) -%><%= ',' if index < ((categories.length) - 1) %>
|
||||
<% end %>
|
||||
</aside>
|
||||
<% end %>
|
||||
</section>
|
||||
</header>
|
||||
<%= @blog_post.body.html_safe %>
|
||||
|
||||
<% if BlogPost::ShareThis.enabled? %>
|
||||
<span class="st_sharethis" displayText="ShareThis"></span>
|
||||
<% end %>
|
||||
</article>
|
||||
<%= render :partial => '/shared/draft_page_message' unless @blog_post.nil? or @blog_post.live? -%>
|
||||
<%= render 'nav' if next_or_previous?(@blog_post) %>
|
||||
|
||||
</div>
|
||||
|
||||
<% if BlogPost.comments_allowed? %>
|
||||
<aside id="comments">
|
||||
<h2><%= t('.comments.title') %></h2>
|
||||
<% if (comments = @blog_post.comments.approved).any? %>
|
||||
<%= render :partial => "comment", :collection => comments %>
|
||||
<% else %>
|
||||
<p>
|
||||
<%= t('none', :scope => 'blog.shared.comments') %>.
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<% flash.each do |key, value| %>
|
||||
<div id='flash' class="flash flash_<%= key %>">
|
||||
<%= value %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<h2><%= t('.comments.add') %></h2>
|
||||
<%= form_for [:blog_post, @blog_comment] do |f| %>
|
||||
<%= render :partial => "/shared/admin/error_messages",
|
||||
:locals => {
|
||||
:object => f.object,
|
||||
:include_object_name => true
|
||||
} %>
|
||||
<div class='field'>
|
||||
<%= f.label :name %>
|
||||
<%= f.text_field :name %>
|
||||
</div>
|
||||
<div class='field'>
|
||||
<%= f.label :email %>
|
||||
<%= f.email_field :email %>
|
||||
</div>
|
||||
<div class='field message_field'>
|
||||
<%= f.label :message %>
|
||||
<%= f.text_area :message, :rows => 6 %>
|
||||
</div>
|
||||
<div class='field form-actions'>
|
||||
<%= f.submit t('.submit') %>
|
||||
</div>
|
||||
<% end %>
|
||||
</aside>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% content_for :body_content_right do %>
|
||||
<%= render :partial => "/blog/shared/categories" %>
|
||||
<%= render :partial => "/blog/shared/tags" %>
|
||||
<%= render :partial => "/blog/shared/related_posts" %>
|
||||
<%= render :partial => "/blog/shared/rss_feed" %>
|
||||
<%= render :partial => "/blog/shared/archive_list" %>
|
||||
<% end %>
|
||||
|
||||
<%= render :partial => "/shared/content_page", :locals => { :remove_automatic_sections => true } %>
|
||||
|
||||
<% content_for :stylesheets, stylesheet_link_tag('refinerycms-blog') %>
|
||||
<% content_for :before_javascript_libraries, jquery_include_tags(:jquery_ui => false) %>
|
||||
<% content_for :javascripts do %>
|
||||
<%# enable AJAX'd post nav at your own risk until html5 history API implemented. %>
|
||||
<%#= javascript_include_tag('refinerycms-blog') %>
|
||||
<script src="http://w.sharethis.com/button/buttons.js"></script>
|
||||
<script>stLight.options({publisher:'<%= BlogPost::ShareThis.key %>'});</script>
|
||||
<% end if BlogPost::ShareThis.enabled? %>
|
22
app/views/blog/posts/tagged.html.erb
Normal file
22
app/views/blog/posts/tagged.html.erb
Normal file
|
@ -0,0 +1,22 @@
|
|||
<% content_for :body_content_title, "#{t('.posts_tagged')} “#{@tag_name.titleize}”".html_safe -%>
|
||||
|
||||
<% content_for :body_content_left do %>
|
||||
<% if @blog_posts.any? %>
|
||||
<section id="blog_posts">
|
||||
<%= render :partial => "/blog/shared/post", :collection => @blog_posts %>
|
||||
<%= will_paginate @blog_posts %>
|
||||
</section>
|
||||
<% else %>
|
||||
<p><%= t('.no_blog_articles_yet') %></p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% content_for :body_content_right do %>
|
||||
<%= render :partial => "/blog/shared/categories" %>
|
||||
<%= render :partial => "/blog/shared/tags" %>
|
||||
<%= render :partial => "/blog/shared/rss_feed" %>
|
||||
<%= render :partial => "/blog/shared/archive_list" %>
|
||||
<% end %>
|
||||
|
||||
<%= render :partial => "/shared/content_page" %>
|
||||
<% content_for :stylesheets, stylesheet_link_tag('refinerycms-blog') %>
|
9
app/views/blog/shared/_archive_list.html.erb
Normal file
9
app/views/blog/shared/_archive_list.html.erb
Normal file
|
@ -0,0 +1,9 @@
|
|||
<%
|
||||
archive_posts = blog_archive_list
|
||||
%>
|
||||
<% if archive_posts.present? %>
|
||||
<h2><%= t('archives', :scope => 'blog.shared') %></h2>
|
||||
<ul>
|
||||
<%= archive_posts %>
|
||||
</ul>
|
||||
<% end %>
|
|
@ -1,9 +1,9 @@
|
|||
<% if @categories.any? %>
|
||||
<% if @blog_categories.any? %>
|
||||
<h2><%= t('.title') %></h2>
|
||||
<ul id='categories'>
|
||||
<% @categories.each do |category| %>
|
||||
<% @blog_categories.each do |category| %>
|
||||
<li<%= " class='selected'" if @category.present? and @category.id == category.id %>>
|
||||
<%= link_to "#{category.title} (#{category.post_count})", refinery.blog_category_path(category) %>
|
||||
<%= link_to "#{category.title} (#{category.post_count})", blog_category_url(category) %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
46
app/views/blog/shared/_post.html.erb
Normal file
46
app/views/blog/shared/_post.html.erb
Normal file
|
@ -0,0 +1,46 @@
|
|||
<% if post.live? %>
|
||||
<article class="blog_post" id="<%= dom_id(post) %>">
|
||||
<header>
|
||||
<h1><%= link_to post.title, blog_post_url(post) %></h1>
|
||||
<section class='details'>
|
||||
<time datetime="<%=l post.published_at.to_date, :format => :default %>" class='posted_at'>
|
||||
<%= t('created_at', :scope => 'blog.shared.posts', :when => l(post.published_at.to_date, :format => :short)) %>
|
||||
</time>
|
||||
<%= "#{t('by', :scope => 'blog.posts.show')} #{post.author.username}" if post.author.present? %>.
|
||||
<% if (categories = post.categories).any? %>
|
||||
<aside class='filed_in'>
|
||||
<%= t('filed_in', :scope => 'blog.posts.show') %>
|
||||
<%=raw categories.collect { |category| link_to category.title, blog_category_url(category) }.to_sentence %>
|
||||
</aside>
|
||||
<% end %>
|
||||
<% if (tags = post.tags).any? %>
|
||||
<aside class='tagged'>
|
||||
<%= t('tagged', :scope => 'blog.posts.show') %>
|
||||
<%=raw tags.collect { |tag| link_to tag, tagged_posts_path(tag.id, tag.name.parameterize) }.to_sentence %>
|
||||
</aside>
|
||||
<% end %>
|
||||
</section>
|
||||
</header>
|
||||
<section class='clearfix'>
|
||||
<% if blog_post_teaser_enabled? %>
|
||||
<%= blog_post_teaser(post) %>
|
||||
<% else %>
|
||||
<%= post.body.html_safe %>
|
||||
<% end %>
|
||||
</section>
|
||||
<footer>
|
||||
<p>
|
||||
<%= link_to t('read_more', :scope => 'blog.shared.posts'), blog_post_url(post) if blog_post_teaser_enabled? %>
|
||||
</p>
|
||||
<aside class='comment_count'>
|
||||
<% if BlogPost.comments_allowed? %>
|
||||
<% if post.comments.any? %>
|
||||
(<%= pluralize(post.comments.approved.count, t('singular', :scope => 'blog.shared.comments')) %>)
|
||||
<% else %>
|
||||
(<%= t('none', :scope => 'blog.shared.comments') %>)
|
||||
<% end %>
|
||||
<% end %>
|
||||
</aside>
|
||||
</footer>
|
||||
</article>
|
||||
<% end %>
|
10
app/views/blog/shared/_related_posts.html.erb
Normal file
10
app/views/blog/shared/_related_posts.html.erb
Normal file
|
@ -0,0 +1,10 @@
|
|||
<% if @blog_posts.many? %>
|
||||
<h2><%= t('.other') %></h2>
|
||||
<ul id="blog_posts">
|
||||
<% @blog_posts.each do |blog_post| %>
|
||||
<li class='clearfix'>
|
||||
<%= link_to blog_post.title, blog_post_url(blog_post) %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
2
app/views/blog/shared/_rss_feed.html.erb
Normal file
2
app/views/blog/shared/_rss_feed.html.erb
Normal file
|
@ -0,0 +1,2 @@
|
|||
<h2><%= t('.title') %></h2>
|
||||
<%= link_to t('.subscribe'), blog_rss_feed_url, :id => "rss_feed_subscribe"%>
|
|
@ -2,7 +2,7 @@
|
|||
<h2><%= t('.title') %></h2>
|
||||
<nav id='tags'>
|
||||
<% tag_cloud(@tags, %w(tag1 tag2 tag3 tag4)) do |tag, css_class| %>
|
||||
<%= link_to tag.name, refinery.blog_tagged_posts_path(tag.id, tag.name.parameterize), :class => css_class %>
|
||||
<%= link_to tag.name, tagged_posts_path(tag.id, tag.name.parameterize), :class => css_class %>
|
||||
<% end %>
|
||||
</nav>
|
||||
<% end %>
|
|
@ -1 +0,0 @@
|
|||
<%= render "form" %>
|
|
@ -1,27 +0,0 @@
|
|||
<%= render '/refinery/blog/admin/submenu' %>
|
||||
<div id='records'>
|
||||
<% if searching? %>
|
||||
<h2><%= t('results_for', :scope => 'refinery.admin.search',
|
||||
:query => params[:search]) %></h2>
|
||||
<% if @categories.any? %>
|
||||
<%= render :partial => "blog_categories",
|
||||
:collection => @categories %>
|
||||
<% else %>
|
||||
<p><%= t('no_results', :scope => 'refinery.admin.search') %></p>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if @categories.any? %>
|
||||
<%= will_paginate @categories %>
|
||||
|
||||
<%= render "sortable_list" %>
|
||||
|
||||
<%= will_paginate @categories %>
|
||||
<% else %>
|
||||
<p>
|
||||
<strong>
|
||||
<%= t('.no_items_yet', :create => t('new', :scope => 'refinery.blog.admin.submenu.categories')) %>
|
||||
</strong>
|
||||
</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
|
@ -1 +0,0 @@
|
|||
<%= render "form" %>
|
|
@ -1,30 +0,0 @@
|
|||
<%= render '/refinery/blog/admin/submenu' %>
|
||||
<div id='records'>
|
||||
<% if searching? %>
|
||||
<h2><%= t('results_for', :scope => 'shared.admin.search', :query => params[:search]) %></h2>
|
||||
<% if @comments.any? %>
|
||||
<%= will_paginate @comments %>
|
||||
|
||||
<ul>
|
||||
<%= render :partial => "blog_comments",
|
||||
:collection => @comments %>
|
||||
</ul>
|
||||
|
||||
<%= will_paginate @comments %>
|
||||
<% else %>
|
||||
<p><%= t('search_no_results', :scope => 'admin') %></p>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if @comments.any? %>
|
||||
<%= will_paginate @comments %>
|
||||
|
||||
<%= render "sortable_list" %>
|
||||
|
||||
<%= will_paginate @comments %>
|
||||
<% else %>
|
||||
<h3>
|
||||
<%= t('.no_items_yet', :type => action_name.gsub('index', 'new').downcase) %>
|
||||
</h3>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
|
@ -1,63 +0,0 @@
|
|||
<div id='actions'>
|
||||
<h2><%= t('.details')%></h2>
|
||||
<p>
|
||||
<strong><%= t('.age') %>:</strong> <%= time_ago_in_words(@comment.created_at) %>
|
||||
</p>
|
||||
<h2><%= t('.actions') %></h2>
|
||||
<ul>
|
||||
<li>
|
||||
<%= link_to t('.back'), refinery.blog_admin_comments_path, :class => "back_icon" %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.reject'), refinery.rejected_blog_admin_comment_path(@comment, :return_to => 'rejected'),
|
||||
:class => 'comment_cross_icon' unless @comment.rejected? %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.approve'), refinery.approved_blog_admin_comment_path(@comment, :return_to => 'approved'),
|
||||
:class => 'comment_tick_icon' unless @comment.approved? %>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id='records'>
|
||||
<h2><%= t('.comment') %></h2>
|
||||
<table id='inquiry'>
|
||||
<tr>
|
||||
<td>
|
||||
<strong><%= t('.blog_post') %></strong>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to @comment.post.title,
|
||||
refinery.blog_post_path(@comment.post, :anchor => "comment-#{@comment.to_param}"),
|
||||
:target => '_blank' %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<strong><%= t('.from') %></strong>
|
||||
</td>
|
||||
<td>
|
||||
<%= @comment.name %> [<%= mail_to @comment.email, @comment.email, {:title => t('.click_to_email')} %>]
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<strong><%= t('.date') %></strong>
|
||||
</td>
|
||||
<td>
|
||||
<%= l(Date.parse(@comment.created_at.to_s), :format => :long) %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign='top'>
|
||||
<strong><%= t('.message') %></strong>
|
||||
</td>
|
||||
<td>
|
||||
<p style='margin-top: 0px'>
|
||||
<%= @comment.message.gsub("\r\n\r\n", "\r\n").gsub("\r\n", "</p><p>") %>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<% content_for :stylesheets, stylesheet_link_tag('refinery/blog/backend') %>
|
|
@ -1,25 +0,0 @@
|
|||
<li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(post) -%>">
|
||||
<span class='title'>
|
||||
<%= post.title %>
|
||||
<span class="preview">
|
||||
<%= " by #{post.author.username}" if post.author.present? %>
|
||||
<% if post.draft? %>
|
||||
<span class="label notice"><%= t('refinery.blog.admin.posts.post.draft') %></span>
|
||||
<% else %>
|
||||
<%= post.published_at.strftime('%b %d, %Y') %>
|
||||
<% end %>
|
||||
</span>
|
||||
</span>
|
||||
<span class='actions'>
|
||||
<%= link_to refinery_icon_tag("application_go.png"), refinery.blog_post_path(post),
|
||||
:title => t('.view_live_html'),
|
||||
:target => "_blank" %>
|
||||
<%= link_to refinery_icon_tag("application_edit.png"), refinery.edit_blog_admin_post_path(post),
|
||||
:title => t('.edit') %>
|
||||
<%= link_to refinery_icon_tag("delete.png"), refinery.blog_admin_post_path(post),
|
||||
:class => "cancel confirm-delete",
|
||||
:title => t('.delete'),
|
||||
:method => :delete,
|
||||
:confirm => t('message', :scope => 'refinery.admin.delete', :title => post.title) %>
|
||||
</span>
|
||||
</li>
|
|
@ -1 +0,0 @@
|
|||
<%= render "form" %>
|
|
@ -1,27 +0,0 @@
|
|||
<%= render '/refinery/blog/admin/submenu' %>
|
||||
<div id='records'>
|
||||
<% if searching? %>
|
||||
<h2><%= t('results_for', :scope => 'refinery.admin.search', :query => params[:search]) %></h2>
|
||||
<% if @posts.any? %>
|
||||
<ul>
|
||||
<%= render :partial => "post", :collection => @posts %>
|
||||
</ul>
|
||||
<% else %>
|
||||
<p><%= t('no_results', :scope => 'refinery.admin.search') %></p>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if @posts.any? %>
|
||||
<%= will_paginate @posts %>
|
||||
|
||||
<%= render "sortable_list" %>
|
||||
|
||||
<%= will_paginate @posts %>
|
||||
<% else %>
|
||||
<p>
|
||||
<strong>
|
||||
<%= t('.no_items_yet', :create => t('new', :scope => 'refinery.blog.admin.submenu.posts')) %>
|
||||
</strong>
|
||||
</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
|
@ -1 +0,0 @@
|
|||
<%= render "form" %>
|
|
@ -1,27 +0,0 @@
|
|||
<%= render '/refinery/blog/admin/submenu' %>
|
||||
<div id='records'>
|
||||
<% if searching? %>
|
||||
<h2><%= t('results_for', :scope => 'refinery.admin.search',
|
||||
:query => params[:search]) %></h2>
|
||||
<% if @posts.any? %>
|
||||
<%= render :partial => "blog_posts",
|
||||
:collection => @posts %>
|
||||
<% else %>
|
||||
<p><%= t('no_results', :scope => 'refinery.admin.search') %></p>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if @posts.any? %>
|
||||
<%= will_paginate @posts %>
|
||||
|
||||
<%= render "sortable_list" %>
|
||||
|
||||
<%= will_paginate @posts %>
|
||||
<% else %>
|
||||
<p>
|
||||
<strong>
|
||||
<%= t('.no_items_yet') %>
|
||||
</strong>
|
||||
</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
|
@ -1,21 +0,0 @@
|
|||
<% content_for :body_content_title, @category.title %>
|
||||
|
||||
<% content_for :body do %>
|
||||
<% if @posts.any? %>
|
||||
<section id="blog_posts">
|
||||
<%= render :partial => "/refinery/blog/shared/post", :collection => @posts %>
|
||||
<%= will_paginate @posts %>
|
||||
</section>
|
||||
<% else %>
|
||||
<p>
|
||||
<%= t('.no_posts') %>
|
||||
</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% content_for :side_body do %>
|
||||
<%= render "/refinery/blog/shared/categories" %>
|
||||
<% end %>
|
||||
|
||||
<%= render "/refinery/content_page" %>
|
||||
<% content_for :stylesheets, stylesheet_link_tag('refinery/blog/frontend') %>
|
|
@ -1,40 +0,0 @@
|
|||
<aside id="comments">
|
||||
<h2><%= t('title', :scope => 'refinery.blog.posts.show.comments') %></h2>
|
||||
<% if (comments = @post.comments.approved).any? %>
|
||||
<%= render :partial => "comment", :collection => comments %>
|
||||
<% else %>
|
||||
<p>
|
||||
<%= t('none', :scope => 'refinery.blog.shared.comments') %>.
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<% flash.each do |key, value| %>
|
||||
<div id='flash' class="flash flash_<%= key %>">
|
||||
<%= value %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<h2><%= t('add', :scope => 'refinery.blog.posts.show.comments') %></h2>
|
||||
<%= form_for [refinery, :blog, @comment] do |f| %>
|
||||
<%= render :partial => "/refinery/admin/error_messages",
|
||||
:locals => {
|
||||
:object => f.object,
|
||||
:include_object_name => true
|
||||
} %>
|
||||
<div class='field'>
|
||||
<%= f.label :name %>
|
||||
<%= f.text_field :name %>
|
||||
</div>
|
||||
<div class='field'>
|
||||
<%= f.label :email %>
|
||||
<%= f.email_field :email %>
|
||||
</div>
|
||||
<div class='field message_field'>
|
||||
<%= f.label :message %>
|
||||
<%= f.text_area :message, :rows => 6 %>
|
||||
</div>
|
||||
<div class='field form-actions'>
|
||||
<%= f.submit t('submit', :scope => 'refinery.blog.posts.show') %>
|
||||
</div>
|
||||
<% end %>
|
||||
</aside>
|
|
@ -1,17 +0,0 @@
|
|||
<nav id="next_prev_article">
|
||||
<% if @post.next.present? -%>
|
||||
<%= link_to (truncate(@post.next.title) + " »").html_safe,
|
||||
refinery.blog_post_path(@post.next),
|
||||
:class => 'next' %>
|
||||
<% end -%>
|
||||
|
||||
<%= link_to t('blog_home', :scope => 'refinery.blog.posts.show'),
|
||||
refinery.blog_root_path,
|
||||
:class => 'home' %>
|
||||
|
||||
<% if @post.prev.present? -%>
|
||||
<%= link_to ("« " + truncate(@post.prev.title)).html_safe,
|
||||
refinery.blog_post_path(@post.prev),
|
||||
:class => 'prev' %>
|
||||
<% end -%>
|
||||
</nav><!-- /next_prev_article -->
|
|
@ -1,37 +0,0 @@
|
|||
<% flash.each do |key, value| %>
|
||||
<div id='flash' class="flash flash_<%= key %>">
|
||||
<%= value %>
|
||||
</div>
|
||||
<% end %>
|
||||
<article id="blog_post">
|
||||
<header>
|
||||
<h1><%= @post.title %></h1>
|
||||
<section class='details'>
|
||||
<time datetime="<%=l @post.published_at.to_date, :format => :default %>" class='posted_at'>
|
||||
<%= t('created_at', :scope => 'refinery.blog.shared.posts', :when => l(@post.published_at.to_date, :format => :short)) %>
|
||||
</time>
|
||||
<%= content_tag(:div, "#{t('by', :scope => 'refinery.blog.posts.show')} #{@post.author.username}", :class => "blog_author") if @post.author.present? %>
|
||||
<% if @post.source_url.present? %>
|
||||
<div class='blog_source'>
|
||||
<%= "#{t('source', :scope => 'refinery.blog.posts.show')}: " %>
|
||||
<%= link_to (@post.source_url_title.blank? ? @post.source_url : @post.source_url_title), @post.source_url %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if (categories = @post.categories).any? %>
|
||||
<aside class='filed_in'>
|
||||
<%= t('filed_in', :scope => 'refinery.blog.posts.show') %>
|
||||
<% categories.each_with_index do |category, index| %>
|
||||
<%= link_to category.title, refinery.blog_category_path(category) -%><%= ',' if index < ((categories.length) - 1) %>
|
||||
<% end %>
|
||||
</aside>
|
||||
<% end %>
|
||||
</section>
|
||||
</header>
|
||||
<%= @post.body.html_safe %>
|
||||
|
||||
<% if Refinery::Blog::Post::ShareThis.enabled? %>
|
||||
<span class="st_sharethis" displayText="ShareThis"></span>
|
||||
<% end %>
|
||||
</article>
|
||||
<%= render '/refinery/draft_page_message' unless @post.nil? or @post.live? -%>
|
||||
<%= render 'nav' if next_or_previous?(@post) %>
|
|
@ -1,17 +0,0 @@
|
|||
<% content_for :title, "#{t('.blog_archive_for', :date => @archive_date.strftime('%B %Y'))}" %>
|
||||
|
||||
<% content_for :body do %>
|
||||
<h1><%= t('.blog_archive_for', :date => @archive_date.strftime('%B %Y')) %></h1>
|
||||
<% if @posts.any? %>
|
||||
<section id="blog_posts">
|
||||
<%= render :partial => "/refinery/blog/shared/post", :collection => @posts %>
|
||||
</section>
|
||||
<% else %>
|
||||
<p><%= t('.no_blog_articles_posted', :date => @archive_date.strftime('%B %Y')) %></p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= render '/refinery/blog/shared/body_content_right' %>
|
||||
|
||||
<%= render "/refinery/content_page" %>
|
||||
<% content_for :stylesheets, stylesheet_link_tag('refinery/blog/frontend') %>
|
|
@ -1,20 +0,0 @@
|
|||
<% content_for :body do %>
|
||||
<%= raw @page.content_for(Refinery::Pages.default_parts.first.to_sym) if Refinery::Pages.default_parts.any? %>
|
||||
|
||||
<% if @posts.any? %>
|
||||
<section id="blog_posts">
|
||||
<%= render :partial => "/refinery/blog/shared/post", :collection => @posts %>
|
||||
<%= will_paginate @posts %>
|
||||
</section>
|
||||
<% else %>
|
||||
<p><%= t('.no_blog_articles_yet') %></p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% content_for :side_body_prepend do -%>
|
||||
<%= raw @page.content_for(Refinery::Pages.default_parts.second.to_sym) %>
|
||||
<% end if Refinery::Pages.default_parts.many? -%>
|
||||
<%= render '/refinery/blog/shared/body_content_right' %>
|
||||
|
||||
<%= render "/refinery/content_page" %>
|
||||
<% content_for :stylesheets, stylesheet_link_tag('refinery/blog/frontend') %>
|
|
@ -1,17 +0,0 @@
|
|||
xml.instruct! :xml, :version => "1.0"
|
||||
xml.rss :version => "2.0" do
|
||||
xml.channel do
|
||||
xml.title Refinery::Core.site_name
|
||||
xml.description Refinery::Core.site_name + " Blog Posts"
|
||||
xml.link refinery.blog_root_url
|
||||
|
||||
@posts.each do |post|
|
||||
xml.item do
|
||||
xml.title post.title
|
||||
xml.description post.body
|
||||
xml.pubDate post.published_at.to_s(:rfc822)
|
||||
xml.link refinery.blog_post_url(post)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,21 +0,0 @@
|
|||
<% content_for :body do %>
|
||||
<div id="show_blog_post">
|
||||
<%= render 'post' %>
|
||||
</div>
|
||||
|
||||
<% if Refinery::Blog::Post.comments_allowed? %>
|
||||
<%= render 'comments'%>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= render '/refinery/blog/shared/body_content_right' %>
|
||||
|
||||
<%= render :partial => "/refinery/content_page", :locals => { :remove_automatic_sections => true } %>
|
||||
|
||||
<% content_for :stylesheets, stylesheet_link_tag('refinery/blog/frontend') %>
|
||||
<% content_for :javascripts do %>
|
||||
<%# enable AJAX'd post nav at your own risk until html5 history API implemented. %>
|
||||
<%#= javascript_include_tag('refinery/blog/frontend') %>
|
||||
<script src="http://w.sharethis.com/button/buttons.js"></script>
|
||||
<script>stLight.options({publisher:'<%= Refinery::Blog.share_this_key %>'});</script>
|
||||
<% end if Refinery::Blog::Post::ShareThis.enabled? %>
|
|
@ -1,19 +0,0 @@
|
|||
<% content_for :title, "#{t('.posts_tagged')} '#{@tag_name.titleize}'" %>
|
||||
|
||||
<% content_for :body_content_title, "#{t('.posts_tagged')} “#{@tag_name.titleize}”".html_safe -%>
|
||||
|
||||
<% content_for :body do %>
|
||||
<% if @posts.any? %>
|
||||
<section id="blog_posts">
|
||||
<%= render :partial => "/refinery/blog/shared/post", :collection => @posts %>
|
||||
<%= will_paginate @posts %>
|
||||
</section>
|
||||
<% else %>
|
||||
<p><%= t('.no_blog_articles_yet') %></p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= render '/refinery/blog/shared/body_content_right' %>
|
||||
|
||||
<%= render "/refinery/content_page" %>
|
||||
<% content_for :stylesheets, stylesheet_link_tag('refinery/blog/frontend') %>
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue