radiant-find_replace-extension 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -6,13 +6,13 @@ Supports regular expressions and case (in)sensitivity.
|
|
6
6
|
When showing results, you can check which matches you want to update with the replace string.
|
7
7
|
If you are using regular expressions, you can render matches in the replace string. For example, find:
|
8
8
|
|
9
|
-
<p class="title">([
|
9
|
+
<p class="title">([^<]*)</p>
|
10
10
|
|
11
11
|
Replace:
|
12
12
|
|
13
13
|
<h2>\1</h2>
|
14
14
|
|
15
15
|
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
|
16
|
+
All the more reason to be extra careful when you use the replace functionality, and even more so when using regular expressions.
|
17
17
|
|
18
18
|
Created by Benny Degezelle.
|
@@ -12,9 +12,14 @@ class Admin::SearchController < ApplicationController
|
|
12
12
|
srch = Regexp.new(params[:query], params[:case_insensitive])
|
13
13
|
|
14
14
|
if class_name == 'page'
|
15
|
-
Page.find(id)
|
15
|
+
page = Page.find(id)
|
16
|
+
[:slug, :title, :breadcrumb].each do |attr|
|
17
|
+
page.update_attribute(attr, page.send(attr).gsub(srch, params[:replace]))
|
18
|
+
end
|
19
|
+
page.parts.each do |page_part|
|
16
20
|
page_part.update_attribute :content, page_part.content.gsub(srch, params[:replace])
|
17
21
|
end
|
22
|
+
|
18
23
|
else
|
19
24
|
to_replace.update_attribute :content, to_replace.content.gsub(srch, params[:replace])
|
20
25
|
end
|
@@ -36,8 +41,10 @@ class Admin::SearchController < ApplicationController
|
|
36
41
|
sqlike = params[:case_insensitive] ? "LIKE" : "LIKE BINARY"
|
37
42
|
end
|
38
43
|
end
|
39
|
-
|
40
|
-
|
44
|
+
|
45
|
+
pages_with_matching_slug = Page.find(:all, :conditions => ["slug #{like} ?", match])
|
46
|
+
# Is not [page, ...] but [[page, boolean], ...] to mark dangerous matches
|
47
|
+
@page_results = Page.find(:all, :include => [ :parts ], :conditions => ["page_parts.content #{like} ? OR pages.slug #{like} ? OR pages.breadcrumb #{like} ? OR pages.title #{like} ? ", [match]* 4].flatten).map{|page| [page, pages_with_matching_slug.include?(page)]}
|
41
48
|
@snippet_results = Snippet.find(:all, :conditions => ["content #{like} ?", match])
|
42
49
|
@layout_results = Layout.find(:all, :conditions => ["content #{like} ?", match])
|
43
50
|
end
|
@@ -6,14 +6,23 @@
|
|
6
6
|
%table.index#results{:summary=>"Results", :style => "margin-bottom: 60px"}
|
7
7
|
%thead
|
8
8
|
%tr
|
9
|
-
%th{:style => "width:
|
9
|
+
%th{:style => "width: 2.5em"}
|
10
10
|
%input{:type => 'checkbox', :id => 'toggler', :onclick => "toggle_cbs()"}
|
11
11
|
%th.identifier Search result
|
12
12
|
%tbody
|
13
|
-
- @page_results.
|
13
|
+
- if @page_results.select{|page, bool| bool}.any?
|
14
|
+
%tr
|
15
|
+
%td{:colspan => 2}
|
16
|
+
%em{:style => "font-weight: bold"} Warning:
|
17
|
+
pages marked with an
|
18
|
+
%span{:style => "color: red; font-weight: bold"} !
|
19
|
+
have a match in their slug. Replacing these matches will change the URL of the page, and consequently those of all children it may have (irrespective of whether they themselves match the search term or not).
|
20
|
+
- @page_results.each do |page, slug_matches|
|
14
21
|
%tr
|
15
22
|
%td
|
16
23
|
%input{:type => 'checkbox', :name => "page_#{page.id}"}
|
24
|
+
- if slug_matches
|
25
|
+
%span{:title => "This page has a match in it's slug. Consequently, replacing this match will change the URL of this page and all its children!", :style => "color: red; font-weight: bold"} !
|
17
26
|
%td
|
18
27
|
= image_tag 'admin/page.png', :class => "icon", :title => 'Page'
|
19
28
|
= link_to page.path, edit_admin_page_path(page)
|
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.1
|
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: 2016-
|
12
|
+
date: 2016-06-27 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,7 @@ 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
|
32
33
|
- radiant-find_replace-extension.gemspec
|
33
34
|
- Rakefile
|
34
35
|
- README.md
|