radiant-find_replace-extension 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +4 -3
- data/app/controllers/admin/search_controller.rb +15 -3
- data/app/views/admin/search/results.html.haml +4 -1
- data/lib/radiant-find_replace-extension.rb +1 -1
- data/radiant-find_replace-extension-1.0.0.gem +0 -0
- data/radiant-find_replace-extension-1.0.1.gem +0 -0
- data/radiant-find_replace-extension-1.0.2.gem +0 -0
- data/radiant-find_replace-extension-1.0.3.gem +0 -0
- metadata +6 -2
data/README.md
CHANGED
@@ -2,8 +2,7 @@
|
|
2
2
|
|
3
3
|
This extension adds find and replace functionality to the backend of your Radiant CMS based website.
|
4
4
|
|
5
|
-
Supports regular expressions and case (in)sensitivity.
|
6
|
-
When showing results, you can check which matches you want to update with the replace string.
|
5
|
+
Supports regular expressions and case (in)sensitivity, and a checkbox to also search page field names and page part names. When showing results, you can check which matches you want to update with the replace string.
|
7
6
|
If you are using regular expressions, you can render matches in the replace string. For example, find:
|
8
7
|
|
9
8
|
<p class="title">([^</p>]*)</p>
|
@@ -13,6 +12,8 @@ Replace:
|
|
13
12
|
<h2>\1</h2>
|
14
13
|
|
15
14
|
The results page does not show the actual results, but the pages, snippets and layouts that had at least one match.
|
16
|
-
All the more reason to be
|
15
|
+
All the more reason to be extra careful when you use the replace functionality, and even more so when using regular expressions.
|
16
|
+
|
17
|
+
|
17
18
|
|
18
19
|
Created by Benny Degezelle.
|
@@ -14,11 +14,17 @@ class Admin::SearchController < ApplicationController
|
|
14
14
|
|
15
15
|
if class_name == 'page'
|
16
16
|
[:slug, :title, :breadcrumb].each do |attr|
|
17
|
-
to_replace.
|
17
|
+
to_replace.send("#{attr}=", to_replace.send(attr).gsub(srch, params[:replace]))
|
18
18
|
end
|
19
19
|
to_replace.parts.each do |page_part|
|
20
|
-
page_part.
|
20
|
+
page_part.content = page_part.content.gsub(srch, params[:replace])
|
21
|
+
page_part.name = page_part.name.gsub(srch, params[:replace]) if params[:include_field_and_part_names]
|
21
22
|
end
|
23
|
+
to_replace.fields.each do |field|
|
24
|
+
field.content = field.content.gsub(srch, params[:replace])
|
25
|
+
field.name = field.name.gsub(srch, params[:replace]) if params[:include_field_and_part_names]
|
26
|
+
end
|
27
|
+
page.save
|
22
28
|
else
|
23
29
|
to_replace.update_attribute :content, to_replace.content.gsub(srch, params[:replace])
|
24
30
|
end
|
@@ -42,8 +48,14 @@ class Admin::SearchController < ApplicationController
|
|
42
48
|
end
|
43
49
|
|
44
50
|
pages_with_matching_slug = Page.find(:all, :conditions => ["slug #{like} ?", match])
|
51
|
+
|
52
|
+
includes = [ :parts, :fields ]
|
53
|
+
cols = %w(page_parts.content pages.slug pages.breadcrumb pages.title page_fields.content)
|
54
|
+
cols+= %w(page_fields.name page_parts.name) if params[:include_field_and_part_names]
|
45
55
|
# Is not [page, ...] but [[page, boolean], ...] to mark dangerous matches
|
46
|
-
|
56
|
+
conditions = cols.map{|c| "#{c} #{like} ?"}.join(' OR ')
|
57
|
+
@page_results = Page.find(:all, :include => includes, :conditions => [conditions, [match]* cols.size].flatten).map{|page| [page, pages_with_matching_slug.include?(page)]}
|
58
|
+
|
47
59
|
@snippet_results = Snippet.find(:all, :conditions => ["content #{like} ?", match])
|
48
60
|
@layout_results = Layout.find(:all, :conditions => ["content #{like} ?", match])
|
49
61
|
end
|
@@ -70,11 +70,14 @@
|
|
70
70
|
%li
|
71
71
|
%input{:type => 'checkbox', :name => 'case_insensitive', :checked => params[:case_insensitive] }
|
72
72
|
Ignore case
|
73
|
+
%li
|
74
|
+
%input{:type => 'checkbox', :name => 'include_field_and_part_names', :checked => params[:include_field_and_part_names] }
|
75
|
+
Also search page field- and part-names
|
73
76
|
%li
|
74
77
|
%input{:type => :submit, :class => 'action_button', :value => 'Find all'}
|
75
78
|
- if params[:query]
|
76
79
|
%li
|
77
|
-
= submit_tag 'Replace selected', {:class => 'action_button', :name => 'doReplace', :confirm => "Are you sure you want to replace all instances of '#{params[:query]}' with '
|
80
|
+
= submit_tag 'Replace selected', {:class => 'action_button', :name => 'doReplace', :confirm => "Are you sure you want to replace all instances of '#{params[:query]}#{params[:replace] ? '\' with \'' + params[:replace]: ''}' in all of the selected Pages, Snippets and Layouts? This can not be reverted!"}
|
78
81
|
/ %input{:type => :submit}
|
79
82
|
|
80
83
|
:javascript
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radiant-find_replace-extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-11-23 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Adds backend search and replace functionality to Radiant CMS!
|
15
15
|
email:
|
@@ -29,6 +29,10 @@ files:
|
|
29
29
|
- find_replace_extension.rb
|
30
30
|
- lib/radiant-find_replace-extension.rb
|
31
31
|
- lib/tasks/find_replace_extension_tasks.rake
|
32
|
+
- radiant-find_replace-extension-1.0.0.gem
|
33
|
+
- radiant-find_replace-extension-1.0.1.gem
|
34
|
+
- radiant-find_replace-extension-1.0.2.gem
|
35
|
+
- radiant-find_replace-extension-1.0.3.gem
|
32
36
|
- radiant-find_replace-extension.gemspec
|
33
37
|
- Rakefile
|
34
38
|
- README.md
|