Moves the edition link code to a helper module
| 1 | module WikiHelper | module WikiHelper | 1 |
|---|---|---|---|
| 2 | 2 | ||
def edition_link(user, page) | 3 | ||
if user.nil? | 4 | ||
content_tag('span', "#{'Edit'.t} #{'(requires authentication)'.t}", | 5 | ||
:class => 'disabled') | 6 | ||
elsif !user.can_edit?(page) | 7 | ||
'Edit'.t + ' ' + content_tag('span', '(not authorized)'.t, | 8 | ||
:class => flash[:not_authorized] ? 'marked' : 'none') | 9 | ||
else | 10 | ||
link_to('Edit'.t, :controller => 'wiki', :action => 'edit', | 11 | ||
:page_name => page.name) | 12 | ||
end | 13 | ||
end | 14 | ||
| 15 | |||
| 3 | def raw_text_link(page) | def raw_text_link(page) | 16 |
| 4 | '| ' + link_to('View raw text'.t, | '| ' + link_to('View raw text'.t, | 17 |
| 5 | :controller => :wiki, :action => 'raw', | :controller => :wiki, :action => 'raw', | 18 |
| 1 | <div class='toolbar bottombar'> | <div class='toolbar bottombar'> | 1 |
|---|---|---|---|
| 2 | <%= render :partial => 'editor' %> | <%= render :partial => 'editor' %> | 2 |
| 3 | <% if current_user.nil? then %> | <%= edition_link(current_user, @page) -%> | 3 |
| 4 | <span class='disabled'> | ||
| 5 | <%= 'Edit'.t -%> <%= '(requires authentication)'.t -%> | ||
| 6 | </span> | ||
| 7 | <% elsif !current_user.can_edit?(@page) then | ||
| 8 | klass = if flash[:not_authorized] then 'marked' else 'none' end | ||
| 9 | %> | ||
| 10 | <span class='disabled'> | ||
| 11 | <%= 'Edit'.t -%> <%= content_tag('span', | ||
| 12 | '(not authorized)'.t, | ||
| 13 | :class => klass) -%> | ||
| 14 | </span> | ||
| 15 | <% else %> | ||
| 16 | <%= link_to( 'Edit'.t, | ||
| 17 | { :controller => 'wiki', | ||
| 18 | :action => 'edit', | ||
| 19 | :page_name => @page.name } )%> | ||
| 20 | <% end %> | ||
| 21 | <%= raw_text_link(@page) -%> | <%= raw_text_link(@page) -%> | 4 |
| 22 | <%= page_history_link(@page) -%> | <%= page_history_link(@page) -%> | 5 |
| 23 | </div> | </div> | 6 |