Upgrading from 0.9.7.1 to 0.9.7.4 and my plugins are no longer being included


(Keith Newton) #1

I’ve created a fresh VM with yesterday’s latest source to test out upgrading to 0.9.7.4 and my plugins aren’t getting compiled into the deployment. I’m doing what I’ve been doing for the last few months which is stop bluepill and execute

RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ENV=production bundle exec rake assets:precompile

every time I need to make a change to the plugins. Rummaging through the forums I don’t see any topics that indicate the plugin interface has changed. My directory structure looks like:

plugins/external_auth/plugin.rb
plugins/external_auth/assets/javascripts/external_auth.js

I added an alert("Hello World!") to verify that nothing is getting executed but other than that I haven’t changed any of the plugin code which works just fine with 0.9.7.1.

Thanks for the help!


(Sam Saffron) #2

can you include full source of the plugins with passwords etc scrubbed?


(Keith Newton) #3

external_auth.js:

Discourse.logout = function ()
{
	Discourse.User.logout().then(function ()
	{
		// Reloading will refresh unbound properties
		Discourse.KeyValueStore.abandonLocal();
		
		// delete the subdir version of the cookie so that it doesn't override our root cookie
		document.cookie = '_t=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
		window.location.replace("https://blah.com/blah?redirect=" + window.location.protocol + "//" + window.location.hostname);
	});
};

Discourse.ApplicationRoute.reopen({
	actions:
	{
		showLogin: function()
		{
			window.location.href = "https://blah.com?dialog=" + JSON.stringify({ Name: "Login", Arguments: { Redirect: window.location.protocol + "//" + window.location.hostname } });
		}
	}
});

Discourse.PreferencesController.reopen({
	actions:
	{
		changePassword: function()
		{
			// disable
		}
	}
});

Discourse.User.reopen({
	changePassword: function()
	{
		// disable
	},
	changeUsername: function(newUsername)
	{
		// disable
	},
	changeEmail: function(email)
	{
		// disable
	},
	createAccount: function(name, email, password, username, passwordConfirm, challenge)
	{
		// disable
	}
});

alert("Hello World!");

plugin.rb:

register_asset "javascripts/external_auth.js"

after_initialize do
  UsersController.class_eval do
    def create
      render json: { message: "hi" }
    end

    def username
      render nothing: true
    end

    def password_reset
      render layout: 'no_js'
    end

    def change_email
      render nothing: true
    end

    def authorize_email
      render layout: 'no_js'
    end

    def activate_account
      render layout: 'no_js'
    end

    def send_activation_email
      render nothing: true
    end

    def create_third_party_auth_records(user, auth)
    end
  end
end 

I don’t get any errors in the javascript console


(Sam Saffron) #4

after pre-compiling can you find Discourse.ApplicationRoute.reopen inside your application.js file?


(Keith Newton) #5

I’m assuming the application.js you’re referring to is along the lines of:

<script src="/assets/application-44cca988737df8272ccb4d1ae7e75e1d.js"></script>

If that’s the correct application.js then no, I don’t see it in there


(Keith Newton) #6

Hey @sam any idea what could be causing this? I just updated to the latest source and I am still having a problem. If you’re busy with other things is there somewhere in the source you could point me where you think the problem may lie? Thanks!


(Sam Saffron) #7

I recently fixed up asset registration in rails 4, it was quite buggy. Can you try again?


(Keith Newton) #8

Hi Sam thanks a bunch for your work on this. I ended up finally fixing the problem and it had nothing to do with Discourse. Somehow the ownership of the javascript file was set to my root account and that apparently was preventing Discourse from compiling it in during asset compilation. There was no warning or error emitted or any indication that the file couldn’t be accessed. It took me quite a while to track down but everything is working fine now with my plugin!


(Sam Saffron) #9

This topic was automatically closed after 3 days. New replies are no longer allowed.