Permalink
Browse files

Fix display of theme homepage links

Many thanks to Gustavo Sales (aka vatsu) for pointing out this bug and
proposing a fix:

http://github.com/vatsu/mephisto/commit/e7b0ecaaca4457dd7d542ac218baf979e1b7a190
http://github.com/vatsu/mephisto/commit/fbe32e923ad6dfb963a8311053214b3395aeb37b

In order to minimize code duplication in the *.erb files, I've rewritten
this code as a helper method.
  • Loading branch information...
1 parent 5c568b5 commit 1473acf8307ec21d2002acab94691841d8003580 @emk emk committed Feb 2, 2009
@@ -1,2 +1,7 @@
module Admin::ThemesHelper
+ def theme_author_link theme
+ author = theme.author || 'unknown'
+ homepage = theme.homepage
+ homepage.blank? ? h(author) : link_to(h(author), homepage)
+ end
end
View
@@ -1,4 +1,6 @@
class Theme
+
+
@@root_theme_files = %w(about.yml preview.png)
@@theme_directories = %w(templates layouts javascripts stylesheets images)
@@allowed_extensions = %w(.js .css .png .gif .jpg .swf .ico) | Site.extensions
@@ -88,11 +90,6 @@ class << self ; attr_reader :title ; end
@title = properties['title'] || name
end
- def linked_author
- class << self ; attr_reader :linked_author ; end
- @linked_author = homepage.blank? ? author : %(<a href="#{CGI.escapeHTML homepage}">#{author}</a>)
- end
-
def attachments
class << self ; attr_reader :attachments ; end
@attachments, @templates, @resources = Attachments.new, Templates.new, Resources.new
@@ -154,4 +151,4 @@ def write_theme_files_with(file_class, relative_path = '')
file_class.open((relative_path + full_path.relative_path_from(path)).to_s, write_mode) { |f| f << full_path.read }
end
end
-end
+end
@@ -3,7 +3,7 @@
<span title="stored in /<%=h theme.name %>"><%=h theme.title %></span>
<span class="thememeta">
<% unless theme.version.blank? -%>v<%=h theme.version %> |<% end -%>
- by <%=h theme.linked_author.blank? ? 'unknown' : theme.linked_author %>
+ by <%= theme_author_link(theme) %>
</span>
</h3>
<a id="theme-dialog-<%= theme_counter %>" class="theme_dialog">
@@ -1,6 +1,6 @@
<div id="theme-info" class="clearfix">
<h3>
- <%=h @theme.title %> (v<%=h @theme.version %>)by <% if @theme.author %><a href="<%=h @theme.homepage %>"><%=h @theme.author %></a><% else %>Unknown<% end %>
+ <%=h @theme.title %> (v<%=h @theme.version %>)by <%= theme_author_link(@theme) %>
<%= link_to_function 'close', 'Dialog.close()', :id => 'close-dialog' %>
</h3>
<div id="screenshot">

0 comments on commit 1473acf

Please sign in to comment.