You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

previews_controller.rb 2.5 kB

13 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
13 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
13 years ago
​
​
​
​
13 years ago
​
​
12 years ago
​
​
​
​
​
​
​
13 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2013 Jean-Philippe Lang
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. class PreviewsController < ApplicationController
  18. before_filter :find_project, :find_attachments, except: :contestnotification
  19. def issue
  20. @issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank?
  21. if @issue
  22. @description = params[:issue] && params[:issue][:description]
  23. if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
  24. @description = nil
  25. end
  26. # params[:notes] is useful for preview of notes in issue history
  27. @notes = params[:notes] || (params[:issue] ? params[:issue][:notes] : nil)
  28. else
  29. @description = (params[:issue] ? params[:issue][:description] : nil)
  30. end
  31. render :layout => false
  32. end
  33. def news
  34. if params[:id].present? && news = News.visible.find_by_id(params[:id])
  35. @previewed = news
  36. end
  37. @text = (params[:news] ? params[:news][:description] : nil)
  38. render :partial => 'common/preview'
  39. end
  40. def contestnotification
  41. @previewed = Contestnotification.find(params[:id])
  42. @text = (params[:contestnotification] ? params[:contestnotification][:description] : nil)
  43. render :partial => 'common/preview'
  44. end
  45. private
  46. def find_project
  47. project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
  48. @project = Project.find(project_id)
  49. rescue ActiveRecord::RecordNotFound
  50. render_404
  51. end
  52. def contestnotifications
  53. if params[:id].present? && contestnotifications = Contestnotifications.visible.find_by_id(params[:id])
  54. @previewed = contestnotifications
  55. end
  56. @text = (params[:contestnotifications] ? params[:contestnotifications][:description] : nil)
  57. render :partial => 'common/preview'
  58. end
  59. end

软件技术创新是当今国家整体创新能力的重要基础和发展引擎。近年来,大众参与的软件创新与创业活动已经成为网络时代软件开发和应用的新形态,正在快速改变着全球软件创新模式和软件产业格局。 ...