From 582ccd2ecf282a819b247db6946351a6fddb63cc Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 13 Aug 2014 14:45:10 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0wiki=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=E9=A1=B9=E7=9B=AE=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E6=A8=A1=E5=9D=97=E5=9B=9E=E5=8E=BB=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E5=AD=97=E7=AC=A6=E4=B8=B2=E4=B8=8D=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 44 ++++++++++++++++++++++- app/helpers/wiki_helper.rb | 10 ++++++ app/views/messages/_project_show.html.erb | 4 +-- app/views/wiki/_content.html.erb | 2 +- db/schema.rb | 7 ++-- 5 files changed, 60 insertions(+), 7 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b1006d239..23f6b6994 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -685,7 +685,7 @@ module ApplicationHelper when 2 obj = args.shift attr = args.shift - text = obj.send(attr).to_s + text = obj.send(attr).html_safe.to_s else raise ArgumentError, 'invalid arguments to textilizable' end @@ -716,6 +716,48 @@ module ApplicationHelper text.html_safe end + # + #格式化字符串,不转义html代码 + def textAreailizable(*args) + options = args.last.is_a?(Hash) ? args.pop : {} + case args.size + when 1 + obj = options[:object] + text = args.shift + when 2 + obj = args.shift + attr = args.shift + text = obj.send(attr).html_safe.to_s + else + raise ArgumentError, 'invalid arguments to textilizable' + end + return '' if text.blank? + project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil) + only_path = options.delete(:only_path) == false ? false : true + + text = text.dup + macros = catch_macros(text) + text = Redmine::WikiFormatting.to_html("CKEditor", text, :object => obj, :attribute => attr) + + @parsed_headings = [] + @heading_anchors = {} + @current_section = 0 if options[:edit_section_links] + + parse_sections(text, project, obj, attr, only_path, options) + text = parse_non_pre_blocks(text, obj, macros) do |text| + [:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links].each do |method_name| + send method_name, text, project, obj, attr, only_path, options + end + end + parse_headings(text, project, obj, attr, only_path, options) + + if @parsed_headings.any? + replace_toc(text, @parsed_headings) + end + + text.html_safe + end + def parse_non_pre_blocks(text, obj, macros) s = StringScanner.new(text) tags = [] diff --git a/app/helpers/wiki_helper.rb b/app/helpers/wiki_helper.rb index c6cb3b39d..8278ce035 100644 --- a/app/helpers/wiki_helper.rb +++ b/app/helpers/wiki_helper.rb @@ -40,4 +40,14 @@ module WikiHelper link_to(h(parent.pretty_title), {:controller => 'wiki', :action => 'show', :id => parent.title, :project_id => parent.project, :version => nil}) }) end + + def wiki_content_format wiki + text = wiki.text.html_safe + text = parse_non_pre_blocks(text, wiki, text) do |text| + [:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links].each do |method_name| + send method_name, text, project, wiki, attr, only_path, options + end + end + text + end end diff --git a/app/views/messages/_project_show.html.erb b/app/views/messages/_project_show.html.erb index 66027e6ec..0bae1a761 100644 --- a/app/views/messages/_project_show.html.erb +++ b/app/views/messages/_project_show.html.erb @@ -161,8 +161,8 @@
- <%#= textilizable message,:content,:attachments => message.attachments %> - <%= message.content.html_safe %> + <%= textAreailizable message,:content,:attachments => message.attachments %> + <%#= message.content.html_safe %>
<%= link_to_attachments message, :author => false %> diff --git a/app/views/wiki/_content.html.erb b/app/views/wiki/_content.html.erb index fcfcc1351..96d358381 100644 --- a/app/views/wiki/_content.html.erb +++ b/app/views/wiki/_content.html.erb @@ -1,5 +1,5 @@
- <%= textilizable content, :text, :attachments => content.page.attachments, + <%= textAreailizable content, :text, :attachments => content.page.attachments, :edit_section_links => (@sections_editable && {:controller => 'wiki', :action => 'edit', :project_id => @page.project, :id => @page.title}) %> <%#= content.text.html_safe %>
diff --git a/db/schema.rb b/db/schema.rb index f087206ee..d90541472 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140812032957) do +ActiveRecord::Schema.define(:version => 20140812065417) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -304,8 +304,9 @@ ActiveRecord::Schema.define(:version => 20140812032957) do t.string "disk_directory" t.integer "attachtype" t.integer "is_public" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "container_id", :default => 0 end create_table "course_infos", :force => true do |t| From 0e35967433e913646a0ea8e61312fbe5df1086f1 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 13 Aug 2014 15:19:05 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9wiki=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=88=9D=E5=A7=8B=E5=8C=96=E9=AB=98=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/wiki/edit.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/wiki/edit.html.erb b/app/views/wiki/edit.html.erb index 35f905eef..3a1abdd83 100644 --- a/app/views/wiki/edit.html.erb +++ b/app/views/wiki/edit.html.erb @@ -16,7 +16,7 @@

