diff --git a/plugin.rb b/plugin.rb
index e3ae62f..f10dcfb 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -4,7 +4,7 @@
# name: discourse-legacy_links
# about: A plugin to handle legacy Gossamer Forums URLs
-# version: 0.33
+# version: 0.35
# authors: saint@federated.computer
# url: https://gitea.federated.computer/saint/discourse-legacy_links.git
@@ -15,7 +15,7 @@
# after_initialize do
after_initialize do
- require_dependency 'application_controller'
+# require_dependency 'application_controller'
module ::DiscourseLegacyLinks
class Engine < ::Rails::Engine
@@ -23,9 +23,17 @@ after_initialize do
isolate_namespace DiscourseLegacyLinks
end
- # Define the custom controller
- class DiscourseLegacyLinks::CustomPostController < ::ApplicationController
- layout false
+ # Define the custom controller, inheriting from Discourse's CustomPostController
+ # This gives us access to post-related functionality and user authentication
+# class DiscourseLegacyLinks::CustomPostController < ::ApplicationController
+ class DiscourseLegacyLinks < ::ApplicationController::CustomPostController
+
+# layout false
+
+ # Skip certain before_actions for our index method.
+ # This allows the route to be accessed directly via a browser
+ skip_before_action :check_xhr, only: [:index]
+ skip_before_action :verify_authenticity_token, only: [:index]
# skip_before_action :verify_authenticity_token
# skip_before_action :ensure_logged_in
# skip_before_action :redirect_to_login_if_required
@@ -33,10 +41,9 @@ after_initialize do
# skip_before_action :ensure_staff
def index2
-# Rails.logger.warn "[WARN WARN WARN WARN WARN WARN WARN WARN WARN WARN AMDG JMJ PAX WARN WARN WARN WARN]"
-# render plain: 'Test route'
- gtk sucks
- render html: '
JMJ
'
+ Rails.logger.warn "[WARN WARN WARN WARN WARN WARN WARN WARN WARN WARN AMDG JMJ PAX WARN WARN WARN WARN]"
+ render plain: 'Test route JMJ'
+# render html: 'JMJ
'
end
# Match URLs that include a post_id at the end or query parameter
@@ -137,23 +144,30 @@ after_initialize do
redirect topic_url
end
end
+ end
+ # Register custom routes to handle legacy URLs
+ Rails.logger.warn "[DEBUG DEBUG DEBUG DEBUG DEBUG WOW WOW WOW]"
+# Rails.application.routes.routes.each do |route|
+# Rails.logger.warn "[ROUTE] #{route.path.spec}"
+# end
+#
+# Discourse::Application.routes.append do
+# Discourse::Application.routes.prepend do
+# get '/forum/*path', to: 'discourse_legacy_links/custom_post#index', constraints: lambda { |req| !Permalink.exists?(url: req.path) }
+# get '/forum', to: 'discourse_legacy_links/custom_post#index', constraints: lambda { |request| Rails.logger.warn("[DEBUG] NoStarForum Route matched: #{request.path}") }
+# get '/forum/*path', to: 'discourse_legacy_links/custom_post#index', constraints: lambda { |request| Rails.logger.warn("[DEBUG] StarForum Route matched: #{request.path}") }
+# get '/forum2', to: 'discourse_legacy_links/custom_post#index2', constraints: lambda { |request| Rails.logger.warn("[DEBUG] NoStarTestRoute Route matched: #{request.path}") }
+# get '/forum2/*path', to: 'discourse_legacy_links/custom_post#index2', constraints: lambda { |request| Rails.logger.warn("[DEBUG] StarTestRoute Route matched: #{request.path}") }
+# get '/forum2' => "'discourse_legacy_links/custom_post#index2'
+# get '/forum/*path' => 'discourse_legacy_links/custom_post#index'
+# get '/forum' => 'discourse_legacy_links/custom_post#index'
- # Register custom routes to handle legacy URLs
- Rails.logger.warn "[DEBUG DEBUG DEBUG DEBUG DEBUG WOW WOW WOW]"
-# Rails.application.routes.routes.each do |route|
-# Rails.logger.warn "[ROUTE] #{route.path.spec}"
-# end
-# Discourse::Application.routes.append do
- Discourse::Application.routes.prepend do
-# get '/forum/*path', to: 'discourse_legacy_links/custom_post#index', constraints: lambda { |req| !Permalink.exists?(url: req.path) }
-# get '/forum', to: 'discourse_legacy_links/custom_post#index', constraints: lambda { |request| Rails.logger.warn("[DEBUG] NoStarForum Route matched: #{request.path}") }
-# get '/forum/*path', to: 'discourse_legacy_links/custom_post#index', constraints: lambda { |request| Rails.logger.warn("[DEBUG] StarForum Route matched: #{request.path}") }
-# get '/forum2', to: 'discourse_legacy_links/custom_post#index2', constraints: lambda { |request| Rails.logger.warn("[DEBUG] NoStarTestRoute Route matched: #{request.path}") }
-# get '/forum2/*path', to: 'discourse_legacy_links/custom_post#index2', constraints: lambda { |request| Rails.logger.warn("[DEBUG] StarTestRoute Route matched: #{request.path}") }
- get '/forum2' => 'discourse_legacy_links/custom_post#index2'
-# get '/forum/*path' => 'discourse_legacy_links/custom_post#index'
-# get '/forum' => 'discourse_legacy_links/custom_post#index'
- end
+ DiscourseLegacyLinks::Engine.routes.draw do
+ get "/forum2" =< "legacy_links#index2"
+ end
+
+ Discourse::Application.routes.append do
+ mount ::DiscourseLegacyLinks::Engine, at: "/"
end
end