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 !
Use ActionController::AbstractRequest.relative_url_root for sites under a 
root path like /blog

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@1979 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Sat Sep 02 10:30:33 -0700 2006
commit  58e5614d15a8460c85670840c414b054061f98ee
tree    0b0b5770146db033c320cb45fdc356709b04c6ec
parent  2747e838c2281ee6423647ea10b8548dc02f3e0d
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 * SVN *
0
 
0
+* Use ActionController::AbstractRequest.relative_url_root for sites under a root path like /blog
0
+
0
 * fix odd timezone bug when saving articles
0
 
0
 * fix bug with <typo:code> macro
...
36
37
38
 
 
 
39
40
41
...
36
37
38
39
40
41
42
43
44
0
@@ -36,6 +36,9 @@ end
0
 # Include your application configuration below
0
 require 'mephisto_init'
0
 
0
+# Set this if you're running on a root path
0
+# ActionController::AbstractRequest.relative_url_root = '/blog'
0
+
0
 # turn this on to get detailed cache sweeper logging in production mode
0
 # Mephisto::SweeperMethods.cache_sweeper_tracing = true
0
 
...
1
2
3
 
4
5
6
...
12
13
14
15
 
16
17
18
...
1
2
3
4
5
6
7
...
13
14
15
 
16
17
18
19
0
@@ -1,6 +1,7 @@
0
 module Mephisto
0
   module Liquid
0
     class ArticleDrop < ::Liquid::Drop
0
+ include UrlMethods
0
       include DropMethods
0
       
0
       def article() @source end
0
@@ -12,7 +13,7 @@ module Mephisto
0
           'id' => @source.id,
0
           'title' => @source.title,
0
           'permalink' => @source.permalink,
0
- 'url' => @source.full_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),
...
2
3
4
 
5
6
7
...
36
37
38
39
 
40
41
42
...
44
45
46
47
48
 
49
50
51
...
64
65
66
67
68
 
 
69
70
71
72
73
 
 
 
 
 
 
74
75
76
77
78
 
79
80
81
82
83
 
84
85
86
...
2
3
4
5
6
7
8
...
37
38
39
 
40
41
42
43
...
45
46
47
 
 
48
49
50
51
...
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
0
@@ -2,6 +2,7 @@ require 'digest/md5'
0
 module Mephisto
0
   module Liquid
0
     module Filters
0
+ include UrlMethods
0
       include ActionView::Helpers::TagHelper
0
       include ActionView::Helpers::AssetTagHelper
0
 
0
@@ -36,7 +37,7 @@ module Mephisto
0
           singular
0
         elsif plural
0
           plural
0
- elsif Object.const_defined?("Inflector")
0
+ elsif Object.const_defined?(:Inflector)
0
           Inflector.pluralize(singular)
0
         else
0
           singular + "s"
0
@@ -44,8 +45,7 @@ module Mephisto
0
       end
0
 
0
       def textilize(text)
0
- return '' if text.blank?
0
- RedCloth.new(text).to_html
0
+ text.blank? ? '' : RedCloth.new(text).to_html
0
       end
0
 
0
       def format_date(date, format, ordinalized = false)
0
@@ -64,23 +64,26 @@ module Mephisto
0
         tag 'img', {:src => asset_url(img), :alt => img.split('.').first }.merge(options)
0
       end
0
       
0
- def asset_url(asset)
0
- "/images/#{asset}"
0
+ def stylesheet_url(css)
0
+ absolute_url :stylesheets, css
0
       end
0
       
0
- def stylesheet(stylesheet, options = {})
0
- stylesheet << '.css' unless stylesheet.include? '.'
0
- tag 'link', options.merge(:rel => 'stylesheet', :type => 'text/css', :href => "/stylesheets/#{stylesheet}")
0
+ def javascript_url(js)
0
+ absolute_url :javascripts, js
0
+ end
0
+
0
+ def asset_url(asset)
0
+ absolute_url :images, asset
0
       end
0
 
0
       def stylesheet(stylesheet, media = nil)
0
         stylesheet << '.css' unless stylesheet.include? '.'
0
- tag 'link', :rel => 'stylesheet', :type => 'text/css', :href => "/stylesheets/#{stylesheet}", :media => media
0
+ tag 'link', :rel => 'stylesheet', :type => 'text/css', :href => stylesheet_url(stylesheet), :media => media
0
       end
0
 
0
       def javascript(javascript)
0
         javascript << '.js' unless javascript.include? '.'
0
- content_tag 'script', '', :type => 'text/javascript', :src => "/javascripts/#{javascript}"
0
+ content_tag 'script', '', :type => 'text/javascript', :src => javascript_url(javascript)
0
       end
0
       
0
       def month_list
...
1
2
3
 
4
5
6
7
8
9
10
 
11
12
13
...
1
2
3
4
5
6
7
8
9
10
 
11
12
13
14
0
@@ -1,13 +1,14 @@
0
 module Mephisto
0
   module Liquid
0
     class Head < ::Liquid::Block
0
+ include UrlMethods
0
       include ActionView::Helpers::TagHelper
0
     
0
       def render(context)
0
         result = []
0
         context.stack do
0
           context['head'] = {
0
- 'feed' => tag(:link, :rel => 'alternate', :type => 'application/atom+xml', :href => '/feed/atom.xml')
0
+ 'feed' => tag(:link, :rel => 'alternate', :type => 'application/atom+xml', :href => absolute_url('feed/atom.xml'))
0
           }
0
 
0
           result << content_tag(:head, render_all(@nodelist, context))
...
1
2
3
 
4
5
6
...
17
18
19
20
 
21
22
23
...
1
2
3
4
5
6
7
...
18
19
20
 
21
22
23
24
0
@@ -1,6 +1,7 @@
0
 module Mephisto
0
   module Liquid
0
     class SectionDrop < ::Liquid::Drop
0
+ include UrlMethods
0
       include DropMethods
0
       
0
       def section() @source end
0
@@ -17,7 +18,7 @@ module Mephisto
0
       end
0
       
0
       def url
0
- @url ||= '/' + @source.to_url.join('/')
0
+ @url ||= absolute_url(*@source.to_url)
0
       end
0
 
0
       def is_blog

Comments

    No one has commented yet.