Compare commits
10 Commits
88a51b128f
...
b572818b2c
Author | SHA1 | Date | |
---|---|---|---|
|
b572818b2c | ||
|
8e0f961ebd | ||
|
65de36530c | ||
|
72adf36b32 | ||
|
3049324dd8 | ||
|
fd7c3c3deb | ||
|
517decb464 | ||
|
c30fdae698 | ||
|
e8658550a3 | ||
|
3e14a86bcb |
39
README.md
Normal file
39
README.md
Normal file
@ -0,0 +1,39 @@
|
||||
# Redmine Glossary Plugin
|
||||
|
||||
This is a plugin for Redmine to create a glossary that is a list of terms in a project.
|
||||
|
||||
This is a remake version of [the original glossary plugin](https://ja.osdn.net/projects/rp-glossary/releases/). The main goal of remaking is to fit for the recent redmine version to be maintainable.
|
||||
|
||||
## 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
|
||||
|
||||
## To get
|
||||
|
||||
### Repository
|
||||
|
||||
- <https://github.com/torutk/redmine_glossary>
|
||||
|
||||
The branches are as follows:
|
||||
|
||||
- __master__ for the recent Redmine version
|
||||
- __develop__ under developping for the next release
|
||||
- __support/2.x__ original glossary plugin ported for Redmine 2.x
|
||||
- __support/3.x__ original glossary plugin ported for Redmine 3.x
|
||||
- __support/4.0or1/based_original__ original glossary plugin ported for Redmine 4.0 or 4.1
|
||||
|
||||
### Installation and Setup
|
||||
|
||||
1. Copy the plugin directory into the Redmine's plugin directory. Note that the name of plugin's directory should be "redmine_glossary".
|
||||
2. Migrate plugin task.
|
||||
3. Restart the redmine.
|
||||
4. Set permission of glossary plugin in "Administration > Roles and permissions"
|
||||
|
||||
### Uninstall
|
||||
|
||||
- rails redmine:plugins:migrate NAME=redmine_glossary VERSION=0
|
||||
|
||||
|
@ -1,5 +0,0 @@
|
||||
= redmine_glossary
|
||||
|
||||
This is a plugin for Redmine to create a glossary that is a list of terms in a project.
|
||||
|
||||
To adapt Redmine 4.0(Rails 5.1), reconstruct a glossary plugin from scratch.
|
@ -64,6 +64,11 @@ class GlossaryTermsController < ApplicationController
|
||||
render_404
|
||||
end
|
||||
|
||||
def import
|
||||
GlossaryTerm.import(params[:file], @project)
|
||||
redirect_to project_glossary_terms_path(@project)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def glossary_term_params
|
||||
|
@ -1,9 +1,14 @@
|
||||
require 'csv'
|
||||
|
||||
class GlossaryTerm < ActiveRecord::Base
|
||||
belongs_to :category, class_name: 'GlossaryCategory', foreign_key: 'category_id'
|
||||
belongs_to :project
|
||||
belongs_to :author, class_name: 'User', foreign_key: 'author_id'
|
||||
belongs_to :updater, class_name: 'User', foreign_key: 'updater_id'
|
||||
|
||||
# class method from Redmine::Acts::Attachable::ClassMethods
|
||||
acts_as_attachable view_permission: :view_glossary, edit_permission: :manage_glossary, delete_permission: :manage_glossary
|
||||
acts_as_attachable view_permission: :view_glossary_terms, edit_permission: :manage_glossary_terms,
|
||||
delete_permission: :manage_glossary_terms
|
||||
|
||||
acts_as_event datetime: :updated_at,
|
||||
description: :description,
|
||||
@ -15,9 +20,15 @@ class GlossaryTerm < ActiveRecord::Base
|
||||
project_id: o.project }
|
||||
}
|
||||
|
||||
acts_as_searchable columns: [ "#{table_name}.name", "#{table_name}.description", "#{table_name}.rubi"],
|
||||
preload: [:project ],
|
||||
date_column: "#{table_name}.created_at",
|
||||
scope: joins(:project),
|
||||
permission: :view_glossary_terms
|
||||
|
||||
acts_as_activity_provider scope: joins(:project),
|
||||
type: 'glossary_terms',
|
||||
permission: :view_glossary,
|
||||
permission: :view_glossary_terms,
|
||||
timestamp: :updated_at
|
||||
|
||||
scope :search_by_name, -> (keyword) {
|
||||
@ -28,4 +39,21 @@ class GlossaryTerm < ActiveRecord::Base
|
||||
where 'rubi like ?', "#{sanitize_sql_like(keyword)}%"
|
||||
}
|
||||
|
||||
def self.csv_attributes
|
||||
["name", "name_en", "datatype", "codename", "description", "rubi", "abbr_whole"]
|
||||
end
|
||||
|
||||
def self.import(file, project)
|
||||
CSV.foreach(file.path, headers: true, encoding: "CP932:UTF-8" ) do |row|
|
||||
term = new
|
||||
term.attributes = row.to_hash.slice(*csv_attributes)
|
||||
term.project = project
|
||||
unless row["category"].blank?
|
||||
term.category = GlossaryCategory.find_by(name: row["category"]) ||
|
||||
GlossaryCategory.create(name: row["category"], project: project)
|
||||
end
|
||||
term.save!
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -23,6 +23,15 @@
|
||||
<td class="name"><%= link_to category.name, [@project, category] %></td>
|
||||
<td class="buttons">
|
||||
<%= reorder_handle(category, url: project_glossary_category_path(@project, category)) %>
|
||||
<%= link_to_if_authorized l(:button_edit), {
|
||||
controller: :glossary_categories, action: :edit, id: category,
|
||||
project_id: @project
|
||||
}, class: 'icon icon-edit' %>
|
||||
<%= link_to_if_authorized l(:button_delete), {
|
||||
controller: :glossary_categories, action: :destroy, id: category,
|
||||
project_id: @project
|
||||
}, method: :delete, data: {confirm: l(:text_are_you_sure)},
|
||||
class: 'icon icon-del' %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
@ -17,6 +17,18 @@
|
||||
{ controller: :glossary_terms, action: :new, project_id: @project },
|
||||
class: 'icon icon-add' %></p>
|
||||
|
||||
<fieldset class="collapsible collapsed">
|
||||
<legend onclick="toggleFieldset(this);" class="icon icon-collapsed">
|
||||
<%=l :label_glossary_term_import_csv %>
|
||||
</legend>
|
||||
<div style="display: none;">
|
||||
<%= form_with url: import_project_glossary_terms_path, method: :post, local: true do |form| %>
|
||||
<%= form.file_field :file %>
|
||||
<%= form.submit l(:label_import) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<h3><%=l :label_glossary_category %></h3>
|
||||
<p><%= link_to_if_authorized l(:label_glossary_category_new),
|
||||
{ controller: :glossary_categories, action: :new, project_id: @project},
|
||||
|
@ -3,7 +3,4 @@
|
||||
<%= labelled_form_for :glossary_term, @term, url: project_glossary_term_path, html: {multipart: true, id: 'term-form'} do |f| %>
|
||||
<%= render partial: 'glossary_terms/form', locals: {form: f} %>
|
||||
<%= f.submit l(:button_edit) %>
|
||||
<%= preview_link preview_project_glossary_term_path(@project, @term), 'term-form' %>
|
||||
<% end %>
|
||||
|
||||
<div id="preview" class="wiki" ></div>
|
||||
|
19
app/views/glossary_terms/index.csv.ruby
Normal file
19
app/views/glossary_terms/index.csv.ruby
Normal file
@ -0,0 +1,19 @@
|
||||
require 'csv'
|
||||
|
||||
CSV.generate(row_sep: "\r\n", encoding: "CP932") do |csv|
|
||||
column_names = ["name", "name_en", "category", "datatype", "codename", "description", "rubi", "abbr_whole"]
|
||||
csv << column_names
|
||||
@glossary_terms.each do |term|
|
||||
column_values = [
|
||||
term.name,
|
||||
term.name_en,
|
||||
term.category&.name,
|
||||
term.datatype,
|
||||
term.codename,
|
||||
term.description,
|
||||
term.rubi,
|
||||
term.abbr_whole
|
||||
]
|
||||
csv << column_values
|
||||
end
|
||||
end
|
@ -23,4 +23,6 @@
|
||||
<%= render 'index_terms', terms: @glossary_terms %>
|
||||
<% end %>
|
||||
|
||||
|
||||
<% other_formats_links do |f| %>
|
||||
<%= f.link_to_with_query_parameters 'CSV' %>
|
||||
<% end %>
|
||||
|
@ -4,7 +4,6 @@
|
||||
url: project_glossary_terms_path, html: {multipart: true, id: 'term-form'} do |f| %>
|
||||
<%= render partial: 'glossary_terms/form', locals: {form: f} %>
|
||||
<%= f.submit l(:button_create) %>
|
||||
<%= preview_link preview_project_glossary_terms_path(@project), 'term-form' %>
|
||||
<% end %>
|
||||
|
||||
<div id="preview" class="wiki"></div>
|
||||
|
@ -59,5 +59,5 @@
|
||||
|
||||
<%= render partial: 'attachments/links',
|
||||
locals: {attachments: @term.attachments,
|
||||
options: {deletable: User.current.allowed_to?(:manage_glossary, @project)}
|
||||
options: {deletable: User.current.allowed_to?(:manage_glossary_terms, @project)}
|
||||
}%>
|
||||
|
@ -3,6 +3,7 @@ en:
|
||||
label_glossary_terms: "Glossary terms"
|
||||
label_glossary_term: "Glossary term"
|
||||
label_glossary_term_new: "New glossary term"
|
||||
label_glossary_term_import_csv: "Import from CSV"
|
||||
label_glossary_categories: "Glossary categories"
|
||||
label_glossary_category: "Glossary category"
|
||||
label_glossary_category_new: "New glossary category"
|
||||
@ -11,6 +12,7 @@ en:
|
||||
project_module_glossary: Glossary
|
||||
|
||||
label_view: View
|
||||
label_import: Import
|
||||
label_glossary_index: index
|
||||
label_not_categorized: Not categorized
|
||||
label_grouping: Grouping
|
||||
@ -27,8 +29,8 @@ en:
|
||||
index_rubi: |
|
||||
|
||||
|
||||
permission_view_glossary: View glossary
|
||||
permission_manage_glossary: Manage glossary
|
||||
permission_view_glossary_terms: View glossary
|
||||
permission_manage_glossary_terms: Manage glossary
|
||||
|
||||
field_name_en: English
|
||||
field_abbr_whole: Whole word for Abbreviation
|
||||
|
@ -2,6 +2,7 @@ ja:
|
||||
label_glossary_terms: "用語集"
|
||||
label_glossary_term: "用語"
|
||||
label_glossary_term_new: "用語の作成"
|
||||
label_glossary_term_import_csv: "CSVからインポート"
|
||||
label_glossary_categories: "用語のカテゴリ一覧"
|
||||
label_glossary_category: "用語のカテゴリ"
|
||||
label_glossary_category_new: "カテゴリの作成"
|
||||
@ -10,6 +11,7 @@ ja:
|
||||
project_module_glossary: 用語集
|
||||
|
||||
label_view: 表示
|
||||
label_import: インポート
|
||||
label_glossary_index: 索引
|
||||
label_not_categorized: 未分類
|
||||
label_grouping: グループ化
|
||||
@ -29,8 +31,8 @@ ja:
|
||||
わ を ん
|
||||
|
||||
|
||||
permission_view_glossary: 用語集の閲覧
|
||||
permission_manage_glossary: 用語集の管理
|
||||
permission_view_glossary_terms: 用語集の閲覧
|
||||
permission_manage_glossary_terms: 用語集の管理
|
||||
|
||||
field_name_en: 英語名
|
||||
field_abbr_whole: 略語の展開名称
|
||||
|
@ -9,6 +9,7 @@ Rails.application.routes.draw do
|
||||
end
|
||||
collection do
|
||||
post 'preview'
|
||||
post 'import'
|
||||
end
|
||||
end
|
||||
resources :glossary_categories
|
||||
|
@ -1,10 +0,0 @@
|
||||
class CreateGlossaryTerms < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :glossary_terms do |t|
|
||||
t.string :name, null: false
|
||||
t.text :description
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
34
db/migrate/001_create_terms.rb
Normal file
34
db/migrate/001_create_terms.rb
Normal file
@ -0,0 +1,34 @@
|
||||
class CreateTerms < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
# CreateTermCategories
|
||||
create_table :term_categories, :force => true do |t|
|
||||
t.column :project_id, :integer, :default => 0, :null => false
|
||||
t.column :name, :string, :default => '', :null => false
|
||||
t.column :position, :integer, :default => 1
|
||||
end
|
||||
|
||||
add_index "term_categories", ["project_id"], :name => "categories_project_id"
|
||||
|
||||
create_table :terms, :force => true do |t|
|
||||
t.column :project_id, :integer, :default => 0, :null => false
|
||||
t.column :category_id, :integer
|
||||
t.column :author_id, :integer, :default => 0, :null => false
|
||||
t.column :updater_id, :integer
|
||||
t.column :name, :string, :default => '', :null => false
|
||||
t.column :name_en, :string, :default => ''
|
||||
t.column :datatype, :string, :default => ''
|
||||
t.column :codename, :string, :default => ''
|
||||
t.column :description, :text
|
||||
t.column :created_on, :timestamp
|
||||
t.column :updated_on, :timestamp
|
||||
end
|
||||
|
||||
add_index "terms", ["project_id"], :name => "terms_project_id"
|
||||
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :term_categories
|
||||
drop_table :terms
|
||||
end
|
||||
end
|
@ -1,7 +0,0 @@
|
||||
class CreateGlossaryCategories < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :glossary_categories do |t|
|
||||
t.string :name
|
||||
end
|
||||
end
|
||||
end
|
24
db/migrate/002_create_glossary_styles.rb
Normal file
24
db/migrate/002_create_glossary_styles.rb
Normal file
@ -0,0 +1,24 @@
|
||||
class CreateGlossaryStyles < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
create_table :glossary_styles do |t|
|
||||
t.column :show_desc, :boolean, :default => false
|
||||
t.column :groupby, :integer, :default => 1
|
||||
t.column :project_scope, :integer, :default => 0
|
||||
t.column :sort_item_0, :string, :default => ''
|
||||
t.column :sort_item_1, :string, :default => ''
|
||||
t.column :sort_item_2, :string, :default => ''
|
||||
t.column :user_id, :integer, :default => 0
|
||||
end
|
||||
|
||||
add_column :terms, :rubi, :string, :default => ''
|
||||
add_column :terms, :abbr_whole, :string, :default => ''
|
||||
|
||||
end
|
||||
|
||||
|
||||
def self.down
|
||||
drop_table :glossary_styles
|
||||
remove_column :terms, :abbr_whole
|
||||
remove_column :terms, :rubi
|
||||
end
|
||||
end
|
@ -1,5 +0,0 @@
|
||||
class AddCategoryToGlossaryTerms < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
add_reference :glossary_terms, :category, foreign_key: true
|
||||
end
|
||||
end
|
14
db/migrate/003_terms_add_columns.rb
Normal file
14
db/migrate/003_terms_add_columns.rb
Normal file
@ -0,0 +1,14 @@
|
||||
class TermsAddColumns < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
add_column :terms, :tech_en, :string, :default => ''
|
||||
add_column :terms, :name_cn, :string, :default => ''
|
||||
add_column :terms, :name_fr, :string, :default => ''
|
||||
end
|
||||
|
||||
|
||||
def self.down
|
||||
remove_column :terms, :tech_en
|
||||
remove_column :terms, :name_cn
|
||||
remove_column :terms, :name_fr
|
||||
end
|
||||
end
|
@ -1,6 +0,0 @@
|
||||
class AddProjectToTermsAndCategories < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
add_reference :glossary_terms, :project, foreign_key: true
|
||||
add_reference :glossary_categories, :project, foreign_key: true
|
||||
end
|
||||
end
|
12
db/migrate/004_rename_glossary_terms_from_terms.rb
Normal file
12
db/migrate/004_rename_glossary_terms_from_terms.rb
Normal file
@ -0,0 +1,12 @@
|
||||
class RenameGlossaryTermsFromTerms < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
remove_column :terms, :tech_en, :string
|
||||
remove_column :terms, :name_cn, :string
|
||||
remove_column :terms, :name_fr, :string
|
||||
change_column :terms, :created_on, :timestamp, default: -> { 'CURRENT_TIMESTAMP' }
|
||||
rename_column :terms, :created_on, :created_at
|
||||
change_column :terms, :updated_on, :timestamp, default: -> { 'CURRENT_TIMESTAMP' }
|
||||
rename_column :terms, :updated_on, :updated_at
|
||||
rename_table :terms, :glossary_terms
|
||||
end
|
||||
end
|
@ -1,9 +0,0 @@
|
||||
class AddColumnsToGlossaryTerms < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
add_column :glossary_terms, :name_en, :string, default: ''
|
||||
add_column :glossary_terms, :rubi, :string, default: ''
|
||||
add_column :glossary_terms, :abbr_whole, :string, default: ''
|
||||
add_column :glossary_terms, :datatype, :string, default: ''
|
||||
add_column :glossary_terms, :codename, :string, default: ''
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class RenameGlossaryCategoriesFromTermCategories < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
rename_table :term_categories, :glossary_categories
|
||||
end
|
||||
end
|
@ -1,6 +0,0 @@
|
||||
class AddPositionToGlossaryCategories < ActiveRecord::Migration[5.2]
|
||||
|
||||
def change
|
||||
add_column :glossary_categories, :position, :integer, default: nil
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class RenameGlossaryViewSettingsFromGlossaryStyles < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
rename_table :glossary_styles, :glossary_view_settings
|
||||
end
|
||||
end
|
15
init.rb
15
init.rb
@ -1,23 +1,25 @@
|
||||
Rails.configuration.to_prepare do
|
||||
require_dependency "glossary_macros"
|
||||
Redmine::Activity.register :glossary_terms
|
||||
Redmine::Search.available_search_types << 'glossary_terms'
|
||||
end
|
||||
|
||||
Redmine::Plugin.register :redmine_glossary do
|
||||
name 'Redmine Glossary plugin'
|
||||
author 'Toru Takahashi'
|
||||
description 'This is a plugin for Redmine to create a glossary that is a list of terms in a project.'
|
||||
version '1.0.1'
|
||||
version '1.1.0'
|
||||
url 'https://github.com/torutk/redmine_glossary'
|
||||
author_url 'http://www.torutk.com'
|
||||
|
||||
requires_redmine version_or_higher: '4.0'
|
||||
|
||||
project_module :glossary do
|
||||
permission :view_glossary, {
|
||||
permission :view_glossary_terms, {
|
||||
glossary_terms: [:index, :show],
|
||||
glossary_categories: [:index, :show]
|
||||
}
|
||||
permission :manage_glossary, {
|
||||
glossary_terms: [:new, :create, :edit, :update, :destroy],
|
||||
permission :manage_glossary_terms, {
|
||||
glossary_terms: [:new, :create, :edit, :update, :destroy, :import],
|
||||
glossary_categories: [:new, :create, :edit, :update, :destroy],
|
||||
},
|
||||
require: :member
|
||||
@ -30,6 +32,3 @@ Redmine::Plugin.register :redmine_glossary do
|
||||
param: :project_id
|
||||
|
||||
end
|
||||
|
||||
|
||||
Redmine::Activity.register :glossary_terms
|
||||
|
Loading…
Reference in New Issue
Block a user