<%=text_area_tag 'content[text]', @text, :required => true, :id => 'editor02', :cols => 100, :rows => 25 %>

From 4934c8c801051e2b3bdfd91be65adea47f20094c Mon Sep 17 00:00:00 2001 From: zhanghaitao <562681745@qq.com> Date: Wed, 13 Aug 2014 15:37:28 +0800 Subject: [PATCH 3/5] =?UTF-8?q?#=20=E9=A1=B5=E9=9D=A2=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/stores_controller.rb | 6 +++++ app/models/issue.rb | 13 ++++----- app/views/stores/index.html.erb | 4 +-- app/views/welcome/contest.html.erb | 40 ++++++++++++++-------------- 4 files changed, 35 insertions(+), 28 deletions(-) diff --git a/app/controllers/stores_controller.rb b/app/controllers/stores_controller.rb index ae9336161..26ed51a59 100644 --- a/app/controllers/stores_controller.rb +++ b/app/controllers/stores_controller.rb @@ -5,12 +5,18 @@ class StoresController < ApplicationController layout 'base_stores' def search + begin q = "%#{params[:name].strip}%" (redirect_to stores_path, :notice => l(:label_sumbit_empty);return) if params[:name].blank? result = find_public_attache q @searched_attach = paginateHelper result @result_all_count = result.count; + rescue Exception => e + #render 'stores' + redirect_to stores_path + end + end def find_public_attache keywords diff --git a/app/models/issue.rb b/app/models/issue.rb index 1978f5405..f81665035 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -138,10 +138,10 @@ class Issue < ActiveRecord::Base nil when 'default' user_ids = [user.id] + user.groups.map(&:id) - "(#{table_name}.is_private = #{connection.quoted_false} OR #{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))" + "(#{table_name}.is_private = #{connection.quoted_false}) OR (#{table_name}.author_id = #{user.id} OR #{table_name}.tracker_id IN (#{user_ids.join(',')}) OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))" when 'own' user_ids = [user.id] + user.groups.map(&:id) - "(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))" + "(#{table_name}.author_id = #{user.id} OR #{table_name}.tracker_id IN (#{user_ids.join(',')}) OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))" else '1=0' end @@ -159,9 +159,9 @@ class Issue < ActiveRecord::Base when 'all' true when 'default' - !self.is_private? || (self.author == user || user.is_or_belongs_to?(assigned_to)) - when 'own' - self.author == user || user.is_or_belongs_to?(assigned_to) + (!self.is_private? ||self.tracker == user) || (self.author == user || user.is_or_belongs_to?(assigned_to)) + when 'own' + self.tracker == user || self.author == user || user.is_or_belongs_to?(assigned_to) else false end @@ -1009,9 +1009,10 @@ class Issue < ActiveRecord::Base s << ' overdue' if overdue? s << ' child' if child? s << ' parent' unless leaf? - s << ' private' if is_private? + #s << ' private' if is_private? s << ' created-by-me' if User.current.logged? && author_id == User.current.id s << ' assigned-to-me' if User.current.logged? && assigned_to_id == User.current.id + s << ' tracker-id' if User.current.logged? && tracker_id == User.current.id s end diff --git a/app/views/stores/index.html.erb b/app/views/stores/index.html.erb index 8ad37f504..6984169d7 100644 --- a/app/views/stores/index.html.erb +++ b/app/views/stores/index.html.erb @@ -21,7 +21,7 @@ <% k.each do |c1|%>
- <%= link_to c1.filename, (attachFromUrl c1), {:title => c1.filename, :target => "_blank"} %> + <%= link_to c1.filename, (attachFromUrl c1), {:title => c1.filename, :target => "_blank"} %>
<%= c1.downloads %> @@ -32,7 +32,7 @@
<% end -%>
- + <% end; reset_cycle %> diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index f2140fd9b..d735e1013 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -14,7 +14,7 @@ $('#' + id).val(''); } } - + $(function(){ $("#main").find("a").attr("target", "_blank"); setCss(); @@ -118,23 +118,23 @@ +
- +
<% if get_avatar?(@contest_page) %> <%= image_tag(url_to_avatar(@contest_page), width:@contest_page.image_width,height: @contest_page.image_height) %> <% else %> <%= image_tag '/images/transparent.png', width:@contest_page.image_width,height: @contest_page.image_height %> <% end %> -
+
<% unless @contest_page.nil? %> <%= @contest_page.title %> , <%= @contest_page.description %> <% end %>
- +
<%= form_tag({controller: :welcome, action: :search }, method: :get) do %> <%= text_field_tag 'name', params[:name], :placeholder => l(:label_search_intimation), name: "name", :class => 'blueinputbar', :style => 'width:240px; padding-right:50px;'%> @@ -162,7 +162,7 @@
<%= image_tag('/images/contest1.png')%>
- +
<%= link_to(contest.name, contest_contestnotifications_path(contest.id), :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", :target => "_blank") %> @@ -172,19 +172,19 @@ (<%= link_to("#{contest.contesting_softapplications.count}"+l(:label_work_quantity), show_attendingcontest_contest_path(contest), :target => "_blank") %>) <% end %>
- +
<%=contest.description.truncate(100, omission: '...')%>

- +
- + <%=l(:label_release_time)%>: <%=format_time contest.created_on %>
- + - <% end; reset_cycle %> - + <% end; reset_cycle %> +
@@ -299,31 +299,31 @@ <% if Softapplication.count > 0%>
<% find_all_hot_softapplication.map do |softapplication| break if(softapplication == find_all_hot_softapplication[5]) %> - +
  • <%= image_tag('/images/app1.png')%>
    - +
    <%= link_to(softapplication.name, softapplication_path(softapplication.id), :class => "d-g-blue d-p-project-name", :title => "#{softapplication.name}", :target => "_blank") %>
    - +
    ><%=softapplication.description.to_s.truncate(50, omission: '...')%>

    - +
    <%=l(:label_release_time)%>: <%=format_time softapplication.created_at %>
    - +
  • - <% end; reset_cycle %> - + <% end; reset_cycle %> +
    <% else %>

    <%= l(:label_no_ftapplication) %>

    - + <% end %> From ce7d91d164d8d0ac1dc28e69313209ddb11ebd02 Mon Sep 17 00:00:00 2001 From: zhanghaitao <562681745@qq.com> Date: Wed, 13 Aug 2014 16:29:26 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=20#932=20=E8=BE=93=E5=85=A5=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E4=B8=BA=E9=9D=9E=E6=B1=89=E5=AD=97=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E4=B8=94=E5=AD=97=E6=95=B0=E8=BE=83=E5=A4=9A=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E8=B6=85=E5=87=BA=E8=BE=B9=E6=A1=86Bug?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/issues_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 5e7f7c18c..315a86340 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -73,7 +73,7 @@ module IssuesHelper ancestors.each do |ancestor| s << '
    ' + content_tag('p', link_to_issue(ancestor, :project => (issue.project_id != ancestor.project_id))) end - s << '
    ' + s << '
    ' subject = h(issue.subject) if issue.is_private? subject = content_tag('span', l(:field_is_private), :class => 'private') + ' ' + subject From bc6ad5d4163175a5d283fa4ccaeb5637b0826ebd Mon Sep 17 00:00:00 2001 From: zhanghaitao <562681745@qq.com> Date: Wed, 13 Aug 2014 16:45:50 +0800 Subject: [PATCH 5/5] =?UTF-8?q?#936=20=E8=BE=93=E5=85=A5=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E9=9D=9E=E6=B1=89=E6=97=8F=E6=98=BE=E7=A4=BA?= =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/documents/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/documents/show.html.erb b/app/views/documents/show.html.erb index 2964a06ba..45f54ad9b 100644 --- a/app/views/documents/show.html.erb +++ b/app/views/documents/show.html.erb @@ -9,7 +9,7 @@ <% end %>
    -

    <%=h @document.title %>

    +

    <%=h @document.title %>

    <%#=h @document.category.name %>
    <%= format_date @document.created_on %>