Skip to content

Commit

Permalink
Merge branch 'master' of github.com:fdv/typo
Browse files Browse the repository at this point in the history
  • Loading branch information
Frédéric de Villamil committed Jan 28, 2011
2 parents 95a939a + 3e4e193 commit 3231825
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 46 deletions.
15 changes: 0 additions & 15 deletions TODO.todo
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,11 @@ neuro for 6.0.2:
- New time display internationalization

mvz for 6.0.2
- fix bug 136: Clicking Save as draft in published article unpublishes it
- fix bug 193: Provide documentation on how to set up Typo on Debian and Ubuntu.
- avoid accidentally creating published articles with a permalink like draft-article-123
- continued clean-ups and spec improvements.
- Evaluate http://typogarden.org/brown-type.html
- Evaluate http://typogarden.org/lindholmen.html
- fix typo:xxx macros (flickr at minima)
- fix Akismet support. Stack trace at
NameError (uninitialized constant Feedback::Akismet):
app/models/feedback.rb:123:in `const_missing'
app/models/feedback.rb:123:in `akismet'
app/models/feedback.rb:130:in `akismet_is_spam?'
app/models/feedback.rb:129:in `akismet_is_spam?'
app/models/feedback.rb:104:in `classify'
app/models/feedback/states.rb:54:in `classify_content'
app/models/feedback/states.rb:62:in `before_save_handler'
lib/stateful.rb:65:in `__send__'
lib/stateful.rb:65:in `before_save_handler'
app/controllers/comments_controller.rb:18:in `create'


