[geeklog-hg] geeklog: style.css.php of modern_curve theme is properly cached now
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Fri Apr 5 07:03:15 EDT 2013
changeset 9037:eaf35384fc39
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/eaf35384fc39
user: Kenji ITO <mystralkk at gmail.com>
date: Fri Apr 05 20:02:16 2013 +0900
description:
style.css.php of modern_curve theme is properly cached now
diffstat:
public_html/layout/modern_curve/style.css.php | 118 ++++++++++++++-----------
1 files changed, 68 insertions(+), 50 deletions(-)
diffs (150 lines):
diff -r bbd7490f096b -r eaf35384fc39 public_html/layout/modern_curve/style.css.php
--- a/public_html/layout/modern_curve/style.css.php Thu Apr 04 15:30:49 2013 -0400
+++ b/public_html/layout/modern_curve/style.css.php Fri Apr 05 20:02:16 2013 +0900
@@ -29,78 +29,96 @@
// | |
// +---------------------------------------------------------------------------+
+require_once '../../siteconfig.php';
+
+// We assume /data directory is right under $_CONF['path'] directory. If you
+// have moved or renamed /data directory, please change the following line accordingly.
+define('MODERN_CURVE_ETAG_FILE', $_CONF['path'] . 'data/modern_curve_etag.cache');
+
+if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
+ if (is_readable(MODERN_CURVE_ETAG_FILE)) {
+ $etag = file_get_contents(MODERN_CURVE_ETAG_FILE);
+
+ if (!empty($etag) AND (trim($_SERVER['HTTP_IF_NONE_MATCH'], '"\'') === $etag)) {
+ header('HTTP/1.1 304 Not Modified');
+ header('Status: 304 Not Modified');
+ exit;
+ }
+ }
+}
+
+// Creates a new ETag value and saves it into the file
+$etag = md5(microtime(TRUE));
+ at file_put_contents(MODERN_CURVE_ETAG_FILE, $etag);
+
// Send correct header type:
header('Content-Type: text/css; charset=UTF-8');
-header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 3600) . ' GMT');
+header('ETag: "' . $etag . '"');
// List of CSS files to be loaded
$files = array(
- "compatible.css",
- "default.css",
- "common.css",
- "layout.css",
- "block.css",
- "option.css",
- "form.css",
- "story.css",
+ 'compatible.css',
+ 'default.css',
+ 'common.css',
+ 'layout.css',
+ 'block.css',
+ 'option.css',
+ 'form.css',
+ 'story.css',
- "article/article.css",
- "comment/comment.css",
- "navbar/navbar.css",
- "preferences/preferences.css",
- "search/search.css",
- "stats/stats.css",
- "submit/submit.css",
- "trackback/trackback.css",
- "users/users.css",
+ 'article/article.css',
+ 'comment/comment.css',
+ 'navbar/navbar.css',
+ 'preferences/preferences.css',
+ 'search/search.css',
+ 'stats/stats.css',
+ 'submit/submit.css',
+ 'trackback/trackback.css',
+ 'users/users.css',
- "admin/common.css",
- "admin/block.css",
- "admin/group.css",
- "admin/lists.css",
- "admin/moderation.css",
- "admin/plugins.css",
- "admin/story.css",
- "admin/topic.css",
- "admin/trackback.css",
- "admin/user.css",
- "admin/configuration.css",
+ 'admin/common.css',
+ 'admin/block.css',
+ 'admin/group.css',
+ 'admin/lists.css',
+ 'admin/moderation.css',
+ 'admin/plugins.css',
+ 'admin/story.css',
+ 'admin/topic.css',
+ 'admin/trackback.css',
+ 'admin/user.css',
+ 'admin/configuration.css',
- "plugin/japanize.css",
- "plugin/sitecalendar.css",
+ 'plugin/japanize.css',
+ 'plugin/sitecalendar.css',
- "tooltips/tooltips.css"
+ 'tooltips/tooltips.css'
);
+// Also output the contents of the custom CSS file, if it's available
+if (is_readable('css/custom.css')) {
+ $files[] = 'custom.css';
+}
+
// Create directions for RTL support
-$left = 'left';
+$left = 'left';
$right = 'right';
-if ($_GET['dir'] == 'rtl') {
- $left = 'right';
+
+if ($_GET['dir'] === 'rtl') {
+ $left = 'right';
$right = 'left';
}
// Output the contents of each file
foreach ($files as $file) {
- $css = file_get_contents("css/$file");
- $css = preg_replace("@/\*.*?\*/@sm", "", $css); // strip comments
+ $css = file_get_contents('css/' . $file);
+ $css = preg_replace("@/\*.*?\*/@sm", '', $css); // strip comments
$css = preg_replace("@\s*\n+\s*@sm", "\n", $css); // strip indentation
+
// Replace {right} and {left} placeholders with actual values.
// Used for RTL support.
- $css = preg_replace("@\{right\}@", $right, $css);
- $css = preg_replace("@\{left\}@", $left, $css);
- // Output
- echo "\n/* $file */\n";
- echo $css;
-}
+ $css = str_replace('{right}', $right, $css);
+ $css = str_replace('{left}', $left, $css);
-// Also output the contents of the custom CSS file, if it's available
-if (is_readable("css/custom.css")) {
- $css = file_get_contents("css/custom.css");
- // Replace {right} and {left} placeholders with actual values.
- // Used for RTL support.
- $css = preg_replace("@\{right\}@", $right, $css);
- $css = preg_replace("@\{left\}@", $left, $css);
// Output
echo "\n/* $file */\n";
echo $css;
More information about the geeklog-cvs
mailing list