Skip to content

Commit e48669d

Browse files
committed
reorganize files
1 parent 22d6fb9 commit e48669d

File tree

6 files changed

+46
-25
lines changed

6 files changed

+46
-25
lines changed

.discourse-compatibility

Whitespace-only changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Discourse Plugin
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
ci:
11+
uses: discourse/.github/.github/workflows/discourse-plugin.yml@v1

LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2025 Retool
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

config/routes.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
CommunityCustomFields::Engine.routes.draw do
4+
put '/:topic_id' => 'custom_fields#update'
5+
end
6+
7+
Discourse::Application.routes.append do
8+
mount ::CommunityCustomFields::Engine, at: '/admin/plugins/community-custom-fields'
9+
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# frozen_string_literal: true
2+
3+
module ::CommunityCustomFields
4+
class Engine < ::Rails::Engine
5+
engine_name PLUGIN_NAME
6+
isolate_namespace CommunityCustomFields
7+
config.autoload_paths << File.join(config.root, "lib")
8+
scheduled_job_dir = "#{config.root}/app/jobs/scheduled"
9+
config.to_prepare do
10+
Rails.autoloaders.main.eager_load_dir(scheduled_job_dir) if Dir.exist?(scheduled_job_dir)
11+
end
12+
end
13+
end

plugin.rb

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,13 @@
88

99
enabled_site_setting :community_custom_fields_enabled
1010

11-
after_initialize do
12-
module ::CommunityCustomFields
13-
class Engine < ::Rails::Engine
14-
engine_name "community_custom_fields"
15-
isolate_namespace CommunityCustomFields
16-
config.autoload_paths << File.join(config.root, "lib")
17-
scheduled_job_dir = "#{config.root}/app/jobs/scheduled"
18-
config.to_prepare do
19-
Rails.autoloaders.main.eager_load_dir(scheduled_job_dir) if Dir.exist?(scheduled_job_dir)
20-
end
21-
end
22-
end
23-
24-
#############################################################################
25-
# /config/routes.rb
26-
27-
CommunityCustomFields::Engine.routes.draw do
28-
put '/:topic_id' => 'custom_fields#update'
29-
end
30-
31-
Discourse::Application.routes.append do
32-
mount ::CommunityCustomFields::Engine, at: '/admin/plugins/community-custom-fields'
33-
end
11+
module ::DiscourseSolved
12+
PLUGIN_NAME = "community-custom-fields"
13+
end
3414

35-
#############################################################################
15+
require_relative 'lib/community_custom_fields/engine.rb'
3616

17+
after_initialize do
3718
require_dependency 'application_controller'
3819
class CommunityCustomFields::CustomFieldsController < ::ApplicationController
3920
before_action :ensure_logged_in
@@ -65,7 +46,7 @@ def update
6546
end
6647

6748
on(:topic_created) do |topic, params, user|
68-
topic.custom_fields["assignee_id"] ||= 0 # or any default value
49+
topic.custom_fields["assignee_id"] ||= 0
6950
topic.custom_fields["status"] ||= "new"
7051
topic.save_custom_fields
7152
end

0 commit comments

Comments
 (0)