public
Fork of vigetlabs/crash_cart
Description: Tools to manage ExpressionEngine ... maybe.
Clone URL: git://github.com/reagent/crash_cart.git
Search Repo:
Allow changing of root path for site
reagent (author)
Tue May 13 19:55:27 -0700 2008
commit  ad013784e472c6104e62dbe7f46466b52e1d125a
tree    a8b03574c992015f1aa4b0a743b2ef80c37560c2
parent  4ecef0ec4bc52b1abd774e97bb1dec9870733b06
...
8
9
10
 
 
 
 
 
 
 
 
11
12
13
14
15
...
27
28
29
 
 
 
 
 
 
 
 
30
31
32
33
34
35
36
37
38
39
40
 
41
42
43
...
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
35
36
37
38
39
40
41
42
43
44
45
46
47
 
 
 
 
 
 
 
48
 
49
50
51
52
0
@@ -8,6 +8,14 @@
0
       has_many :template_groups
0
       has_many :templates
0
 
0
+ PREFERENCE_PATHS = [
0
+ 'system:theme_folder_path',
0
+ 'system:captcha_path',
0
+ 'template:tmpl_file_basepath',
0
+ 'member:avatar_path',
0
+ 'member:photo_path'
0
+ ]
0
+
0
       def name
0
         self.site_label
0
       end
0
0
0
@@ -27,17 +35,18 @@
0
         @preferences
0
       end
0
 
0
+ def root_path=(other)
0
+ pattern = Regexp.quote(self.root_path)
0
+ PREFERENCE_PATHS.each do |preference|
0
+ group, setting = preference.split(':')
0
+ self.preferences[group.to_sym][setting.to_sym].gsub!(/^#{pattern}/, other)
0
+ end
0
+ end
0
+
0
       def root_path
0
         common_elements = nil
0
- preferences = [
0
- 'system:theme_folder_path',
0
- 'system:captcha_path',
0
- 'template:tmpl_file_basepath',
0
- 'member:avatar_path',
0
- 'member:photo_path'
0
- ]
0
         
0
- preferences.each do |preference|
0
+ PREFERENCE_PATHS.each do |preference|
0
           group, setting = preference.split(':')
0
           path = self.preferences[group.to_sym][setting.to_sym].split('/')
0
 
...
31
32
33
 
 
34
35
 
 
 
 
 
 
 
36
37
38
...
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
0
@@ -31,8 +31,17 @@
0
       end
0
     end
0
     
0
+ it "should save its associated preferences when it is saved"
0
+
0
     it "should know the current root path" do
0
       @site.root_path.should == '/home/www/ExpressionEngine1.6.2'
0
+ end
0
+
0
+ it "should update the root path when set" do
0
+ path = '/new/root/path'
0
+ @site.root_path = path
0
+
0
+ @site.root_path.should == path
0
     end
0
     
0
   end

Comments

    No one has commented yet.