├── lang └── en.yml ├── toolbar.png ├── assets ├── images │ └── bt_wiki_unc.png ├── stylesheets │ └── redmine_wiki_unc.css └── javascripts │ └── redmine_wiki_unc.js ├── lib └── redmine_wiki_unc_hooks.rb ├── test └── test_helper.rb ├── app └── views │ └── redmine_wiki_unc │ └── _redmine_wiki_unc_partial.html.erb ├── init.rb ├── README.rdoc.ja └── README.rdoc /lang/en.yml: -------------------------------------------------------------------------------- 1 | # English strings go here 2 | my_label: "My label" 3 | -------------------------------------------------------------------------------- /toolbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bearmini/redmine_wiki_unc/HEAD/toolbar.png -------------------------------------------------------------------------------- /assets/images/bt_wiki_unc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bearmini/redmine_wiki_unc/HEAD/assets/images/bt_wiki_unc.png -------------------------------------------------------------------------------- /lib/redmine_wiki_unc_hooks.rb: -------------------------------------------------------------------------------- 1 | class RedmineWikiUncHooks < Redmine::Hook::ViewListener 2 | render_on :view_layouts_base_html_head, :partial => "redmine_wiki_unc/redmine_wiki_unc_partial" 3 | end -------------------------------------------------------------------------------- /assets/stylesheets/redmine_wiki_unc.css: -------------------------------------------------------------------------------- 1 | .jstb_wiki_unc { 2 | /* https://www.iconfinder.com/icons/3937335/chain_hyperlink_internet_link_linked_icon */ 3 | background-image: url('../images/bt_wiki_unc.png'); 4 | } 5 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | # Load the normal Rails helper 2 | require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper') 3 | 4 | # Ensure that we are using the temporary fixture path 5 | Engines::Testing.set_fixture_path 6 | -------------------------------------------------------------------------------- /app/views/redmine_wiki_unc/_redmine_wiki_unc_partial.html.erb: -------------------------------------------------------------------------------- 1 | <% 2 | header_tags_content = content_for(:header_tags) 3 | if header_tags_content.present? && header_tags_content.include?('/jstoolbar/') 4 | content_for :header_tags do 5 | javascript_include_tag('redmine_wiki_unc.js', plugin: 'redmine_wiki_unc', 'id' => 'js-redmine-wiki-unc-script-tag', 'data-text-formatting' => Setting.text_formatting) + 6 | stylesheet_link_tag('redmine_wiki_unc.css', plugin: 'redmine_wiki_unc') 7 | end 8 | end 9 | %> 10 | -------------------------------------------------------------------------------- /init.rb: -------------------------------------------------------------------------------- 1 | require 'redmine' 2 | require_dependency 'redmine_wiki_unc_hooks' 3 | 4 | class UncHelper 5 | def initialize 6 | @head = /^\\\\/ 7 | end 8 | 9 | def is_unc?(str) 10 | (str =~ @head) != nil 11 | end 12 | 13 | def unc_to_file_proto(str) 14 | Rails.logger.info "str == #{str}, is_unc? == #{is_unc?(str)}, head=#{@head.to_s}" 15 | return "" if !is_unc?(str) 16 | str.gsub(@head, "file://///").gsub(/\\/, "/") 17 | end 18 | 19 | def trim(str) 20 | return str.strip unless str == nil 21 | return nil 22 | end 23 | 24 | def parse_args(args) 25 | unc = trim(args[0]) 26 | label = trim(args[1]) || unc 27 | 28 | return unc, label 29 | end 30 | 31 | def get_tag(args) 32 | return "(No parameters are specified. A UNC path is needed at least.)" if args.empty? 33 | unc, label = parse_args(args) 34 | 35 | return <