public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
integrate experimental dispatcher

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2133 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Sun Sep 10 01:26:01 -0700 2006
commit  cf4c79b86baf1c9c35a3ac81c9bb1be0c1d3c679
tree    bcbc6d42ce377cff49931dd70a098c3ff850b2fd
parent  d4a1e3cddbe810effd5eef464b61103e5d49b32e
...
27
28
29
30
 
31
32
...
27
28
29
 
30
31
32
0
@@ -27,6 +27,6 @@ class AccountController < ApplicationController
0
     cookies.delete :auth_token
0
     reset_session
0
     flash[:notice] = "You have been logged out."
0
- redirect_back_or_default(:controller => 'mephisto', :action => 'list', :sections => [])
0
+ redirect_back_or_default(dispatch_path)
0
   end
0
 end
...
25
26
27
28
 
29
30
31
...
25
26
27
 
28
29
30
31
0
@@ -25,7 +25,7 @@ class Admin::ArticlesController < Admin::BaseController
0
     @article = site.articles.find(params[:id])
0
     @comments = @article.comments.collect &:to_liquid
0
     Mephisto::Liquid::CommentForm.article = @article
0
- @article = @article.to_liquid(:mode => :single)
0
+ @article = @article.to_liquid(:mode => :single, :site => site)
0
     
0
     render :text => site.render_liquid_for(site.sections.home, :single, 'articles' => [@article], 'article' => @article, 'comments' => @comments, 'site' => site.to_liquid)
0
   end
...
39
40
41
42
 
43
44
45
...
39
40
41
 
42
43
44
45
0
@@ -39,7 +39,7 @@ class ApplicationController < ActionController::Base
0
     
0
       if assigns['articles'] && assigns['article'].nil?
0
         self.cached_references += assigns['articles']
0
- assigns['articles'] = assigns['articles'].collect &:to_liquid
0
+ assigns['articles'] = assigns['articles'].collect { |a| a.to_liquid :site => site }
0
       end
0
 
0
       status = (assigns.delete(:status) || '200 OK')
...
1
2
3
 
 
 
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
 
 
 
 
 
64
65
66
67
68
69
70
71
72
73
 
 
74
75
76
77
78
 
 
79
80
81
82
 
 
 
83
84
85
...
88
89
90
91
92
93
94
 
 
 
95
96
97
98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
100
101
102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
104
105
106
 
 
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
...
1
2
 
3
4
5
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
8
9
10
11
12
13
14
 
 
 
 
 
 
 
15
16
17
 
 
 
 
18
19
20
 
 
 
21
22
23
24
25
26
...
29
30
31
 
 
 
 
32
33
34
35
36
 
 
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
 
 
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
 
 
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
0
@@ -1,85 +1,26 @@
0
 class MephistoController < ApplicationController
0
   session :off
0
- caches_page_with_references :list, :show, :date
0
+ caches_page_with_references :dispatch
0
+ cache_sweeper :comment_sweeper
0
+ observer :comment_observer
0
 
