diff --git a/app/controllers/release_notes_controller.rb b/app/controllers/release_notes_controller.rb index 821731b..90e6f2c 100755 --- a/app/controllers/release_notes_controller.rb +++ b/app/controllers/release_notes_controller.rb @@ -63,6 +63,17 @@ def update render_404 end + def view + @issue = Issue.find(params[:issue_id]) + @release_note = @issue.release_note + @format = release_notes_format_from_params + @content = ReleaseNotesGenerator.new(nil, @format).generate_single(@release_note) + + respond_to do |format| + format.api {} + end + end + def destroy release_note = ReleaseNote.find(params[:id]) @issue = release_note.issue diff --git a/app/models/release_notes_generator.rb b/app/models/release_notes_generator.rb index e1dc311..13d877f 100755 --- a/app/models/release_notes_generator.rb +++ b/app/models/release_notes_generator.rb @@ -92,6 +92,14 @@ def generate generate_header << "\n" << generate_release_notes end + def generate_single(release_note) + str = format.start + str << "\n" + str << make_substitutions(format.each_issue, values_for_issue(release_note.issue)) + str << "\n" + str << format.end + end + private def generate_header make_substitutions(format.header, values_for_header(version)) diff --git a/app/views/release_notes/view.api.rsb b/app/views/release_notes/view.api.rsb new file mode 100644 index 0000000..75e1cd7 --- /dev/null +++ b/app/views/release_notes/view.api.rsb @@ -0,0 +1,7 @@ +api.release_note do + api.id @release_note.id + api.issue_id @release_note.issue_id + api.status @issue.release_notes_custom_value.value + api.text @release_note.text + api.formatted @content +end diff --git a/config/routes.rb b/config/routes.rb index c369cb9..7bd21f1 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,6 +26,12 @@ :to => "release_notes#generate", :as => :generate_release_notes + get "/issues/:issue_id/release_notes", + :to => 'release_notes#view', + :as => :release_note_view, + defaults: { format: 'json' } + + patch 'release_notes_formats/preview', :to => 'release_notes_formats#preview', :as => :preview_release_notes_format