Changed layout template, to correctly handle custom.js when --page-file-dir is set
This commit is contained in:
+2
-2
@@ -98,6 +98,7 @@ module Precious
|
||||
forbid unless @allow_editing || request.request_method == "GET"
|
||||
Precious::App.set(:mustache, {:templates => settings.wiki_options[:template_dir]}) if settings.wiki_options[:template_dir]
|
||||
@base_url = url('/', false).chomp('/')
|
||||
@page_dir = settings.wiki_options[:page_file_dir].to_s
|
||||
# above will detect base_path when it's used with map in a config.ru
|
||||
settings.wiki_options.merge!({ :base_path => @base_url })
|
||||
@css = settings.wiki_options[:css]
|
||||
@@ -106,8 +107,7 @@ module Precious
|
||||
end
|
||||
|
||||
get '/' do
|
||||
page_dir = settings.wiki_options[:page_file_dir].to_s
|
||||
redirect clean_url(::File.join(@base_url, page_dir, wiki_new.index_page))
|
||||
redirect clean_url(::File.join(@base_url, @page_dir, wiki_new.index_page))
|
||||
end
|
||||
|
||||
# path is set to name if path is nil.
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/dialog.css" media="all">
|
||||
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/template.css" media="all">
|
||||
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/print.css" media="print">
|
||||
{{#css}}<link rel="stylesheet" type="text/css" href="{{base_url}}/custom.css" media="all">{{/css}}
|
||||
{{#css}}<link rel="stylesheet" type="text/css" href="{{custom_path}}/custom.css" media="all">{{/css}}
|
||||
{{#noindex}}<meta name="robots" content="noindex, nofollow" />{{/noindex}}
|
||||
|
||||
<!--[if IE 7]>
|
||||
@@ -55,7 +55,7 @@
|
||||
(d.head || d.getElementsByTagName('head')[0]).appendChild(j);
|
||||
}(document));
|
||||
</script>{{/mathjax}}
|
||||
{{#js}}<script type="text/javascript" src="{{base_url}}/custom.js"></script>{{/js}}
|
||||
{{#js}}<script type="text/javascript" src="{{custom_path}}/custom.js"></script>{{/js}}
|
||||
|
||||
<title>{{title}}</title>
|
||||
</head>
|
||||
|
||||
@@ -20,10 +20,18 @@ module Precious
|
||||
!@path.nil?
|
||||
end
|
||||
|
||||
def page_dir
|
||||
@page_dir
|
||||
end
|
||||
|
||||
def base_url
|
||||
@base_url
|
||||
end
|
||||
|
||||
def custom_path
|
||||
"#{@base_url}#{@page_dir.nil? ? '' : '/'}#{@page_dir}"
|
||||
end
|
||||
|
||||
def css # custom css
|
||||
@css
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user