Skip to content

Commit

Permalink
Merge pull request gollum#1047 from benubird/custom-template
Browse files Browse the repository at this point in the history
Changed layout template, to handle custom.x with page-file-dir
  • Loading branch information
Dawa Ometto committed Aug 5, 2015
2 parents ba142e3 + 73e61db commit 0ba5e4d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/gollum/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def supported_useragent?(user_agent)
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]
Expand All @@ -106,8 +107,7 @@ def supported_useragent?(user_agent)
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.
Expand Down
4 changes: 2 additions & 2 deletions lib/gollum/templates/layout.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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]>
Expand Down Expand Up @@ -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>
Expand Down
8 changes: 8 additions & 0 deletions lib/gollum/views/layout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,18 @@ def has_path
!@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
Expand Down

0 comments on commit 0ba5e4d

Please sign in to comment.