0
- def list
0
- if params[:sections].blank?
0
- @section = site.sections.home
0
- @section.show_paged_articles? ? show_section_page(nil) : list_section_articles
0
- else
0
- @section, page_name = site.sections.find_section_and_page_name(params[:sections].dup)
0
- @section ||= site.sections.home
0
- if @section.show_paged_articles?
0
- show_section_page(page_name)
0
- else
0
- show_404 and return unless page_name.blank?
0
- list_section_articles
0
- end
0
- end
0
- end
0
-
0
- def search
0
- conditions = ['(published_at IS NOT NULL AND published_at <= :now) AND (title LIKE :q OR excerpt LIKE :q OR body LIKE :q)',
0
- { :now => Time.now.utc, :q => "%#{params[:q]}%" }]
0
- search_count = site.articles.count(conditions)
0
- @article_pages = Paginator.new self, search_count, site.articles_per_page, params[:page]
0
- @articles = site.articles.find(:all, :conditions => conditions, :order => 'published_at DESC',
0
- :include => [:user, :sections],
0
- :limit => @article_pages.items_per_page,
0
- :offset => @article_pages.current.offset)
0
-
0
- render_liquid_template_for(:search, 'articles' => @articles,
0
- 'previous_page' => paged_search_url_for(@article_pages.current.previous),
0
- 'next_page' => paged_search_url_for(@article_pages.current.next),
0
- 'search_string' => params[:q],
0
- 'search_count' => search_count)
0
- end
0
-
0
- def show
0
- @article = site.articles.find_by_permalink(params[:year], params[:month], params[:day], params[:permalink])
0
- show_404 and return unless @article
0
- @comments = @article.comments.collect { |c| c.to_liquid }
0
- self.cached_references << @article
0
- Mephisto::Liquid::CommentForm.article = @article
0
- @article = @article.to_liquid(:mode => :single)
0
- render_liquid_template_for(:single, 'articles' => [@article], 'article' => @article, 'comments' => @comments)
0
- end
0
-
0
- def day
0
- @articles = site.articles.find_all_by_published_date(params[:year], params[:month], params[:day], :include => [:user, :sections])
0
- render_liquid_template_for(:archive, 'articles' => @articles)
0
- end
0
-
0
- def month
0
- count = site.articles.count_by_published_date(params[:year], params[:month], params[:day])
0
- @article_pages = Paginator.new self, count, site.articles_per_page, params[:page]
0
- @articles = site.articles.find_all_by_published_date(params[:year], params[:month], params[:day],
0
- :include => [:user, :sections],
0
- :limit => @article_pages.items_per_page,
0
- :offset => @article_pages.current.offset)
0
- render_liquid_template_for(:archive, 'articles' => @articles,
0
- 'archive_date' => @articles.first.published_at,
0
- 'previous_page' => paged_monthly_url_for(@article_pages.current.previous),
0
- 'next_page' => paged_monthly_url_for(@article_pages.current.next))
0
+ def dispatch
0
+ @dispatch_path = Mephisto::Dispatcher.run(site, params[:path].dup)
0
+ @dispatch_action = @dispatch_path.shift
0
+ @section = @dispatch_path.shift
0
+ @dispatch_action == :error ? show_404 : send("dispatch_#{@dispatch_action}")
0
   end
0
 
0
   protected
0
- def list_section_articles
0
- @article_pages = Paginator.new self, @section.articles.size, @section.articles_per_page, params[:page]
0
- @articles = @section.articles.find_by_date(
0
- :include => [:user],
0
- :limit => @article_pages.items_per_page,
0
- :offset => @article_pages.current.offset)
0
-
0
+ def dispatch_list
0
+ @articles = @section.articles.find_by_date(:include => :user)
0
       self.cached_references << @section
0
- render_liquid_template_for(:section, 'section' => @section.to_liquid(true),
0
- 'articles' => @articles,
0
- 'previous_page' => paged_section_url_for(@article_pages.current.previous),
0
- 'next_page' => paged_section_url_for(@article_pages.current.next))
0
+ render_liquid_template_for(:section, 'section' => @section.to_liquid(true),
0
+ 'articles' => @articles)
0
     end
0
-
0
- def show_section_page(page_name)
0
- @article = page_name.nil? ? @section.articles.find_by_position : @section.articles.find_by_permalink(page_name)
0
+
0
+ def dispatch_page
0
+ @article = @dispatch_path.empty? ? @section.articles.find_by_position : @section.articles.find_by_permalink(@dispatch_path.first)
0
       show_404 and return unless @article
0
     
0
       self.cached_references << @section << @article
0
@@ -88,21 +29,94 @@ class MephistoController < ApplicationController
0
       @section.articles.each_with_index do |article, i|
0
         articles << article.to_liquid(:page => i.zero?)
0
       end
0
- render_liquid_template_for(:page, 'section' => @section.to_liquid(true),
0
- 'pages' => articles,
0
- 'article' => @article.to_liquid(:mode => :single),
0
- 'article_sections' => @article.sections.collect(&:to_liquid))
0
+ render_liquid_template_for(:page, 'section' => @section.to_liquid(true),
0
+ 'pages' => articles,
0
+ 'article' => @article.to_liquid(:mode => :single, :site => site))
0
     end
0
 
