Compare commits
No commits in common. "b572818b2c5adc07fec4aaab1660e8b53307a485" and "88a51b128fe6a1f079337a22f5befe62d9716ea0" have entirely different histories.
b572818b2c
...
88a51b128f
39
README.md
39
README.md
@ -1,39 +0,0 @@
|
||||
# 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
|
||||
|
||||
|
5
README.rdoc
Normal file
5
README.rdoc
Normal file
@ -0,0 +1,5 @@
|
||||
= 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,11 +64,6 @@ 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,14 +1,9 @@
|
||||
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_terms, edit_permission: :manage_glossary_terms,
|
||||
delete_permission: :manage_glossary_terms
|
||||
acts_as_attachable view_permission: :view_glossary, edit_permission: :manage_glossary, delete_permission: :manage_glossary
|
||||
|
||||
acts_as_event datetime: :updated_at,
|
||||
description: :description,
|
||||
@ -20,17 +15,11 @@ 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_terms,
|
||||
permission: :view_glossary,
|
||||
timestamp: :updated_at
|
||||
|
||||
|
||||
scope :search_by_name, -> (keyword) {
|
||||
where 'name like ?', "#{sanitize_sql_like(keyword)}%"
|
||||
}
|
||||
@ -39,21 +28,4 @@ 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,15 +23,6 @@
|
||||
<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,18 +17,6 @@
|
||||
{ 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,4 +3,7 @@
|
||||
<%= 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>
|
||||
|
@ -1,19 +0,0 @@
|
||||
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,6 +23,4 @@
|
||||
<%= render 'index_terms', terms: @glossary_terms %>
|
||||
<% end %>
|
||||
|
||||
<% other_formats_links do |f| %>
|
||||
<%= f.link_to_with_query_parameters 'CSV' %>
|
||||
<% end %>
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
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_terms, @project)}
|
||||
options: {deletable: User.current.allowed_to?(:manage_glossary, @project)}
|
||||
}%>
|
||||
|
@ -3,7 +3,6 @@ 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"
|
||||
@ -12,7 +11,6 @@ en:
|
||||
project_module_glossary: Glossary
|
||||
|
||||
label_view: View
|
||||
label_import: Import
|
||||
label_glossary_index: index
|
||||
label_not_categorized: Not categorized
|
||||
label_grouping: Grouping
|
||||
@ -29,8 +27,8 @@ en:
|
||||
index_rubi: |
|
||||
|
||||
|
||||
permission_view_glossary_terms: View glossary
|
||||
permission_manage_glossary_terms: Manage glossary
|
||||
permission_view_glossary: View glossary
|
||||
permission_manage_glossary: Manage glossary
|
||||
|
||||
field_name_en: English
|
||||
field_abbr_whole: Whole word for Abbreviation
|
||||
|
@ -2,7 +2,6 @@ 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: "カテゴリの作成"
|
||||
@ -11,8 +10,7 @@ ja:
|
||||
project_module_glossary: 用語集
|
||||
|
||||
label_view: 表示
|
||||
label_import: インポート
|
||||
label_glossary_index: 索引
|
||||
label_glossary_index: 索引
|
||||
label_not_categorized: 未分類
|
||||
label_grouping: グループ化
|
||||
label_categorized: カテゴリで分類
|
||||
@ -31,8 +29,8 @@ ja:
|
||||
わ を ん
|
||||
|
||||
|
||||
permission_view_glossary_terms: 用語集の閲覧
|
||||
permission_manage_glossary_terms: 用語集の管理
|
||||
permission_view_glossary: 用語集の閲覧
|
||||
permission_manage_glossary: 用語集の管理
|
||||
|
||||
field_name_en: 英語名
|
||||
field_abbr_whole: 略語の展開名称
|
||||
|
@ -9,7 +9,6 @@ Rails.application.routes.draw do
|
||||
end
|
||||
collection do
|
||||
post 'preview'
|
||||
post 'import'
|
||||
end
|
||||
end
|
||||
resources :glossary_categories
|
||||
|
10
db/migrate/001_create_glossary_terms.rb
Normal file
10
db/migrate/001_create_glossary_terms.rb
Normal file
@ -0,0 +1,10 @@
|
||||
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
|
@ -1,34 +0,0 @@
|
||||
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
|
7
db/migrate/002_create_glossary_categories.rb
Normal file
7
db/migrate/002_create_glossary_categories.rb
Normal file
@ -0,0 +1,7 @@
|
||||
class CreateGlossaryCategories < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :glossary_categories do |t|
|
||||
t.string :name
|
||||
end
|
||||
end
|
||||
end
|
@ -1,24 +0,0 @@
|
||||
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
|
5
db/migrate/003_add_category_to_glossary_terms.rb
Normal file
5
db/migrate/003_add_category_to_glossary_terms.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddCategoryToGlossaryTerms < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
add_reference :glossary_terms, :category, foreign_key: true
|
||||
end
|
||||
end
|
@ -1,14 +0,0 @@
|
||||
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
|
6
db/migrate/004_add_project_to_terms_and_categories.rb
Normal file
6
db/migrate/004_add_project_to_terms_and_categories.rb
Normal file
@ -0,0 +1,6 @@
|
||||
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
|
@ -1,12 +0,0 @@
|
||||
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
|
9
db/migrate/005_add_columns_to_glossary_terms.rb
Normal file
9
db/migrate/005_add_columns_to_glossary_terms.rb
Normal file
@ -0,0 +1,9 @@
|
||||
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
|
@ -1,5 +0,0 @@
|
||||
class RenameGlossaryCategoriesFromTermCategories < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
rename_table :term_categories, :glossary_categories
|
||||
end
|
||||
end
|
6
db/migrate/006_add_position_to_glossary_categories.rb
Normal file
6
db/migrate/006_add_position_to_glossary_categories.rb
Normal file
@ -0,0 +1,6 @@
|
||||
class AddPositionToGlossaryCategories < ActiveRecord::Migration[5.2]
|
||||
|
||||
def change
|
||||
add_column :glossary_categories, :position, :integer, default: nil
|
||||
end
|
||||
end
|
@ -1,5 +0,0 @@
|
||||
class RenameGlossaryViewSettingsFromGlossaryStyles < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
rename_table :glossary_styles, :glossary_view_settings
|
||||
end
|
||||
end
|
15
init.rb
15
init.rb
@ -1,25 +1,23 @@
|
||||
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.1.0'
|
||||
version '1.0.1'
|
||||
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_terms, {
|
||||
permission :view_glossary, {
|
||||
glossary_terms: [:index, :show],
|
||||
glossary_categories: [:index, :show]
|
||||
}
|
||||
permission :manage_glossary_terms, {
|
||||
glossary_terms: [:new, :create, :edit, :update, :destroy, :import],
|
||||
permission :manage_glossary, {
|
||||
glossary_terms: [:new, :create, :edit, :update, :destroy],
|
||||
glossary_categories: [:new, :create, :edit, :update, :destroy],
|
||||
},
|
||||
require: :member
|
||||
@ -32,3 +30,6 @@ Redmine::Plugin.register :redmine_glossary do
|
||||
param: :project_id
|
||||
|
||||
end
|
||||
|
||||
|
||||
Redmine::Activity.register :glossary_terms
|
||||
|
Loading…
Reference in New Issue
Block a user