Skip to content

Commit 7033650

Browse files
committed
Improve indexing / remove style attributes
1 parent 65ca3a2 commit 7033650

File tree

18 files changed

+165
-88
lines changed

18 files changed

+165
-88
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/test/tmp/
99
/test/version_tmp/
1010
/tmp/
11+
rubocop.html
1112

1213
## Specific to RubyMotion:
1314
.dat*

.rubocop.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ AllCops:
2929
- 'vendor/**/*'
3030
# By default, the rails cops are not run. Override in project or home
3131
# directory .rubocop.yml files, or by giving the -R/--rails option.
32-
RunRailsCops: false
32+
Rails:
33+
Enabled: true
3334
# Cop names are not displayed in offense messages by default. Change behavior
3435
# by overriding DisplayCopNames, or by giving the -D/--display-cop-names
3536
# option.
@@ -629,9 +630,8 @@ Style/SpaceAroundEqualsInParameterDefault:
629630
- no_space
630631

631632
Style/SpaceAroundOperators:
632-
MultiSpaceAllowedForOperators:
633-
- '='
634-
- '=>'
633+
AllowForAlignment: true
634+
635635

636636
Style/SpaceBeforeBlockBraces:
637637
EnforcedStyle: space
@@ -674,7 +674,7 @@ Style/TrailingBlankLines:
674674
- final_newline
675675
- final_blank_line
676676

677-
Style/TrailingComma:
677+
Style/TrailingCommaInLiteral:
678678
# If EnforcedStyleForMultiline is comma, the cop requires a comma after the
679679
# last item of a list, but only for lists where each item is on its own line.
680680
# If EnforcedStyleForMultiline is consistent_comma, the cop requires a comma

Gemfile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
source 'https://rubygems.org/'
2-
3-
gem 'sunspot_rails'
4-
gem 'rsolr'
5-
gem 'will_paginate'
1+
gem 'sunspot_rails', '2.2.2'
2+
gem 'rsolr', '~> 1.0.7'
3+
gem 'will_paginate', '3.0.7'
64

75
group :development do
8-
gem 'sunspot_solr'
6+
gem 'sunspot_solr', '2.2.0'
97
end
108

119
group :integration_develop, :testing_develop, :development do
12-
gem 'progress_bar'
10+
gem 'progress_bar', '1.0.3'
1311
end

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
Redsun
1+
redsun
22
======
33

44
Red Sun - Apache Solr Search Integration for Redmine based on Sunspot
5-
6-
Read more about it here: http://dkd.github.io/redsun/

app/controllers/redsun_search_controller.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def index
5353
highlight :name
5454
highlight :notes
5555
highlight :id
56+
highlight :title
5657
end
5758

5859
any_of do
@@ -134,11 +135,7 @@ def index
134135
order_by(:score, :desc)
135136
end
136137
@searchstring = searchstring
137-
138-
# Accessing results will trigger a NoMethodError if the Solr server is gone
139-
@search.results.present?
140-
rescue NoMethodError
141-
render 'connection_refused'
138+
142139
rescue Errno::ECONNREFUSED
143140
render 'connection_refused'
144141
rescue RSolr::Error::Http

app/views/redsun_search/_class_name_facet.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</li>
99
<% results.facet(facet.to_sym).rows.each do |result| %>
1010
<li>
11-
<%= link_to "#{t('redsun.facets.values.'+result.value.to_s.downcase.tr(" ", "_"), default: result.value)} (#{result.count})",
11+
<%= link_to "#{t('redsun.facets.values.'+result.value.to_s.downcase.tr(" ", "_"), default: result.value)} (#{number_with_delimiter(result.count, delimiter: '.')})",
1212
url_for(search_form: {facet.to_sym => result.value}.reverse_merge(params[:search_form])), class: params[:search_form][facet.to_sym].blank? ? "" : "selected"
1313
%>
1414
</li>

