From d618a5fec361b85fafffd5cf4a53d044e82bdb5a Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 6 Nov 2013 09:58:43 +0200 Subject: Refactor search views Signed-off-by: Dmitriy Zaporozhets --- app/views/search/_blob.html.haml | 10 ---- app/views/search/_global_results.html.haml | 5 ++ app/views/search/_project_results.html.haml | 17 +++++++ app/views/search/_result.html.haml | 62 ----------------------- app/views/search/_results.html.haml | 13 +++++ app/views/search/results/_blob.html.haml | 10 ++++ app/views/search/results/_issue.html.haml | 9 ++++ app/views/search/results/_merge_request.html.haml | 12 +++++ app/views/search/results/_project.html.haml | 7 +++ app/views/search/show.html.haml | 2 +- 10 files changed, 74 insertions(+), 73 deletions(-) delete mode 100644 app/views/search/_blob.html.haml create mode 100644 app/views/search/_global_results.html.haml create mode 100644 app/views/search/_project_results.html.haml delete mode 100644 app/views/search/_result.html.haml create mode 100644 app/views/search/_results.html.haml create mode 100644 app/views/search/results/_blob.html.haml create mode 100644 app/views/search/results/_issue.html.haml create mode 100644 app/views/search/results/_merge_request.html.haml create mode 100644 app/views/search/results/_project.html.haml (limited to 'app/views/search') diff --git a/app/views/search/_blob.html.haml b/app/views/search/_blob.html.haml deleted file mode 100644 index 559fdd794fc..00000000000 --- a/app/views/search/_blob.html.haml +++ /dev/null @@ -1,10 +0,0 @@ -%li - .file-holder - .file-title - = link_to project_blob_path(@project, tree_join(blob.ref, blob.filename), :anchor => "L" + blob.startline.to_s) do - %i.icon-file - %strong - = blob.filename - .file-content.code.term - %div{class: user_color_scheme_class} - = raw blob.colorize( formatter: :gitlab, options: { first_line_number: blob.startline } ) diff --git a/app/views/search/_global_results.html.haml b/app/views/search/_global_results.html.haml new file mode 100644 index 00000000000..6e6feeb6c5a --- /dev/null +++ b/app/views/search/_global_results.html.haml @@ -0,0 +1,5 @@ +.search_results + %ul.bordered-list + = render partial: "search/results/project", collection: @projects + = render partial: "search/results/merge_request", collection: @merge_requests + = render partial: "search/results/issue", collection: @issues diff --git a/app/views/search/_project_results.html.haml b/app/views/search/_project_results.html.haml new file mode 100644 index 00000000000..8d04dd27cca --- /dev/null +++ b/app/views/search/_project_results.html.haml @@ -0,0 +1,17 @@ +%ul.nav.nav-pills + %li{class: ("active" if params[:search_code].present?)} + = link_to search_path(params.merge(search_code: true)) do + Repository Code + %li{class: ("active" if params[:search_code].blank?)} + = link_to search_path(params.merge(search_code: nil)) do + Everything else + +.search_results + - if params[:search_code].present? + .blob-results + = render partial: "search/results/blob", collection: @blobs + = paginate @blobs, theme: 'gitlab' + - else + %ul.bordered-list + = render partial: "search/results/merge_request", collection: @merge_requests + = render partial: "search/results/issue", collection: @issues diff --git a/app/views/search/_result.html.haml b/app/views/search/_result.html.haml deleted file mode 100644 index 5f7540d1b16..00000000000 --- a/app/views/search/_result.html.haml +++ /dev/null @@ -1,62 +0,0 @@ -%fieldset - %legend - Search results - %span.cgray (#{@total_results}) - -- if @project - %ul.nav.nav-pills - %li{class: ("active" if params[:search_code].present?)} - = link_to search_path(params.merge(search_code: true)) do - Repository Code - %li{class: ("active" if params[:search_code].blank?)} - = link_to search_path(params.merge(search_code: nil)) do - Everything else - -.search_results - %ul.bordered-list - - @projects.each do |project| - %li - project: - = link_to project do - %strong.term= project.name_with_namespace - - @merge_requests.each do |merge_request| - %li - merge request: - = link_to [merge_request.target_project, merge_request] do - %span ##{merge_request.iid} - %strong.term - = truncate merge_request.title, length: 50 - - if merge_request.for_fork? - %span.light (#{merge_request.source_project.name_with_namespace}:#{merge_request.source_branch} → #{merge_request.target_project.name_with_namespace}:#{merge_request.target_branch}) - - else - %span.light (#{merge_request.source_branch} → #{merge_request.target_branch}) - - if merge_request.closed? - %span.label Closed - - - @issues.each do |issue| - %li - issue: - = link_to [issue.project, issue] do - %span ##{issue.iid} - %strong.term - = truncate issue.title, length: 50 - %span.light (#{issue.project.name_with_namespace}) - - if issue.closed? - %span.label Closed - - - @wiki_pages.each do |wiki_page| - %li - wiki: - = link_to project_wiki_path(wiki_page.project, wiki_page) do - %strong.term - = truncate wiki_page.title, length: 50 - %span.light (#{wiki_page.project.name_with_namespace}) - - - @blobs.each do |blob| - = render 'blob', blob: blob - - = paginate @blobs, theme: 'gitlab' - -:javascript - $(".search_results .term").highlight("#{escape_javascript(params[:search])}"); - diff --git a/app/views/search/_results.html.haml b/app/views/search/_results.html.haml new file mode 100644 index 00000000000..75f134aae66 --- /dev/null +++ b/app/views/search/_results.html.haml @@ -0,0 +1,13 @@ +%fieldset + %legend + Search results + %span.cgray (#{@total_results}) + +- if @project + = render "project_results" +- else + = render "global_results" + +:javascript + $(".search_results .term").highlight("#{escape_javascript(params[:search])}"); + diff --git a/app/views/search/results/_blob.html.haml b/app/views/search/results/_blob.html.haml new file mode 100644 index 00000000000..a2e4a00b718 --- /dev/null +++ b/app/views/search/results/_blob.html.haml @@ -0,0 +1,10 @@ +.blob-result + .file-holder + .file-title + = link_to project_blob_path(@project, tree_join(blob.ref, blob.filename), :anchor => "L" + blob.startline.to_s) do + %i.icon-file + %strong + = blob.filename + .file-content.code.term + %div{class: user_color_scheme_class} + = raw blob.colorize( formatter: :gitlab, options: { first_line_number: blob.startline } ) diff --git a/app/views/search/results/_issue.html.haml b/app/views/search/results/_issue.html.haml new file mode 100644 index 00000000000..7a24b76bced --- /dev/null +++ b/app/views/search/results/_issue.html.haml @@ -0,0 +1,9 @@ +%li + issue: + = link_to [issue.project, issue] do + %span ##{issue.iid} + %strong.term + = truncate issue.title, length: 50 + %span.light (#{issue.project.name_with_namespace}) + - if issue.closed? + %span.label Closed diff --git a/app/views/search/results/_merge_request.html.haml b/app/views/search/results/_merge_request.html.haml new file mode 100644 index 00000000000..22d7587f6c1 --- /dev/null +++ b/app/views/search/results/_merge_request.html.haml @@ -0,0 +1,12 @@ +%li + merge request: + = link_to [merge_request.target_project, merge_request] do + %span ##{merge_request.iid} + %strong.term + = truncate merge_request.title, length: 50 + - if merge_request.for_fork? + %span.light (#{merge_request.source_project.name_with_namespace}:#{merge_request.source_branch} → #{merge_request.target_project.name_with_namespace}:#{merge_request.target_branch}) + - else + %span.light (#{merge_request.source_branch} → #{merge_request.target_branch}) + - if merge_request.closed? + %span.label Closed diff --git a/app/views/search/results/_project.html.haml b/app/views/search/results/_project.html.haml new file mode 100644 index 00000000000..abc86c72bef --- /dev/null +++ b/app/views/search/results/_project.html.haml @@ -0,0 +1,7 @@ +%li + project: + = link_to project do + %strong.term= project.name_with_namespace + - if project.description.present? + – + %span.light.term= project.description diff --git a/app/views/search/show.html.haml b/app/views/search/show.html.haml index f1f65981b37..25e8c00888a 100644 --- a/app/views/search/show.html.haml +++ b/app/views/search/show.html.haml @@ -13,4 +13,4 @@ .results.prepend-top-10 - if params[:search].present? - = render 'search/result' + = render 'search/results' -- cgit v1.2.1