Compare commits
309 commits
1-x-stable
...
master
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d34735e1de | ||
![]() |
91114fd837 | ||
![]() |
81dd47e649 | ||
![]() |
30ea168afd | ||
![]() |
976b607ff5 | ||
![]() |
4e8e714099 | ||
![]() |
0bb265521c | ||
![]() |
67a177fbb1 | ||
![]() |
f4b647cc93 | ||
![]() |
c72d5d65f6 | ||
![]() |
ccf9c0e5c0 | ||
![]() |
92d5455d94 | ||
![]() |
86fa2d2f5d | ||
![]() |
6fa5bbdf33 | ||
![]() |
538e6653f0 | ||
![]() |
5577b8e701 | ||
![]() |
1cd514b3c9 | ||
![]() |
65f84593fa | ||
![]() |
ab1fa7ec32 | ||
![]() |
d1bfab99ce | ||
![]() |
69b9699fca | ||
![]() |
7e1b4831f1 | ||
![]() |
8f6007c2ba | ||
![]() |
976fafb9df | ||
![]() |
18065463e6 | ||
![]() |
8b8ce1f21b | ||
![]() |
dbeed9bb77 | ||
![]() |
70f7be1652 | ||
![]() |
9a150112ae | ||
![]() |
981fc6ef68 | ||
![]() |
d36af516ea | ||
![]() |
14cd410324 | ||
![]() |
3627b8f865 | ||
![]() |
cc6800d17e | ||
![]() |
3a1c30fa5d | ||
![]() |
8584cc942b | ||
![]() |
7f4ac3b6d4 | ||
![]() |
72375e0a00 | ||
![]() |
6df59131f1 | ||
![]() |
2a00257420 | ||
![]() |
cb88d9508e | ||
![]() |
dd3002f8bb | ||
![]() |
0c78cd138d | ||
![]() |
435763f307 | ||
![]() |
f8e38d516a | ||
![]() |
31bdd586f2 | ||
![]() |
96448fc374 | ||
![]() |
3049816aa9 | ||
![]() |
460351e81f | ||
![]() |
fccc86e63c | ||
![]() |
1a3e0d057c | ||
![]() |
0ea3690741 | ||
![]() |
52b1fce8aa | ||
![]() |
c6f36117a7 | ||
![]() |
6958ab82df | ||
![]() |
215ea87e45 | ||
![]() |
2e79e4f7a9 | ||
![]() |
9bcf2b3dda | ||
![]() |
70d8f46c12 | ||
![]() |
8edc3ab3dd | ||
![]() |
4e7847dcbe | ||
![]() |
594dd8ca96 | ||
![]() |
837ddfe42b | ||
![]() |
44ec487542 | ||
![]() |
bd2bcc0f2a | ||
![]() |
98f8d3f515 | ||
![]() |
d353cd556c | ||
![]() |
5eaad8997f | ||
![]() |
2537923034 | ||
![]() |
c9ff548329 | ||
![]() |
5ea1b7399b | ||
![]() |
f82d2c96e4 | ||
![]() |
aa729edc84 | ||
![]() |
c37461cc43 | ||
![]() |
5440fad815 | ||
![]() |
602759af1b | ||
![]() |
4f0b5f8223 | ||
![]() |
39fc086982 | ||
![]() |
29809838f4 | ||
![]() |
45cad84f49 | ||
![]() |
2bcb7c8551 | ||
![]() |
e05fedb9b7 | ||
![]() |
dee1a9d539 | ||
![]() |
f140ed284f | ||
![]() |
94ae01ce6f | ||
![]() |
922bc8b98f | ||
![]() |
aaf26e22d2 | ||
![]() |
80187eac7d | ||
![]() |
2275cde2ac | ||
![]() |
1af631b501 | ||
![]() |
34fd7b7b89 | ||
![]() |
6cfebfae84 | ||
![]() |
6d06af3400 | ||
![]() |
5691a96a9d | ||
![]() |
ba9091cd14 | ||
![]() |
5c3de1175f | ||
![]() |
e1d6605d23 | ||
![]() |
e63bf074af | ||
![]() |
0df8829a59 | ||
![]() |
1244370bc5 | ||
![]() |
c9e5edcf6d | ||
![]() |
82a929d60a | ||
![]() |
a85aaf6aaa | ||
![]() |
bd7daa09ae | ||
![]() |
76998c2885 | ||
![]() |
33bfa4dd23 | ||
![]() |
30ebf2d338 | ||
![]() |
adcf66751c | ||
![]() |
e46f0549c6 | ||
![]() |
2a672af348 | ||
![]() |
f9d51ed549 | ||
![]() |
44a059a475 | ||
![]() |
f8cd5804ad | ||
![]() |
d8bdcb482c | ||
![]() |
c89b4dfc1f | ||
![]() |
6b1fcc8ea1 | ||
![]() |
e274bb1757 | ||
![]() |
d1ad82d42e | ||
![]() |
f62ad53f8f | ||
![]() |
79a7551e73 | ||
![]() |
be73028ee8 | ||
![]() |
5eab0be340 | ||
![]() |
492fd663ca | ||
![]() |
ea2f177b0d | ||
![]() |
3abf537eaa | ||
![]() |
ad0b7f6ac8 | ||
![]() |
083fd20ee5 | ||
![]() |
3dbbbbfdda | ||
![]() |
4eb17bb58d | ||
![]() |
f77592bc05 | ||
![]() |
b1e4fd0094 | ||
![]() |
b3a25c1b68 | ||
![]() |
2a2fcca649 | ||
![]() |
889127a58c | ||
![]() |
d642260538 | ||
![]() |
becdbfaa9b | ||
![]() |
bbc6e90939 | ||
![]() |
63b0bec5ff | ||
![]() |
e3e5bcffc3 | ||
![]() |
7dd6cb5e60 | ||
![]() |
edfa8b81e7 | ||
![]() |
4a8a46ccc7 | ||
![]() |
d6e9af98ef | ||
![]() |
0eb88e2d95 | ||
![]() |
d108f9c5df | ||
![]() |
5e650f6800 | ||
![]() |
c84d887187 | ||
![]() |
223a719300 | ||
![]() |
fd0521bb99 | ||
![]() |
26243ddade | ||
![]() |
567bdd6334 | ||
![]() |
547c8bcff2 | ||
![]() |
de5c02994c | ||
![]() |
9a8d38ad78 | ||
![]() |
8cc819aeed | ||
![]() |
7c63d8188e | ||
![]() |
cc316ceb5b | ||
![]() |
04b49b2371 | ||
![]() |
3bef84c3f8 | ||
![]() |
3a7a9198a4 | ||
![]() |
c0cecdaad9 | ||
![]() |
9255e1a71e | ||
![]() |
d90c831cca | ||
![]() |
1d5dfb1fdd | ||
![]() |
92e8230194 | ||
![]() |
f9f56c6f1c | ||
![]() |
81475ff380 | ||
![]() |
f5d94d60b8 | ||
![]() |
36c005ecd1 | ||
![]() |
d18364d359 | ||
![]() |
9936281bb8 | ||
![]() |
a85b7ffab0 | ||
![]() |
151629f044 | ||
![]() |
c2a0ef9f41 | ||
![]() |
fd7ce5e692 | ||
![]() |
b1baeba3d2 | ||
![]() |
be06f1658d | ||
![]() |
3165574730 | ||
![]() |
4577f788e5 | ||
![]() |
e01e9ff9b7 | ||
![]() |
14daff297b | ||
![]() |
2b73c292c8 | ||
![]() |
5a958007c5 | ||
![]() |
8cd4a282d8 | ||
![]() |
0de4fd9582 | ||
![]() |
4ddc2b3754 | ||
![]() |
5dd11ffc61 | ||
![]() |
993b4a8b1b | ||
![]() |
db93751fd6 | ||
![]() |
1b3195bf30 | ||
![]() |
4ab9eccdee | ||
![]() |
64d83c5ce4 | ||
![]() |
eb487f0e4e | ||
![]() |
754cddb141 | ||
![]() |
85419ce88e | ||
![]() |
19ee4b8f69 | ||
![]() |
5e91670a80 | ||
![]() |
df0664b142 | ||
![]() |
8a69c623bb | ||
![]() |
1b51e2343d | ||
![]() |
362088d027 | ||
![]() |
be7d341532 | ||
![]() |
de4cc6b9ef | ||
![]() |
c40eb83af3 | ||
![]() |
d37ef11f63 | ||
![]() |
7fe5fe5de6 | ||
![]() |
66b445ad5c | ||
![]() |
76be452faf | ||
![]() |
65cb81b4c0 | ||
![]() |
cc3be37a41 | ||
![]() |
6be013e0c0 | ||
![]() |
d8f36a4196 | ||
![]() |
88556fe709 | ||
![]() |
f584651b58 | ||
![]() |
b9c44d851e | ||
![]() |
4d4ae4e682 | ||
![]() |
e35e3994d5 | ||
![]() |
ba38b63370 | ||
![]() |
3431b15ef3 | ||
![]() |
ec6ed3f951 | ||
![]() |
7903bdfed2 | ||
![]() |
40be4f71ee | ||
![]() |
6212e60f9e | ||
![]() |
80ca7c1bf9 | ||
![]() |
4439f6afda | ||
![]() |
0497261f39 | ||
![]() |
67cc6b4512 | ||
![]() |
2053a022a2 | ||
![]() |
fc68f22858 | ||
![]() |
1779274971 | ||
![]() |
05bc8bc962 | ||
![]() |
34e5da1347 | ||
![]() |
5e5c6a78af | ||
![]() |
2bd8df5d4f | ||
![]() |
372235b963 | ||
![]() |
0791d3a2e5 | ||
![]() |
2f695519da | ||
![]() |
9df6580d9c | ||
![]() |
36affef45e | ||
![]() |
6b73469c1a | ||
![]() |
d0681c273c | ||
![]() |
d8f82439eb | ||
![]() |
5e6f9bc270 | ||
![]() |
9363e8d8c5 | ||
![]() |
8434790df7 | ||
![]() |
028489bf15 | ||
![]() |
eaaa351f3a | ||
![]() |
aed0b8f173 | ||
![]() |
13cafc0947 | ||
![]() |
87bc12a1e4 | ||
![]() |
9b74f31a2a | ||
![]() |
cb2bcf387c | ||
![]() |
e70193ca11 | ||
![]() |
dbb02d953f | ||
![]() |
fbcf2bd34a | ||
![]() |
d0d5d9eb7d | ||
![]() |
7ae6e146b2 | ||
![]() |
83d407c8bb | ||
![]() |
eca7a1a591 | ||
![]() |
45d8663de5 | ||
![]() |
cfba1b86d1 | ||
![]() |
ad784342dd | ||
![]() |
87f478e664 | ||
![]() |
0516a2cc00 | ||
![]() |
82ca14af89 | ||
![]() |
ee215655cb | ||
![]() |
8bd056e3e8 | ||
![]() |
84a2fcdf08 | ||
![]() |
c3b7d0b1d2 | ||
![]() |
a23689a6aa | ||
![]() |
1c186d26d0 | ||
![]() |
c481c78afa | ||
![]() |
e85535da5f | ||
![]() |
d3eff64d19 | ||
![]() |
274ba14ea2 | ||
![]() |
13c35c2620 | ||
![]() |
00d71519a9 | ||
![]() |
5e24eeb3d2 | ||
![]() |
21b19db5a3 | ||
![]() |
3454a9c300 | ||
![]() |
fddcebd878 | ||
![]() |
476ad3f158 | ||
![]() |
806aef1858 | ||
![]() |
a86b7698a1 | ||
![]() |
999f9e7c0e | ||
![]() |
bd3591c6d1 | ||
![]() |
302c1ea05a | ||
![]() |
b70ed6de02 | ||
![]() |
28492b69e0 | ||
![]() |
dbedb27c04 | ||
![]() |
0f3be1a0b4 | ||
![]() |
6e2046f4b9 | ||
![]() |
0cf860f577 | ||
![]() |
f0c2eb9867 | ||
![]() |
a70ea17038 | ||
![]() |
17f08ab5cb | ||
![]() |
3475603f72 | ||
![]() |
106571cded | ||
![]() |
9d23338de2 | ||
![]() |
e0714c2ed0 | ||
![]() |
80048a6a31 | ||
![]() |
bba9d632d6 | ||
![]() |
d3da59e3f2 | ||
![]() |
109184377f | ||
![]() |
164dc27a42 | ||
![]() |
ded42bc691 | ||
![]() |
b5646a35c9 | ||
![]() |
06071e5580 | ||
![]() |
3fa8937b95 |
10
.gitignore
vendored
|
@ -14,6 +14,7 @@ doc/*
|
|||
*.autobackupbyrefinery.*
|
||||
/refinerycms-blog*.gem
|
||||
.autotest
|
||||
spec/dummy
|
||||
|
||||
# Mac
|
||||
.DS_Store
|
||||
|
@ -42,3 +43,12 @@ nbproject
|
|||
|
||||
# Capybara Bug
|
||||
capybara-*html
|
||||
|
||||
# rvm
|
||||
.rvmrc
|
||||
|
||||
#rbenv
|
||||
.rbenv-version
|
||||
|
||||
Gemfile.lock
|
||||
.rbx
|
1
.rspec
Normal file
|
@ -0,0 +1 @@
|
|||
--colour
|
20
.travis.yml
Normal file
|
@ -0,0 +1,20 @@
|
|||
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
|
73
Gemfile
|
@ -1,7 +1,70 @@
|
|||
source 'http://rubygems.org'
|
||||
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'
|
||||
|
||||
group :development, :test do
|
||||
gem 'sqlite3'
|
||||
gem 'mysql2'
|
||||
gem 'pg'
|
||||
end
|
||||
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'
|
||||
|
|
20
Guardfile
Normal file
|
@ -0,0 +1,20 @@
|
|||
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
Normal file
|
@ -0,0 +1,19 @@
|
|||
#!/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__)
|
Before Width: | Height: | Size: 512 B After Width: | Height: | Size: 512 B |
Before Width: | Height: | Size: 413 B After Width: | Height: | Size: 413 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 557 B After Width: | Height: | Size: 557 B |
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 110 B |
Before Width: | Height: | Size: 537 B After Width: | Height: | Size: 537 B |
Before Width: | Height: | Size: 668 B After Width: | Height: | Size: 668 B |
Before Width: | Height: | Size: 733 B After Width: | Height: | Size: 733 B |
Before Width: | Height: | Size: 635 B After Width: | Height: | Size: 635 B |
Before Width: | Height: | Size: 739 B After Width: | Height: | Size: 739 B |
Before Width: | Height: | Size: 663 B After Width: | Height: | Size: 663 B |
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 111 B |
Before Width: | Height: | Size: 689 B After Width: | Height: | Size: 689 B |
0
app/assets/images/refinerycms-blog/.gitkeep
Normal file
|
@ -47,4 +47,69 @@ $(document).ready(function(){
|
|||
}, $(this)));
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$(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();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function split( val ) {
|
||||
return val.split( /,\s*/ );
|
||||
}
|
||||
function extractLast( term ) {
|
||||
return split( term ).pop();
|
||||
}
|
||||
|
||||
page_options.init(false, '', '')
|
||||
|
||||
$('<%= dom_id %>').bind( "keydown", function( event ) {
|
||||
if ( event.keyCode === $.ui.keyCode.TAB && $( this ).data( "autocomplete" ).menu.active ) {
|
||||
event.preventDefault()
|
||||
}
|
||||
}).autocomplete({
|
||||
source: function( request, response ) {
|
||||
$.getJSON( "<%= url %>", {
|
||||
term: extractLast( request.term )
|
||||
}, response );
|
||||
},
|
||||
search: function() {
|
||||
// custom minLength
|
||||
var term = extractLast( this.value );
|
||||
if ( term.length < 2 ) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
focus: function() {
|
||||
// prevent value inserted on focus
|
||||
return false;
|
||||
},
|
||||
select: function( event, ui ) {
|
||||
var terms = split( this.value );
|
||||
// remove the current input
|
||||
terms.pop();
|
||||
// add the selected item
|
||||
terms.push( ui.item.value );
|
||||
// add placeholder to get the comma-and-space at the end
|
||||
terms.push( "" );
|
||||
this.value = terms.join( ", " );
|
||||
return false;
|
||||
}
|
||||
})
|
||||
});
|
0
app/assets/javascripts/refinerycms-blog/.gitkeep
Normal file
73
app/assets/stylesheets/refinery/blog/backend.css.scss
Normal file
|
@ -0,0 +1,73 @@
|
|||
.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;
|
||||
}
|
|
@ -22,7 +22,7 @@
|
|||
#rss_feed_subscribe {
|
||||
display: block;
|
||||
padding-left: 25px;
|
||||
background: url('/images/refinerycms-blog/rss-feed.png') no-repeat;
|
||||
background: image_url('refinery/blog/rss-feed.png') no-repeat;
|
||||
}
|
||||
#next_prev_article{
|
||||
overflow:hidden;
|
||||
|
@ -58,7 +58,7 @@
|
|||
.flash_notice, .flash_message {
|
||||
border: 1px solid #00A017;
|
||||
color: #00A017;
|
||||
background: 7px 7px no-repeat url('/images/refinery/icons/accept.png') #E0F5E0;
|
||||
background: 7px 7px no-repeat image_url('refinery/blog/icons/accept.png') #E0F5E0;
|
||||
}
|
||||
.flash_notice, .flash_notice * {
|
||||
color: #00A017;
|
||||
|
@ -66,7 +66,7 @@
|
|||
.flash_error {
|
||||
border: 1px solid #A00027;
|
||||
color: #A00027;
|
||||
background: 7px 7px no-repeat url('/images/refinery/icons/cancel.png') #FFB1B1;
|
||||
background: 7px 7px no-repeat image_url('refinery/blog/icons/cancel.png') #FFB1B1;
|
||||
}
|
||||
.flash.flash_notice #flash_close, .flash.flash_error #flash_close {
|
||||
text-transform: lowercase;
|
Before Width: | Height: | Size: 260 B After Width: | Height: | Size: 260 B |
Before Width: | Height: | Size: 251 B After Width: | Height: | Size: 251 B |
Before Width: | Height: | Size: 178 B After Width: | Height: | Size: 178 B |
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 104 B |
Before Width: | Height: | Size: 125 B After Width: | Height: | Size: 125 B |
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 105 B |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 90 B After Width: | Height: | Size: 90 B |
Before Width: | Height: | Size: 129 B After Width: | Height: | Size: 129 B |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
0
app/assets/stylesheets/refinerycms-blog/.gitkeep
Normal file
0
app/controllers/.gitkeep
Normal file
|
@ -1,11 +0,0 @@
|
|||
module Admin
|
||||
module Blog
|
||||
class CategoriesController < Admin::BaseController
|
||||
|
||||
crudify :blog_category,
|
||||
:title_attribute => :title,
|
||||
:order => 'title ASC'
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,40 +0,0 @@
|
|||
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
|
|
@ -1,97 +0,0 @@
|
|||
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
|
|
@ -1,53 +0,0 @@
|
|||
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
|
|
@ -1,13 +0,0 @@
|
|||
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
|
|
@ -1,109 +0,0 @@
|
|||
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
|
|
@ -1,16 +0,0 @@
|
|||
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
|
12
app/controllers/refinery/blog/admin/categories_controller.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
module Refinery
|
||||
module Blog
|
||||
module Admin
|
||||
class CategoriesController < ::Refinery::AdminController
|
||||
|
||||
crudify :'refinery/blog/category',
|
||||
:order => 'title ASC'
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
49
app/controllers/refinery/blog/admin/comments_controller.rb
Normal file
|
@ -0,0 +1,49 @@
|
|||
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
|
90
app/controllers/refinery/blog/admin/posts_controller.rb
Normal file
|
@ -0,0 +1,90 @@
|
|||
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
|
55
app/controllers/refinery/blog/admin/settings_controller.rb
Normal file
|
@ -0,0 +1,55 @@
|
|||
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
|
17
app/controllers/refinery/blog/blog_controller.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
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
|
12
app/controllers/refinery/blog/categories_controller.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
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
|
85
app/controllers/refinery/blog/posts_controller.rb
Normal file
|
@ -0,0 +1,85 @@
|
|||
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
|
0
app/helpers/.gitkeep
Normal file
|
@ -1,59 +0,0 @@
|
|||
module BlogPostsHelper
|
||||
def blog_archive_list
|
||||
posts = BlogPost.select('published_at').all_previous
|
||||
return nil if posts.blank?
|
||||
html = '<section id="blog_archive_list"><h2>'
|
||||
html << t('archives', :scope => 'blog.shared')
|
||||
html << '</h2><nav><ul>'
|
||||
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.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.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 << '</ul></nav></section>'
|
||||
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
|
29
app/helpers/refinery/blog/controller_helper.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
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
|
72
app/helpers/refinery/blog/posts_helper.rb
Normal file
|
@ -0,0 +1,72 @@
|
|||
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
|
|
@ -1,13 +0,0 @@
|
|||
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
|
14
app/mailers/refinery/blog/comment_mailer.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
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
|
0
app/models/.gitkeep
Normal file
|
@ -1 +0,0 @@
|
|||
require File.expand_path('../../../mailers/blog/comment_mailer', __FILE__)
|
|
@ -1,19 +0,0 @@
|
|||
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
|
|
@ -1,131 +0,0 @@
|
|||
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 = {})
|
||||
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 = 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
|
|
@ -1,114 +0,0 @@
|
|||
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
|
|
@ -1,7 +0,0 @@
|
|||
class Categorization < ActiveRecord::Base
|
||||
|
||||
set_table_name 'blog_categories_blog_posts'
|
||||
belongs_to :blog_post
|
||||
belongs_to :blog_category
|
||||
|
||||
end
|
25
app/models/refinery/blog/category.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
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
|
135
app/models/refinery/blog/comment.rb
Normal file
|
@ -0,0 +1,135 @@
|
|||
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
|
120
app/models/refinery/blog/post.rb
Normal file
|
@ -0,0 +1,120 @@
|
|||
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
|
10
app/models/refinery/categorization.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
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
|
26
app/sweepers/refinery/blog_sweeper.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
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
|
0
app/views/.gitkeep
Normal file
|
@ -1 +0,0 @@
|
|||
<%= render :partial => "form" %>
|
|
@ -1,26 +0,0 @@
|
|||
<%= 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 +0,0 @@
|
|||
<%= render :partial => "form" %>
|
|
@ -1,35 +0,0 @@
|
|||
<%= 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>
|
|
@ -1,63 +0,0 @@
|
|||
<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') %>
|
|
@ -1,20 +0,0 @@
|
|||
<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,23 +0,0 @@
|
|||
<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>
|
|
@ -1,21 +0,0 @@
|
|||
<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>
|
||||
<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 +0,0 @@
|
|||
<%= render :partial => "form" %>
|
|
@ -1,28 +0,0 @@
|
|||
<%= 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 +0,0 @@
|
|||
<%= render :partial => "form" %>
|
|
@ -1,26 +0,0 @@
|
|||
<%= 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,21 +0,0 @@
|
|||
<% 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') %>
|
|
@ -1,11 +0,0 @@
|
|||
<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 -->
|
|
@ -1,31 +0,0 @@
|
|||
<% 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) %>
|
|
@ -1,20 +0,0 @@
|
|||
<% 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" %>
|
||||
<%= blog_archive_list %>
|
||||
<% end %>
|
||||
|
||||
<%= render :partial => "/shared/content_page" %>
|
||||
<% content_for :stylesheets, stylesheet_link_tag('refinerycms-blog') %>
|
|
@ -1,24 +0,0 @@
|
|||
<% 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" %>
|
||||
<%= blog_archive_list %>
|
||||
<% end %>
|
||||
|
||||
<%= render :partial => "/shared/content_page" %>
|
||||
<% content_for :stylesheets, stylesheet_link_tag('refinerycms-blog') %>
|
|
@ -1,17 +0,0 @@
|
|||
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
|
|
@ -1,67 +0,0 @@
|
|||
<% content_for :body_content_left do %>
|
||||
<div id="show_blog_post">
|
||||
<%= render '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/posts" %>
|
||||
<%= render :partial => "/blog/shared/rss_feed" %>
|
||||
<%= blog_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? %>
|
|
@ -1,22 +0,0 @@
|
|||
<% 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" %>
|
||||
<%= blog_archive_list %>
|
||||
<% end %>
|
||||
|
||||
<%= render :partial => "/shared/content_page" %>
|
||||
<% content_for :stylesheets, stylesheet_link_tag('refinerycms-blog') %>
|
|
@ -1,46 +0,0 @@
|
|||
<% 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 %>
|
|
@ -1,10 +0,0 @@
|
|||
<% 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 %>
|
|
@ -1,2 +0,0 @@
|
|||
<h2><%= t('.title') %></h2>
|
||||
<%= link_to t('.subscribe'), blog_rss_feed_url, :id => "rss_feed_subscribe"%>
|
|
@ -1,9 +1,9 @@
|
|||
<nav id='actions' class='multilist'>
|
||||
<ul class='search_list'>
|
||||
<li class='not_a_link'>
|
||||
<%= render :partial => "/shared/admin/search",
|
||||
<%= render :partial => "/refinery/admin/search",
|
||||
:locals => {
|
||||
:url => admin_blog_posts_url
|
||||
:url => refinery.blog_admin_posts_path
|
||||
} %>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -14,23 +14,23 @@
|
|||
:class => 'page_copy_icon' %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.posts.manage'), admin_blog_posts_path,
|
||||
<%= link_to t('.posts.manage'), refinery.blog_admin_posts_path,
|
||||
:class => 'page_icon' %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.posts.uncategorized'), uncategorized_admin_blog_posts_url,
|
||||
<%= link_to t('.posts.uncategorized'), refinery.uncategorized_blog_admin_posts_path,
|
||||
:class => 'page_icon' %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.posts.new'), new_admin_blog_post_url,
|
||||
<%= link_to t('.posts.new'), refinery.new_blog_admin_post_path,
|
||||
:class => 'page_add_icon' %>
|
||||
</li>
|
||||
</ul>
|
||||
<% if BlogPost.comments_allowed? %>
|
||||
<% if Refinery::Blog::Post.comments_allowed? %>
|
||||
<ul class='collapsible_menu'>
|
||||
<li class='not_a_link'>
|
||||
<% if BlogComment.unmoderated.any? %>
|
||||
<% title = t('.comments.title_with_count', :new_count => BlogComment.unmoderated.size) %>
|
||||
<% if Refinery::Blog::Comment.unmoderated.any? %>
|
||||
<% title = t('.comments.title_with_count', :new_count => Refinery::Blog::Comment.unmoderated.size) %>
|
||||
<% else %>
|
||||
<% title = t('.comments.title') %>
|
||||
<% end %>
|
||||
|
@ -38,15 +38,15 @@
|
|||
:class => 'comments_icon' %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.comments.new'), admin_blog_comments_path,
|
||||
<%= link_to t('.comments.new'), refinery.blog_admin_comments_path,
|
||||
:class => 'comment_icon' %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.comments.approved'), approved_admin_blog_comments_path,
|
||||
<%= link_to t('.comments.approved'), refinery.approved_blog_admin_comments_path,
|
||||
:class => 'comment_tick_icon' %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.comments.rejected'), rejected_admin_blog_comments_path,
|
||||
<%= link_to t('.comments.rejected'), refinery.rejected_blog_admin_comments_path,
|
||||
:class => 'comment_cross_icon' %>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -58,39 +58,39 @@
|
|||
:class => 'folder_icon' %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.categories.manage'), admin_blog_categories_url,
|
||||
<%= link_to t('.categories.manage'), refinery.blog_admin_categories_path,
|
||||
:class => 'folder_edit_icon' %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.categories.new'), new_admin_blog_category_url(:dialog => true, :height => 325),
|
||||
<%= link_to t('.categories.new'), refinery.new_blog_admin_category_path,
|
||||
:class => 'folder_add_icon' %>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class='collapsible_menu'>
|
||||
<li class='not_a_link'>
|
||||
<%= link_to t('.settings.title'), admin_blog_settings_path,
|
||||
<%= link_to t('.settings.title'), refinery.blog_admin_settings_path,
|
||||
:class => 'settings_icon' %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.settings.comments'), comments_admin_blog_settings_url,
|
||||
:class => "#{BlogPost.comments_allowed? ? 'success' : 'failure'}_icon" %>
|
||||
<%= link_to t('.settings.comments'), refinery.comments_blog_admin_settings_path,
|
||||
:class => "#{Refinery::Blog::Post.comments_allowed? ? 'success' : 'failure'}_icon" %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.settings.moderation'), moderation_admin_blog_settings_url,
|
||||
:class => "#{BlogComment::Moderation.enabled? ? 'success' : 'failure'}_icon" %>
|
||||
<%= link_to t('.settings.moderation'), refinery.moderation_blog_admin_settings_path,
|
||||
:class => "#{Refinery::Blog::Comment::Moderation.enabled? ? 'success' : 'failure'}_icon" %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.settings.update_notified'),
|
||||
notification_recipients_admin_blog_settings_url(:dialog => true, :height => 400),
|
||||
refinery.notification_recipients_blog_admin_settings_path(:dialog => true, :height => 400),
|
||||
:class => 'user_comment_icon' %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('.settings.teasers'),
|
||||
teasers_admin_blog_settings_url, :class => "#{BlogPost.teasers_enabled? ? 'success' : 'failure'}_icon" %>
|
||||
refinery.teasers_blog_admin_settings_path, :class => "#{Refinery::Blog::Post.teasers_enabled? ? 'success' : 'failure'}_icon" %>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</nav>
|
||||
|
||||
<% content_for :stylesheets, stylesheet_link_tag('refinery/refinerycms-blog')%>
|
||||
<% content_for :stylesheets, stylesheet_link_tag('refinery/blog/backend') %>
|
|
@ -5,12 +5,12 @@
|
|||
</span>
|
||||
<span class='actions'>
|
||||
<%= link_to refinery_icon_tag("application_edit.png"),
|
||||
edit_admin_blog_category_path(category, :dialog => true, :height => 325),
|
||||
refinery.edit_blog_admin_category_path(category, :dialog => true, :height => 325),
|
||||
:title => t('.edit') %>
|
||||
<%= link_to refinery_icon_tag("delete.png"), admin_blog_category_path(category),
|
||||
<%= link_to refinery_icon_tag("delete.png"), refinery.blog_admin_category_path(category),
|
||||
:class => "cancel confirm-delete",
|
||||
:title => t('.delete'),
|
||||
:method => :delete,
|
||||
:confirm => t('message', :scope => 'shared.admin.delete', :title => category.title) %>
|
||||
:confirm => t('message', :scope => 'refinery.admin.delete', :title => category.title) %>
|
||||
</span>
|
||||
</li>
|