You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

helper.rb 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2017 Jean-Philippe Lang
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. module Redmine
  18. module WikiFormatting
  19. module Textile
  20. module Helper
  21. def wikitoolbar_for(field_id, preview_url = preview_text_path)
  22. heads_for_wiki_formatter
  23. # Is there a simple way to link to a public resource?
  24. url = "#{Redmine::Utils.relative_url_root}/help/#{current_language.to_s.downcase}/wiki_syntax_textile.html"
  25. javascript_tag("var wikiToolbar = new jsToolBar(document.getElementById('#{field_id}')); wikiToolbar.setHelpLink('#{escape_javascript url}'); wikiToolbar.setPreviewUrl('#{escape_javascript preview_url}'); wikiToolbar.draw();")
  26. end
  27. def initial_page_content(page)
  28. "h1. #{@page.pretty_title}"
  29. end
  30. def heads_for_wiki_formatter
  31. unless @heads_for_wiki_formatter_included
  32. content_for :header_tags do
  33. javascript_include_tag('jstoolbar/jstoolbar') +
  34. javascript_include_tag('jstoolbar/textile') +
  35. javascript_include_tag("jstoolbar/lang/jstoolbar-#{current_language.to_s.downcase}") +
  36. javascript_tag("var wikiImageMimeTypes = #{Redmine::MimeType.by_type('image').to_json};") +
  37. stylesheet_link_tag('jstoolbar')
  38. end
  39. @heads_for_wiki_formatter_included = true
  40. end
  41. end
  42. end
  43. end
  44. end
  45. end