v0.16 So close, but it doesn't work still...
This commit is contained in:
		
							
								
								
									
										27
									
								
								plugin.rb
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								plugin.rb
									
									
									
									
									
								
							@@ -4,7 +4,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
# name: discourse-legacy_links
 | 
					# name: discourse-legacy_links
 | 
				
			||||||
# about: A plugin to handle legacy Gossamer Forums URLs
 | 
					# about: A plugin to handle legacy Gossamer Forums URLs
 | 
				
			||||||
# version: 0.15
 | 
					# version: 0.16
 | 
				
			||||||
# authors: saint@federated.computer
 | 
					# authors: saint@federated.computer
 | 
				
			||||||
# url: https://gitea.federated.computer/saint/discourse-legacy_links.git
 | 
					# url: https://gitea.federated.computer/saint/discourse-legacy_links.git
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -21,14 +21,20 @@ after_initialize do
 | 
				
			|||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Define the custom controller
 | 
					    # Define the custom controller
 | 
				
			||||||
    class CustomPostController < ::ApplicationController
 | 
					    class DiscourseLegacyLinks::CustomPostController < ::ApplicationController
 | 
				
			||||||
      # Match URLs that include a post_id at the end or query parameter
 | 
					      skip_before_action :verify_authenticity_token
 | 
				
			||||||
      # Main action triggered when the route is matched.
 | 
					      skip_before_action :ensure_logged_in
 | 
				
			||||||
 | 
					      skip_before_action :redirect_to_login_if_required
 | 
				
			||||||
 | 
					      skip_before_action :check_xhr
 | 
				
			||||||
 | 
					      skip_before_action :ensure_staff
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      def test
 | 
					      def test
 | 
				
			||||||
        Rails.logger.warn "[WARN WARN WARN WARN WARN WARN WARN WARN WARN WARN AMDG JMJ PAX WARN WARN WARN WARN]"
 | 
					        Rails.logger.warn "[WARN WARN WARN WARN WARN WARN WARN WARN WARN WARN AMDG JMJ PAX WARN WARN WARN WARN]"
 | 
				
			||||||
        render plain: 'Test route'
 | 
					        render plain: 'Test route'
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      # Match URLs that include a post_id at the end or query parameter
 | 
				
			||||||
 | 
					      # Main action triggered when the route is matched.
 | 
				
			||||||
      def index
 | 
					      def index
 | 
				
			||||||
        Rails.logger.warn "[DEBUG] Reached the index action"
 | 
					        Rails.logger.warn "[DEBUG] Reached the index action"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -128,11 +134,18 @@ after_initialize do
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    # Register custom routes to handle legacy URLs
 | 
					    # Register custom routes to handle legacy URLs
 | 
				
			||||||
    Rails.logger.warn "[DEBUG DEBUG DEBUG DEBUG DEBUG WOW WOW WOW]"
 | 
					    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.append do
 | 
				
			||||||
    Discourse::Application.routes.prepend do
 | 
					    Discourse::Application.routes.prepend do
 | 
				
			||||||
      get '/test_route' => 'discourse_legacy_links/custom_post#test'
 | 
					#      get '/forum/*path', to: 'discourse_legacy_links/custom_post#index', constraints: lambda { |req| !Permalink.exists?(url: req.path) }
 | 
				
			||||||
      get '/forum/*path' => 'discourse_legacy_links/custom_post#index'
 | 
					      get '/forum/*path', to: 'discourse_legacy_links/custom_post#index', constraints: lambda { |request| Rails.logger.warn("[DEBUG] StarForum Route matched: #{request.path}") }
 | 
				
			||||||
      get '/forum' => 'discourse_legacy_links/custom_post#index'
 | 
					      get '/forum', to: 'discourse_legacy_links/custom_post#index', constraints: lambda { |request| Rails.logger.warn("[DEBUG] NoStarForum Route matched: #{request.path}") }
 | 
				
			||||||
 | 
					      get '/testroute2', to: 'discourse_legacy_links/custom_post#test', constraints: lambda { |request| Rails.logger.warn("[DEBUG] TestRoute Route matched: #{request.path}") }
 | 
				
			||||||
 | 
					#      get '/testroute2' => 'discourse_legacy_links/custom_post#test'
 | 
				
			||||||
 | 
					#      get '/forum/*path' => 'discourse_legacy_links/custom_post#index'
 | 
				
			||||||
 | 
					#      get '/forum' => 'discourse_legacy_links/custom_post#index'
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user