0
- def paged_search_url_for(page)
0
- page ? search_url(:q => params[:q], :page => page) : ''
0
+ def dispatch_single
0
+ show_article
0
+ end
0
+
0
+ def dispatch_comments
0
+ show_404 and return unless find_article
0
+ if request.get? || params[:comment].blank?
0
+ redirect_to site.permalink_for(@article) and return
0
+ end
0
+
0
+ @comment = @article.comments.build(params[:comment].merge(:author_ip => request.remote_ip))
0
+
0
+ if @comment.valid?
0
+ @comment.approved = site.approve_comments?
0
+ if [:akismet_key, :akismet_url].all? { |attr| !site.send(attr).blank? }
0
+ @comment.approved = Akismet.new(site.akismet_key, site.akismet_url).comment_check \
0
+ :user_ip => @comment.author_ip,
0
+ :user_agent => request.user_agent,
0
+ :referrer => request.referer,
0
+ :permalink => "http://#{request.host_with_port}#{site.permalink_for(@article)}",
0
+ :comment_author => @comment.author,
0
+ :comment_author_email => @comment.author_email,
0
+ :comment_author_url => @comment.author_url,
0
+ :comment_content => @comment.body
0
+ logger.info "Checking Akismet (#{site.akismet_key}) for new comment on Article #{@article.id}. #{@comment.approved ? 'Approved' : 'Blocked'}"
0
+ end
0
+ end
0
+
0
+ @comment.save!
0
+ redirect_to dispatch_path(:path => (site.permalink_for(@article)[1..-1].split('/') << 'comments' << @comment.id.to_s), :anchor => @comment.dom_id)
0
+ rescue ActiveRecord::RecordInvalid
0
+ show_article_with 'errors' => @comment.errors.full_messages, 'submitted' => params[:comment]
0
+ rescue Article::CommentNotAllowed
0
+ show_article_with 'errors' => ["Commenting has been disabled on this article"]
0
     end
0
     
0
- def paged_monthly_url_for(page)
0
- page ? paged_monthly_url(:year => params[:year], :month => params[:month], :page => page) : ''
0
+ def dispatch_comment
0
+ show_article_with 'message' => 'Thanks for the comment!'
0
+ end
0
+
0
+ def dispatch_archives
0
+ @articles = site.articles.find_all_in_month(@dispatch_path.shift, @dispatch_path.shift, :include => :user)
0
+ render_liquid_template_for(:archive, 'articles' => @articles, 'archive_date' => @articles.first.published_at)
0
+ end
0
+
0
+ def dispatch_search
0
+ conditions = ['(published_at IS NOT NULL AND published_at <= :now) AND (title LIKE :q OR excerpt LIKE :q OR body LIKE :q)',
0
+ { :now => Time.now.utc, :q => "%#{params[:q]}%" }]
0
+ search_count = site.articles.count(conditions)
0
+ @article_pages = Paginator.new self, search_count, site.articles_per_page, params[:page]
0
+ @articles = site.articles.find(:all, :conditions => conditions, :order => 'published_at DESC',
0
+ :include => [:user, :sections],
0
+ :limit => @article_pages.items_per_page,
0
+ :offset => @article_pages.current.offset)
0
+
0
+ render_liquid_template_for(:search, 'articles' => @articles,
0
+ 'previous_page' => paged_search_url_for(@article_pages.current.previous),
0
+ 'next_page' => paged_search_url_for(@article_pages.current.next),
0
+ 'search_string' => params[:q],
0
+ 'search_count' => search_count)
0
     end
0
     
0
- def paged_section_url_for(page)
0
- page ? section_url(:sections => @section.to_url << 'page' << page) : ''
0
+ def dispatch_tags
0
+ raise NotImplementedError
0
     end
0
+
0
+ def paged_search_url_for(page)
0
+ page ? search_url(:q => params[:q], :page => page) : ''
0
+ end
0
+
0
+ def find_article
0
+ @article = site.articles.find_by_permalink(@dispatch_path.first)
0
+ end
0
+
0
+ def show_article_with(assigns = {})
0
+ find_article if @article.nil?
0
+ show_404 and return unless @article
0
+ @comments = @article.comments.reject(&:new_record?).collect(&:to_liquid)
0
+ self.cached_references << @article
0
+ Mephisto::Liquid::CommentForm.article = @article
0
+ @article = @article.to_liquid(:mode => :single, :site => site)
0
+ render_liquid_template_for(:single, assigns.merge('articles' => [@article], 'article' => @article, 'comments' => @comments))
0
+ end
0
+
0
+ alias show_article show_article_with
0
 end
