alexbevi / redmine_knowledgebase

A knowledgebase plugin for Redmine
453 stars 197 forks source link

Participate in Global Search #11

Closed fabiob closed 11 years ago

fabiob commented 13 years ago

Make KB articles appear on Redmine's global search, using the search box at the top.

ghost commented 13 years ago

This feature would be very useful. Are there any plans to implement this in the near future?

bennun commented 13 years ago

I agree with this feature too. Would be a perfect addition, wonder how difficult it would be.

alexbevi commented 13 years ago

There is an issue at the moment with registering plugins for Redmine integrated search if the plugin doesn't have a project dependency. Until that is resolved, we cannot really do anything ... at least not without hacks and workarounds ;)

ghost commented 13 years ago

This is a real shame as we are seriously considering using this plugin to handle knowledge management throughout our organisation of 50 people.

From my point of the view the only thing stopping us is the inability to access the information through the standard Redmine search facility.

Is there a way this could be resolved, albeit temporarily, to get this working?

How about if, through a simple plugin config screen, the user to could select a project to assign the knowledgebase to? For example we have a specific 'generic' project which we use as a site-wide wiki (using the following hack: http://www.redmine.org/boards/1/topics/18791) and could use this as the project 'home' for knowledgebase.

I appreciate this isn't ideal, but unless there is some kind of search functionality to retrieve the information stored in the articles, then I don't see this plugin being widely adopted. Apart from this, I am very happy with the plugin and think it will be a great tool for our organisation.

Chris

On 08/04/11 21:03, alexbevi wrote:

There is an issue at the moment with registering plugins for Redmine integrated search if the plugin doesn't have a project dependency. Until that is resolved, we cannot really do anything ... at least not without hacks and workarounds ;)

ghost commented 13 years ago

Shouldn't this issue remain open until it has been resolved? I think marking it as closed may be slightly misleading.

bennun commented 13 years ago

Chris, I'm totally with you on this one. We too are kind of holding back, because the knowledge management needs to be searchable for obvious reasons. I like the concept of a plugin knowledgebase that can "belong" to selectively. Otherwise, you're always tied to a static project. I feel this plugin has huge potential. I'm loving it. Would like to extend it further.

alexbevi commented 13 years ago

I've put in a request to the Redmine devs to consider this at http://www.redmine.org/issues/8215. I'd love to have searching working without the need for convoluted hacks ;)

bennun commented 13 years ago

Very glad to see the new request Alex. In the mean time, does anyone have a good hack? I kinda see where Chris is going with his hack, but I'd like to know if anyone has been successful in searching KBs?

ghost commented 13 years ago

I've managed to get searching working by simply assigning a value to the project_id field in the kb_articles table. It now works fine.

See here for more conversation on the topic: http://www.redmine.org/boards/3/topics/11643?r=23597

TheEmpty commented 13 years ago

why doesn't github have a 'watch' ability! Anyway, just wanted to get e-mail notifications on this. Also because you added a period the issue link is invalid :P correct link is: http://www.redmine.org/issues/8215

LuisSerrano commented 13 years ago

Look this http://www.redmine.org/boards/3/topics/23591?r=23740#message-23740, and works well

ghost commented 12 years ago

The search is still not working.

I have no clue how to debug it. :(

kb_article.rb looks fine to me. acts as searchable is defined well. However the "def project" method returns nil". Maybe this is an issue?

I use redmine 1-3

Following observations:

How could i debug it? Maybe the reason is the xapian plugin?

Thans alot!

alexbevi commented 12 years ago

honestly, no real work has gone into search (on my part at least). Since a project dependency is a REQUIREMENT for redmine search, unless i discard the "global" aspect in favour of "scoped-to-project" knowledgebases, it's unlikely search will ever work without needing a bunch of hacks :(

I'm open to suggestions, and have kept this issue open as I WANT searching to be an option, but I'm reticent to override the internal Redmine query methods as this would open up a whole new can of worms (from a support and maintenance standpoint).

Any ideas are welcome ... patches more so :P

tmt1020 commented 12 years ago

Would it be reasonable to implement a knowledgebase-only search for the time being? For example, a search box could appear above the category or commands at the right side of knowledgebase pages. I believe that this would be better than not having one at all. Especially for those that have built up a large amount of articles. Just wanted to throw the idea out there while I was thinking about it. I'm a new Redmine user and so far the knowledgebase is my favorite plugin. I'm glad to see that it is under continual development and can't wait to see what's to come in the future! Thanks for all your hard work!

martin-denizet commented 12 years ago

That or to affect automatically all articles to a project seen by everyone. I'd like to have a try with that because we absolutely need a solution to be able to search that knowledge. I'll try to see what could be done when I've time, within 3 months.

tmt1020 commented 12 years ago

Sounds good. I'm not a coder, but I'd be happy to test anything if needed or help any other way. The knowledgebase is one of the most essential features for me and I would love to see search added to it.

jniggemann commented 12 years ago

For the record, here's what I did to have KB-articles in the global search like the OP requested; I took the same approach martin-denizet suggested.

How to get search working

  1. Define a project that everyone may at least read.
  2. Look into the database to see which project id it has.
  3. Set this project id to be the default value for the column _projectid in table _kbarticles.

Depending of the version of this plugin, you should now be set. If you use an older version of this plugin Open redmine_knowledgebase/config/routes.rb and add the code below if it isn't already present:

map.connect "/knowledgebase/articles/:article_id",  :controller => "articles", :action => "show", :conditions => { :method => [:get, :post] }
tomhanax commented 12 years ago

Please, can anybody help me to make searching work? I set project_id in table kb_articles as suggested by jniggemann. I tried changing redmine_knowledgebase/config/routes.rb. I use redmine 2.x so it's written in new form. I tried several changes but no luck. What should be the content of that file? Or should I hack some other files (that's no problem for our instalation). Thanx

mj00 commented 12 years ago

Search seems to be broken again with 2.x I've folled jniggemann's instructions - without modifying routes.rb I get a database error when searching, when adding above line I get a Ruby error. Migrating the database also produces said error:

An error occurred while loading the routes definition of redmine_knowledgebase plugin (/opt/redmine-2.0.3/plugins/redmine_knowledgebase/config/routes.rb): undefined local variable or method `map' for #ActionDispatch::Routing::Mapper:0x2b00597caa40.

Another attempt was adding this line to routes.rb:

match '/articles/show', :to => 'articles#show', :via => [:get, :post]

This does resturn search results but the links is still wrong - instead of linking to knowledgebase/articles/1 it links to articles/show?article_id=1

Any idea how to fix this?

mj00 commented 12 years ago

Yet another update. I found out that the map.connect directive only works with Rails 2.x whereas Redmine 2.0 already uses Rails 3.x. Converting the above statement to an identical match statement would look like this:

match '/knowledgebase/articles/:article_id', :to => 'articles#show', :via => [:get, :post]

This does work in that it returns search results with correct links but the links themselves have stopped working: I can't open a single KB article anymore - all of them return Error 500.

jniggemann commented 12 years ago

Reading this http://markconnell.co.uk/posts/2010/02/rails-3-routing-examples and not having any more knowledge I'd say that the Rails 2 route

map.connect "/knowledgebase/articles/:article_id",  :controller => "articles", :action => "show"

would be the following in Rails 3

match '/knowledgebase/articles/:article_id' => 'articles#show'

I'm not sure about the "conditions-get-post" part though...

mj00 commented 12 years ago

Thanks, but like I've said in my second update I've already tried this and the result is mixed. Search works, the links are correct but I cannot open a single kb article because I'm getting a Redmine 500 error when trying to do so.

alexbevi commented 12 years ago

Can you post the full backtrace?

On Thu, Aug 9, 2012 at 7:43 AM, mj00 notifications@github.com wrote:

Thanks, but like I've said in my second update I've already tried this and the result is mixed. Search works, the links are correct but I cannot open a single kb article because I'm getting a Redmine 500 error when trying to do so.

— Reply to this email directly or view it on GitHubhttps://github.com/alexbevi/redmine_knowledgebase/issues/11#issuecomment-7611867.

mj00 commented 12 years ago

I'd love to if you could tell me what log file to look into ;)

alexbevi commented 12 years ago

@mj00 /path/to/redmine/log/production.log

mj00 commented 12 years ago

Thanks, just found that myself too :)

Without above line in routes.rb (aka can open articles, but search links are broken):

Started GET "/knowledgebase/articles/13" for 192.168.3.115 at Thu Aug 09 13:46:40 +0200 2012 Processing by ArticlesController#show as HTML Parameters: {"id"=>"13"} DEPRECATION WARNING: :confirm option is deprecated and will be removed from Rails 4.0. Use ':data => { :confirm => 'Text' }' instead. (called from link_to_if_authorized_globally at /opt/redmine-2.0.3/plugins/redmine_knowledgebase/app/helpers/knowledgebase_helper.rb:6) Rendered plugins/redmine_knowledgebase/app/views/articles/_rating.html.erb (8.9ms) Rendered plugins/redmine_knowledgebase/app/views/articles/show.html.erb within layouts/base (181.6ms) Completed 200 OK in 229ms (Views: 100.3ms | ActiveRecord: 118.3ms)

With above line in routes.rb (aka search works and returns correct links but cannot open a single article):

Connecting to database specified by database.yml OpenIdAuthentication.store is nil. Using in-memory store. Creating scope :active. Overwriting existing method User.active. Creating scope :open. Overwriting existing method Version.open. DEPRECATION WARNING: The InstanceMethods module inside ActiveSupport::Concern will be no longer included automatically. Please define instance methods directly in CollectiveIdea::Acts::NestedSet::Model instead. (called from include at /opt/redmine-2.0.3/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:58) DEPRECATION WARNING: The InstanceMethods module inside ActiveSupport::Concern will be no longer included automatically. Please define instance methods directly in CollectiveIdea::Acts::NestedSet::Model instead. (called from include at /opt/redmine-2.0.3/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:58) Creating scope :open. Overwriting existing method Issue.open.

Started GET "/knowledgebase/articles/13" for 192.168.3.115 at Thu Aug 09 13:47:21 +0200 2012 Processing by ArticlesController#show as HTML Parameters: {"article_id"=>"13"} Completed 500 Internal Server Error in 335ms

NoMethodError (undefined method view' for nil:NilClass): plugins/redmine_knowledgebase/app/controllers/articles_controller.rb:38:inshow' actionpack (3.2.6) lib/action_controller/metal/implicit_render.rb:4:in send_action' actionpack (3.2.6) lib/action_controller/metal/implicit_render.rb:4:insend_action' actionpack (3.2.6) lib/abstract_controller/base.rb:167:in process_action' actionpack (3.2.6) lib/action_controller/metal/rendering.rb:10:inprocess_action' actionpack (3.2.6) lib/abstract_controller/callbacks.rb:18:in process_action' activesupport (3.2.6) lib/active_support/callbacks.rb:469:in_run1246313170process_action453433196callbacks' activesupport (3.2.6) lib/active_support/callbacks.rb:405:in send' activesupport (3.2.6) lib/active_support/callbacks.rb:405:inrun_callback' activesupport (3.2.6) lib/active_support/callbacks.rb:385:in _run_process_action_callbacks' activesupport (3.2.6) lib/active_support/callbacks.rb:81:insend' activesupport (3.2.6) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (3.2.6) lib/abstract_controller/callbacks.rb:17:inprocess_action' actionpack (3.2.6) lib/action_controller/metal/rescue.rb:29:in process_action' actionpack (3.2.6) lib/action_controller/metal/instrumentation.rb:30:inprocess_action' activesupport (3.2.6) lib/active_support/notifications.rb:123:in instrument' activesupport (3.2.6) lib/active_support/notifications/instrumenter.rb:20:ininstrument' activesupport (3.2.6) lib/active_support/notifications.rb:123:in instrument' actionpack (3.2.6) lib/action_controller/metal/instrumentation.rb:29:inprocess_action' actionpack (3.2.6) lib/action_controller/metal/params_wrapper.rb:206:in process_action' activerecord (3.2.6) lib/active_record/railties/controller_runtime.rb:18:inprocess_action' actionpack (3.2.6) lib/abstract_controller/base.rb:121:in process' actionpack (3.2.6) lib/abstract_controller/rendering.rb:45:inprocess' actionpack (3.2.6) lib/action_controller/metal.rb:203:in dispatch' actionpack (3.2.6) lib/action_controller/metal/rack_delegation.rb:14:indispatch' actionpack (3.2.6) lib/action_controller/metal.rb:246:in action' actionpack (3.2.6) lib/action_dispatch/routing/route_set.rb:73:incall' actionpack (3.2.6) lib/action_dispatch/routing/route_set.rb:73:in dispatch' actionpack (3.2.6) lib/action_dispatch/routing/route_set.rb:36:incall' journey (1.0.4) lib/journey/router.rb:68:in call' journey (1.0.4) lib/journey/router.rb:56:ineach' journey (1.0.4) lib/journey/router.rb:56:in call' actionpack (3.2.6) lib/action_dispatch/routing/route_set.rb:600:incall' rack-openid (1.3.1) lib/rack/openid.rb:98:in call' actionpack (3.2.6) lib/action_dispatch/middleware/best_standards_support.rb:17:incall' rack (1.4.1) lib/rack/etag.rb:23:in call' rack (1.4.1) lib/rack/conditionalget.rb:25:incall' actionpack (3.2.6) lib/action_dispatch/middleware/head.rb:14:in call' actionpack (3.2.6) lib/action_dispatch/middleware/params_parser.rb:21:incall' actionpack (3.2.6) lib/action_dispatch/middleware/flash.rb:242:in call' rack (1.4.1) lib/rack/session/abstract/id.rb:205:incontext' rack (1.4.1) lib/rack/session/abstract/id.rb:200:in call' actionpack (3.2.6) lib/action_dispatch/middleware/cookies.rb:338:incall' activerecord (3.2.6) lib/active_record/query_cache.rb:64:in call' activerecord (3.2.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:473:incall' actionpack (3.2.6) lib/action_dispatch/middleware/callbacks.rb:28:in call' activesupport (3.2.6) lib/active_support/callbacks.rb:405:in_run397314981call4callbacks' activesupport (3.2.6) lib/active_support/callbacks.rb:405:in send' activesupport (3.2.6) lib/active_support/callbacks.rb:405:inrun_callback' activesupport (3.2.6) lib/active_support/callbacks.rb:385:in _run_call_callbacks' activesupport (3.2.6) lib/active_support/callbacks.rb:81:insend' activesupport (3.2.6) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (3.2.6) lib/action_dispatch/middleware/callbacks.rb:27:incall' actionpack (3.2.6) lib/action_dispatch/middleware/remote_ip.rb:31:in call' actionpack (3.2.6) lib/action_dispatch/middleware/debug_exceptions.rb:16:incall' actionpack (3.2.6) lib/action_dispatch/middleware/show_exceptions.rb:56:in call' railties (3.2.6) lib/rails/rack/logger.rb:26:incall_app' railties (3.2.6) lib/rails/rack/logger.rb:16:in call' actionpack (3.2.6) lib/action_dispatch/middleware/request_id.rb:22:incall' rack (1.4.1) lib/rack/methodoverride.rb:21:in call' rack (1.4.1) lib/rack/runtime.rb:17:incall' activesupport (3.2.6) lib/active_support/cache/strategy/local_cache.rb:72:in call' rack (1.4.1) lib/rack/lock.rb:15:incall' actionpack (3.2.6) lib/action_dispatch/middleware/static.rb:62:in call' rack-cache (1.2) lib/rack/cache/context.rb:136:inforward' rack-cache (1.2) lib/rack/cache/context.rb:245:in fetch' rack-cache (1.2) lib/rack/cache/context.rb:185:inlookup' rack-cache (1.2) lib/rack/cache/context.rb:66:in call!' rack-cache (1.2) lib/rack/cache/context.rb:51:incall' railties (3.2.6) lib/rails/engine.rb:479:in call' railties (3.2.6) lib/rails/application.rb:220:incall' railties (3.2.6) lib/rails/railtie/configurable.rb:30:in send' railties (3.2.6) lib/rails/railtie/configurable.rb:30:inmethod_missing' passenger (3.0.11) lib/phusion_passenger/rack/request_handler.rb:96:in process_request' passenger (3.0.11) lib/phusion_passenger/abstract_request_handler.rb:513:inaccept_and_process_next_request' passenger (3.0.11) lib/phusion_passenger/abstract_request_handler.rb:274:in main_loop' passenger (3.0.11) lib/phusion_passenger/rack/application_spawner.rb:206:instart_request_handler' passenger (3.0.11) lib/phusion_passenger/rack/application_spawner.rb:171:in send' passenger (3.0.11) lib/phusion_passenger/rack/application_spawner.rb:171:inhandle_spawn_application' passenger (3.0.11) lib/phusion_passenger/utils.rb:479:in safe_fork' passenger (3.0.11) lib/phusion_passenger/rack/application_spawner.rb:166:inhandle_spawn_application' passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:357:in __send__' passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:357:inserver_main_loop' passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:206:instart_synchronously' passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:180:instart' passenger (3.0.11) lib/phusion_passenger/rack/application_spawner.rb:129:instart' passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:253:inspawn_rack_application' passenger (3.0.11) lib/phusion_passenger/abstract_server_collection.rb:132:inlookup_or_add' passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:246:inspawn_rack_application' passenger (3.0.11) lib/phusion_passenger/abstract_server_collection.rb:82:insynchronize' passenger (3.0.11) lib/phusion_passenger/abstract_server_collection.rb:79:insynchronize' passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:244:inspawn_rack_application' passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:137:inspawn_application' passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:275:inhandle_spawn_application' passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:357:insend' passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:357:inserver_main_loop' passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:206:instart_synchronously' passenger (3.0.11) helper-scripts/passenger-spawn-server:99

mj00 commented 12 years ago

I think I just found the diff:

Without the match directive:

Started GET "/knowledgebase/articles/13" for 192.168.3.115 at Thu Aug 09 13:46:40 +0200 2012 Processing by ArticlesController#show as HTML Parameters: {"id"=>"13"}

With the match directive:

Started GET "/knowledgebase/articles/13" for 192.168.3.115 at Thu Aug 09 13:47:21 +0200 2012 Processing by ArticlesController#show as HTML Parameters: {"article_id"=>"13"}

alexbevi commented 12 years ago

@mj00 try changing the following in ArticlesController:

def get_article @article = KbArticle.where(:id => params[:id]) @article = @article.first if @article.is_a?(ActiveRecord::Relation) end

to

def get_article @article = KbArticle.where(:id => params[:id] || params[:article_id]) @article = @article.first if @article.is_a?(ActiveRecord::Relation) end

jniggemann commented 12 years ago

@mjoo, you wrote match bla bla , :to => bla bla in your route, what is that for, the page I linked to does not do that...

mj00 commented 12 years ago

alexbevi: Genius! That fixed it, thanks a lot.

jniggemann: that's what I found as example for RoR3 matches. Apparantly both seem to be working.

Update: scratch that, the :to => doesn't seem to be working properly. It works for some articles but not all of them. Yours however does the trick.

alexbevi commented 12 years ago

I just pushed a quick update as well.

mj00 commented 12 years ago

I'm afraid that was too soon... while it fixed search it broke creating and editing articles.

Creating a new article:

Started GET "/knowledgebase/articles/new?category_id=26" for 192.168.3.115 at Thu Aug 09 14:44:49 +0200 2012 Processing by ArticlesController#show as HTML Parameters: {"category_id"=>"26", "article_id"=>"new"} Completed 500 Internal Server Error in 9ms

Editing an existing article:

Started GET "/knowledgebase/articles/11/edit" for 192.168.3.115 at Thu Aug 09 14:44:03 +0200 2012 Processing by ArticlesController#edit as HTML Parameters: {"id"=>"11"} Rendered plugins/redmine_knowledgebase/app/views/articles/_form.html.erb (287.2ms) Rendered plugins/redmine_knowledgebase/app/views/articles/edit.html.erb within layouts/base (288.8ms) Completed 500 Internal Server Error in 301ms

By the way: is it correct that the edit definition in routes.rb is completely empty?

alexbevi commented 12 years ago

ok, reverted. It's dangerous how tempting it is to edit files using github (without testing anything) ...

alexbevi commented 12 years ago

Since this whole global search thing has been nothing but a series of hacks (and I don't personally use it), I'm going to leave this alone and wait for a properly tested patch :)

mj00 commented 12 years ago

Do you have any idea what exactly could be causing the errors when creating / editing articles? A working search is the last thing that keeps me from deploying your plugin on our production system, we've been testing it for a while and it's an amazing way to organize knowledge.

alexbevi commented 12 years ago

@mj00 it shouldn't be too difficult to fix, but I'm at work right now and can't really look into it too closely. If no one gets around to this, I'll have a closer look when I have a bit of free time.

tomhanax commented 12 years ago

just asking... any progress?

alexbevi commented 12 years ago

I was hoping for a patch from someone who actually uses the functionality. I haven't ever used the searching hacks, and the quick fixes I did borked other functionality, so I'm waiting as well ;)

tomhanax commented 12 years ago

We consider searching through KB very important (it's a wiki-style habit). I'd be glad to help... only if I know to code in Rails... All my amateur attempts left me with above-mentioned two consequences: Err 500 or can't create/edit articles...

mj00 commented 12 years ago

Sent a patch to @alexbevi . Hopefully it gets commited... :)

jasir commented 12 years ago

Hi, is patch available somewhere? Thanx

alexbevi commented 12 years ago

https://gist.github.com/3773063

I actually just started reviewing it today, but the more the merrier ;)

JozefResetar commented 12 years ago

Hi, if I click http://localhost:3000/knowledgebase

Internal error...

I patched KB and in log was this :

SyntaxError (/usr/share/redmine-2.1/plugins/redmine_knowledgebase/app/models/kb_article.rb:24: syntax error, unexpected tSYMBEG, expecting kDO or '{' or '(' acts_as_event :title => Proc.new { |o| "#{l(:...

alexbevi commented 12 years ago

@dodoslav I haven't actually tested the patches, I was just going to review them. It looks like you didn't successfully patch the plugin though.

Post your app/models/kb_article.rb to a gist so we can have a quick look

mj00 commented 12 years ago

The patches are for 2.x tested with Redmine 2.0.3 and 2.0.4

JozefResetar commented 12 years ago

Here is my kb_article.rb https://gist.github.com/3786218

ruby 1.8.7 Rails 3.2.8 redmine 2.1.1

alexbevi commented 12 years ago

@dodoslav there is a trailing comma on line 21 that you need to remove:

:date_column => "kb_articles.created_at", <-------

JozefResetar commented 12 years ago

Yeah, there was mistake, thx. So, searching was working after this mistake but when I clicked on found link - Internal error appeared. I looked at logs and found that link_to_remote method is missing, so I rewrote each to : link_to .. {... , :remote => true } ... and works perfectly!!!

But is it possible to port this patch to redmine version 1.3.2 ?

alexbevi commented 11 years ago

Without doing some serious patching of the redmine core, it doesn't look like searching will ever work "properly" for the 1.x or 2.x branches of this plugin.

With 3.x, we're moving to a traditional, project-based approach (as all other plugins do) in order to allow us to take advantage of the types of features Redmine core offers (like searching).

Closing for now.

alexbevi commented 11 years ago

Just wanted to add that this was a good discussion and all feedback was/is appreciated :)