typo 5.4 → 5.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/CHANGELOG +23 -30
  2. data/Typo users guide.pdf +0 -0
  3. data/app/controllers/admin/content_controller.rb +28 -36
  4. data/app/controllers/admin/tags_controller.rb +4 -4
  5. data/app/controllers/articles_controller.rb +119 -1
  6. data/app/controllers/comments_controller.rb +0 -7
  7. data/app/controllers/content_controller.rb +1 -0
  8. data/app/helpers/admin/content_helper.rb +9 -28
  9. data/app/helpers/admin/themes_helper.rb +4 -6
  10. data/app/helpers/articles_helper.rb +4 -0
  11. data/app/models/article.rb +21 -12
  12. data/app/models/blog.rb +0 -1
  13. data/app/models/category.rb +1 -6
  14. data/app/models/content.rb +10 -6
  15. data/app/models/feedback/states.rb +6 -6
  16. data/app/models/tag.rb +8 -8
  17. data/app/views/admin/content/_drafts.html.erb +1 -1
  18. data/app/views/admin/content/_form.html.erb +7 -4
  19. data/app/views/admin/content/index.html.erb +3 -3
  20. data/app/views/admin/feedback/index.html.erb +4 -4
  21. data/app/views/admin/settings/feedback.html.erb +8 -7
  22. data/app/views/admin/settings/write.html.erb +71 -72
  23. data/app/views/admin/tags/index.html.erb +4 -4
  24. data/app/views/admin/themes/editor.html.erb +13 -10
  25. data/app/views/articles/_article.html.erb +6 -4
  26. data/bin/typo +25 -0
  27. data/config/initializers/access_rules.rb +4 -0
  28. data/config/routes.rb +2 -2
  29. data/db/schema.rb +32 -26
  30. data/db/schema.sqlite3.sql +3 -0
  31. data/lang/fr_FR.rb +46 -44
  32. data/lib/tasks/release.rake +1 -1
  33. data/lib/typo_version.rb +1 -1
  34. data/public/images/admin/loading.gif +0 -0
  35. data/public/images/closelabel.gif +0 -0
  36. data/public/stylesheets/administration.css +28 -8
  37. data/spec/controllers/admin/content_controller_spec.rb +91 -7
  38. data/spec/controllers/articles_controller_spec.rb +209 -0
  39. data/spec/controllers/comments_controller_spec.rb +0 -17
  40. data/spec/controllers/xml_controller_spec.rb +0 -5
  41. data/spec/factories.rb +8 -3
  42. data/spec/models/article_spec.rb +31 -4
  43. data/spec/models/configuration_spec.rb +0 -4
  44. data/spec/models/user_spec.rb +13 -0
  45. data/spec/spec_helper.rb +13 -0
  46. data/spec/views/articles/index_spec.rb +9 -11
  47. data/spec/views/articles/read_spec.rb +3 -5
  48. data/test/fixtures/blogs.yml +0 -1
  49. data/themes/dirtylicious/views/articles/_article.html.erb +6 -4
  50. data/themes/scribbish/views/articles/_article.html.erb +6 -4
  51. data/themes/standard_issue/views/articles/_article.html.erb +6 -4
  52. data/themes/true-blue-3/views/articles/_article.html.erb +8 -6
  53. data/themes/true-blue-3/views/categories/_article.html.erb +1 -1
  54. data/themes/typographic/views/articles/_article.html.erb +7 -5
  55. metadata +6 -8
  56. data/app/controllers/admin/previews_controller.rb +0 -10
  57. data/app/controllers/previews_controller.rb +0 -10
  58. data/app/controllers/redirect_controller.rb +0 -143
  59. data/app/helpers/redirect_helper.rb +0 -13
  60. data/spec/controllers/previews_controller_spec.rb +0 -28
  61. data/spec/controllers/redirect_controller_spec.rb +0 -165
