Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GEM
remote: http://rubygems.org/
remote: https://rubygems.org/
specs:
RedCloth (4.2.9)
abstract (1.0.0)
Expand Down Expand Up @@ -205,3 +205,6 @@ DEPENDENCIES
thin
uuidtools (~> 2.1.1)
webrat

BUNDLED WITH
1.11.2
12 changes: 8 additions & 4 deletions app/controllers/admin/categories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ class Admin::CategoriesController < Admin::BaseController
def index; redirect_to :action => 'new' ; end
def edit; new_or_edit; end

def new
def new
respond_to do |format|
format.html { new_or_edit }
format.js {
format.js {
@category = Category.new
}
end
Expand All @@ -25,12 +25,16 @@ def destroy

def new_or_edit
@categories = Category.find(:all)
@category = Category.find(params[:id])
if params[:id].nil?
@category = Category.new
else
@category = Category.find(params[:id])
end
@category.attributes = params[:category]
if request.post?
respond_to do |format|
format.html { save_category }
format.js do
format.js do
@category.save
@article = Article.new
@article.categories << @category
Expand Down
22 changes: 16 additions & 6 deletions app/controllers/admin/content_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def auto_complete_for_article_keywords

def index
@search = params[:search] ? params[:search] : {}

@articles = Article.search_with_pagination(@search, {:page => params[:page], :per_page => this_blog.admin_display_elements})

if request.xhr?
Expand All @@ -37,14 +37,24 @@ def edit
new_or_edit
end

def reverse
@article = Article.find(params[:id])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This find method will return an error if it cannot find an Article with this ID so I don't think it would get to the next line. Consider using an alternate method to find.

text = @article.body
reverse_string = text.split.reverse!.join(" ")
@article.body = reverse_string
@article.save
redirect_to :action => 'index'
end


def destroy
@record = Article.find(params[:id])

unless @record.access_by?(current_user)
flash[:error] = _("Error, you are not allowed to perform this action")
return(redirect_to :action => 'index')
end

return(render 'admin/shared/destroy') unless request.post?

@record.destroy
Expand Down Expand Up @@ -77,7 +87,7 @@ def attachment_box_add

def attachment_save(attachment)
begin
Resource.create(:filename => attachment.original_filename, :mime => attachment.content_type.chomp,
Resource.create(:filename => attachment.original_filename, :mime => attachment.content_type.chomp,
:created_at => Time.now).write_to_disk(attachment)
rescue => e
logger.info(e.message)
Expand All @@ -92,7 +102,7 @@ def autosave
@article.text_filter = current_user.text_filter if current_user.simple_editor?

get_fresh_or_existing_draft_for_article

@article.attributes = params[:article]
@article.published = false
set_article_author
Expand Down Expand Up @@ -159,13 +169,13 @@ def new_or_edit
@article.keywords = Tag.collection_to_string @article.tags
@article.attributes = params[:article]
# TODO: Consider refactoring, because double rescue looks... weird.

@article.published_at = DateTime.strptime(params[:article][:published_at], "%B %e, %Y %I:%M %p GMT%z").utc rescue Time.parse(params[:article][:published_at]).utc rescue nil

if request.post?
set_article_author
save_attachments

@article.state = "draft" if @article.draft

if @article.save
Expand Down
3 changes: 2 additions & 1 deletion app/helpers/admin/base_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def subtab(label, options = {})
end

def show_page_heading
return if @page_heading.nil? or @page_heading.blank?
return if @page_heading.nil? or @page_heading.blank?
heading = "<div class='page-header'>"
heading << content_tag(:h2, @page_heading.html_safe)
heading << "</div>"
Expand Down Expand Up @@ -175,6 +175,7 @@ def show_actions item
html = <<-HTML
<div class='action'>
<small>#{link_to_published item}</small> |
<small>#{link_to _("Reverse"), :action => 'reverse', :id => item.id}</small> |
<small>#{link_to _("Edit"), :action => 'edit', :id => item.id}</small> |
<small>#{link_to _("Delete"), :action => 'destroy', :id => item.id}</small> |
#{get_short_url item}
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
# AuthorsController
match '/author/:id(.:format)', :to => 'authors#show', :format => /rss|atom/, :as => 'xml'
match '/author(/:id)', :to => 'authors#show', :format => false
get '/admin/article/:id/reverse', :to => 'articles#reverse', :format => false

# ThemesController
scope :controller => 'theme', :filename => /.*/ do
Expand Down
Binary file added db/db_development
Binary file not shown.
Binary file added db/db_test
Binary file not shown.
25 changes: 25 additions & 0 deletions features/add_edit_category.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Feature: Add and Edit Category
As an author
In order to know what each blog is about
I want to create categories

Background:
Given the blog is set up
And I am logged into the admin panel

Scenario: Successfully add category
When I follow "Categories"
And I should be on the new category page
When I fill in "Name" with "Baby Stuff"
And I press "Save"
Then I should be on the new category page
And I should see "Baby Stuff"


Scenario: Successfully edit a category
When I follow "Categories"
When I follow "Edit"
And I fill in "Name" with "Mommy Stuff"
And I press "Save"
Then I should be on the new category page
And I should see "Mommy Stuff"
22 changes: 22 additions & 0 deletions features/merge_articles.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Feature: Merge Articles
As a the admin
In order to condense similar articles
I want to be able to merge articles

Background:
Given the blog is set up
And I am logged into the admin panel

Scenario: Successfully merge articles
Given I am on the new article page
When I fill in "article_title" with "Merge me!"
And I fill in "article__body_and_extended_editor" with "I like tomato soup"
And I press "Publish"
Then I should be on the admin content page
When I go to the home page
Then I should see "Hello World!"
And I should see "Merge me!"
When I go to the new article page
And I fill in "merge" with "1"
And I follow "Merge"
Then I should be on the new article page
18 changes: 18 additions & 0 deletions features/reverse_article.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Feature: Reverse Article
As an author
In order to see the world in a different way
I want to reverse a blog

Background:
Given the blog is set up
And I am logged into the admin panel

Scenario: Successfully reverse articles
Given I am on the new article page
When I fill in "article_title" with "Test"
And I fill in "article__body_and_extended_editor" with "Pink shirt"
And I press "Publish"
Then I should be on the admin content page
When I follow "Reverse"
And I follow "Test"
Then I should see "shirt Pink"
4 changes: 4 additions & 0 deletions features/support/paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ def path_to(page_name)
'/'
when /^the new article page$/
'/admin/content/new'
when /^the new category page$/
'/admin/categories/new'
when /^the manage articles page$/
'/admin/content'

# Add more mappings here.
# Here is an example that pulls values out of the Regexp:
Expand Down
2 changes: 1 addition & 1 deletion public/javascripts/ckeditor/config.bak
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CKEDITOR.editorConfig = function( config )
config.PreserveSessionOnFileBrowser = true;
// Define changes to default configuration here. For example:
//config.language = '';
config.uiColor = '#E0ECFF';
config.uiColor = '#eee';
config.toolbar = 'Basic';
config.entities_greek = false;
config.entities_latin = false;
Expand Down
2 changes: 1 addition & 1 deletion public/javascripts/ckeditor/config.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CKEDITOR.editorConfig = function( config )
config.PreserveSessionOnFileBrowser = true;
// Define changes to default configuration here. For example:
//config.language = '';
config.uiColor = '#E0ECFF';
config.uiColor = '#eee';
config.toolbar = 'Basic';
config.entities_greek = false;
config.entities_latin = false;
Expand Down
11 changes: 9 additions & 2 deletions spec/controllers/admin/categories_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
assert_response :redirect, :action => 'index'
end

describe "new category" do
it "it should render new page" do
get :new
response.should render_template(:new)
end
end

describe "test_destroy with GET" do
before(:each) do
test_id = Factory(:category).id
Expand All @@ -48,7 +55,7 @@

it 'should render destroy template' do
assert_response :success
assert_template 'destroy'
assert_template 'destroy'
end
end

Expand All @@ -62,5 +69,5 @@

assert_raise(ActiveRecord::RecordNotFound) { Category.find(test_id) }
end

end
9 changes: 5 additions & 4 deletions spec/controllers/categories_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'spec_helper'


describe CategoriesController, "/index" do
before do
Factory(:blog)
Expand Down Expand Up @@ -73,14 +74,14 @@ def do_get
do_get
response.should render_template('articles/index')
end

it 'should render personal when template exists' do
pending "Stubbing #template_exists is not enough to fool Rails"
controller.stub!(:template_exists?) \
.and_return(true)
do_get
response.should render_template('personal')
end
end

it 'should show only published articles' do
do_get
Expand All @@ -94,7 +95,7 @@ def do_get

describe "when rendered" do
render_views

it 'should have a canonical URL' do
do_get
response.should have_selector('head>link[href="http://myblog.net/category/personal/"]')
Expand Down Expand Up @@ -154,7 +155,7 @@ def do_get

assert_tag :tag => "input",
:attributes => { :id => "article_password" }
end
end
end

describe CategoriesController, "SEO Options" do
Expand Down