public
Description: The ultra-lightweight ultra-flexible blogging engine with a fetish for birds and misspellings.
Homepage: http://chyrp.net/
Clone URL: git://github.com/vito/chyrp.git
Click here to lend your support to: chyrp and make a donation at www.pledgie.com !
* You can now set certain URLs to exclude from being cached.
* Moved the "cancelled" attribute to the Modules class.
* Added a "route_done" trigger, called after route_init tries all
  possible calls.
vito (author)
Thu Nov 06 13:37:52 -0800 2008
commit  48203516d0630d46d32b962f69edb8bae21353ef
tree    f3412154847398053fbcecccedd8f83bc855307d
parent  69cb90bf89a13fc7ec09e1bd28d867a29a153910
...
8
9
10
 
 
 
 
11
12
13
...
8
9
10
11
12
13
14
15
16
17
0
@@ -8,6 +8,10 @@
0
         # Holds all Module instantiations.
0
         static $instances = array();
0
 
0
+        # Boolean: $cancelled
0
+        # Is the module's execution cancelled?
0
+        public $cancelled = false;
0
+
0
         /**
0
          * Function: setPriority
0
          * Sets the priority of an action for the module this function is called from.
...
100
101
102
103
104
 
 
 
 
105
106
107
108
 
 
 
 
109
110
111
...
100
101
102
 
 
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
0
@@ -100,12 +100,18 @@
0
                 else
0
                     $response = false;
0
 
0
-                if ($response !== false or $call !== false)
0
-                    return $this->success = true;
0
+                if ($response !== false or $call !== false) {
0
+                    $this->success = true;
0
+                    break;
0
+                }
0
 
0
                 if (++$count == count($try) and isset($this->controller->fallback) and method_exists($this->controller, "display"))
0
                     call_user_func_array(array($this->controller, "display"), $this->controller->fallback);
0
             }
0
+
0
+            $trigger->call("route_done", $this);
0
+
0
+            return true;
0
         }
0
 
0
         /**
...
1
2
3
4
5
6
7
...
19
20
21
 
 
 
22
23
24
25
26
 
27
28
29
30
31
 
32
33
34
35
 
 
 
36
37
38
39
40
41
42
43
44
45
46
47
48
...
56
57
58
 
59
60
61
...
147
148
149
150
 
 
151
152
153
...
1
2
 
 
3
4
5
...
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
43
44
45
 
 
 
 
 
46
47
48
...
56
57
58
59
60
61
62
...
148
149
150
 
151
152
153
154
155
0
@@ -1,7 +1,5 @@
0
 <?php
0
     class Cacher extends Modules {
0
-        public $cancelled = false;
0
-
0
         public function __init() {
0
             $this->user = (logged_in()) ? Visitor::current()->login : "guest" ;
0
             $this->path = INCLUDES_DIR."/caches/".sanitize($this->user);
0
@@ -19,30 +17,32 @@
0
 
0
             # Remove all expired files.
0
             $this->remove_expired();
0
+
0
+            $config = Config::current();
0
+            $config->cache_exclude = (array) $config->cache_exclude;
0
         }
0
 
0
         static function __install() {
0
             $config = Config::current();
0
             $config->set("cache_expire", 1800);
0
+            $config->set("cache_exclude", array());
0
         }
0
 
0
         static function __uninstall() {
0
             $config = Config::current();
0
             $config->remove("cache_expire");
0
+            $config->remove("cache_exclude");
0
         }
0
 
0
         public function route_init($route) {
0
-            if (!($route->controller instanceof MainController) or
0
+            if (!empty($_POST) or
0
+                !($route->controller instanceof MainController) or
0
+                in_array($this->url, Config::current()->cache_exclude) or
0
                 $this->cancelled or
0
                 !file_exists($this->file) or
0
                 Flash::exists())
0
                 return;
0
 
0
-            $action = $route->action;
0
-
0
-            if (!empty($_POST))
0
-                return;
0
-
0
             if (DEBUG)
0
                 error_log("SERVING cache file for ".$this->url."...");
0
 
0
@@ -56,6 +56,7 @@
0
 
0
         public function end($route) {
0
             if (!($route->controller instanceof MainController) or
0
+                in_array($this->url, Config::current()->cache_exclude) or
0
                 $this->cancelled or
0
                 file_exists($this->file) or
0
                 Flash::exists())
0
@@ -147,7 +148,8 @@
0
             if (!isset($_POST['hash']) or $_POST['hash'] != Config::current()->secure_hashkey)
0
                 show_403(__("Access Denied"), __("Invalid security key."));
0
 
0
-            if (Config::current()->set("cache_expire", $_POST['cache_expire']))
0
+            $config = Config::current();
0
+            if ($config->set("cache_expire", $_POST['cache_expire']) and $config->set("cache_exclude", explode(", ", $_POST['cache_exclude'])))
0
                 Flash::notice(__("Settings updated."), "/admin/?action=cache_settings");
0
         }
0
 
...
10
11
12
 
 
 
 
13
14
15
...
10
11
12
13
14
15
16
17
18
19
0
@@ -10,6 +10,10 @@
0
                         <label for="cache_expire">${ "Expire Cache After&hellip;" | translate("cacher") }</label>
0
                         <input class="text" type="text" name="cache_expire" value="${ site.cache_expire | escape }" id="cache_expire" /> <span class="sub">${ "(seconds)" | translate("cacher") }</span>
0
                     </p>
0
+                    <p>
0
+                        <label for="cache_exclude">${ "Exclude URLs" | translate("cacher") }</label>
0
+                        <input class="text" type="text" name="cache_exclude" value="${ site.cache_exclude | join(", ") | escape }" id="cache_exclude" /> <span class="sub">${ "(comma separated)" | translate("cacher") }</span>
0
+                    </p>
0
 
0
                     <p class="buttons">
0
                         <p>

Comments