-
Notifications
You must be signed in to change notification settings - Fork 5
/
init.rb
93 lines (81 loc) · 2.96 KB
/
init.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Global Hooks
require File.expand_path('../lib/redmine_gtt/hooks/view_layouts_base_html_head_hook', __FILE__)
require File.expand_path('../lib/redmine_gtt/view_hooks', __FILE__)
Redmine::Plugin.register :redmine_gtt do
name 'Redmine GTT plugin'
author 'Georepublic'
author_url 'https://github.com/georepublic'
url 'https://github.com/gtt-project/redmine_gtt'
description 'Adds location-based task management and maps'
version '5.1.2'
requires_redmine :version_or_higher => '5.0.0'
project_module :gtt do
permission :manage_gtt_settings, {
projects: [ :update_gtt_configuration ]
}, require: :member
permission :view_gtt_settings, {
gtt_configuration: %i( default_setting_configuration )
}, require: :member, read: true
end
settings(
:default => {
'default_collapsed_issues_page_map' => false,
'default_map_center_longitude' => 139.691706,
'default_map_center_latitude' => 35.689524,
'default_map_zoom_level' => 13,
'default_map_maxzoom_level' => 19,
'default_map_fit_maxzoom_level' => 17,
'vector_minzoom_level' => 0,
'default_target_enabled' => false,
'default_measure_enabled' => false,
'default_geocoder_options' => '{}',
'editable_geometry_types_on_issue_map' => ["Point"],
'enable_geojson_upload_on_issue_map' => false,
'enable_geocoding_on_map' => false,
'hide_map_for_invalid_geom' => false
},
partial: 'settings/gtt/settings'
)
menu :admin_menu,
:gtt_map_layers,
{ controller: 'gtt_map_layers', action: 'index' },
caption: :'map_layer.plural', html: { class: 'icon icon-gtt-map' }
end
# Register MIME Types
Mime::Type.register_alias "application/json", :geojson
# Automatically encode points to geojson with as_json in rails3
RGeo::ActiveRecord::GeometryMixin.set_json_generator(:geojson)
RGeo::ActiveRecord::SpatialFactoryStore.instance.tap do |config|
config.register RGeo::Cartesian.preferred_factory(has_z_coordinate: true, srid: 4326), geo_type: 'geometry', sql_type: "geometry", srid: 4326
end
if Rails.version > '6.0' && Rails.autoloaders.zeitwerk_enabled?
Dir.glob("#{Rails.root}/plugins/redmine_gtt/app/overrides/**/*.rb").each do |path|
Rails.autoloaders.main.ignore(path)
require path
end
RedmineGtt.setup_normal_patches
Rails.application.config.after_initialize do
RedmineGtt.setup_controller_patches
end
else
require 'redmine_gtt'
# Configure View Overrides
Rails.application.paths["app/overrides"] ||= []
Rails.application.paths["app/overrides"] << File.expand_path("../app/overrides", __FILE__)
ActiveSupport::Reloader.to_prepare do
RedmineGtt.setup_normal_patches
# ActiveRecord::Base.include_root_in_json = true
# module RGeo
# module Feature
# module Point
# def as_json(params)
# ::RGeo::GeoJSON.encode(self)
# end
# end
# end
# end
end
Rails.configuration.to_prepare do
RedmineGtt.setup_controller_patches
end
end