...
65
66
67
68
69
70
71
72
73
74
75
 
 
 
 
 
 
 
76
77
78
79
80
81
82
 
83
84
85
86
87
88
89
90
91
92
93
 
94
95
96
...
116
117
118
 
119
120
121
...
65
66
67
 
 
 
 
 
 
 
 
68
69
70
71
72
73
74
75
 
 
 
 
 
 
76
77
78
79
80
81
 
 
 
 
 
 
82
83
84
85
...
105
106
107
108
109
110
111
0
@@ -65,32 +65,21 @@ class Article < Content
0
   end
0
 
0
   class << self
0
- def find_by_permalink(year, month, day, permalink, options = {})
0
- from, to = Time.delta(year, month, day)
0
- find :first, options.merge(:conditions => ["contents.published_at <= ? AND contents.permalink = ? AND contents.published_at BETWEEN ? AND ?",
0
- Time.now.utc, permalink, from, to])
0
- end
0
-
0
- def find_all_by_published_date(year, month, day = nil, options = {})
0
- from, to = Time.delta(year, month, day)
0
+ def find_all_in_month(year, month, options = {})
0
+ if year
0
+ month ||= '1'
0
+ else
0
+ year = Time.now.utc.year
0
+ month = Time.now.utc.month
0
+ end
0
       find(:all, options.merge(:order => 'contents.published_at DESC', :conditions => ["contents.published_at <= ? AND contents.published_at BETWEEN ? AND ?",
0
- Time.now.utc, from, to]))
0
- end
0
-
0
- def count_by_published_date(year, month, day = nil)
0
- from, to = Time.delta(year, month, day)
0
- count :all, :conditions => ["published_at <= ? AND published_at BETWEEN ? AND ?", Time.now.utc, from, to]
0
+ Time.now.utc, *Time.delta(year.to_i, month.to_i)]))
0
     end
0
   end
0
 
0
   [:year, :month, :day].each { |m| delegate m, :to => :published_at }
0
 
0
- # Follow Mark Pilgrim's rules on creating a good ID
0
- # http://diveintomark.org/archives/2004/05/28/howto-atom-id
0
- def guid
0
- "/#{self.class.to_s.underscore}#{full_permalink}"
0
- end
0
-
0
+ # AX
0
   def full_permalink
0
     published? && ['', published_at.year, published_at.month, published_at.day, permalink] * '/'
0
   end
0
@@ -116,6 +105,7 @@ class Article < Content
0
     write_attribute :filter, new_filter
0
   end
0
 
0
+ # AX
0
   def hash_for_permalink(options = {})
0
     [:year, :month, :day, :permalink].inject(options) { |o, a| o.update a => send(a) }
0
   end
...
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
...
67
68
69
70
 
71
72
73
...
31
32
33
 
 
 
 
 
 
 
 
 
 
 
 
34
35
36
...
55
56
57
 
58
59
60
61
0
@@ -31,18 +31,6 @@ class Section < ActiveRecord::Base
0
         block_given? ? yield : find(:all, options)
0
       end
0
     end
0
-
0
- # given a section name like ['about', 'site_map'], about is the section and site_map is a left over page_name
0
- # returns [<#Section: about>, 'site_map']
0
- def find_section_and_page_name(section_path)
0
- page_name = []
0
- section = nil
0
- while section.nil? && section_path.any?
0
- section = find_by_path(section_path.join('/'))
0
- page_name << section_path.pop if section.nil?
0
- end
0
- [section, page_name.any? ? page_name.join('/') : nil]
0
- end
0
 
0
     def articles_count
0
       Article.count :all, :group => :section_id, :joins => ARTICLES_COUNT_SQL
0
@@ -67,7 +55,7 @@ class Section < ActiveRecord::Base
0
   end
0
 
0
   def hash_for_url(options = {})
0
- { :sections => to_url }.merge(options)
0
+ { :path => to_url }.merge(options)
0
   end
0
 
0
   def home?
