Actualizar plugin Glossary a 1.1.0

This commit is contained in:
Manuel Cillero 2020-11-22 21:35:04 +01:00
parent 24560c8598
commit b9e569d03f
103 changed files with 954 additions and 2967 deletions

View file

@ -1,23 +0,0 @@
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

View file

@ -1,69 +0,0 @@
#
# 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

View file

@ -0,0 +1,38 @@
module GlossaryMacros
Redmine::WikiFormatting::Macros.register do
desc "create macro which links to glossary term by id."
macro :termno do |obj, args|
begin
raise 'no parameters' if args.count.zero?
raise 'too many parameters' if args.count > 1
term_id = args.first
term = GlossaryTerm.find(term_id)
link_to term.name, project_glossary_term_path(@project, term)
rescue => err_msg
raise <<-TEXT.html_safe
Parameter error: #{err_msg}<br>
Usage: {{termno(glossary_term_id)}}
TEXT
end
end
desc "create macro which links to glossary term by name."
macro :term do |obj, args|
begin
raise 'no parameters' if args.count.zero?
raise 'too many parameters' if args.count > 1
term = GlossaryTerm.find_by!(name: args.first)
link_to term.name, project_glossary_term_path(@project, term)
rescue => err_msg
raise <<-TEXT.html_safe
Parameter error: #{err_msg}<br>
Usage: {{term(name)}}
TEXT
end
end
end
end

View file

@ -1,50 +0,0 @@
#
# 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

View file

@ -1,35 +0,0 @@
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