app/views/redsun_search/_results.html.erb

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<br><%= page_entries_info @search.results, {model: "record"} %>
2-
<div style="text-align:center;margin-bottom: 2em">
2+
<div class="redsun-pagination-top">
33
<%= will_paginate @search.results %>
44
</div>
55

66
<%= facet(:class_name, @search, :class_name, "class_name_facet") %>
77

88
<% @search.each_hit_with_result do |hit, record| %>
9-
<div style="background: <%= !record.active? ? "red" : "" %>" class="redsun-result">
10-
<div style="float:left; width: 70%" class="redsun-result-item">
9+
<div class="redsun-result <%=record.active? ? "" : "redsun-inactive"%>">
10+
<div class="redsun-result-item">
1111
<%= render "redsun_search/results/#{hit.class_name.underscore}_result", hit: hit, record: record %>
1212
</div>
1313
<div style="float:right;padding-top: 2em">
1414
<% if !record.active? %>
15-
<span style="background: red; color:white; padding: 1em;border-radius: 10px">
15+
<span class="redsun-label-inactive">
1616
<%= t "redsun.inactive" %>
1717
</span>
1818
<% end %>
@@ -21,36 +21,9 @@
2121

2222
<% end %>
2323

24-
<div style="text-align:center; clear: both;margin-top: 1em">
24+
<div class="redsun-pagination-bottom">
2525
<%= will_paginate @search.results %>
2626
</div>
27-
<style>
28-
.redsun-result {
29-
display: table;
30-
width: 100%;
31-
border-bottom: 1px solid #e9e9e9;
32-
clear: left;
33-
background: white;
34-
}
35-
.redsun-result:hover {
36-
background: #f4f4f4;
37-
}
38-
ul.facets {
39-
max-height: 200px;
40-
overflow: scroll;
41-
}
42-
.redsun-result-item .redsun-highlight {
43-
background: #FDBF8D;
44-
padding: 2px;
45-
border-radius: 2px;
46-
-webkit-transition: background 2000ms ease-in-out;
47-
-moz-transition: background 2000ms ease-in-out;
48-
-ms-transition: background 2000ms ease-in-out;
49-
-o-transition: background 2000ms ease-in-out;
50-
transition: background 2000ms ease-in-out;
51-
}
52-
</style>
53-
5427
<% content_for :sidebar do %>
5528
<%= facet(:project_name, @search, :project_name) %>
5629
<%= facet(:active, @search, :active) %>

app/views/redsun_search/index.html.erb