...
15
16
17
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
20
21
...
79
80
81
 
 
 
 
 
 
82
83
84
...
102
103
104
 
 
 
 
105
106
107
...
110
111
112
 
 
 
 
 
 
113
114
115
...
15
16
17
 
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
...
100
101
102
103
104
105
106
107
108
109
110
111
...
129
130
131
132
133
134
135
136
137
138
...
141
142
143
144
145
146
147
148
149
150
151
152
0
@@ -15,7 +15,28 @@ class Site < ActiveRecord::Base
0
     end
0
   end
0
 
0
- has_many :articles
0
+ has_many :articles do
0
+ def find_by_permalink(options)
0
+ conditions =
0
+ returning ["(contents.published_at IS NOT NULL AND contents.published_at <= ?)", Time.now.utc] do |cond|
0
+ if options[:year]
0
+ from, to = Time.delta(options[:year], options[:month], options[:day])
0
+ cond.first << ' AND (contents.published_at BETWEEN ? AND ?)'
0
+ cond << from << to
0
+ end
0
+
0
+ [:id, :permalink].each do |attr|
0
+ if options[attr]
0
+ cond.first << " AND (contents.#{attr} = ?)"
0
+ cond << options[attr]
0
+ end
0
+ end
0
+ end
0
+
0
+ find :first, :conditions => conditions
0
+ end
0
+ end
0
+
0
   has_many :events
0
   
0
   has_many :cached_pages
0
@@ -79,6 +100,12 @@ class Site < ActiveRecord::Base
0
     @permalink_regex
0
   end
0
 
0
+ def permalink_for(article)
0
+ permalink_slug.split('/').inject [''] do |s, piece|
0
+ s << (piece =~ PERMALINK_VAR && PERMALINK_OPTIONS.keys.include?($1) ? article.send($1).to_s : piece)
0
+ end.join('/')
0
+ end
0
+
0
   def accept_comments?
0
     comment_age.to_i > -1
0
   end
0
@@ -102,6 +129,10 @@ class Site < ActiveRecord::Base
0
   end
0
 
0
   protected
0
+ def permalink_variable?(var)
0
+ var =~ PERMALINK_VAR && PERMALINK_OPTIONS.keys.include?(var)
0
+ end
0
+
0
     def check_permalink_slug
0
       permalink_slug.sub! /^\//, ''
0
       permalink_slug.sub! /\/$/, ''
0
@@ -110,6 +141,12 @@ class Site < ActiveRecord::Base
0
       pieces.each do |p|
0
         errors.add :permalink_slug, "cannot contain '#{$1}' variable" if p =~ PERMALINK_VAR && !PERMALINK_OPTIONS.keys.include?($1)
0
       end
0
+ unless pieces.include?(':id') || pieces.include?(':permalink')
0
+ errors.add :permalink_slug, "must contain either :permalink or :id"
0
+ end
0
+ if !pieces.include?(':year') && (pieces.include?(':month') || pieces.include?(':day'))
0
+ errors.add :permalink_slug, "must contain :year for any date-based permalinks"
0
+ end
0
     end
0
 
0
     def downcase_host
...
2
3
4
5
 
6
7
8
9
10
11
 
12
13
14
...
2
3
4
 
5
6
7
8
9
10
 
11
12
13
14
0
@@ -2,13 +2,13 @@ xm.entry do
0
   xm.author do
0
     xm.name article.user.login
0
   end
0
- xm.id "tag:#{request.host},#{article.published_at.to_date.to_s :db}:#{article.guid}"
0
+ xm.id "tag:#{request.host_with_port},#{article.published_at.to_date.to_s :db}:#{article.id}"
0
   xm.published article.published_at.xmlschema
0
   xm.updated article.published_at.xmlschema
0
   article.sections.each do |section|
0
     xm.category "term" => section.name unless section.home?
0
   end
0
- xm.link "rel" => "alternate", "type" => "text/html", "href" => article_url(article.hash_for_permalink)
0
+ xm.link "rel" => "alternate", "type" => "text/html", "href" => "http://#{request.host_with_port}#{site.permalink_for(article)}"
0
   xm.title strip_tags(article.title)
0
   unless article.excerpt_html.blank?
