|
1 |
| -require 'redmine' |
| 1 | +# Global Hooks |
| 2 | +require File.expand_path('../lib/redmine_gtt/hooks/view_layouts_base_html_head_hook', __FILE__) |
| 3 | +require File.expand_path('../lib/redmine_gtt/view_hooks', __FILE__) |
2 | 4 |
|
3 | 5 | Redmine::Plugin.register :redmine_gtt do
|
4 | 6 | name 'Redmine GTT plugin'
|
5 | 7 | author 'Georepublic'
|
6 | 8 | author_url 'https://github.com/georepublic'
|
7 | 9 | url 'https://github.com/gtt-project/redmine_gtt'
|
8 | 10 | description 'Adds location-based task management and maps'
|
9 |
| - version '3.0.0' |
| 11 | + version '3.0.0' # TODO: 4.0.0? |
10 | 12 |
|
11 | 13 | requires_redmine :version_or_higher => '4.0.0'
|
12 | 14 |
|
|
38 | 40 | caption: :label_gtt_tile_source_plural, :html => {:class => 'icon'}
|
39 | 41 | end
|
40 | 42 |
|
41 |
| -ActiveSupport::Reloader.to_prepare do |
| 43 | +# Register MIME Types |
| 44 | +Mime::Type.register_alias "application/json", :geojson |
42 | 45 |
|
43 |
| - # Automatically encode points to geojson with as_json in rails3 |
44 |
| - RGeo::ActiveRecord::GeometryMixin.set_json_generator(:geojson) |
| 46 | +# Automatically encode points to geojson with as_json in rails3 |
| 47 | +RGeo::ActiveRecord::GeometryMixin.set_json_generator(:geojson) |
45 | 48 |
|
46 |
| - RedmineGtt.setup_normal_patches |
| 49 | +RGeo::ActiveRecord::SpatialFactoryStore.instance.tap do |config| |
| 50 | + # By default, use the GEOS implementation for spatial columns. |
| 51 | + # config.default = RGeo::Geos.factory_generator |
| 52 | + |
| 53 | + config.register RGeo::Cartesian.preferred_factory(srid: 4326), geo_type: 'geometry', sql_type: "geometry", srid: 4326 |
47 | 54 |
|
48 |
| - # ActiveRecord::Base.include_root_in_json = true |
49 |
| - # module RGeo |
50 |
| - # module Feature |
51 |
| - # module Point |
52 |
| - # def as_json(params) |
53 |
| - # ::RGeo::GeoJSON.encode(self) |
54 |
| - # end |
55 |
| - # end |
56 |
| - # end |
57 |
| - # end |
| 55 | + # But use a geographic implementation for point columns. |
| 56 | + # config.register(RGeo::Geographic.spherical_factory(srid: 4326), geo_type: "point") |
58 | 57 | end
|
59 | 58 |
|
60 |
| -Rails.configuration.to_prepare do |
61 |
| - RedmineGtt.setup_controller_patches |
| 59 | +if Rails.version > '6.0' && Rails.autoloaders.zeitwerk_enabled? |
| 60 | + require File.expand_path('../app/overrides/issues', __FILE__) |
| 61 | + require File.expand_path('../app/overrides/projects', __FILE__) |
| 62 | + require File.expand_path('../app/overrides/users', __FILE__) |
| 63 | + RedmineGtt.setup_normal_patches |
| 64 | + Rails.application.config.after_initialize do |
| 65 | + RedmineGtt.setup_controller_patches |
| 66 | + end |
| 67 | +else |
| 68 | + # Configure View Overrides |
| 69 | + Rails.application.paths["app/overrides"] ||= [] |
| 70 | + Rails.application.paths["app/overrides"] << File.expand_path("../app/overrides", __FILE__) |
| 71 | + |
| 72 | + ActiveSupport::Reloader.to_prepare do |
| 73 | + RedmineGtt.setup_normal_patches |
| 74 | + |
| 75 | + # ActiveRecord::Base.include_root_in_json = true |
| 76 | + # module RGeo |
| 77 | + # module Feature |
| 78 | + # module Point |
| 79 | + # def as_json(params) |
| 80 | + # ::RGeo::GeoJSON.encode(self) |
| 81 | + # end |
| 82 | + # end |
| 83 | + # end |
| 84 | + # end |
| 85 | + end |
| 86 | + |
| 87 | + Rails.configuration.to_prepare do |
| 88 | + RedmineGtt.setup_controller_patches |
| 89 | + end |
62 | 90 | end
|
63 | 91 |
|
64 |
| -class GttListener < Redmine::Hook::ViewListener |
| 92 | +#class GttListener < Redmine::Hook::ViewListener |
| 93 | +Class.new(Redmine::Hook::ViewListener) do |c| |
65 | 94 | render_on :view_layouts_base_html_head, inline: <<-END
|
66 | 95 | <%= stylesheet_link_tag 'gtt', :plugin => 'redmine_gtt' %>
|
67 | 96 | END
|
|
0 commit comments