ook for 6.0.2
- enable category creation on the fly, in "write" tab (http://fdv.lighthouseapp.com/projects/11171/tickets/141-enable-category-creation-in-the-write-page)
Expand Down
11 changes: 4 additions & 7 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,6 @@ def reset_local_cache
@current_user = nil
end

# Helper method to get the blog object.
def this_blog
@blog ||= Blog.default
end

helper_method :this_blog

# The base URL for this request, calculated by looking up the URL for the main
# blog index page.
def blog_base_url
Expand All @@ -79,4 +72,8 @@ def add_to_cookies(name, value, path=nil, expires=nil)
cookies[name] = { :value => value, :path => path || "/#{controller_name}",
:expires => 6.weeks.from_now }
end

def this_blog
@blog ||= Blog.default
end
end
4 changes: 4 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,8 @@ def display_date_and_time(timestamp)
def js_distance_of_time_in_words_to_now(date)
display_date_and_time date
end

def this_blog
@blog ||= Blog.default
end
end
2 changes: 1 addition & 1 deletion app/models/redirect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Redirect < ActiveRecord::Base

def full_to_path
path = self.to_path
url_root = this_blog.root_path
url_root = Blog.default.root_path
path = url_root + path unless url_root.nil? or path[0,url_root.length] == url_root
path
end
Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class Application < Rails::Application
config.plugins = [ :localization, :prototype_legacy_helper, :all ]

config.autoload_paths += %W(
vendor/akismet
app/apis
).map {|dir| "#{::Rails.root.to_s}/#{dir}"}.select { |dir| File.directory?(dir) }

Expand Down Expand Up @@ -60,6 +59,7 @@ class Application < Rails::Application
require 'rails_patch/active_support'

require 'vendor/plugins/typo_login_system/lib/login_system'
require 'vendor/akismet/akismet'

Date::DATE_FORMATS.merge!(
:long_weekday => '%a %B %e, %Y %H:%M'
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/admin/pages_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe Admin::PagesController do
before do
Factory(:blog)
@blog = Factory(:blog)
request.session = { :user => users(:tobi).id }
end

Expand Down Expand Up @@ -39,7 +39,7 @@
assert_not_nil assigns(:page)

assert_equal users(:tobi), assigns(:page).user
assert_equal TextFilter.find_by_name(this_blog.text_filter), assigns(:page).text_filter
assert_equal TextFilter.find_by_name(@blog.text_filter), assigns(:page).text_filter

post :new, :page => { :name => "new_page", :title => "New Page Title",
:body => "Emphasis _mine_, arguments *strong*" }
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/articles_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@

describe ArticlesController, "previewing" do
render_views
before(:each) { Factory(:blog) }
before(:each) { @blog = Factory(:blog) }

describe 'with non logged user' do
before :each do
Expand All @@ -281,7 +281,7 @@

with_each_theme do |theme, view_path|
it "should render template #{view_path}/articles/read" do
this_blog.theme = theme if theme
@blog.theme = theme if theme
get :preview, :id => @article.id
response.should render_template('articles/read')
end
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/setup_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
specify { response.should redirect_to(:action => 'confirm') }

it "should correctly initialize blog and users" do
this_blog.blog_name.should == 'Foo'
Blog.default.blog_name.should == 'Foo'
admin = User.find_by_login("admin")
admin.should_not be_nil
admin.email.should == 'foo@bar.net'
Expand Down Expand Up @@ -75,7 +75,7 @@
specify { response.should redirect_to(:controller => 'articles', :action => 'index') }

it "should not initialize blog and users" do
this_blog.blog_name.should_not == 'Foo'
Blog.default.blog_name.should_not == 'Foo'
admin = User.find_by_login("admin")
admin.should be_nil
end
Expand Down
9 changes: 4 additions & 5 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

describe ApplicationHelper do
before(:each) { Factory(:blog) }
before(:each) { @blog = Factory(:blog) }
describe '#render_flash' do
it 'should render empty string if no flash' do
render_flash.should == ''
Expand Down Expand Up @@ -36,20 +36,19 @@

describe '#display_date' do
before(:each) {
Factory.create(:article, :body => "hello world and im herer")
@article = Article.find(:first)
@article = Factory.create(:article, :body => "hello world and im herer")
}

['%d/%m/%y', '%m/%m/%y', '%d %b %Y', '%b %d %Y'].each do |spec|
it "should return date with format #{spec}" do
this_blog.date_format = spec
@blog.date_format = spec
display_date(@article.published_at).should == @article.published_at.strftime(spec)
end
end

['%I:%M%p', '%H:%M', '%Hh%M'].each do |spec|
it "should return time with format #{spec}" do
this_blog.time_format = spec
@blog.time_format = spec
display_time(@article.published_at).should == @article.published_at.strftime(spec)
end
end
Expand Down
4 changes: 0 additions & 4 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ def assert_xml(xml)
end
end

def this_blog
Blog.default || Blog.create!
end

# test standard view and all themes
def with_each_theme
yield nil, ""
Expand Down
16 changes: 9 additions & 7 deletions spec/views/comments/html_sanitization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

shared_examples_for "CommentSanitization" do
before do
@blog = Factory(:blog)
@article = mock_model(Article, :created_at => Time.now, :published_at => Time.now)
Article.stub!(:find).and_return(@article)
this_blog.plugin_avatar = ''
this_blog.lang = 'en_US'
@blog.plugin_avatar = ''
@blog.lang = 'en_US'

prepare_comment

Expand All @@ -23,7 +24,7 @@ def prepare_comment

['', 'markdown', 'textile', 'smartypants', 'markdown smartypants'].each do |value|
it "Should sanitize content rendered with the #{value} textfilter" do
this_blog.comment_text_filter = value
@blog.comment_text_filter = value

render :file => 'comments/show'
rendered.should have_selector('.content')
Expand Down Expand Up @@ -119,11 +120,12 @@ def comment_options

shared_examples_for "CommentSanitizationWithDofollow" do
before do
@blog = Factory(:blog)
@article = mock_model(Article, :created_at => Time.now, :published_at => Time.now)
Article.stub!(:find).and_return(@article)
this_blog.plugin_avatar = ''
this_blog.lang = 'en_US'
this_blog.nofollowify = false
@blog.plugin_avatar = ''
@blog.lang = 'en_US'
@blog.nofollowify = false

prepare_comment

Expand All @@ -141,7 +143,7 @@ def prepare_comment

['', 'markdown', 'textile', 'smartypants', 'markdown smartypants'].each do |value|
it "Should sanitize content rendered with the #{value} textfilter" do
this_blog.comment_text_filter = value
@blog.comment_text_filter = value

render :file => 'comments/show'
rendered.should have_selector('.content')
Expand Down

0 comments on commit 3231825

Please sign in to comment.