«
前
|
次
»
リビジョン 0819898b
| README.ja.rdoc | ||
|---|---|---|
|
= Redmine 用語集プラグイン
|
||
|
|
||
|
Redmine(プロジェクト管理システム)に用語集の機能を追加するプラグインです。
|
||
|
ーハイシ、ホ、隍ヲ、ハヘムナモ、ヒサネ、ィ、゙、ケ。」
|
||
|
* 業務分析工程での専門用語の管理
|
||
|
* ツミフス
|
||
|
* 用語とデータ型(クラス名)との変換辞書
|
||
|
* コーディング時の略名の付け方の方針管理
|
||
|
|
||
|
|
||
|
== ・ラ・鬣ー・、・ム・テ・ア。シ・ク、ホシ霹タ
|
||
|
|
||
|
・ラ・鬣ー・、・ム・テ・ア。シ・ク、マーハイシ、ォ、鮠霹タ、キ、ニ、ッ、タ、オ、、。」
|
||
|
* {SourceForge.JP}[http://sourceforge.jp/projects/rp-glossary/releases/]
|
||
|
|
||
|
|
||
|
== インストールと設定
|
||
|
|
||
|
1. 取得した圧縮ファイルを (インストールディレクトリ)/vender/plugins に展開します。
|
||
|
2. ・ヌ。シ・ソ・ル。シ・ケ、ホタ゚ト熙ヤ、、、゙、ケ。」 http://www.redmine.org/wiki/1/Plugins
|
||
|
rake db:migrate_plugins RAILS_ENV=production
|
||
|
3. Redmine 、ホ WEB ・オ。シ・ミ(Apache 、ハ、ノ)、ニオッニー、キ、゙、ケ。」
|
||
|
4. "管理" メニューの "ロールと権限" から用語集の各権限を設定します。
|
||
|
5. 用語集を使用したいプロジェクトの "設定" メニューで "用語集" のモジュールにチェックを入れます。
|
||
|
6. 非表示にしたい項目があれば、プラグインの "設定" ページで設定してください。
|
||
|
|
||
|
cf. http://www.r-labs.org/projects/r-labs/wiki/%E3%83%97%E3%83%A9%E3%82%B0%E3%82%A4%E3%83%B3%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%E6%96%B9%E6%B3%95
|
||
|
|
||
|
|
||
|
== サネヘムヒ。
|
||
|
|
||
|
プロジェクトメニューの "用語集" からご利用ください。
|
||
|
|
||
|
サネヘムヒ。、ホセワコル、マーハイシ、エヘッ、タ、オ、、。」
|
||
|
* http://www.r-labs.org/projects/rp-glossary/wiki/Usage
|
||
|
|
||
|
|
||
|
== シチフ茖「・ミ・ーハハ、ノ
|
||
|
|
||
|
不具合報告や要望などありましたら、以下で Defect や Proposal のチケットを発行して下さい。
|
||
|
http://www.r-labs.org/projects/rp-glossary/issues
|
||
|
|
||
|
シチフ荀ハ、ノ、マーハイシ、ホ・ユ・ゥ。シ・鬣爨ヒオュスメ、キ、ニイシ、オ、、。」ヘラヒセ、ハ、ノ、マ、ウ、チ、鬢ヒス、、ニ、筅鬢テ、ニ、筅ォ、゙、、、゙、サ、」
|
||
|
http://www.r-labs.org/projects/rp-glossary/boards
|
||
|
|
||
|
|
||
|
|
||
| README.rdoc | ||
|---|---|---|
|
= Redmine Glossary Plugin
|
||
|
|
||
|
This is the Redmine(Project manage system) plug-in which adds the feature of the glossary.
|
||
|
|
||
|
== The Use
|
||
|
|
||
|
* Management of technical terms in a system analysis phase
|
||
|
* Interlinear translation table
|
||
|
* Translate table from term to data type (class name)
|
||
|
* Management of naming examples in a coding
|
||
|
|
||
|
|
||
|
== Gegging a plugin package
|
||
|
|
||
|
{SourceForge.JP}[http://sourceforge.jp/projects/rp-glossary/releases/]
|
||
|
|
||
|
|
||
|
== Installation and Setup
|
||
|
|
||
|
cf. http://www.redmine.org/wiki/1/Plugins
|
||
|
|
||
|
1. Extends the dawnloaded package in vender/plugins directory.
|
||
|
2. run the following command to upgrade your database.
|
||
|
rake db:migrate_plugins RAILS_ENV=production
|
||
|
3. Restart Redmine WEB server.
|
||
|
4. Set permissions of glossary plugin in "Administration" -> "Roles and permissions"
|
||
|
5. Open the setting page of projects you need, check the "Glossray" module
|
||
|
6. If you need, select items to make hidden in plugin setting page.
|
||
|
|
||
|
== Usage
|
||
|
|
||
|
Start from "Glossary" item of a project menu.
|
||
|
|
||
|
|
||
|
For the details of the usage, see the following page.
|
||
|
* http://www.r-labs.org/projects/rp-glossary/wiki/UsageEn
|
||
|
|
||
|
|
||
|
== Quesion or Proposal
|
||
|
|
||
|
If you find a bug(Defect) or hava a Proposal, create a new issue.
|
||
|
http://www.r-labs.org/projects/rp-glossary/issues
|
||
|
|
||
|
If you quest about this plugin, write the forum.
|
||
|
http://www.r-labs.org/projects/rp-glossary/boards
|
||
| app/controllers/glossary_controller.rb | ||
|---|---|---|
|
|
||
|
class GlossaryController < ApplicationController
|
||
|
unloadable
|
||
|
|
||
|
layout 'base'
|
||
|
before_filter :find_project, :authorize
|
||
|
before_filter :find_term, :only => [:show, :edit, :destroy]
|
||
|
before_filter :retrieve_glossary_style, :only => [:index, :show, :show_all, :import_csv_exec]
|
||
|
|
||
|
helper :attachments
|
||
|
include AttachmentsHelper
|
||
|
helper :sort
|
||
|
include SortHelper
|
||
|
helper :glossary
|
||
|
include GlossaryHelper
|
||
|
helper :glossary_port
|
||
|
include GlossaryPortHelper
|
||
|
helper :glossary_styles
|
||
|
include GlossaryStylesHelper
|
||
|
|
||
|
|
||
|
def index
|
||
|
|
||
|
@is_index = true
|
||
|
set_show_params
|
||
|
@terms = find_terms(@glossary_style.project_scope)
|
||
|
unless @terms.empty?
|
||
|
sortparams = @glossary_style.sort_params
|
||
|
sort_terms(@terms, sortparams) unless sortparams.empty?
|
||
|
off_params = @show_params.clone
|
||
|
off_params.delete("category")
|
||
|
off_params.delete("project")
|
||
|
if (!@glossary_style.grouping?)
|
||
|
check_nouse_params(@terms, off_params)
|
||
|
else
|
||
|
@terms = grouping(@glossary_style.groupby, @terms, off_params)
|
||
|
end
|
||
|
@show_params.delete_if {|prm| off_params.member?(prm) }
|
||
|
end
|
||
|
|
||
|
|
||
|
respond_to do |format|
|
||
|
format.html { render :template => 'glossary/index.html.erb', :layout => !request.xhr? }
|
||
|
format.csv {
|
||
|
ary = @terms
|
||
|
ary = GroupingTerms.flatten(@terms) if (@glossary_style.grouping?)
|
||
|
send_data(glossary_to_csv(ary), :type => 'text',
|
||
|
:filename => "glossary-export.csv")
|
||
|
}
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|
||
|
def index_clear
|
||
|
params[:search_index_ch] = nil
|
||
|
redirect_to :controller => 'glossary', :action => 'index', :id => @project
|
||
|
end
|
||
|
|
||
|
|
||
|
def show
|
||
|
set_show_params
|
||
|
@term_categories = TermCategory.find(:all, :conditions => "project_id = #{@project.id}", :order => "position")
|
||
|
respond_to do |format|
|
||
|
format.html { render :template => 'glossary/show.html.erb', :layout => !request.xhr? }
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def new
|
||
|
@term_categories = TermCategory.find(:all, :conditions => "project_id = #{@project.id}", :order => "position")
|
||
|
@term = Term.new(params[:term])
|
||
|
@term.name = CGI::unescapeHTML(params[:new_term_name]) if params[:new_term_name]
|
||
|
@term.project_id = @project.id
|
||
|
|
||
|
unless (request.get? || request.xhr?)
|
||
|
@term.author_id = User.current.id
|
||
|
@term.updater_id = User.current.id
|
||
|
if @term.save
|
||
|
attach_files(@term, params[:attachments])
|
||
|
flash[:notice] = l(:notice_successful_create)
|
||
|
if (params[:continue])
|
||
|
redirect_to :controller => 'glossary', :action => 'new', :id => @project
|
||
|
else
|
||
|
redirect_to :controller => 'glossary', :action => 'show', :id => @project,
|
||
|
:term_id => @term
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def preview
|
||
|
@text = params[:term][:description]
|
||
|
render :partial => 'common/preview'
|
||
|
end
|
||
|
|
||
|
def edit
|
||
|
@term_categories = TermCategory.find(:all, :conditions => "project_id = #{@project.id}", :order => "position")
|
||
|
|
||
|
if request.post?
|
||
|
@term.attributes = params[:term]
|
||
|
@term.updater_id = User.current.id
|
||
|
if @term.save
|
||
|
attach_files(@term, params[:attachments])
|
||
|
flash[:notice] = l(:notice_successful_update)
|
||
|
redirect_to :controller => 'glossary', :action => 'show', :id => @project, :term_id => @term
|
||
|
return
|
||
|
end
|
||
|
end
|
||
|
rescue ActiveRecord::StaleObjectError
|
||
|
# Optimistic locking exception
|
||
|
flash.now[:error] = l(:notice_locking_conflict)
|
||
|
end
|
||
|
|
||
|
def destroy
|
||
|
@term.destroy
|
||
|
redirect_to :action => 'index', :id => @project
|
||
|
end
|
||
|
|
||
|
def add_term_category
|
||
|
@category = TermCategory.new(params[:category])
|
||
|
@category.project_id = @project.id
|
||
|
if request.post? and @category.save
|
||
|
respond_to do |format|
|
||
|
format.html do
|
||
|
flash[:notice] = l(:notice_successful_create)
|
||
|
redirect_to :controller => 'term_categories', :action => 'index', :id => @project
|
||
|
end
|
||
|
format.js do
|
||
|
term_categories = TermCategory.find(:all, :conditions => "project_id = #{@project.id}")
|
||
|
render(:update) {|page| page.replace "term_category_id",
|
||
|
content_tag('select', '<option></option>' + options_from_collection_for_select(term_categories, 'id', 'name', @category.id), :id => 'term_category_id', :name => 'term[category_id]')
|
||
|
}
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|
||
|
def move_all
|
||
|
projs = Project.visible.find(:all)
|
||
|
@allowed_projs = projs.find_all {|proj|
|
||
|
User.current.allowed_to?({:controller =>'glossary', :action => 'index'}, proj) and
|
||
|
User.current.allowed_to?({:controller =>'glossary', :action => 'move_all'}, proj) and
|
||
|
proj != @project
|
||
|
}
|
||
|
if request.post?
|
||
|
newproj = Project.find(params[:new_project_id])
|
||
|
cats = TermCategory.find(:all, :conditions => "project_id = #{newproj.id}",
|
||
|
:order => "position")
|
||
|
posbase = (cats.blank?) ? 0 : cats.last.position - 1;
|
||
|
cats = TermCategory.find(:all, :conditions => "project_id = #{@project.id}")
|
||
|
cats.each {|cat|
|
||
|
cat.project_id = newproj.id
|
||
|
cat.position += cat.position + posbase
|
||
|
cat.save
|
||
|
}
|
||
|
Term::update_all("project_id = #{newproj.id}", "project_id = #{@project.id}")
|
||
|
flash[:notice] = l(:notice_successful_update)
|
||
|
redirect_to({:action => 'index', :id => newproj})
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|
||
|
def import_csv
|
||
|
end
|
||
|
|
||
|
def import_csv_exec
|
||
|
@import_info = CsvGlossaryImportInfo.new(params)
|
||
|
glossary_from_csv(@import_info, @project.id)
|
||
|
if (@import_info.success?)
|
||
|
flash[:notice] = l(:notice_successful_create)
|
||
|
else
|
||
|
flash.now[:error] = l(:error_import_failed) + " " + @import_info.err_string
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|
||
|
private
|
||
|
|
||
|
def show_param?(prmname)
|
||
|
case prmname
|
||
|
when 'project'
|
||
|
return false unless @glossary_style.project_scope != GlossaryStyle::ProjectCurrent
|
||
|
return true unless @is_index
|
||
|
@glossary_style.groupby != GlossaryStyle::GroupByProject
|
||
|
when 'category'
|
||
|
return true unless @is_index
|
||
|
@glossary_style.groupby != GlossaryStyle::GroupByCategory
|
||
|
when 'rubi'
|
||
|
(param_visible?(prmname) and !@is_index)
|
||
|
when 'abbr_whole'
|
||
|
(param_visible?(prmname) and !@is_index)
|
||
|
else
|
||
|
param_visible?(prmname)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def set_show_params
|
||
|
@show_params = default_show_params.find_all {|prmname|
|
||
|
show_param?(prmname)
|
||
|
}
|
||
|
end
|
||
|
|
||
|
def check_nouse_params(terms, off_params)
|
||
|
terms.each {|term|
|
||
|
return if off_params.empty?
|
||
|
off_params.delete_if {|prm| !term[prm].empty? }
|
||
|
}
|
||
|
end
|
||
|
|
||
|
def grouping(type, terms, off_params)
|
||
|
grouptbl = {}
|
||
|
terms.each {|term|
|
||
|
off_params.delete_if {|prm| !term[prm].empty? }
|
||
|
tgt = (type == GlossaryStyle::GroupByProject) ? term.project : term.category
|
||
|
gterms = grouptbl[tgt];
|
||
|
unless (gterms)
|
||
|
gterms = GroupingTerms.new(type, tgt)
|
||
|
grouptbl[tgt] = gterms
|
||
|
end
|
||
|
gterms.ary << term
|
||
|
}
|
||
|
grouptbl.values.sort
|
||
|
end
|
||
|
|
||
|
|
||
|
#### sort
|
||
|
|
||
|
def sort_terms(terms, prms)
|
||
|
terms.sort! {|a, b|
|
||
|
re = nil
|
||
|
prms.each {|prm|
|
||
|
re = Term.compare_by_param(prm, a, b)
|
||
|
break if (re != 0)
|
||
|
}
|
||
|
(re == 0) ? a.id <=> b.id : re
|
||
|
}
|
||
|
end
|
||
|
|
||
|
|
||
|
#### find
|
||
|
|
||
|
def join_queries(ary, ex = 'OR')
|
||
|
joinstr = " #{ex} "
|
||
|
((ary.size == 1) ? ary[0] : "( #{ary.join(joinstr)} )")
|
||
|
end
|
||
|
|
||
|
def query_project_scope(projscope, queries)
|
||
|
ary = authorized_projects(projscope, @project,
|
||
|
{:controller => :glossary, :action => :index})
|
||
|
return false if ary.empty?
|
||
|
queries << join_queries(ary.collect{|proj| "project_id = #{proj.id}" })
|
||
|
true
|
||
|
end
|
||
|
|
||
|
def query_category(catname, queries)
|
||
|
return if (!catname or catname.empty? )
|
||
|
if (catname == "(#{l(:label_not_categorized)})")
|
||
|
queries << "( category_id IS NULL )"
|
||
|
else
|
||
|
cats = TermCategory.find(:all, :conditions => ["name LIKE :catname",
|
||
|
{:catname => catname + "%"}])
|
||
|
ary = []
|
||
|
ptn = /^#{Regexp.escape(catname)}\//
|
||
|
cats.each {|encat|
|
||
|
if (encat.name == catname or encat.name =~ ptn)
|
||
|
ary << "category_id = #{encat.id}"
|
||
|
end
|
||
|
}
|
||
|
queries << join_queries(ary) unless (ary.empty?)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|
||
|
def query_search_str(str, queries, symbols)
|
||
|
return unless (str and !str.empty?)
|
||
|
strs = tokenize_by_space(str)
|
||
|
cnt = 0
|
||
|
strs.each {|ss|
|
||
|
symbols["search_str_#{cnt}".to_sym] = "%#{ss}%"
|
||
|
cnt += 1
|
||
|
}
|
||
|
ary = []
|
||
|
default_searched_params.each {|prm|
|
||
|
subary = []
|
||
|
cnt = 0
|
||
|
strs.each {|ss|
|
||
|
subary << "( #{prm} LIKE :search_str_#{cnt} )"
|
||
|
cnt += 1
|
||
|
}
|
||
|
ary << join_queries(subary, 'AND')
|
||
|
}
|
||
|
queries << join_queries(ary) if (0 < ary.size)
|
||
|
end
|
||
|
|
||
|
|
||
|
def get_search_index_charset(ch, type)
|
||
|
charset = [ch]
|
||
|
return charset if type
|
||
|
idx = l(:index_ary).index(ch)
|
||
|
subary = l(:index_subary)
|
||
|
if (subary.is_a?(Array) and subary[idx] and !subary[idx].empty?)
|
||
|
if (subary[idx].is_a?(Array))
|
||
|
subary[idx].each {|subch|
|
||
|
charset << subch
|
||
|
}
|
||
|
else
|
||
|
charset << subary[idx]
|
||
|
end
|
||
|
end
|
||
|
charset
|
||
|
end
|
||
|
|
||
|
|
||
|
def query_search_index(ch, type, queries, symbols)
|
||
|
return unless (ch and !ch.empty?)
|
||
|
charset = get_search_index_charset(ch, type)
|
||
|
searchprms = [:name, :abbr_whole, :rubi]
|
||
|
searchprms << [:name_en] if (type)
|
||
|
cnt = 0
|
||
|
charset.each {|tch|
|
||
|
symbols["search_ch_#{cnt}".to_sym] = tch + '%'
|
||
|
cnt += 1
|
||
|
}
|
||
|
ary = []
|
||
|
searchprms.each {|prm|
|
||
|
subary = []
|
||
|
cnt = 0
|
||
|
charset.each {|tch|
|
||
|
subary << "( #{prm} LIKE :search_ch_#{cnt} )"
|
||
|
cnt += 1
|
||
|
}
|
||
|
ary << join_queries(subary)
|
||
|
}
|
||
|
@query_string = join_queries(ary)
|
||
|
queries << join_queries(ary) if (0 < ary.size)
|
||
|
end
|
||
|
|
||
|
|
||
|
def find_terms(project_scope)
|
||
|
queries = []
|
||
|
symbols = {}
|
||
|
return [] unless query_project_scope(project_scope, queries)
|
||
|
query_category(params[:search_category], queries)
|
||
|
query_search_str(params[:search_str], queries, symbols)
|
||
|
query_search_index(params[:search_index_ch], params[:search_index_type],
|
||
|
queries, symbols)
|
||
|
terms = nil
|
||
|
if (queries.empty?)
|
||
|
terms = Term.find(:all)
|
||
|
else
|
||
|
query_str = join_queries(queries, "AND")
|
||
|
terms = Term.find(:all, :conditions => [query_str, symbols])
|
||
|
end
|
||
|
if (terms and params[:latest_days] and !params[:latest_days].empty?)
|
||
|
limitsec = Time.now.to_i - params[:latest_days].to_i * 60 * 60 * 24
|
||
|
limittm = Time.at(limitsec)
|
||
|
terms.delete_if {|prm|
|
||
|
(prm.datetime < limittm)
|
||
|
}
|
||
|
else
|
||
|
terms
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|
||
|
def find_project
|
||
|
@project = Project.find(params[:id])
|
||
|
rescue ActiveRecord::RecordNotFoundpp
|
||
|
render_404
|
||
|
end
|
||
|
|
||
|
def find_term
|
||
|
@term = Term.find(:first,
|
||
|
:conditions => "project_id = #{@project.id} and id = #{params[:term_id]}")
|
||
|
render_404 unless @term
|
||
|
rescue
|
||
|
render_404
|
||
|
end
|
||
|
|
||
|
def attach_files(val, prm)
|
||
|
Attachment.attach_files(val, prm)
|
||
|
end
|
||
|
|
||
|
end
|
||
| app/controllers/glossary_styles_controller.rb | ||
|---|---|---|
|
class GlossaryStylesController < ApplicationController
|
||
|
unloadable
|
||
|
|
||
|
helper :glossary_styles
|
||
|
include GlossaryStylesHelper
|
||
|
|
||
|
def search
|
||
|
newparams = {
|
||
|
:controller => 'glossary', :action => 'index', :id => params[:id]
|
||
|
}
|
||
|
unless (params[:search_clear])
|
||
|
for prm in [:search_category, :search_str, :latest_days]
|
||
|
if (params[prm] and !params[prm].empty?)
|
||
|
if (prm == :latest_days and !(params[prm] =~ /^\d+$/))
|
||
|
flash[:warning] = sprintf(l(:error_to_number), params[prm])
|
||
|
else
|
||
|
newparams[prm] = params[prm]
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
redirect_to(newparams)
|
||
|
end
|
||
|
|
||
|
|
||
|
def edit
|
||
|
if (User.current.anonymous?)
|
||
|
if (params[:clear])
|
||
|
session[:glossary_style] = nil
|
||
|
else
|
||
|
session[:glossary_style] = params[:glossary_style]
|
||
|
end
|
||
|
else
|
||
|
unless params[:glossary_style_id].blank?
|
||
|
@glossary_style = GlossaryStyle.find(params[:glossary_style_id])
|
||
|
end
|
||
|
|
||
|
if (@glossary_style)
|
||
|
if (params[:clear])
|
||
|
@glossary_style.set_default!
|
||
|
else
|
||
|
params[:glossary_style].each {|key,val|
|
||
|
@glossary_style[key] = val
|
||
|
}
|
||
|
end
|
||
|
else
|
||
|
@glossary_style = GlossaryStyle.new(params[:glossary_style])
|
||
|
end
|
||
|
|
||
|
@glossary_style.user_id = User.current.id
|
||
|
unless @glossary_style.save
|
||
|
flash[:error] = l(:notice_glossary_style_create_f)
|
||
|
end
|
||
|
end
|
||
|
newparams = {:controller => 'glossary', :action => 'index',
|
||
|
:id => params[:id],
|
||
|
:glossary_style_id => @glossary_style_id}
|
||
|
add_search_params(newparams)
|
||
|
redirect_to(newparams)
|
||
|
end
|
||
|
end
|
||
| app/controllers/term_categories_controller.rb | ||
|---|---|---|
|
class TermCategoriesController < ApplicationController
|
||
|
unloadable
|
||
|
|
||
|
layout 'base'
|
||
|
menu_item :glossary, :only => [:index, :edit, :destroy]
|
||
|
|
||
|
before_filter :find_project, :authorize
|
||
|
before_filter :retrieve_glossary_style, :only => [:index]
|
||
|
|
||
|
verify :method => :post, :only => :destroy
|
||
|
verify :mothod => :post, :only => :change_order
|
||
|
|
||
|
helper :glossary
|
||
|
include GlossaryHelper
|
||
|
helper :glossary_styles
|
||
|
include GlossaryStylesHelper
|
||
|
|
||
|
|
||
|
def index
|
||
|
@categories = TermCategory.find(:all, :conditions => "project_id = #{@project.id}",
|
||
|
:order => "position")
|
||
|
end
|
||
|
|
||
|
def edit
|
||
|
@category = TermCategory.find(:first, :conditions => "project_id = #{@project.id} and id = #{params[:category_id]}")
|
||
|
if request.post? and @category.update_attributes(params[:category])
|
||
|
flash[:notice] = l(:notice_successful_update)
|
||
|
redirect_to :controller => 'term_categories', :action => 'index', :id => @project
|
||
|
end
|
||
|
rescue ActiveRecord::RecordNotFound
|
||
|
render_404
|
||
|
end
|
||
|
|
||
|
def change_order
|
||
|
if request.post?
|
||
|
category = TermCategory.find(:first, :conditions => "project_id = #{@project.id} and id = #{params[:category_id]}")
|
||
|
case params[:position]
|
||
|
when 'highest'; category.move_to_top
|
||
|
when 'higher'; category.move_higher
|
||
|
when 'lower'; category.move_lower
|
||
|
when 'lowest'; category.move_to_bottom
|
||
|
end if params[:position]
|
||
|
redirect_to :controller => 'term_categories', :action => 'index', :id => @project
|
||
|
end
|
||
|
rescue ActiveRecord::RecordNotFound
|
||
|
render_404
|
||
|
end
|
||
|
|
||
|
def destroy
|
||
|
@category = TermCategory.find(:first, :conditions => "project_id = #{@project.id} and id = #{params[:category_id]}")
|
||
|
@term_count = @category.terms.size
|
||
|
if @term_count == 0
|
||
|
@category.destroy
|
||
|
redirect_to :controller => 'term_categories', :action => 'index', :id => @project
|
||
|
elsif params[:todo]
|
||
|
reassign_to = TermCategory.find(:first, :conditions => "project_id = #{@project.id} and id = #{params[:reassign_to_id]}") if params[:todo] == 'reassign'
|
||
|
@category.destroy(reassign_to)
|
||
|
redirect_to :controller => 'term_categories', :action => 'index', :id => @project
|
||
|
end
|
||
|
@categories = TermCategory.find(:all, :conditions => "project_id = #{@project.id}") - [@category]
|
||
|
rescue ActiveRecord::RecordNotFound
|
||
|
render_404
|
||
|
end
|
||
|
|
||
|
private
|
||
|
def find_project
|
||
|
@project = Project.find(params[:id])
|
||
|
rescue ActiveRecord::RecordNotFound
|
||
|
render_404
|
||
|
end
|
||
|
|
||
|
def conditions_projects()
|
||
|
ary = authorized_projects(@glossary_style.project_scope, @project,
|
||
|
{:controller => :term_categories, :action => :edit})
|
||
|
return nil if ary.empty?
|
||
|
return ary.collect{|proj| "project_id = #{proj.id}" }.join(" OR ")
|
||
|
end
|
||
|
|
||
|
end
|
||
| app/helpers/glossary_helper.rb | ||
|---|---|---|
|
require 'glossary_import_info'
|
||
|
|
||
|
module GlossaryHelper
|
||
|
|
||
|
def label_param(prmname)
|
||
|
case prmname
|
||
|
when 'id'
|
||
|
'#'
|
||
|
when 'project'
|
||
|
I18n.t(:label_project)
|
||
|
when 'category'
|
||
|
I18n.t(:field_category)
|
||
|
when 'datetime'
|
||
|
I18n.t(:field_updated_on)
|
||
|
when 'author'
|
||
|
I18n.t(:field_author)
|
||
|
when 'updater'
|
||
|
I18n.t(:label_updater)
|
||
|
when 'created_on'
|
||
|
I18n.t(:field_created_on)
|
||
|
when 'updated_on'
|
||
|
I18n.t(:field_updated_on)
|
||
|
when 'description'
|
||
|
I18n.t(:field_description)
|
||
|
else
|
||
|
I18n.t("label.#{prmname}")
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|
||
|
def param_visible?(prmname)
|
||
|
!Setting.plugin_redmine_glossary["hide_item_#{prmname}"]
|
||
|
end
|
||
|
|
||
|
def collect_visible_params(prmary)
|
||
|
ary = []
|
||
|
prmary {|prm|
|
||
|
ary << prm if param_visible?(prm)
|
||
|
}
|
||
|
end
|
||
|
|
||
|
def default_show_params; Term.default_show_params; end
|
||
|
def default_searched_params; Term.default_searched_params; end
|
||
|
def default_sort_params; Term.default_sort_params; end
|
||
|
|
||
|
|
||
|
def params_select(form, name, prms)
|
||
|
options = prms.collect{|prm| [label_param(prm), prm]}
|
||
|
form.select(name, options, :include_blank=>true)
|
||
|
end
|
||
|
|
||
|
def params_select_tag(name, prms, defaultprm)
|
||
|
options = [""]
|
||
|
options += prms.collect{|prm| [label_param(prm), prm]}
|
||
|
select_tag(name, options_from_collection_for_select(options), defaultprm)
|
||
|
end
|
||
|
|
||
|
|
||
|
# extract tokens from the question
|
||
|
# eg. hello "bye bye" => ["hello", "bye bye"]
|
||
|
def tokenize_by_space(str)
|
||
|
str.scan(%r{((\s|^)"[\s\w]+"(\s|$)|\S+)}).collect {|m|
|
||
|
m.first.gsub(%r{(^\s*"\s*|\s*"\s*$)}, '')
|
||
|
}
|
||
|
end
|
||
|
|
||
|
|
||
|
|
||
|
def updated_by(updated, author)
|
||
|
time_tag = content_tag('acronym', distance_of_time_in_words(Time.now, updated), :title => format_time(updated))
|
||
|
author_tag = (author.is_a?(User) && !author.is_a?(AnonymousUser)) ? link_to(h(author), :controller => 'account', :action => 'show', :id => author) : h(author || 'Anonymous')
|
||
|
l(:label_updated_time_by, :author => author_tag, :age => time_tag)
|
||
|
end
|
||
|
|
||
|
end
|
||
| app/helpers/glossary_port_helper.rb | ||
|---|---|---|
|
module GlossaryPortHelper
|
||
|
|
||
|
|
||
|
def glossary_csvout(csv, ic, ary)
|
||
|
csv << ary.collect {|c|
|
||
|
begin
|
||
|
ic.iconv(c.to_s)
|
||
|
rescue
|
||
|
c.to_s
|
||
|
end
|
||
|
}
|
||
|
end
|
||
|
|
||
|
def glossary_to_csv(terms)
|
||
|
ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
|
||
|
export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
|
||
|
# csv header fields
|
||
|
headers = Term.export_params.collect {|prm|
|
||
|
label_param(prm)
|
||
|
}
|
||
|
|
||
|
glossary_csvout(csv, ic, headers)
|
||
|
|
||
|
# csv lines
|
||
|
terms.each do |term|
|
||
|
fields = Term.export_params.collect {|prm|
|
||
|
term.param_to_s(prm)
|
||
|
}
|
||
|
glossary_csvout(csv, ic, fields)
|
||
|
end
|
||
|
end
|
||
|
export
|
||
|
end
|
||
|
|
||
|
|
||
|
def glossary_from_csv(portinfo, projid)
|
||
|
line_count = 0
|
||
|
begin
|
||
|
ic = Iconv.new('UTF-8', portinfo.in_encoding)
|
||
|
|
||
|
raise l(:error_file_none) if (!portinfo.import_file)
|
||
|
FCSV::parse(portinfo.import_file) { |row|
|
||
|
line_count += 1
|
||
|
next if (portinfo.is_first_comment and line_count == 1)
|
||
|
next if (row.empty?)
|
||
|
|
||
|
name = row[portinfo.param_col('name')]
|
||
|
raise sprintf(l(:error_no_name), t("label.name")) unless name
|
||
|
|
||
|
name = ic.iconv(name)
|
||
|
term = Term.find(:first,
|
||
|
:conditions => ["project_id = #{projid} AND name = :name",
|
||
|
{:name=>name}])
|
||
|
if (term)
|
||
|
portinfo.upterm_num += 1
|
||
|
else
|
||
|
term = Term.new(:name => name, :project_id => projid)
|
||
|
portinfo.newterm_num += 1
|
||
|
end
|
||
|
|
||
|
for col in 0 ... row.size
|
||
|
prm = portinfo.col_param(col)
|
||
|
next unless prm
|
||
|
val = ic.iconv(row[col].to_s)
|
||
|
case prm
|
||
|
when 'name'
|
||
|
when 'category'
|
||
|
cat = TermCategory.find_by_name(val)
|
||
|
unless (cat)
|
||
|
cat = TermCategory.new(:name => val)
|
||
|
unless (cat.save)
|
||
|
raise l(:error_create_term_category)
|
||
|
end
|
||
|
portinfo.cat_num += 1
|
||
|
end
|
||
|
term['category_id'] = cat.id
|
||
|
else
|
||
|
term[prm] = val
|
||
|
end
|
||
|
end
|
||
|
unless (term.save)
|
||
|
raise l(:error_create_term)
|
||
|
end
|
||
|
}
|
||
|
rescue => evar
|
||
|
portinfo.err_string = evar.to_s
|
||
|
if (0 < line_count)
|
||
|
portinfo.err_string += sprintf(l(:error_csv_import_row), line_count)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
end
|
||
| app/helpers/glossary_styles_helper.rb | ||
|---|---|---|
|
module GlossaryStylesHelper
|
||
|
|
||
|
def retrieve_glossary_style
|
||
|
if (User.current.anonymous?)
|
||
|
if (session[:glossary_style])
|
||
|
@glossary_style = GlossaryStyle.new(session[:glossary_style])
|
||
|
end
|
||
|
else
|
||
|
if !params[:glossary_style_id].blank?
|
||
|
@glossary_style = GlossaryStyle.find(params[:glossary_style_id])
|
||
|
else
|
||
|
@glossary_style= GlossaryStyle.find(:first, :conditions => "user_id = #{User.current.id}")
|
||
|
end
|
||
|
end
|
||
|
|
||
|
unless (@glossary_style)
|
||
|
@glossary_style = GlossaryStyle.new(:groupby => GlossaryStyle::GroupByCategory)
|
||
|
@glossary_style.user_id = User.current.id
|
||
|
end
|
||
|
|
||
|
end
|
||
|
|
||
|
def search_index_table(ary, sepcnt, proj, search_index_type = nil)
|
||
|
return "" if (!ary.is_a?(Array) or sepcnt <= 0)
|
||
|
str = '<table><tr>'
|
||
|
cnt = 0
|
||
|
for ch in ary
|
||
|
str += '</tr><tr>' if ((cnt != 0) and (cnt % sepcnt) == 0 )
|
||
|
cnt += 1
|
||
|
str += '<td>'
|
||
|
if (ch and !ch.empty?)
|
||
|
prms = {:controller => 'glossary', :action => 'index', :id => proj,
|
||
|
:search_index_ch => ch}
|
||
|
prms[:search_index_type] = search_index_type if (search_index_type)
|
||
|
str += link_to(ch, prms)
|
||
|
end
|
||
|
str += '</td>'
|
||
|
end
|
||
|
str += '</tr></table>'
|
||
|
end
|
||
|
|
||
|
def search_params
|
||
|
[:search_str, :search_category, :latest_days]
|
||
|
end
|
||
|
|
||
|
def search_params_all
|
||
|
search_params + [:search_index_ch, :search_index_type]
|
||
|
end
|
||
|
|
||
|
def add_search_params(prms)
|
||
|
search_params_all.each {|prm|
|
||
|
prms[prm] = params[prm] if (params[prm] and !params[prm].empty?)
|
||
|
}
|
||
|
end
|
||
|
|
||
|
def glossary_searching?
|
||
|
search_params.each {|prm|
|
||
|
return true if (params[prm] and !params[prm].empty?)
|
||
|
}
|
||
|
return false
|
||
|
end
|
||
|
|
||
|
|
||
|
def authorized_projects(projscope, curproj, authcnd)
|
||
|
ary = []
|
||
|
case projscope
|
||
|
when GlossaryStyle::ProjectCurrent
|
||
|
return [curproj]
|
||
|
when GlossaryStyle::ProjectMine
|
||
|
ary = User.current.memberships.collect(&:project).compact.uniq
|
||
|
when GlossaryStyle::ProjectAll
|
||
|
ary = Project.visible.find(:all)
|
||
|
end
|
||
|
ary.find_all {|proj|
|
||
|
User.current.allowed_to?(authcnd, proj)
|
||
|
}
|
||
|
end
|
||
|
|
||
|
|
||
|
def break_categories(cats)
|
||
|
catstrs = []
|
||
|
cats.each {|cat|
|
||
|
catstrs << cat.name
|
||
|
if (cat.name.include?('/'))
|
||
|
str = cat.name
|
||
|
while (str =~ /^(.+)\/[^\/]+$/)
|
||
|
str = $1
|
||
|
catstrs << str
|
||
|
end
|
||
|
end
|
||
|
}
|
||
|
catstrs
|
||
|
end
|
||
|
|
||
|
def seach_category_options(projscope, curproj)
|
||
|
options = [""]
|
||
|
projs = authorized_projects(projscope, curproj, {:controller => :glossary, :action => :index})
|
||
|
unless (projs.empty?)
|
||
|
querystr = projs.collect {|proj| "project_id = #{proj.id}"}.join(" OR ")
|
||
|
options += break_categories(TermCategory.find(:all, :conditions => querystr)).sort.uniq
|
||
|
end
|
||
|
options << "(#{l(:label_not_categorized)})"
|
||
|
end
|
||
|
|
||
|
|
||
|
end
|
||
| app/helpers/term_categories_helper.rb | ||
|---|---|---|
|
module TermCategoriesHelper
|
||
|
end
|
||
| app/models/glossary_style.rb | ||
|---|---|---|
|
class GlossaryStyle < ActiveRecord::Base
|
||
|
unloadable
|
||
|
|
||
|
GroupByNone = 0
|
||
|
GroupByCategory = 1
|
||
|
GroupByProject = 2
|
||
|
|
||
|
ProjectCurrent = 0
|
||
|
ProjectMine = 1
|
||
|
ProjectAll = 2
|
||
|
|
||
|
belongs_to :project
|
||
|
|
||
|
|
||
|
def grouping?
|
||
|
case groupby
|
||
|
when GroupByCategory
|
||
|
return true
|
||
|
when GroupByProject
|
||
|
return (project_scope != ProjectCurrent)
|
||
|
end
|
||
|
return false
|
||
|
end
|
||
|
|
||
|
def set_default!
|
||
|
self['show_desc'] = false
|
||
|
self['groupby'] = 1
|
||
|
self['project_scope'] = 0
|
||
|
self['sort_item_0'] = ''
|
||
|
self['sort_item_1'] = ''
|
||
|
self['sort_item_2'] = ''
|
||
|
end
|
||
|
|
||
|
def sort_params
|
||
|
ary = []
|
||
|
for cnt in 0...3
|
||
|
prm = self["sort_item_#{cnt}"]
|
||
|
if (prm and !prm.empty?)
|
||
|
case prm
|
||
|
when 'project'
|
||
|
next if (groupby == GroupByProject or project_scope == ProjectCurrent)
|
||
|
when 'category'
|
||
|
next if (groupby == GroupByCategory)
|
||
|
end
|
||
|
ary << prm
|
||
|
end
|
||
|
end
|
||
|
ary.uniq
|
||
|
end
|
||
|
|
||
|
end
|
||
| app/models/term.rb | ||
|---|---|---|
|
class Term < ActiveRecord::Base
|
||
|
unloadable
|
||
|
|
||
|
belongs_to :category, :class_name => 'TermCategory', :foreign_key => 'category_id'
|
||
|
belongs_to :project
|
||
|
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||
|
|
||
|
validates_presence_of :name, :project
|
||
|
validates_length_of :name, :maximum => 255
|
||
|
|
||
|
acts_as_attachable
|
||
|
|
||
|
acts_as_searchable :columns => ["#{table_name}.name", "#{table_name}.description"],
|
||
|
:include => [:project]
|
||
|
|
||
|
acts_as_event :title => Proc.new {|o| "#{l(:glossary_title)} ##{o.id}: #{o.name}" },
|
||
|
:description => Proc.new {|o| "#{o.description}"},
|
||
|
:datetime => :created_on,
|
||
|
:type => 'terms',
|
||
|
:url => Proc.new {|o| {:controller => 'glossary', :action => 'show', :id => o.project, :term_id => o.id} }
|
||
|
|
||
|
|
||
|
def author
|
||
|
author_id ? User.find(:first, :conditions => "users.id = #{author_id}") : nil
|
||
|
end
|
||
|
|
||
|
def updater
|
||
|
updater_id ? User.find(:first, :conditions => "users.id = #{updater_id}") : nil
|
||
|
end
|
||
|
|
||
|
def project
|
||
|
Project.find(:first, :conditions => "projects.id = #{project_id}")
|
||
|
end
|
||
|
|
||
|
def datetime
|
||
|
(self[:created_on] != self[:updated_on]) ? self[:updated_on] : self[:created_on]
|
||
|
end
|
||
|
|
||
|
def value(prmname)
|
||
|
case prmname
|
||
|
when 'project'
|
||
|
(project) ? project.name : ""
|
||
|
when 'category'
|
||
|
(category) ? category : ""
|
||
|
when 'datetime'
|
||
|
datetime
|
||
|
else
|
||
|
self[prmname]
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def param_to_s(prmname)
|
||
|
if (prmname == 'created_on' or prmname == 'updated_on')
|
||
|
format_time(self[prmname])
|
||
|
else
|
||
|
value(prmname).to_s
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def <=>(term)
|
||
|
id <=> term.id
|
||
|
end
|
||
|
|
||
|
|
||
|
def self.compare_safe(a, b, &blk)
|
||
|
if (!a and !b)
|
||
|
return 0
|
||
|
elsif (!a or !b)
|
||
|
return -1 if a
|
||
|
return 1 if b
|
||
|
end
|
||
|
yield(a,b)
|
||
|
end
|
||
|
|
||
|
|
||
|
def self.compare_by_param(prm, a, b)
|
||
|
case prm
|
||
|
when 'project'
|
||
|
a.project.identifier <=> b.project.identifier
|
||
|
when 'category'
|
||
|
self.compare_safe(a.category, b.category) {|acat, bcat|
|
||
|
acat.position <=> bcat.position
|
||
|
}
|
||
|
when 'datetime'
|
||
|
self.compare_safe(a.value(prm), b.value(prm)) {|aval, bval|
|
||
|
(aval <=> bval) * -1
|
||
|
}
|
||
|
when 'name'
|
||
|
((a.rubi.empty?) ? a.name : a.rubi) <=> ((b.rubi.empty?) ? b.name : b.rubi)
|
||
|
else
|
||
|
self.compare_safe(a.value(prm), b.value(prm)) {|aval, bval|
|
||
|
aval <=> bval
|
||
|
}
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|
||
|
|
||
|
def to_s
|
||
|
"##{id}: #{name}"
|
||
|
end
|
||
|
|
||
|
def self.find_for_macro(tname, proj, all_project = false)
|
||
|
if proj
|
||
|
term = Term.find(:first,
|
||
|
:conditions => "project_id = #{proj.id} and name = '#{tname}'")
|
||
|
return term if term
|
||
|
end
|
||
|
return nil unless all_project
|
||
|
return self.find_by_name(tname)
|
||
|
end
|
||
|
|
||
|
def self.default_show_params
|
||
|
['name_en', 'rubi', 'abbr_whole', 'datatype', 'codename', 'project', 'category']
|
||
|
end
|
||
|
|
||
|
def self.default_searched_params
|
||
|
['name', 'name_en', 'abbr_whole', 'datatype', 'codename', 'description']
|
||
|
end
|
||
|
|
||
|
def self.default_sort_params
|
||
|
['id', 'name', 'name_en', 'abbr_whole', 'datatype', 'codename', 'project', 'category',
|
||
|
'datetime']
|
||
|
end
|
||
|
|
||
|
def self.hidable_params
|
||
|
['name_en', 'rubi', 'abbr_whole', 'datatype', 'codename']
|
||
|
end
|
||
|
|
||
|
def self.setting_params
|
||
|
['name_en', 'rubi', 'abbr_whole', 'datatype', 'codename']
|
||
|
end
|
||
|
|
||
|
def self.export_params
|
||
|
['id','project',
|
||
|
'name', 'name_en', 'rubi', 'abbr_whole', 'category', 'datatype', 'codename',
|
||
|
'author', 'updater', 'created_on', 'updated_on',
|
||
|
'description']
|
||
|
end
|
||
|
|
||
|
def self.import_params
|
||
|
['name', 'name_en', 'rubi', 'abbr_whole', 'category', 'datatype', 'codename',
|
||
|
'description']
|
||
|
end
|
||
|
|
||
|
|
||
|
|
||
|
end
|
||
| app/models/term_category.rb | ||
|---|---|---|
|
class TermCategory < ActiveRecord::Base
|
||
|
belongs_to :project
|
||
|
has_many :terms, :foreign_key => 'category_id', :dependent => :nullify
|
||
|
|
||
|
acts_as_list :scope => :project_id
|
||
|
|
||
|
validates_presence_of :name
|
||
|
validates_uniqueness_of :name, :scope => [:project_id]
|
||
|
|
||
|
alias :destroy_without_reassign :destroy
|
||
|
|
||
|
# Destroy the category
|
||
|
# If a category is specified, terms are reassigned to this category
|
||
|
def destroy(reassign_to = nil)
|
||
|
if reassign_to && reassign_to.is_a?(TermCategory) && reassign_to.project == self.project
|
||
|
Term.update_all("category_id = #{reassign_to.id}", "category_id = #{id}")
|
||
|
end
|
||
|
destroy_without_reassign
|
||
|
end
|
||
|
|
||
|
def <=>(category)
|
||
|
position <=> category.position
|
||
|
end
|
||
|
|
||
|
def to_s; name end
|
||
|
|
||
|
end
|
||
| app/views/glossary/_form.html.erb | ||
|---|---|---|
|
|
||
|
<p><%= f.text_field :name, :label=>t('label.name'), :size => 100, :required => true %></p>
|
||
|
|
||
|
<% for prm in Term.setting_params %>
|
||
|
<% if param_visible?(prm) %>
|
||
|
<p><%= f.text_field prm, :label=>label_param(prm), :size => 100 %></p>
|
||
|
<% end %>
|
||
|
<% end %>
|
||
|
|
||
|
<div class="splitcontentleft">
|
||
|
<p><%= f.select :category_id, (@term_categories.collect {|c| [c.name, c.id]}), :include_blank => true %>
|
||
|
<%= prompt_to_remote(l(:label_term_category_new),
|
||
|
l(:label_term_category_new), 'category[name]',
|
||
|
{:controller => 'glossary', :action => 'add_term_category', :id => @project},
|
||
|
:class => 'icon icon-add', :tabindex => 199) if authorize_for('glossary', 'add_term_category') %></p>
|
||
|
</div>
|
||
|
<p><%= f.text_area :description, :label=>t('label.description'),
|
||
|
:cols => 60,
|
||
|
:rows => (@term.description.blank? ? 10 : [[10, @term.description.length / 50].max, 100].min),
|
||
|
:accesskey => accesskey(:edit),
|
||
|
:class => 'wiki-edit' %></p>
|
||
|
|
||
|
|
||
|
|
||
|
<p />
|
||
|
<p><label><%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form' %></p>
|
||
|
|
||
|
<%= wikitoolbar_for 'term_description' %>
|
||
| app/views/glossary/_index_in_category.html.erb | ||
|---|---|---|
|
<table class="list glossary">
|
||
|
<thead><tr align="left">
|
||
|
<th>#</th>
|
||
|
<th><%=h t('label.name') %></th>
|
||
|
<% for prm in @show_params %>
|
||
|
<th><%=h label_param(prm) %></th>
|
||
|
<% end %>
|
||
|
<th><%=h l(:field_description)%></th>
|
||
|
<th></th>
|
||
|
</tr></thead>
|
||
|
<tbody>
|
||
|
<% for term in index_in_category -%>
|
||
|
<tr class="<%= cycle("odd", "even") %> term">
|
||
|
<td><%=h term.id %></td>
|
||
|
<td><%= term_link(term) %></td>
|
||
|
<% for prm in @show_params %>
|
||
|
<td><%=h term.value(prm) %></td>
|
||
|
<% end %>
|
||
|
<td><%=h truncate(term.description, :length=>50) %></td>
|
||
|
<td align="right">
|
||
|
<%= link_to_if_authorized(image_tag('edit.png'), {:action => 'edit', :id => @project, :term_id => term}, :title => l(:button_edit)) %>
|
||
|
<%= link_to_if_authorized(image_tag('delete.png'), {:action => 'destroy', :id => @project, :term_id => term}, :confirm => l(:text_are_you_sure), :method => :post, :title => l(:button_delete)) %>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<% end %>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
<br />
|
||
| app/views/glossary/_show_all_in_category.html.erb | ||
|---|---|---|
|
|
||
|
<% for term in show_all_in_category -%>
|
||
|
<div class="term" >
|
||
|
<h3> <%= term_link(term) %> </h3>
|
||
|
<%= render(:partial => "glossary/show_one", :object => term) %>
|
||
|
|
||
|
</div>
|
||
|
<br />
|
||
|
<% end %>
|
||
|
<br />
|
||
| app/views/glossary/_show_one.html.erb | ||
|---|---|---|
|
|
||
|
<% term = show_one %>
|
||
|
<table class="term_items">
|
||
|
<% for prm in @show_params %>
|
||
|
<tr><th><%=h label_param(prm) %>:</th><td><%= term.value(prm) %></td></tr>
|
||
|
<% end %>
|
||
|
</table>
|
||
|
<% unless (term.description.empty?) %>
|
||
|
<strong><%=l(:field_description)%></strong>:
|
||
|
<div class="wiki">
|
||
|
<%= textilizable term, :description, :attachments => term.attachments %>
|
||
|
</div>
|
||
|
|
||
|
<% if term.attachments.any? %>
|
||
|
<%= (@is_index) ? "" : '<hr />' %>
|
||
|
<%= link_to_attachments term %>
|
||
|
<% end %>
|
||
|
<% end %>
|
||
|
|
||
| app/views/glossary/_sidebar.html.erb | ||
|---|---|---|
|
|
||
|
<% if User.current.allowed_to?(:view_terms, @project, :global => true) %>
|
||
|
<h3><%= l(:label_view) %></h3>
|
||
|
<%= render(:partial => "glossary_styles/form",
|
||
|
:object => @view_style) %>
|
||
|
<br />
|
||
|
<% end %>
|
||
|
|
||
|
|
||
|
<% if User.current.allowed_to?(:manage_terms, @project, :global => true) %>
|
||
|
<h3><%= l(:label_term) %></h3>
|
||
|
<%= link_to(l(:label_term_new), {:controller => 'glossary', :action => 'new', :id => @project}, :class => 'icon icon-add') %>
|
||
|
<br />
|
||
|
<% if (Term.find(:first, :conditions => "project_id = #{@project.id}")) %>
|
||
|
<%= link_to_if_authorized(l(:label_move_all_terms), {:controller => 'glossary', :action => 'move_all', :id => @project}, :class => 'icon icon-move') %>
|
||
|
<br />
|
||
|
<% end %>
|
||
|
<%= link_to(l(:label_glossary_import_csv), {:controller => 'glossary', :action => 'import_csv', :id => @project}) %>
|
||
|
<br />
|
||
|
<% end %>
|
||
|
|
||
|
|
||
|
<% if User.current.allowed_to?(:manage_term_categories, @project, :global => true) %>
|
||
|
<h3><%= l(:label_term_category) %></h3>
|
||
|
<%= link_to l(:label_term_category_new), {:controller => 'glossary', :action => 'add_term_category', :id => @project}, :class => 'icon icon-add' %>
|
||
|
<br />
|
||
|
<%= link_to l(:label_manage_term_category), { :controller => 'term_categories', :action => 'index', :id => @project } %>
|
||
|
<br />
|
||
|
<% end %>
|
||
|
|
||
|
|
||
|
<% if User.current.allowed_to?(:view_terms, @project, :global => true) %>
|
||
|
<h3><%= l(:label_glossary_style_index) %></h3>
|
||
|
|
||
|
<% if params[:search_index_ch] %>
|
||
|
<div class="contextual">
|
||
|
<%= link_to_if_authorized(l(:button_clear), {:controller => 'glossary', :action => 'index_clear', :id => @project}, :class => 'icon icon-reload') %>
|
||
|
</div>
|
||
|
<% end %>
|
||
|
|
||
|
<%= search_index_table(l(:index_ary_en), l(:index_ary_en_sep_cnt), @project, 'en') %>
|
||
|
<br />
|
||
|
<%= search_index_table(l(:index_ary), l(:index_ary_sep_cnt), @project) %>
|
||
|
<br />
|
||
|
<% end %>
|
||
| app/views/glossary/_view_term.html.erb | ||
|---|---|---|
|
|
||
|
<% content_for :sidebar do %>
|
||
|
<%= render :partial => 'glossary/sidebar' %>
|
||
|
<% end %>
|
||
|
|
||
|
<% content_for :header_tags do %>
|
||
|
<%= stylesheet_link_tag 'glossary', :plugin => 'redmine_glossary' %>
|
||
|
<% end %>
|
||
|
|
||
|
<% html_title(l(:glossary_title)) -%>
|
||
| app/views/glossary/add_term_category.rhtml | ||
|---|---|---|
|
<h2><%=l(:label_term_category_new)%></h2>
|
||
|
|
||
|
<% labelled_tabular_form_for :category, @category, :url => { :action => 'add_term_category' } do |f| %>
|
||
|
<%= render :partial => 'term_categories/form', :locals => { :f => f } %>
|
||
|
<%= submit_tag l(:button_create) %>
|
||
|
<% end %>
|
||
|
|
||
|
<% html_title(l(:glossary_title)) -%>
|
||
| app/views/glossary/edit.html.erb | ||
|---|---|---|
|
<h2><%= l(:label_term) %> #<%= @term.id %></h2>
|
||
|
|
||
|
<% labelled_tabular_form_for :term, @term,
|
||
|
:url => {:action => 'edit', :id => @project, :term_id => @term},
|
||
|
:html => {:multipart => true, :id => 'term-form'} do |f| %>
|
||
|
<%= error_messages_for 'term' %>
|
||
|
<div class="box">
|
||
|
<%= render :partial => 'glossary/form', :locals => {:f => f} %>
|
||
|
</div>
|
||
|
<%= submit_tag l(:button_edit) %>
|
||
|
<%= link_to_remote l(:label_preview),
|
||
|
{ :url => { :controller => 'glossary', :action => 'preview', :id => @project },
|
||
|
:method => 'post',
|
||
|
:update => 'preview',
|
||
|
:with => "Form.serialize('term-form')",
|
||
|
:complete => "Element.scrollTo('preview')"
|
||
|
}, :accesskey => accesskey(:preview) %>
|
||
|
<% end %>
|
||
|
|
||
|
<div id="preview" class="wiki"></div>
|
||
|
|
||
|
<% html_title(l(:glossary_title)) -%>
|
||
| app/views/glossary/import_csv.html.erb | ||
|---|---|---|
|
<h2><%=h l(:label_glossary_import_csv) %> </h2>
|
||
|
|
||
|
|
||
|
<% form_tag({:controller => 'glossary', :action => 'import_csv_exec', :id=>@project},
|
||
|
{:multipart => true}) do %>
|
||
|
|
||
|
<%= l(:label_csv_file) %>
|
||
|
<%= file_field_tag 'import_file', :accept => 'text/csv', :size => '60%' %>
|
||
|
<br />
|
||
|
<br />
|
||
|
<% encs = l(:in_encoding_candidates)
|
||
|
if (encs and encs.is_a?(Array) and !encs.empty?)
|
||
|
enc_options = []
|
||
|
encs.each {|enc|
|
||
|
enc_options << enc
|
||
|
}
|
||
|
%>
|
||
|
<%=h l(:label_file_encoding) %>
|
||
|
<%= select_tag("in_encoding", options_for_select(enc_options)) %>
|
||
|
<br />
|
||
|
<% end %>
|
||
|
|
||
|
<label> <%= check_box_tag("is_first_comment", '1', true) %>
|
||
|
<%= l(:label_csv_import_is_first_comment) %> </label>
|
||
|
<br />
|
||
|
|
||
|
<br />
|
||
|
|
||
|
<%
|
||
|
name_options = []
|
||
|
options = [""]
|
||
|
for num in 1 ... 30
|
||
|
name_options << num
|
||
|
options << num
|
||
|
end
|
||
|
%>
|
||
|
<fieldset>
|
||
|
<legend><%= l(:label_import_items) %></legend>
|
||
|
|
||
|
<table>
|
||
|
<tr><th><%=h l(:label_item) %></th><th><%=h l(:label_column) %></th></tr>
|
||
|
<% CsvGlossaryImportInfo.default_param_cols {|prm, col| %>
|
||
|
<tr><td><%=h label_param(prm) %></td><td>
|
||
|
<%= select_tag("colno_#{prm}",
|
||
|
options_for_select((prm == 'name') ? name_options : options, col)) %>
|
||
|
</td></tr>
|
||
|
<% } %>
|
||
|
</table>
|
||
|
* <%=h l(:message_import_item) %>
|
||
|
</fieldset>
|
||
|
<br />
|
||
|
|
||
|
<%= submit_tag(l(:label_import)) %>
|
||
|
<% end %>
|
||
|
|
||
|
<% html_title(l(:glossary_title)) -%>
|
||
| app/views/glossary/import_csv_exec.html.erb | ||
|---|---|---|
|
<h2> <%=h l(:label_csv_import_finished) %> </h2>
|
||
|
|
||
|
|
||
|
<table class="term_items">
|
||
|
<tr><th><%=h l(:label_csv_file) %> : </th><td>
|
||
|
<%=h (@import_info.import_file) ? @import_info.import_file.original_filename : "" %>
|
||
|
</td></tr>
|
||
|
<tr><th><%=h l(:label_create_category_num) %> : </th><td> <%= @import_info.cat_num %> </td></tr>
|
||
|
<tr><th><%=h l(:label_create_term_num) %> : </th><td> <%= @import_info.newterm_num %> </td></tr>
|
||
|
<tr><th><%=h l(:label_update_term_num) %> : </th><td> <%= @import_info.upterm_num %> </td></tr>
|
||
|
</table>
|
||
|
|
||
|
<%= render :partial => 'glossary/view_term' %>
|
||
Original plugin from r-lab, redmine_glossary version 0.6.1