Module: WikiHelper
- Defined in:
- app/helpers/wiki_helper.rb
Instance Method Summary collapse
- #edition_link(user, page) ⇒ Object
- #page_history_link(page) ⇒ Object
- #render_wiki_diff(old_revision, new_revision) ⇒ Object
- #render_wiki_sourcediff(old_revision, new_revision) ⇒ Object
- #rss_item_for_revision(rev) ⇒ Object
- #switch_view_link(page) ⇒ Object
Instance Method Details
#edition_link(user, page) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'app/helpers/wiki_helper.rb', line 3 def edition_link(user, page) if user.nil? content_tag('span', "#{'Edit'.t} #{'(requires authentication)'.t}", :class => 'disabled') elsif !user.can_edit?(page) 'Edit'.t + ' ' + content_tag('span', '(not authorized)'.t, :class => flash[:not_authorized] ? 'marked' : 'none') else link_to('Edit'.t, :controller => 'wiki', :action => 'edit', :page_name => page.name) end end |
#page_history_link(page) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/wiki_helper.rb', line 23 def page_history_link(page) case page.revisions.size when 0 then '' when 1 then '| ' + 'Page has no history yet'.t else '| ' + link_to('Page history (%s revisions)'/page.revisions.size.to_s, :controller => 'wiki', :action => 'history', :page_name => page.name) end end |
#render_wiki_diff(old_revision, new_revision) ⇒ Object
33 34 35 36 37 38 39 |
# File 'app/helpers/wiki_helper.rb', line 33 def render_wiki_diff(old_revision, new_revision) begin @renderer.render_wiki_diff(old_revision.text, new_revision.text) rescue parsing_error_box + render_wiki_sourcediff(old_revision, new_revision) end end |
#render_wiki_sourcediff(old_revision, new_revision) ⇒ Object
41 42 43 |
# File 'app/helpers/wiki_helper.rb', line 41 def render_wiki_sourcediff(old_revision, new_revision) render_diff_table(old_revision.diff(new_revision)) end |
#rss_item_for_revision(rev) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/helpers/wiki_helper.rb', line 45 def rss_item_for_revision(rev) Builder::XmlMarkup.new.item do |xml| xml.title h(rev.title) if rev.position > 1 xml.description @renderer.render_wiki_diff( @page.revisions[rev.position - 2].text, rev.text) else xml.description @renderer.render_wiki_text(rev.text) end xml.pubDate h(rev.modified_at.to_s(:rfc822)) xml.dc :creator, h(rev.last_editor.login) xml.guid server_url_for(:action => 'show', :page_name => @page.name, :revision => rev.position) end rescue '' end |
#switch_view_link(page) ⇒ Object
16 17 18 19 20 21 |
# File 'app/helpers/wiki_helper.rb', line 16 def switch_view_link(page) action, text = 'raw' == params[:action].to_s ? ['show','View wiki output'] : ['raw' ,'View raw text'] '| ' + link_to(text.t, :controller => :wiki, :action => action, :page_name => page.name, :revision => page.position) end |