Nuevo plugin Redmine Glossary 0.9.2
This commit is contained in:
parent
5d298a7529
commit
693eb3ee50
72 changed files with 2962 additions and 0 deletions
23
plugins/redmine_glossary/lib/glossary_asset_tag_helper_patch.rb
Executable file
23
plugins/redmine_glossary/lib/glossary_asset_tag_helper_patch.rb
Executable file
|
@ -0,0 +1,23 @@
|
|||
module ActionView
|
||||
module Helpers
|
||||
module AssetTagHelper
|
||||
def javascript_include_tag_with_glossary(*sources)
|
||||
out = javascript_include_tag_without_glossary(*sources)
|
||||
if sources.is_a?(Array) and sources[0] == 'jstoolbar/textile'
|
||||
out += javascript_tag <<-javascript_tag
|
||||
jsToolBar.prototype.elements.termlink = {
|
||||
type: 'button',
|
||||
title: '#{l(:label_tag_termlink)}',
|
||||
fn: {
|
||||
wiki: function() { this.encloseSelection("{{term(", ")}}") }
|
||||
}
|
||||
}
|
||||
javascript_tag
|
||||
out += stylesheet_link_tag 'termlink', :plugin => 'redmine_glossary'
|
||||
end
|
||||
out
|
||||
end
|
||||
alias_method_chain :javascript_include_tag, :glossary
|
||||
end
|
||||
end
|
||||
end
|
69
plugins/redmine_glossary/lib/glossary_import_info.rb
Executable file
69
plugins/redmine_glossary/lib/glossary_import_info.rb
Executable file
|
@ -0,0 +1,69 @@
|
|||
#
|
||||
# glossary_import_info.rb
|
||||
#
|
||||
# Author : Mitsuyoshi Yoshida
|
||||
# This program is freely distributable under the terms of an MIT-style license.
|
||||
#
|
||||
|
||||
require 'i18n'
|
||||
|
||||
class GlossaryImportInfo
|
||||
attr_accessor :import_file
|
||||
attr_accessor :err_string
|
||||
|
||||
def initialize(tbl)
|
||||
@import_file = tbl[:import_file]
|
||||
end
|
||||
|
||||
def success?
|
||||
(err_string) ? false : true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
class CsvGlossaryImportInfo < GlossaryImportInfo
|
||||
attr_accessor :is_first_comment
|
||||
attr_reader :col_max
|
||||
attr_accessor :cat_num, :newterm_num, :upterm_num
|
||||
attr_writer :in_encoding
|
||||
|
||||
def initialize(tbl)
|
||||
super(tbl)
|
||||
@is_first_comment = tbl[:is_first_comment]
|
||||
@in_encoding = tbl[:in_encoding]
|
||||
@colno_tbl = {}
|
||||
Term.import_params.each {|prm|
|
||||
prmcol = tbl["colno_#{prm}"]
|
||||
if (prmcol and !prmcol.empty?)
|
||||
@colno_tbl[prmcol.to_i] = prm
|
||||
end
|
||||
}
|
||||
@col_max = @colno_tbl.keys.max
|
||||
@cat_num = 0
|
||||
@newterm_num = 0
|
||||
@upterm_num = 0
|
||||
end
|
||||
|
||||
def in_encoding
|
||||
(@in_encoding) ? @in_encoding : 'UTF-8'
|
||||
end
|
||||
|
||||
def col_param(colno)
|
||||
@colno_tbl[colno]
|
||||
end
|
||||
|
||||
def param_col(prm)
|
||||
@colno_tbl.each {|key, val|
|
||||
return key if (val == prm)
|
||||
}
|
||||
nil
|
||||
end
|
||||
|
||||
def self.default_param_cols(&blk)
|
||||
Term.import_params.each {|prm|
|
||||
yield prm, (Term.export_params.index(prm))
|
||||
}
|
||||
end
|
||||
|
||||
end
|
50
plugins/redmine_glossary/lib/grouping_terms.rb
Executable file
50
plugins/redmine_glossary/lib/grouping_terms.rb
Executable file
|
@ -0,0 +1,50 @@
|
|||
#
|
||||
# category_terms.rb
|
||||
#
|
||||
# Author : Mitsuyoshi Yoshida
|
||||
# This program is freely distributable under the terms of an MIT-style license.
|
||||
#
|
||||
|
||||
require 'i18n'
|
||||
|
||||
class GroupingTerms
|
||||
attr_reader :type, :target
|
||||
attr_accessor :ary
|
||||
|
||||
def initialize(type, target)
|
||||
@type = type
|
||||
@target = target
|
||||
@ary = []
|
||||
end
|
||||
|
||||
def name
|
||||
(@target) ? @target.name : I18n.t(:label_not_categorized)
|
||||
end
|
||||
|
||||
def <=>(rhterm)
|
||||
if (!@target and !rhterm.target)
|
||||
return 0
|
||||
elsif (!@target or !rhterm.target)
|
||||
return -1 if @target
|
||||
return 1 if rhterm.target
|
||||
end
|
||||
case type
|
||||
when GlossaryStyle::GroupByCategory
|
||||
@target.position <=> rhterm.target.position
|
||||
when GlossaryStyle::GroupByProject
|
||||
@target.identifier <=> rhterm.target.identifier
|
||||
end
|
||||
end
|
||||
|
||||
def self.flatten(gtarmsary)
|
||||
flatary = []
|
||||
gtarmsary.each {|gtarmsary|
|
||||
return gtarmsary unless gtarmsary.is_a?(GroupingTerms)
|
||||
flatary += gtarmsary.ary
|
||||
}
|
||||
flatary
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
35
plugins/redmine_glossary/lib/term_link_helper.rb
Executable file
35
plugins/redmine_glossary/lib/term_link_helper.rb
Executable file
|
@ -0,0 +1,35 @@
|
|||
require 'redmine'
|
||||
require 'cgi'
|
||||
|
||||
module ActionView
|
||||
module Helpers
|
||||
module TermLinkHelper
|
||||
|
||||
def term_link_new(name, proj)
|
||||
link_to(name + '?',
|
||||
{:controller => 'glossary', :action => 'new', :project_id => proj,
|
||||
:new_term_name => CGI::escapeHTML(name)},
|
||||
{:class=>'new'})
|
||||
end
|
||||
|
||||
def term_link(term)
|
||||
str = link_to(term.name, :controller => 'glossary', :action => 'show', :project_id => term.project,
|
||||
:id => term.id)
|
||||
unless (term.abbr_whole.empty?)
|
||||
str = content_tag(:abbr, str, :title=>term.abbr_whole)
|
||||
end
|
||||
unless (term.rubi.empty?)
|
||||
str = content_tag(:ruby) {
|
||||
tstr = content_tag(:rb, str)
|
||||
tstr += content_tag(:rp, '(')
|
||||
tstr += content_tag(:rt, term.rubi)
|
||||
tstr += content_tag(:rp, ')')
|
||||
}
|
||||
end
|
||||
str
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue