0
@@ -3,54 +3,39 @@ class NotesController < ApplicationController
0
# Display a list of notes
0
- @category = params[:category]
0
- @content_url = params[:return_url]
0
+ @container_name = params[:container_name]
0
+ @note_group = params[:note_group]
0
- @notes = Note.find(:all, :conditions => ["c
ategory = ? AND name = ?", @category, @name], :order=> "created_at ASC")
0
+ @notes = Note.find(:all, :conditions => ["c
ontainer_name = ? AND note_group = ?", @container_name, @note_group], :order=> "created_at ASC")
0
- # Show all immediate children of this note. This only works for classes right now. Because...
0
- # A note is the immediate child of another note if the parent has the format 'somename' and the child the format 'somename.blah'
0
- # currently only methods have this format
0
- @category = params[:category]
0
- @content_url = params[:return_url]
0
- searchName = @name + Note::METHOD_SEPARATOR + '%';
0
- @notes = Note.find_by_sql(["SELECT DISTINCT name FROM notes WHERE category = ? AND name LIKE ?", @category, searchName])
0
# Display a list of notes for the entire site.. up to 30
0
- @category = params[:category]
0
- @content_url = params[:return_url]
0
@notes = Note.find(:all, :limit => 20, :order=> "created_at DESC")
0
+ # Generate an RSS feed of the 20 newest notes
0
@notes = Note.find(:all, :limit => 20, :order=> "created_at DESC")
0
- render
:layout => false
0
+ render
:layout => false
0
- @note.content_url = ""
0
+ @note = Note.new(get_note_params(params[:id], params[:type]))
0
+ @note.ref_id = params[:id]
0
+ @note.ref_type = params[:type]
0
- @note = Note.new(params[:note])
0
+ note_params = get_note_params(params[:note][:ref_id], params[:note][:ref_type])
0
+ @note = Note.new(note_params.merge(params[:note]))
0
@note.created_at = Time.now
0
@note.skip_ban_validation = true
0
@@ -60,18 +45,63 @@ class NotesController < ApplicationController
0
+ # Save the note to the DB
0
- @note = Note.new(params[:note])
0
+ note_params = get_note_params(params[:note][:ref_id], params[:note][:ref_type])
0
+ @note = Note.new(note_params.merge(params[:note]))
0
@note.ip_address = request.remote_ip;
0
render :action => 'preview'
0
- expire_page(:controller => "doc", :action => 'files', :name => @note.name)
0
- expire_page(:controller => "doc", :action => 'modules', :name => @note.name)
0
- expire_page(:controller => "doc", :action => 'classes', :name => @note.name)
0
+ expire_page(:controller => "doc", :action => 'files', :name => @note.container_name)
0
+ expire_page(:controller => "doc", :action => 'modules', :name => @note.container_name)
0
+ expire_page(:controller => "doc", :action => 'classes', :name => @note.container_name)
0
expire_page :action => "list"
0
render :action => 'success'
0
+ # Given the id and type of the object that this note is being attached to
0
+ # get the necessary information to create the note
0
+ def get_note_params(id, type_string)
0
+ when RaModule.to_s then return get_container_params(id, type_string)
0
+ when RaClass.to_s then return get_container_params(id, type_string)
0
+ when RaFile.to_s then return get_container_params(id, type_string)
0
+ when RaMethod.to_s then return get_method_params(id, type_string)
0
+ when RaInFile.to_s then return get_codeobj_params(id, type_string)
0
+ when RaAttribute.to_s then return get_codeobj_params(id, type_string)
0
+ when RaConstant.to_s then return get_codeobj_params(id, type_string)
0
+ when RaInclude.to_s then return get_codeobj_params(id, type_string)
0
+ when RaRequire.to_s then return get_codeobj_params(id, type_string)
0
+ when RaAlias.to_s then return get_codeobj_params(id, type_string)
0
+ def get_container_params(id, type_string)
0
+ type = RaContainer.find(id)
0
+ return {:container_name => type.full_name, :ra_container_id => type.id,
0
+ :note_group => type_string, :note_type => type_string,
0
+ :version => type.ra_library.ver_string }
0
+ def get_method_params(id, type_string)
0
+ type = RaMethod.find(id)
0
+ return {:container_name => type.ra_container.full_name, :ra_container_id => type.ra_container.id,
0
+ :note_group => type.name, :note_type => type_string,
0
+ :version => type.ra_container.ra_library.ver_string }
0
+ def get_codeobj_params(id, type_string)
0
+ type = RaContainer.find(id)
0
+ return {:container_name => type.full_name, :ra_container_id => id,
0
+ :note_group => type_string, :note_type => type_string,
0
+ :version => type.ra_library.ver_string}
0
\ No newline at end of file