[Archivesspace_Users_Group] Overriding/Extending the new public interface in 2.2.0

Flanagan, Patrick PJFlanagan at ship.edu
Fri Dec 22 15:07:18 EST 2017


I think I just encountered that sort of issue. From public/plugin_init.rb both ResourcesController and ApplicationController don't appear to be in scope; so I can't even replace it let alone extend it. That, or I'm supposed to use require to get at the specific classes - but I haven't been able to do so. I think it's one of the intricacies of Rails that is escaping me.


Ideally, for an identifier of A/B/C/D on a given resource, I wanted the breadcrumb to link back to A - B - C - D - This Resource, a behavior that's more similar to Archon, and more useful than the default behavior of simply linking to the repository top itself, I think.


~Patrick Flanagan

KLN Applications Administrator

Keystone Library Network Hub

________________________________
From: archivesspace_users_group-bounces at lyralists.lyrasis.org <archivesspace_users_group-bounces at lyralists.lyrasis.org> on behalf of Majewski, Steven Dennis (sdm7g) <sdm7g at virginia.edu>
Sent: Thursday, December 21, 2017 4:40:29 PM
To: Archivesspace Users Group
Subject: Re: [Archivesspace_Users_Group] Overriding/Extending the new public interface in 2.2.0


I remember running into something like this where the problem was Rails lazy loading of classes.
The base classes were not actually defined when the plugins were loaded, so what was supposed to be additional methods extending an existing class became the entire replacement class definition. I had to add a reference to the class to force lazy loading before trying to extend the class.
This might be what you are running into.
I will look and see if I still have any notes with more details from that experiment.

— Steve.




On Dec 21, 2017, at 4:18 PM, Flanagan, Patrick <PJFlanagan at ship.edu<mailto:PJFlanagan at ship.edu>> wrote:

Hi Bobbi,

Thank you for this! I'll give it a try this way and see if I can make some progress.

~Patrick Flanagan
KLN Applications Administrator
Keystone Library Network Hub
________________________________
From: archivesspace_users_group-bounces at lyralists.lyrasis.org<mailto:archivesspace_users_group-bounces at lyralists.lyrasis.org> <archivesspace_users_group-bounces at lyralists.lyrasis.org<mailto:archivesspace_users_group-bounces at lyralists.lyrasis.org>> on behalf of Fox, Bobbi <bobbi_fox at harvard.edu<mailto:bobbi_fox at harvard.edu>>
Sent: Thursday, December 21, 2017 3:47:18 PM
To: Archivesspace Users Group
Subject: Re: [Archivesspace_Users_Group] Overriding/Extending the new public interface in 2.2.0

Hi, Patrick,

I’m having to do a lot of extending/overriding of controllers & methods in our new public interface.

You are correct; you can’t just override by placing your modified controller in the path location; instead, what *I’m* doing (and I know there’s a more elegant way of doing it); is put the changes in the plugin/plugin_init.rb ,using the [class|module]_eval method on something.

For instance, I’m changing what gets faceted in the Searchable concern this way in plugin_init.rb:
Searchable.module_eval do


def set_up_and_run_search(default_types = [],default_facets=[],default_search_opts={}, params={})
  ~ my stuff here ~~
end
            end


I’m adding methods to controllers in a somewhat similar way, for instance, in plugin_init.rb, I’ve got:

# add a digital only action to the resources controller


class ResourcesController


def digital_only


uri = "/repositories/#{params[:rid]}/resources/#{params[:id]}"


begin
~ etc. ~
end
           end

Hope this helps,
Bobbi

From: archivesspace_users_group-bounces at lyralists.lyrasis.org<mailto:archivesspace_users_group-bounces at lyralists.lyrasis.org> [mailto:archivesspace_users_group-bounces at lyralists.lyrasis.org] On Behalf Of Flanagan, Patrick
Sent: Thursday, December 21, 2017 3:27 PM
To: Archivesspace Users Group <archivesspace_users_group at lyralists.lyrasis.org<mailto:archivesspace_users_group at lyralists.lyrasis.org>>
Subject: [Archivesspace_Users_Group] Overriding/Extending the new public interface in 2.2.0

Hello,

I'm attempting to write a plugin that will modify the way the breadcrumb trail (shown in the new public UI) is generated to include more detail. I decided to try and override one of the files in the controller part of the architecture: resources_controller.rb, since I can see the :crumb being defined there. However, either my path is wrong, or the new UI isn't utilizing it. Following the instructions here:http://archivesspace.github.io/archivesspace/user/archivesspace-plug-ins-readme/<https://urldefense.proofpoint.com/v2/url?u=http-3A__archivesspace.github.io_archivesspace_user_archivesspace-2Dplug-2Dins-2Dreadme_&d=DwMFAw&c=WO-RGvefibhHBZq3fL85hQ&r=5xWUzLrZrVLeTqs3CDoeRpPtLv1fRM04CCu4TDULrSY&m=3DmZ4KyjSuOHTC-7rfq8Dv2MTeEFEBci91sKzca-4YQ&s=is5OAKKChee55MtdTuQYDj2OwuvI8f0Y6lBLS8-ast8&e=> I've placed the file in the following directory:

as220/plugins/local/public/controllers/resources_controller.rb
( source location: /public/app/controllers/resources_controller.rb )
Plugin Config: AppConfig[:plugins] = ['local',  'lcnaf', 'aspace-public-formats']

If I'm not mistaken that document indicates that this is something that can be overridden, but I'm suspecting I can't actually override something in the controller from a plugin.

The version is 2.2.0, running on Linux x64, openjdk version "1.8.0_151". Any advice would be appreciated!

Thank you,

~Patrick Flanagan
KLN Applications Administrator
Keystone Library Network Hub
_______________________________________________
Archivesspace_Users_Group mailing list
Archivesspace_Users_Group at lyralists.lyrasis.org<mailto:Archivesspace_Users_Group at lyralists.lyrasis.org>
http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_users_group/attachments/20171222/4d906438/attachment.html>


More information about the Archivesspace_Users_Group mailing list