0.35 Significnat changes after more research, for testing.
This commit is contained in:
		
							
								
								
									
										38
									
								
								plugin.rb
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								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.33
 | 
					# version: 0.35
 | 
				
			||||||
# 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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -15,7 +15,7 @@
 | 
				
			|||||||
# after_initialize do
 | 
					# after_initialize do
 | 
				
			||||||
after_initialize do
 | 
					after_initialize do
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  require_dependency 'application_controller'
 | 
					#  require_dependency 'application_controller'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  module ::DiscourseLegacyLinks
 | 
					  module ::DiscourseLegacyLinks
 | 
				
			||||||
    class Engine < ::Rails::Engine
 | 
					    class Engine < ::Rails::Engine
 | 
				
			||||||
@@ -23,9 +23,17 @@ after_initialize do
 | 
				
			|||||||
      isolate_namespace DiscourseLegacyLinks
 | 
					      isolate_namespace DiscourseLegacyLinks
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Define the custom controller
 | 
					    # Define the custom controller, inheriting from Discourse's CustomPostController
 | 
				
			||||||
    class DiscourseLegacyLinks::CustomPostController < ::ApplicationController
 | 
					    # This gives us access to post-related functionality and user authentication
 | 
				
			||||||
      layout false
 | 
					#    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 :verify_authenticity_token
 | 
				
			||||||
#      skip_before_action :ensure_logged_in
 | 
					#      skip_before_action :ensure_logged_in
 | 
				
			||||||
#      skip_before_action :redirect_to_login_if_required
 | 
					#      skip_before_action :redirect_to_login_if_required
 | 
				
			||||||
@@ -33,10 +41,9 @@ after_initialize do
 | 
				
			|||||||
#      skip_before_action :ensure_staff
 | 
					#      skip_before_action :ensure_staff
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      def index2
 | 
					      def index2
 | 
				
			||||||
#        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 JMJ'
 | 
				
			||||||
        gtk sucks
 | 
					#        render html: '<h1>JMJ</h1>'
 | 
				
			||||||
        render html: '<h1>JMJ</h1>'
 | 
					 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      # Match URLs that include a post_id at the end or query parameter
 | 
					      # Match URLs that include a post_id at the end or query parameter
 | 
				
			||||||
@@ -137,23 +144,30 @@ after_initialize do
 | 
				
			|||||||
        redirect topic_url
 | 
					        redirect topic_url
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
  # 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.application.routes.routes.each do |route|
 | 
				
			||||||
#    Rails.logger.warn "[ROUTE] #{route.path.spec}"
 | 
					#    Rails.logger.warn "[ROUTE] #{route.path.spec}"
 | 
				
			||||||
#  end
 | 
					#  end
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
#  Discourse::Application.routes.append do
 | 
					#  Discourse::Application.routes.append do
 | 
				
			||||||
    Discourse::Application.routes.prepend 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/*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', 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 '/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', 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/*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 '/forum2' => "'discourse_legacy_links/custom_post#index2'
 | 
				
			||||||
#    get '/forum/*path' => 'discourse_legacy_links/custom_post#index'
 | 
					#    get '/forum/*path' => 'discourse_legacy_links/custom_post#index'
 | 
				
			||||||
#    get '/forum' => 'discourse_legacy_links/custom_post#index'
 | 
					#    get '/forum' => 'discourse_legacy_links/custom_post#index'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  DiscourseLegacyLinks::Engine.routes.draw do
 | 
				
			||||||
 | 
					    get "/forum2" =< "legacy_links#index2"
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Discourse::Application.routes.append do
 | 
				
			||||||
 | 
					    mount ::DiscourseLegacyLinks::Engine, at: "/"
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user