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.8 kB

13 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
13 years ago
​
​
12 years ago
13 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
13 years ago
​
​
​
​
13 years ago
​
​
12 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
13 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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, :find_contest, except: [:contestnotification]
  19. def issue
  20. @issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank?
  21. @issue = @contest.issues.find_by_id(params[:id]) unless params[:id].blank?
  22. if @issue
  23. @description = params[:issue] && params[:issue][:description]
  24. if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
  25. @description = nil
  26. end
  27. # params[:notes] is useful for preview of notes in issue history
  28. @notes = params[:notes] || (params[:issue] ? params[:issue][:notes] : nil)
  29. else
  30. @description = (params[:issue] ? params[:issue][:description] : nil)
  31. end
  32. render :layout => false
  33. end
  34. def news
  35. if params[:id].present? && news = News.visible.find_by_id(params[:id])
  36. @previewed = news
  37. end
  38. @text = (params[:news] ? params[:news][:description] : nil)
  39. render :partial => 'common/preview'
  40. end
  41. def contestnotification
  42. @previewed = Contestnotification.find(params[:id])
  43. @text = (params[:contestnotification] ? params[:contestnotification][:description] : nil)
  44. render :partial => 'common/preview'
  45. end
  46. private
  47. def find_project
  48. project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
  49. @project = Project.find(project_id)
  50. rescue ActiveRecord::RecordNotFound
  51. render_404
  52. end
  53. def contestnotifications
  54. if params[:id].present? && contestnotifications = Contestnotifications.visible.find_by_id(params[:id])
  55. @previewed = contestnotifications
  56. end
  57. @text = (params[:contestnotifications] ? params[:contestnotifications][:description] : nil)
  58. render :partial => 'common/preview'
  59. end
  60. private
  61. def find_contest
  62. contest_id = (params[:issue] && params[:issue][:contest_id]) || params[:contest_id]
  63. @contest = Contest.find(contest_id)
  64. rescue ActiveRecord::RecordNotFound
  65. render_404
  66. end
  67. end

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