Skip to content

Commit

Permalink
Fixes the macro display thing.
Browse files Browse the repository at this point in the history
Apparently, nesting a crapload of content_tag ... do doesn't work as expected, so I'm using a partial instead of a helper here.
  • Loading branch information
Frédéric de Villamil committed Aug 29, 2013
1 parent cc71bcc commit 1539b5a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
20 changes: 0 additions & 20 deletions app/helpers/admin/base_helper.rb
Expand Up @@ -134,26 +134,6 @@ def macro_help_popup(macro, text)
end
end

def render_macros(macros)
content_tag(:div) do
link_to_function(_("Show help on Publify macros") + " (+/-)", update_page { |page| page.visual_effect(:toggle_blind, "macros", :duration => 0.2) })
content_tag(:table, {:id => 'macros', :style => 'display: none'}) do
content_tag(:tr) do
content_tag(:th, _('Name'))
content_tag(:th, _('Description'))
content_tag(:th, _('Tag'))
end
for macro in macros.sort_by { |f| f.short_name }
content_tag(:tr) do
content_tag(:td, macro_help_popup(macro, macro.display_name))
content_tag(:td, h(macro.description))
content_tag(:td, content_tag(:code, "<#{h(macro.short_name)}>"))
end
end
end
end
end

def build_editor_link(label, action, id, update, editor)
link = link_to_remote(label,
:url => { :action => action, 'editor' => editor},
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/content/_form.html.erb
Expand Up @@ -45,7 +45,7 @@

<div id='simple_editor' <%= "style='display: none;'" if current_user.editor == 'visual'%> >
<%= text_area('article', 'body_and_extended', {:class => 'input-block-level', :height => '300px'}) if current_user.editor == 'simple' %>
<%= render_macros(@macros) if current_user.editor == 'simple' %>
<%= render 'admin/shared/macros' if current_user.editor == 'simple' %>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/pages/_form.html.erb
Expand Up @@ -39,7 +39,7 @@
</div>
<div id='simple_editor' <%= "style='display: none;'" if current_user.editor == 'visual'%> >
<%= text_area('page', 'body', {:class => 'input-block-level', :height => '300px', :rows => '20'}) if current_user.editor == 'simple' %>
<%= render_macros(@macros) if current_user.editor == 'simple' %>
<%= render 'admin/shared/macros' if current_user.editor == 'simple' %>
</div>
</div>
<div class='separator'>
Expand Down
21 changes: 21 additions & 0 deletions app/views/admin/shared/_macros.html.erb
@@ -0,0 +1,21 @@
<div>
<%= link_to_function(_("Show help on Publify macros") + " (+/-)", update_page { |page| page.visual_effect(:toggle_blind, "macros", :duration => 0.2) }) %>
<table class='table table-striped' id='macros' style='display: none'>
<thead>
<tr>
<th><%= _("Name") %></th>
<th><%= _("Description") %></th>
<th><%= _("Tag") %></th>
</tr>
</thead>
<tbody>
<% for macro in @macros.sort_by { |f| f.short_name } %>
<tr>
<td><%= macro_help_popup(macro, macro.display_name) %></td>
<td><%= h(macro.description) %></td>
<td><code>&lt;<%= h(macro.short_name) %>&gt;</code></td>
</tr>
<% end %>
</tbody>
</table>
</div>

0 comments on commit 1539b5a

Please sign in to comment.