0
     xm << %{<summary type="html">#{sanitize_content article.excerpt_html}</summary>}
...
3
4
5
6
 
7
8
 
9
10
11
...
3
4
5
 
6
7
 
8
9
10
11
0
@@ -3,9 +3,9 @@ xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
0
 xml.feed "xml:lang" => "en-US", "xmlns" => 'http://www.w3.org/2005/Atom' do
0
   xml.title "#{site.title || 'Mephisto'} - #{@section.name}"
0
   xml.id "tag:#{request.host},#{Time.now.utc.year}:mephisto/#{@section.name}"
0
- xml.generator "Mephisto", :uri => "http://mephisto.techno-weenie.net", :version => '666'
0
+ xml.generator "Mephisto", :uri => "http://mephisto.techno-weenie.net", :version => "#{Mephisto::Version::STRING} #{Mephisto::Version::TITLE}"
0
   xml.link "rel" => "self", "type" => "application/atom+xml", "href" => url_for(:only_path => false)
0
- xml.link "rel" => "alternate", "type" => "text/html", "href" => section_url(@section.hash_for_url(:only_path => false))
0
+ xml.link "rel" => "alternate", "type" => "text/html", "href" => dispatch_url(@section.hash_for_url(:only_path => false))
0
 
0
   if @articles.any?
0
     xml.updated @articles.first.updated_at.xmlschema unless @articles.empty?
...
12
13
14
15
 
16
17
18
...
12
13
14
 
15
16
17
18
0
@@ -12,7 +12,7 @@
0
     <!-- div.header -->
0
     <div id="header">
0
       <ul id="sec-nav">
0
- <li><strong><%= link_to 'Blog', section_path([]) %></strong></li>
0
+ <li><strong><%= link_to 'Blog', dispatch_path([]) %></strong></li>
0
         <li><%= link_to 'Settings', :controller => 'settings' %></li>
0
         <li><%= link_to 'Account', :controller => 'users', :action => 'show', :id => current_user %></li>
0
         <li><%= link_to 'Logout', :controller => '/account', :action => 'logout' %></li>
...
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
45
...
17
18
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
21
0
@@ -17,29 +17,5 @@ ActionController::Routing::Routes.draw do |map|
0
   
0
   map.connect ':controller/:action/:id/:version', :version => nil, :controller => /routing_navigator|account|(admin\/\w+)/
0
   
0
- map.comment ':year/:month/:day/:permalink/comment', :controller => 'comments', :action => 'create',
0
- :year => /\d{4}/, :month => /\d{1,2}/, :day => /\d{1,2}/
0
-
0
- map.comment_preview ':year/:month/:day/:permalink/comment/:comment', :controller => 'comments', :action => 'show',
0
- :year => /\d{4}/, :month => /\d{1,2}/, :day => /\d{1,2}/
0
-
0
- map.with_options :controller => 'mephisto' do |m|
0
- m.article ':year/:month/:day/:permalink', :action => 'show',
0
- :year => /\d{4}/, :month => /\d{1,2}/, :day => /\d{1,2}/
0
-
0
- m.monthly ':year/:month', :action => 'month',
0
- :year => /\d{4}/, :month => /\d{1,2}/
0
-
0
- m.paged_monthly ':year/:month/page/:page', :action => 'month',
0
- :year => /\d{4}/, :month => /\d{1,2}/, :page => /\d+/
0
-
0
- m.daily ':year/:month/:day', :action => 'day',
0
- :year => /\d{4}/, :month => /\d{1,2}/, :day => /\d{1,2}/
0
-
0
- m.yearly ':year', :action => 'yearly',
0
- :year => /\d{4}/
0
-
0
- m.search 'search', :action => 'search'
0
- m.section '*sections', :action => 'list'
0
- end
0
+ map.dispatch '*path', :controller => 'mephisto', :action => 'dispatch'
0
 end
...
77
78
79
80
81
 
82
83
84
...
87
88
89
 
90
91
92
93
94
95
96
97
...
77
78
79
 
80
81
82
83
84
...
87
88
89
90
91
92
93
94
 
95
96
97
0
@@ -77,8 +77,8 @@ ActiveRecord::Schema.define(:version => 56) do
0
     t.column "author_email", :string
0
     t.column "author_ip", :string, :limit => 100
0
     t.column "comments_count", :integer, :default => 0
0
- t.column "version", :integer
0
     t.column "updater_id", :integer
0
+ t.column "version", :integer
0
     t.column "site_id", :integer
0
     t.column "approved", :boolean, :default => false
0
     t.column "comment_age", :integer, :default => 0
0
@@ -87,11 +87,11 @@ ActiveRecord::Schema.define(:version => 56) do
0
 
0
   create_table "events", :force => true do |t|
0
     t.column "mode", :string
0
+ t.column "user_id", :integer
0
     t.column "article_id", :integer
0
     t.column "title", :text
0
     t.column "body", :text
0
     t.column "created_at", :datetime
0
- t.column "user_id", :integer
0
     t.column "author", :string, :limit => 100
0
     t.column "comment_id", :integer
0
     t.column "site_id", :integer
...
27
28
29
30
 
31
32
33
...
27
28
29
 
30
31
32
33
0
@@ -27,7 +27,7 @@ module AuthenticatedSystem
0
       respond_to do |accepts|
0
         accepts.html do
0
           store_location
0
- redirect_to :controller=>"/account", :action =>"login"
0
+ redirect_to :controller => "/account", :action => "login"
0
         end
0
         accepts.xml { access_denied_with_basic_auth }
0
       end
...
36
37
38
39
 
 
 
 
 
 
40
41
42
...
36
37
38
 
39
40
41
42
43
44
45
46
47
0
@@ -36,7 +36,12 @@ module Mephisto
0
         # check for archives
0
         if result[0] == site.archive_slug
0
           # only allow /archives, /archives/yyyy and /archives/yyyy/mm
0
- dispatch_type = (result.size < 4 && year?(result[1]) && month?(result[2])) ? :archives : :error
0
+ if (result.size < 4 && year?(result[1]) && month?(result[2]))
0
+ dispatch_type = :archives
0
+ result.shift
0
+ else
0
+ dispatch_type = :error
0
+ end
0
         end
0
         
0
         # check for pages
...
9
10
11
 
12
13
14
15
16
17
18
19
...
48
49
50
51
 
 
 
 
 
52
53
54
...
9
10
11
12
13
14
15
16
 
17
18
19
...
48
49
50
 
51
52
53
54
55
56
57
58
0
@@ -9,11 +9,11 @@ module Mephisto
0
       def initialize(source, options = {})
0
         @options = options
0
         @source = source
0
+ @site = options.delete(:site)
0
         @article_liquid = {
0
           'id' => @source.id,
0
           'title' => @source.title,
0
           'permalink' => @source.permalink,
0
- 'url' => absolute_url(@source.full_permalink),
0
           'body' => @source.body_html,
0
           'excerpt' => @source.excerpt_html,
0
           'published_at' => (@source.site.timezone.utc_to_local(@source.published_at) rescue nil),
0
@@ -48,7 +48,11 @@ module Mephisto
0
       def content
0
         @content ||= body_for_mode(@options[:mode] || :list)
0
       end
0
-
0
+
0
+ def url
0
+ @url ||= absolute_url(@site.permalink_for(@source))
0
+ end
0
+
0
       protected
0
         def body_for_mode(mode)
0
           contents = [before_method(:excerpt), before_method(:body)]
...
30
31
32
33
 
34
35
36
...
30
31
32
 
33
34
35
36
0
@@ -30,7 +30,7 @@ module Mephisto
0
     def expire_assigned_sections!(record)
0
       record.send :save_assigned_sections
0
       record.sections.each do |section|
0
- controller.expire_page :sections => section.to_url, :controller => '/mephisto', :action => 'list'
0
+ controller.expire_page :path => section.to_url, :controller => '/mephisto', :action => 'dispatch'
0
         controller.expire_page :sections => section.to_feed_url, :controller => '/feed', :action => 'feed'
0
       end
0
     end
...
24
25
26
27
 
28
29
30
...
24
25
26
 
27
28
29
30
0
@@ -24,7 +24,7 @@ module Mephisto
0
       end
0
 
0
       def comment_on(article, comment)
0
- post "#{article.full_permalink}/comment", :comment => comment
0
+ post "#{article.full_permalink}/comments", :comment => comment
0
       end
0
 
0
       def approve_c