Lines changed: 89 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,94 @@
1-
<h2><%= t "redsun.header"%></h2>
2-
<%= form_for("search_form", :url => @redsun_path,
3-
:html => { :style => "border: 1px solid #e9e9e9; padding: 1em; background: #f4f4f4; display: block", :method => :get }) do |f| %>
4-
<%= f.label t("redsun.searchstring")%>
5-
<%= f.text_field(:searchstring, :value => @searchstring, :title => "Search ...", :class => "toggle") %>
1+
<style type="text/css">
2+
.redsun-label-inactive{
3+
background-color: red;
4+
color: #fff;
5+
padding: 10px;
6+
border-radius: 3px;
7+
margin-right: 10px;
8+
}
9+
10+
#redsun-search-form {
11+
border: 1px solid #e9e9e9;
12+
padding: 1em;
13+
background: #FFD;
14+
display: block;
15+
border-radius: 3px;
16+
position: relative;
17+
}
18+
#redsun-search-form .redsun-search-button {
19+
padding: 6px;
20+
font-weight: bold;
21+
margin-left: 5px;
22+
}
23+
#redsun-search-form #search_form_searchstring {
24+
padding: 6px 3px;
25+
width: 200px;
26+
}
27+
#redsun-search-form #search_form_scope {
28+
margin-right: 5px;
29+
}
30+
.redsun-logo {
31+
width: 100px;
32+
position: absolute;
33+
right: 10px;
34+
top: 10px;
35+
}
36+
.redsun-pagination-top {
37+
text-align:center;
38+
margin-bottom: 2em;
39+
}
40+
.redsun-pagination-bottom {
41+
text-align:center;
42+
clear: both;
43+
margin-top: 1em;
44+
}
45+
.redsun-result {
46+
display: table;
47+
width: 100%;
48+
border-bottom: 1px solid #e9e9e9;
49+
clear: left;
50+
background-color: #fff;
51+
}
52+
.redsun-highlight {
53+
background-color: #fdbf8d;
54+
padding: 0px;
55+
box-shadow: 0.25em 0 0 #fdbf8d, -0.25em 0 0 #fdbf8d;
56+
border-radius: 3px;
57+
}
58+
ul.facets {
59+
max-height: 200px;
60+
overflow: scroll;
61+
}
62+
.redsun-result-item {
63+
padding-left: 10px;
64+
float: left;
65+
width: 80%;
66+
}
67+
.redsun-result:hover {
68+
background: #f4f4f4;
69+
-webkit-transition: background-color 100ms ease-in-out;
70+
-moz-transition: background-color 100ms ease-in-out;
71+
-ms-transition: background-color 100ms ease-in-out;
72+
-o-transition: background-color 100ms ease-in-out;
73+
transition: background-color 100ms ease-in-out;
74+
}
75+
.redsun-hints {
76+
margin-top: 4px;
77+
font-size: 0.8em;
78+
opacity: 0.8;
79+
}
80+
81+
</style>
82+
83+
84+
<%= form_for("search_form", url: @redsun_path, html: { id: 'redsun-search-form', method: :get }) do |f| %>
85+
<%= f.label t("redsun.searchstring") %>
86+
<%= f.text_field(:searchstring, value: @searchstring, title: 'Search ...', :class => "toggle") %>
687
<%= f.select :scope, @scope_selector, {:selected => @scope}, { class: "select2"} %>
788
<%= f.label t("redsun.order") %>
889
<%= f.select :sort_field, Issue::SORT_FIELDS.collect { |o| [t("field_#{o}"), o]}, {:selected => @sort_field }, { class: "select2"} %>
990
<%= f.select :sort_order, Issue::SORT_ORDER.collect {|o| [I18n.translate(o[1]), o.first]}, {:selected => @sort_order}, { class: "select2"} %>
10-
<%= f.submit t("redsun.search_button") %>
91+
<%= f.submit t("redsun.search_button"), class: 'redsun-search-button' %>
1192

1293
<%= link_to t("redsun.reset"), url_for(:controller => "redsun_search", :action => :index, :project_id => params[:project_id])%>
1394
<%= f.hidden_field(:author_id, value: params[:search_form][:author_id]) if params[:search_form][:author_id].present? %>
@@ -20,6 +101,8 @@
20101
<%= f.hidden_field(:active, value: params[:search_form][:active]) if params[:search_form][:active].present? %>
21102
<%= f.hidden_field(:project_name, value: params[:search_form][:project_name]) if params[:search_form][:project_name].present? %>
22103
<%= f.hidden_field(:project_id, value: @project.id) if @project %>
104+
<div class="redsun-hints"><%=t('redsun.hints')%></div>
105+
<%= image_tag 'RedSun_Logo_red_on_white.svg', plugin: 'redmine_redsun', class: 'redsun-logo' %>
23106
<% end -%>
24107

25108
<% if @search.results.present? %>

app/views/redsun_search/results/_wiki_page_result.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<h5><%= t "label_wiki_page" %> in <%= link_to record.try(:project).try(:name), record.try(:project) %></h5>
2-
<h3><%= link_to highlighter_for(:title, hit, record).gsub(/_/, " "), record %></h3>
2+
<h3><%= link_to highlighter_for(:title, hit, record).html_safe, record %></h3>
33
<% if record.content.updated_on && record.content.author %>
44
<h5>
55
<%= avatar(record.content.author, :size => "16") %><%= authoring(record.content.updated_on, record.content.author, label: :label_updated_time_by)%>
Lines changed: 30 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)