@@ -1,10 +0,0 @@
1
- class Admin::PreviewsController < Admin::BaseController
2
- before_filter :setup_themer
3
-
4
- def index
5
- @article = Article.find(params[:id])
6
-
7
- render :template => '/articles/read'
8
- end
9
-
10
- end
@@ -1,10 +0,0 @@
1
- class PreviewsController < ContentController
2
- before_filter :login_required
3
- layout :theme_layout
4
-
5
- def index
6
- @article = Article.find(params[:id])
7
-
8
- render :template => '/articles/read'
9
- end
10
- end
@@ -1,143 +0,0 @@
1
- class RedirectController < ContentController
2
- before_filter :verify_config
3
-
4
- layout :theme_layout
5
-
6
- cache_sweeper :blog_sweeper
7
-
8
- caches_page :redirect, :if => Proc.new {|c|
9
- c.request.query_string == ''
10
- }
11
-
12
- helper :'admin/base'
13
-
14
- def self.controller_path
15
- 'articles'
16
- end
17
-
18
- def redirect
19
- part = this_blog.permalink_format.split('/')
20
- part.delete('') # delete all par of / where no data. Avoid all // or / started
21
- params[:from].delete('')
22
- if params[:from].last =~ /\.atom$/
23
- params[:format] = 'atom'
24
- params[:from].last.gsub!(/\.atom$/, '')
25
- elsif params[:from].last =~ /\.rss$/
26
- params[:format] = 'rss'
27
- params[:from].last.gsub!(/\.rss$/, '')
28
- end
29
- zip_part = part.zip(params[:from])
30
- article_params = {}
31
- zip_part.each do |asso|
32
- ['%year%', '%month%', '%day%', '%title%'].each do |format_string|
33
- if asso[0] =~ /(.*)#{format_string}(.*)/
34
- before_format = $1
35
- after_format = $2
36
- next if asso[1].nil?
37
- result = asso[1].gsub(before_format, '')
38
- result.gsub!(after_format, '')
39
- article_params[format_string.gsub('%', '').to_sym] = result
40
- end
41
- end
42
- end
43
- begin
44
- @article = this_blog.requested_article(article_params)
45
- rescue
46
- #Not really good.
47
- # TODO :Check in request_article type of DATA made in next step
48
- end
49
- return show_article if @article
50
-
51
- # Redirect old version with /:year/:month/:day/:title to new format.
52
- # because it's change
53
- ["%year%/%month%/%day%/%title%".split('/'), "articles/%year%/%month%/%day%/%title%".split('/')].each do |part|
54
- part.delete('') # delete all par of / where no data. Avoid all // or / started
55
- params[:from].delete('')
56
- zip_part = part.zip(params[:from])
57
- article_params = {}
58
- zip_part.each do |asso|
59
- ['%year%', '%month%', '%day%', '%title%'].each do |format_string|
60
- if asso[0] =~ /(.*)#{format_string}(.*)/
61
- before_format = $1
62
- after_format = $2
63
- next if asso[1].nil?
64
- result = asso[1].gsub(before_format, '')
65
- result.gsub!(after_format, '')
66
- article_params[format_string.gsub('%', '').to_sym] = result
67
- end
68
- end
69
- end
70
- begin
71
- @article = this_blog.requested_article(article_params)
72
- rescue
73
- #Not really good.
74
- # TODO :Check in request_article type of DATA made in next step
75
- end
76
- if @article
77
- redirect_to @article.permalink_url, :status => 301
78
- return
79
- end
80
- end
81
-
82
-
83
- # see how manage all by this redirect to redirect in different possible
84
- # way maybe define in a controller in admin part in insert in this table
85
- r = Redirect.find_by_from_path(params[:from].join("/"))
86
-
87
- if(r)
88
- path = r.to_path
89
- url_root = self.class.relative_url_root
90
- path = url_root + path unless url_root.nil? or path[0,url_root.length] == url_root
91
- redirect_to path, :status => 301
92
- else
93
- render :text => "Page not found", :status => 404
94
- end
95
- end
96
-
97
-
98
- private
99
-
100
- # See an article We need define @article before
101
- def show_article
102
- @comment = Comment.new
103
- @page_title = @article.title
104
- article_meta
105
-
106
- auto_discovery_feed
107
- respond_to do |format|
108
- format.html { render :template => '/articles/read' }
109
- format.atom { render_feed('atom') }
110
- format.rss { render_feed('rss20') }
111
- format.xml { render_feed('atom') }
112
- end
113
- rescue ActiveRecord::RecordNotFound
114
- error("Post not found...")
115
- end
116
-
117
- def render_feed(type)
118
- render :partial => "/articles/#{type}_feed", :object => @article.published_feedback
119
- end
120
-
121
- def article_meta
122
- @keywords = ""
123
- @keywords << @article.categories.map { |c| c.name }.join(", ") << ", " unless @article.categories.empty?
124
- @keywords << @article.tags.map { |t| t.name }.join(", ") unless @article.tags.empty?
125
- @description = "#{@article.title}, "
126
- @description << @article.categories.map { |c| c.name }.join(", ") << ", " unless @article.categories.empty?
127
- @description << @article.tags.map { |t| t.name }.join(", ") unless @article.tags.empty?
128
- @description << " #{this_blog.blog_name}"
129
- end
130
-
131
- # Test in fist time if we need create some data
132
- # Use only in bootstraping
133
- def verify_config
134
- if User.count == 0
135
- redirect_to :controller => "accounts", :action => "signup"
136
- elsif ! this_blog.configured?
137
- redirect_to :controller => "admin/settings", :action => "redirect"
138
- else
139
- return true
140
- end
141
- end
142
-
143
- end
@@ -1,13 +0,0 @@
1
- module RedirectHelper
2
- def template_path
3
- 'articles'
4
- end
5
-
6
- def feed_rss
7
- @article.feed_url(:rss20)
8
- end
9
-
10
- def feed_atom
11
- @article.feed_url(:atom)
12
- end
13
- end
@@ -1,28 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
-
3
- describe PreviewsController do
4
- integrate_views
5
-
6
- describe 'index action' do
7
- describe 'with non logged user' do
8
- before :each do
9
- @request.session = {}
10
- get :index, :id => Factory(:article).id
11
- end
12
-
13
- it 'should be redirect to login' do
14
- response.should redirect_to(:controller => "accounts/login", :action => :index)
15
- end
16
- end
17
- describe 'with logged user' do
18
- before :each do
19
- @request.session = {:user => users(:tobi).id}
20
- get :index, :id => Factory(:article).id
21
- end
22
-
23
- it 'should render template /articles/read' do
24
- response.should render_template('articles/read.html.erb')
25
- end
26
- end
27
- end
28
- end
@@ -1,165 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
-
3
- describe RedirectController do
4
- before do
5
- ActionController::Base.relative_url_root = nil # avoid failures if environment.rb defines a relative URL root
6
- end
7
-
8
- it 'should split routing path' do
9
- assert_routing "foo/bar/baz", {
10
- :from => ["foo", "bar", "baz"],
11
- :controller => 'redirect', :action => 'redirect'}
12
- end
13
-
14
- it 'should redirect from articles_routing' do
15
- assert_routing "articles", {
16
- :from => ["articles"],
17
- :controller => 'redirect', :action => 'redirect'}
18
- assert_routing "articles/foo", {
19
- :from => ["articles", "foo"],
20
- :controller => 'redirect', :action => 'redirect'}
21
- assert_routing "articles/foo/bar", {
22
- :from => ["articles", "foo", "bar"],
23
- :controller => 'redirect', :action => 'redirect'}
24
- assert_routing "articles/foo/bar/baz", {
25
- :from => ["articles", "foo", "bar", "baz"],
26
- :controller => 'redirect', :action => 'redirect'}
27
- end
28
-
29
-
30
- it 'should redirect' do
31
- get :redirect, :from => ["foo", "bar"]
32
- assert_response 301
33
- assert_redirected_to "http://test.host/someplace/else"
34
- end
35
-
36
- it 'should redirect with url_root' do
37
- ActionController::Base.relative_url_root = "/blog"
38
- get :redirect, :from => ["foo", "bar"]
39
- assert_response 301
40
- assert_redirected_to "http://test.host/blog/someplace/else"
41
-
42
- get :redirect, :from => ["bar", "foo"]
43
- assert_response 301
44
- assert_redirected_to "http://test.host/blog/someplace/else"
45
- end
46
-
47
- it 'should no redirect' do
48
- get :redirect, :from => ["something/that/isnt/there"]
49
- assert_response 404
50
- end
51
-
52
- it 'should redirect to article' do
53
- get :redirect, :from => ["articles", "2004", "04", "01", "second-blog-article"]
54
- assert_response 301
55
- assert_redirected_to "http://myblog.net/2004/04/01/second-blog-article"
56
- end
57
-
58
- it 'should redirect to article with url_root' do
59
- b = blogs(:default)
60
- b.base_url = "http://test.host/blog"
61
- b.save
62
- get :redirect, :from => ["articles", "2004", "04", "01", "second-blog-article"]
63
- assert_response 301
64
- assert_redirected_to "http://test.host/blog/2004/04/01/second-blog-article"
65
- end
66
-
67
- it 'should redirect to article when url_root is articles' do
68
- b = blogs(:default)
69
- b.base_url = "http://test.host/articles"
70
- b.save
71
- get :redirect, :from => ["articles", "2004", "04", "01", "second-blog-article"]
72
- assert_response 301
73
- assert_redirected_to "http://test.host/articles/2004/04/01/second-blog-article"
74
- end
75
-
76
- it 'should redirect to article with articles in url_root' do
77
- b = blogs(:default)
78
- b.base_url = "http://test.host/aaa/articles/bbb"
79
- b.save
80
-
81
- get :redirect, :from => ["articles", "2004", "04", "01", "second-blog-article"]
82
- assert_response 301
83
- assert_redirected_to "http://test.host/aaa/articles/bbb/2004/04/01/second-blog-article"
84
- end
85
-
86
- describe 'with permalink_format like %title%.html' do
87
-
88
- integrate_views
89
-
90
- before(:each) do
91
- b = blogs(:default)
92
- b.permalink_format = '/%title%.html'
93
- b.save
94
- end
95
- describe 'render article' do
96
-
97
- integrate_views
98
-
99
- before(:each) do
100
- get :redirect, :from => ["#{contents(:article1).permalink}.html"]
101
- end
102
-
103
- it 'should render template read to article' do
104
- response.should render_template('articles/read.html.erb')
105
- end
106
-
107
- it 'should have good rss feed link' do
108
- response.should have_tag('head>link[href=?]', "http://myblog.net/#{contents(:article1).permalink}.html.rss")
109
- end
110
-
111
- it 'should have good atom feed link' do
112
- response.should have_tag('head>link[href=?]', "http://myblog.net/#{contents(:article1).permalink}.html.atom")
113
- end
114
-
115
- end
116
-
117
- it 'should get good article with utf8 slug' do
118
- get :redirect, :from => ['2004', '06', '02', 'ルビー']
119
- assigns(:article).should == contents(:utf8_article)
120
- end
121
-
122
- describe 'rendering as atom feed' do
123
- before(:each) do
124
- get :redirect, :from => ["#{contents(:article1).permalink}.html.atom"]
125
- end
126
-
127
- it 'should render atom partial' do
128
- response.should render_template('articles/_atom_feed.atom.builder')
129
- end
130
-
131
- it 'should render a valid feed' do
132
- assert_feedvalidator response.body
133
- end
134
- end
135
-
136
- describe 'rendering as rss feed' do
137
- before(:each) do
138
- get :redirect, :from => ["#{contents(:article1).permalink}.html.rss"]
139
- end
140
-
141
- it 'should render rss20 partial' do
142
- response.should render_template('articles/_rss20_feed.rss.builder')
143
- end
144
-
145
- it 'should render a valid feed' do
146
- assert_feedvalidator response.body
147
- end
148
- end
149
-
150
- describe 'rendering comment feed with problematic characters' do
151
- before(:each) do
152
- @comment = contents(:article1).comments.first
153
- @comment.body = "&eacute;coute! 4 < 2, non?"
154
- @comment.save!
155
- get :redirect, :from => ["#{contents(:article1).permalink}.html.atom"]
156
- end
157
-
158
- it 'should result in a valid atom feed' do
159
- assigns(:article).should == contents(:article1)
160
- assert_feedvalidator response.body
161
- end
162
- end
163
-
164
- end
165
- end