public
Description: All the extra stuff you could want for the Mack Framework.
Homepage: http://www.mackframework.com
Clone URL: git://github.com/markbates/mack-more.git
Distributed views module now uses file cache [#96 state:resolved]
dsutedja (author)
Fri Aug 15 14:20:47 -0700 2008
commit  f6f5f93fef03bbb8f049d18327563774597c1ed2
tree    1217b0028d3eedefde8c5af34b99e695f421be3f
parent  b3da0fa937ab3a0e85517c36c6f7d9a0d1744ceb
...
1
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
 
25
26
27
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 
35
36
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
39
40
41
42
0
@@ -1,27 +1,42 @@
0
 module Mack
0
   module Distributed
0
+    
0
+    class FileCache < Cachetastic::Caches::Base
0
+      class << self
0
+        include Mack::ViewHelpers::LinkHelpers
0
+      
0
+        def get(path)
0
+          raw = super(path) do
0
+            raw = ""
0
+            if File.exists?(path)
0
+              raw = File.read(path)
0
+
0
+              # preprocess the raw content so we can resolve css/javascript/image path
0
+              arr = raw.scan(/<%=.*?%>/)
0
+              arr.each do |scriptlet|
0
+                if scriptlet.match(/stylesheet/) or scriptlet.match(/javascript/) or scriptlet.match(/image/)
0
+                  res = ERB.new(scriptlet).result(binding)
0
+                  raw.gsub!(scriptlet, res)
0
+                end 
0
+              end # if arr.each
0
+            end # if File.exists?
0
+            
0
+            set(path, raw)
0
+          end # super(key)
0
+          return raw
0
+        end # def get
0
+      end # class << self
0
+    end # class FileCache
0
+    
0
     class Views
0
       
0
       include Singleton
0
       include DRbUndumped
0
-      include Mack::ViewHelpers::LinkHelpers
0
       
0
       def get(resource)
0
         path = File.join(Mack.root, resource)
0
-        if File.exists?(path)
0
-          raw = File.read(path)
0
-          
0
-          # preprocess the raw content so we can resolve css/javascript/image path
0
-          arr = raw.scan(/<%=.*?%>/)
0
-          arr.each do |scriptlet|
0
-            if scriptlet.match(/stylesheet/) or scriptlet.match(/javascript/) or scriptlet.match(/image/)
0
-              res = ERB.new(scriptlet).result(binding)
0
-              raw.gsub!(scriptlet, res)
0
-            end
0
-          end
0
-          return raw
0
-        end
0
-        return ""
0
+        raw = FileCache.get(path)
0
+        return raw
0
       end
0
       
0
       class << self

Comments