html5-starter 0.1.3b

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. data/LICENSE +3 -0
  2. data/README.md +135 -0
  3. data/VERSION +1 -0
  4. data/lib/app/helpers/html5_boilerplate_helper.rb +47 -0
  5. data/lib/html5-boilerplate.rb +6 -0
  6. data/stylesheets/_html5-boilerplate.scss +15 -0
  7. data/stylesheets/html5-boilerplate/_fonts.scss +36 -0
  8. data/stylesheets/html5-boilerplate/_handheld.scss +8 -0
  9. data/stylesheets/html5-boilerplate/_helpers.scss +25 -0
  10. data/stylesheets/html5-boilerplate/_print.scss +20 -0
  11. data/stylesheets/html5-boilerplate/_reset.scss +50 -0
  12. data/stylesheets/html5-boilerplate/_styles.scss +100 -0
  13. data/templates/project/_flashes.html.haml +4 -0
  14. data/templates/project/_footer.html.haml +2 -0
  15. data/templates/project/_head.html.haml +32 -0
  16. data/templates/project/_header.html.haml +1 -0
  17. data/templates/project/_javascripts.html.haml +38 -0
  18. data/templates/project/_stylesheets.html.haml +8 -0
  19. data/templates/project/application.html.haml +15 -0
  20. data/templates/project/files/404.html +22 -0
  21. data/templates/project/files/apple-touch-icon.png +0 -0
  22. data/templates/project/files/build/build.xml +636 -0
  23. data/templates/project/files/build/buildinfo.properties +5 -0
  24. data/templates/project/files/build/config/build.properties +3 -0
  25. data/templates/project/files/build/config/default.properties +79 -0
  26. data/templates/project/files/build/config/project.properties +49 -0
  27. data/templates/project/files/build/createproject.sh +73 -0
  28. data/templates/project/files/build/tools/ant-contrib-1.0b3.jar +0 -0
  29. data/templates/project/files/build/tools/css-compressor/CSSCompression.php +465 -0
  30. data/templates/project/files/build/tools/css-compressor/changelog.txt +22 -0
  31. data/templates/project/files/build/tools/css-compressor/cli.php +101 -0
  32. data/templates/project/files/build/tools/css-compressor/helpers/hex2short-colors.json +39 -0
  33. data/templates/project/files/build/tools/css-compressor/helpers/hex2short-safe.json +16 -0
  34. data/templates/project/files/build/tools/css-compressor/helpers/long2hex-colors.json +127 -0
  35. data/templates/project/files/build/tools/css-compressor/lib/Cleanup.php +218 -0
  36. data/templates/project/files/build/tools/css-compressor/lib/Color.php +199 -0
  37. data/templates/project/files/build/tools/css-compressor/lib/Combine.php +191 -0
  38. data/templates/project/files/build/tools/css-compressor/lib/Combine/Aural.php +109 -0
  39. data/templates/project/files/build/tools/css-compressor/lib/Combine/Background.php +107 -0
  40. data/templates/project/files/build/tools/css-compressor/lib/Combine/Border.php +98 -0
  41. data/templates/project/files/build/tools/css-compressor/lib/Combine/BorderOutline.php +109 -0
  42. data/templates/project/files/build/tools/css-compressor/lib/Combine/BorderRadius.php +262 -0
  43. data/templates/project/files/build/tools/css-compressor/lib/Combine/Font.php +125 -0
  44. data/templates/project/files/build/tools/css-compressor/lib/Combine/List.php +104 -0
  45. data/templates/project/files/build/tools/css-compressor/lib/Combine/MarginPadding.php +190 -0
  46. data/templates/project/files/build/tools/css-compressor/lib/Compress.php +212 -0
  47. data/templates/project/files/build/tools/css-compressor/lib/Control.php +236 -0
  48. data/templates/project/files/build/tools/css-compressor/lib/Exception.php +32 -0
  49. data/templates/project/files/build/tools/css-compressor/lib/Format.php +187 -0
  50. data/templates/project/files/build/tools/css-compressor/lib/Individuals.php +307 -0
  51. data/templates/project/files/build/tools/css-compressor/lib/Numeric.php +103 -0
  52. data/templates/project/files/build/tools/css-compressor/lib/Option.php +133 -0
  53. data/templates/project/files/build/tools/css-compressor/lib/Organize.php +149 -0
  54. data/templates/project/files/build/tools/css-compressor/lib/Selectors.php +245 -0
  55. data/templates/project/files/build/tools/css-compressor/lib/Setup.php +292 -0
  56. data/templates/project/files/build/tools/css-compressor/lib/Trim.php +213 -0
  57. data/templates/project/files/build/tools/css-compressor/license.txt +21 -0
  58. data/templates/project/files/build/tools/htmlcompressor-0.9.8.jar +0 -0
  59. data/templates/project/files/build/tools/jpegtran.exe +0 -0
  60. data/templates/project/files/build/tools/optipng-0.6.4-exe/LICENSE.txt +21 -0
  61. data/templates/project/files/build/tools/optipng-0.6.4-exe/optipng.exe +0 -0
  62. data/templates/project/files/build/tools/yuicompressor-2.4.2.jar +0 -0
  63. data/templates/project/files/crossdomain.xml +25 -0
  64. data/templates/project/files/favicon.ico +0 -0
  65. data/templates/project/files/gitignore.txt +32 -0
  66. data/templates/project/files/gitignore_placeholder.txt +2 -0
  67. data/templates/project/files/google.yml +22 -0
  68. data/templates/project/files/htaccess +415 -0
  69. data/templates/project/files/humans.txt +43 -0
  70. data/templates/project/files/lighttpd.conf +149 -0
  71. data/templates/project/files/mime.types +80 -0
  72. data/templates/project/files/nginx.conf +108 -0
  73. data/templates/project/files/robots.txt +5 -0
  74. data/templates/project/files/web.config +207 -0
  75. data/templates/project/handheld.scss +8 -0
  76. data/templates/project/index.html +81 -0
  77. data/templates/project/javascripts/libs/dd_belatedpng.js +13 -0
  78. data/templates/project/javascripts/libs/jquery-1.4.4.js +7179 -0
  79. data/templates/project/javascripts/libs/jquery-1.4.4.min.js +167 -0
  80. data/templates/project/javascripts/libs/modernizr-1.6.min.js +30 -0
  81. data/templates/project/javascripts/plugins.js +13 -0
  82. data/templates/project/javascripts/rails.js +156 -0
  83. data/templates/project/javascripts/script.js +26 -0
  84. data/templates/project/manifest.rb +101 -0
  85. data/templates/project/partials/_base.scss +23 -0
  86. data/templates/project/style.scss +70 -0
  87. metadata +171 -0
@@ -0,0 +1,213 @@
1
+ <?php
2
+ /**
3
+ * CSS Compressor [VERSION]
4
+ * [DATE]
5
+ * Corey Hart @ http://www.codenothing.com
6
+ */
7
+
8
+ Class CSSCompression_Trim
9
+ {
10
+ /**
11
+ * Trim Patterns
12
+ *
13
+ * @class Control: Compression Controller
14
+ * @param (array) options: Reference to options
15
+ * @param (regex) rcmark: Marking point when traversing through sheet for comments
16
+ * @param (regex) rendcomment: Finds the ending comment point
17
+ * @param (regex) rendquote: Finds the ending quote point
18
+ * @param (regex) rendsinglequote: Finds the ending single quote point
19
+ * @param (array) rescape: Array of patterns of groupings that should be escaped
20
+ * @param (array) trimmings: Stylesheet trimming patterns/replacements
21
+ * @param (array) escaped: Array of characters that need to be escaped
22
+ */
23
+ private $Control;
24
+ private $options = array();
25
+ private $rcmark = "/((?<!\\\)\/\*|(?<!\\\)\"|(?<!\\\)')/";
26
+ private $rendcomment = "/\*\//";
27
+ private $rendquote = "/(?<!\\\)\"/";
28
+ private $rendsinglequote = "/(?<!\\\)'/";
29
+ private $rescape = array(
30
+ "/(url\()([^'\"].*?)(\))/is",
31
+ "/((?<!\\\)\")(.*?)((?<!\\\)\")/s",
32
+ "/((?<!\\\)')(.*?)((?<!\\\)')/s",
33
+ );
34
+ private $trimmings = array(
35
+ 'patterns' => array(
36
+ "/(?<!\\\)(\s+)?(?<!\\\)([!,{};>\~\+\/])(?<!\\\)(\s+)?/s", // Remove un-needed spaces around special characters
37
+ "/url\((?<!\\\)\"(.*?)(?<!\\\)\"\)/is", // Remove quotes from urls
38
+ "/url\((?<!\\\)'(.*?)(?<!\\\)'\)/is", // Remove single quotes from urls
39
+ "/url\((.*?)\)/is", // Lowercase url wrapper
40
+ "/(?<!\\\);{2,}/", // Remove unecessary semi-colons
41
+ "/(?<!\\\)\s+/s", // Compress all spaces into single space
42
+ ),
43
+ 'replacements' => array(
44
+ '$2',
45
+ 'url($1)',
46
+ 'url($1)',
47
+ 'url($1)',
48
+ ';',
49
+ ' ',
50
+ )
51
+ );
52
+ private $escaped = array(
53
+ 'search' => array(
54
+ ":",
55
+ ";",
56
+ "}",
57
+ "{",
58
+ "@",
59
+ "!",
60
+ ",",
61
+ ">",
62
+ "+",
63
+ "~",
64
+ "/",
65
+ "*",
66
+ ".",
67
+ "=",
68
+ "#",
69
+ "\r",
70
+ "\n",
71
+ "\t",
72
+ " ",
73
+ ),
74
+ 'replace' => array(
75
+ "\\:",
76
+ "\\;",
77
+ "\\}",
78
+ "\\{",
79
+ "\\@",
80
+ "\\!",
81
+ "\\,",
82
+ "\\>",
83
+ "\\+",
84
+ "\\~",
85
+ "\\/",
86
+ "\\*",
87
+ "\\.",
88
+ "\\=",
89
+ "\\#",
90
+ "\\r",
91
+ "\\n",
92
+ "\\t",
93
+ "\\ ",
94
+ ),
95
+ );
96
+
97
+ /**
98
+ * Stash a reference to the controller on each instantiation
99
+ *
100
+ * @param (class) control: CSSCompression Controller
101
+ */
102
+ public function __construct( CSSCompression_Control $control ) {
103
+ $this->Control = $control;
104
+ $this->options = &$control->Option->options;
105
+ }
106
+
107
+ /**
108
+ * Central trim handler
109
+ *
110
+ * @param (string) css: Stylesheet to trim
111
+ */
112
+ public function trim( $css ) {
113
+ $css = $this->comments( $css );
114
+ $css = $this->escape( $css );
115
+ $css = $this->strip( $css );
116
+ return $css;
117
+ }
118
+
119
+ /**
120
+ * Does a quick run through the script to remove all comments from the sheet,
121
+ *
122
+ * @param (string) css: Stylesheet to trim
123
+ */
124
+ private function comments( $css ) {
125
+ $pos = 0;
126
+ while ( preg_match( $this->rcmark, $css, $match, PREG_OFFSET_CAPTURE, $pos ) ) {
127
+ switch ( $match[ 1 ][ 0 ] ) {
128
+ // Start of comment block
129
+ case "/*":
130
+ if ( preg_match( $this->rendcomment, $css, $m, PREG_OFFSET_CAPTURE, $match[ 1 ][ 1 ] + 1 ) ) {
131
+ $end = $m[ 0 ][ 1 ] - $match[ 1 ][ 1 ] + strlen( $m[ 0 ][ 0 ] );
132
+ $css = substr_replace( $css, '', $match[ 1 ][ 1 ], $end );
133
+ $pos = $match[ 0 ][ 1 ];
134
+ }
135
+ else {
136
+ $css = substr( $css, 0, $match[ 1 ][ 1 ] );
137
+ break 2;
138
+ }
139
+ break;
140
+ // Start of string
141
+ case "\"":
142
+ if ( preg_match( $this->rendquote, $css, $m, PREG_OFFSET_CAPTURE, $match[ 1 ][ 1 ] + 1 ) ) {
143
+ $pos = $m[ 0 ][ 1 ] + strlen( $m[ 0 ][ 0 ] );
144
+ }
145
+ else {
146
+ break 2;
147
+ }
148
+ break;
149
+ // Start of string
150
+ case "'":
151
+ if ( preg_match( $this->rendsinglequote, $css, $m, PREG_OFFSET_CAPTURE, $match[ 1 ][ 1 ] + 1 ) ) {
152
+ $pos = $m[ 0 ][ 1 ] + strlen( $m[ 0 ][ 0 ] );
153
+ }
154
+ else {
155
+ break 2;
156
+ }
157
+ break;
158
+ // Should have never gotten here
159
+ default:
160
+ break 2;
161
+ }
162
+ }
163
+
164
+ return $css;
165
+ }
166
+
167
+ /**
168
+ * Escape out possible splitter characters within urls
169
+ *
170
+ * @param (string) css: Full stylesheet
171
+ */
172
+ private function escape( $css ) {
173
+ foreach ( $this->rescape as $regex ) {
174
+ $start = 0;
175
+ while ( preg_match( $regex, $css, $match, PREG_OFFSET_CAPTURE, $start ) ) {
176
+ $value = $match[ 1 ][ 0 ]
177
+ . str_replace( $this->escaped['search'], $this->escaped['replace'], $match[ 2 ][ 0 ] )
178
+ . $match[ 3 ][ 0 ];
179
+ $css = substr_replace( $css, $value, $match[ 0 ][ 1 ], strlen( $match[ 0 ][ 0 ] ) );
180
+ $start = $match[ 0 ][ 1 ] + strlen( $value ) + 1;
181
+ }
182
+ }
183
+
184
+ return $css;
185
+ }
186
+
187
+ /**
188
+ * Runs initial formatting to setup for compression
189
+ *
190
+ * @param (string) css: CSS Contents
191
+ */
192
+ private function strip( $css ) {
193
+ // Run replacements
194
+ return trim( preg_replace( $this->trimmings['patterns'], $this->trimmings['replacements'], $css ) );
195
+ }
196
+
197
+ /**
198
+ * Access to private methods for testing
199
+ *
200
+ * @param (string) method: Method to be called
201
+ * @param (array) args: Array of paramters to be passed in
202
+ */
203
+ public function access( $method, $args ) {
204
+ if ( method_exists( $this, $method ) ) {
205
+ return call_user_func_array( array( $this, $method ), $args );
206
+ }
207
+ else {
208
+ throw new CSSCompression_Exception( "Unknown method in Trim Class - " . $method );
209
+ }
210
+ }
211
+ };
212
+
213
+ ?>
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2011 Corey Hart
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,21 @@
1
+
2
+ Copyright (C) 2001-2010 Cosmin Truta.
3
+
4
+ This software is provided 'as-is', without any express or implied
5
+ warranty. In no event will the author(s) be held liable for any damages
6
+ arising from the use of this software.
7
+
8
+ Permission is granted to anyone to use this software for any purpose,
9
+ including commercial applications, and to alter it and redistribute it
10
+ freely, subject to the following restrictions:
11
+
12
+ 1. The origin of this software must not be misrepresented; you must not
13
+ claim that you wrote the original software. If you use this software
14
+ in a product, an acknowledgment in the product documentation would be
15
+ appreciated but is not required.
16
+
17
+ 2. Altered source versions must be plainly marked as such, and must not
18
+ be misrepresented as being the original software.
19
+
20
+ 3. This notice may not be removed or altered from any source distribution.
21
+
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0"?>
2
+ <!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
3
+ <cross-domain-policy>
4
+
5
+
6
+ <!-- Read this: www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html -->
7
+
8
+ <!-- Most restrictive policy: -->
9
+ <site-control permitted-cross-domain-policies="none"/>
10
+
11
+
12
+
13
+ <!-- Least restrictive policy: -->
14
+ <!--
15
+ <site-control permitted-cross-domain-policies="all"/>
16
+ <allow-access-from domain="*" to-ports="*" secure="false"/>
17
+ <allow-http-request-headers-from domain="*" headers="*" secure="false"/>
18
+ -->
19
+ <!--
20
+ If you host a crossdomain.xml file with allow-access-from domain=“*”
21
+ and don’t understand all of the points described here, you probably
22
+ have a nasty security vulnerability. ~ simon willison
23
+ -->
24
+
25
+ </cross-domain-policy>
Binary file
@@ -0,0 +1,32 @@
1
+ # Numerous always-ignore extensions
2
+ *.diff
3
+ *.err
4
+ *.orig
5
+ *.log
6
+ *.rej
7
+ *.swo
8
+ *.swp
9
+ *.vi
10
+ *~
11
+
12
+ # OS or Editor folders
13
+ .DS_Store
14
+ .cache
15
+ .project
16
+ .settings
17
+ nbproject
18
+ thumbs.db
19
+
20
+ # Dreamweaver added files
21
+ _notes
22
+ dwsync.xml
23
+
24
+ # Folders to ignore
25
+ .hg
26
+ .svn
27
+ publish
28
+ .idea
29
+
30
+ # build script local files
31
+ build/buildinfo.properties
32
+ build/config/buildinfo.properties
@@ -0,0 +1,2 @@
1
+ !.gitignore
2
+
@@ -0,0 +1,22 @@
1
+ # Html5BoilerplateHelper will first check your ENV and
2
+ # then this yml file for these values. If they are both
3
+ # empty, the google code block will not be used.
4
+ #
5
+ # e.g. ENV['GOOGLE_ACCOUNT_ID'] || yml[:google_account_id]
6
+ # e.g. ENV['GOOGLE_API_KEY'] || yml[:google_api_key]
7
+ #
8
+ defaults: &defaults
9
+ :google_account_id: ''
10
+ :google_api_key: ''
11
+
12
+ :development:
13
+ <<: *defaults
14
+
15
+ :test:
16
+ <<: *defaults
17
+
18
+ :staging:
19
+ <<: *defaults
20
+
21
+ :production:
22
+ <<: *defaults
@@ -0,0 +1,415 @@
1
+ # Apache configuration file
2
+ # httpd.apache.org/docs/2.2/mod/quickreference.html
3
+
4
+ # Note .htaccess files are an overhead, this logic should be in your Apache config if possible
5
+ # httpd.apache.org/docs/2.2/howto/htaccess.html
6
+
7
+ # Techniques in here adapted from all over, including:
8
+ # Kroc Camen: camendesign.com/.htaccess
9
+ # perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/
10
+ # Sample .htaccess file of CMS MODx: modxcms.com
11
+
12
+
13
+ ###
14
+ ### If you run a webserver other than apache, consider:
15
+ ### github.com/paulirish/html5-boilerplate-server-configs
16
+ ###
17
+
18
+
19
+
20
+ # ----------------------------------------------------------------------
21
+ # Better website experience for IE users
22
+ # ----------------------------------------------------------------------
23
+
24
+ # Force the latest IE version, in various cases when it may fall back to IE7 mode
25
+ # github.com/rails/rails/commit/123eb25#commitcomment-118920
26
+ # Use ChromeFrame if it's installed for a better experience for the poor IE folk
27
+
28
+ <IfModule mod_setenvif.c>
29
+ <IfModule mod_headers.c>
30
+ BrowserMatch MSIE ie
31
+ Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie
32
+ </IfModule>
33
+ </IfModule>
34
+
35
+ <IfModule mod_headers.c>
36
+ # Because X-UA-Compatible isn't sent to non-IE (to save header bytes),
37
+ # We need to inform proxies that content changes based on UA
38
+ Header append Vary User-Agent
39
+ # Cache control is set only if mod_headers is enabled, so that's unncessary to declare
40
+ </IfModule>
41
+
42
+
43
+ # ----------------------------------------------------------------------
44
+ # Cross-domain AJAX requests
45
+ # ----------------------------------------------------------------------
46
+
47
+ # Serve cross-domain ajax requests, disabled.
48
+ # enable-cors.org
49
+ # code.google.com/p/html5security/wiki/CrossOriginRequestSecurity
50
+
51
+ # <IfModule mod_headers.c>
52
+ # Header set Access-Control-Allow-Origin "*"
53
+ # </IfModule>
54
+
55
+
56
+
57
+ # ----------------------------------------------------------------------
58
+ # Webfont access
59
+ # ----------------------------------------------------------------------
60
+
61
+ # allow access from all domains for webfonts
62
+ # alternatively you could only whitelist
63
+ # your subdomains like "sub.domain.com"
64
+
65
+ <FilesMatch "\.(ttf|otf|eot|woff|font.css)$">
66
+ <IfModule mod_headers.c>
67
+ Header set Access-Control-Allow-Origin "*"
68
+ </IfModule>
69
+ </FilesMatch>
70
+
71
+
72
+
73
+ # ----------------------------------------------------------------------
74
+ # Proper MIME type for all files
75
+ # ----------------------------------------------------------------------
76
+
77
+ # audio
78
+ AddType audio/ogg oga ogg
79
+
80
+ # video
81
+ AddType video/ogg ogv
82
+ AddType video/mp4 mp4
83
+ AddType video/webm webm
84
+
85
+ # Proper svg serving. Required for svg webfonts on iPad
86
+ # twitter.com/FontSquirrel/status/14855840545
87
+ AddType image/svg+xml svg svgz
88
+ AddEncoding gzip svgz
89
+
90
+ # webfonts
91
+ AddType application/vnd.ms-fontobject eot
92
+ AddType font/truetype ttf
93
+ AddType font/opentype otf
94
+ AddType font/opentype woff
95
+ # ^ hack to avoid chrome console warning: crbug.com/70283
96
+
97
+ # assorted types
98
+ AddType image/x-icon ico
99
+ AddType image/webp webp
100
+ AddType text/cache-manifest appcache manifest
101
+ AddType text/x-component htc
102
+ AddType application/x-chrome-extension crx
103
+ AddType application/x-xpinstall xpi
104
+ AddType application/octet-stream safariextz
105
+
106
+
107
+
108
+ # ----------------------------------------------------------------------
109
+ # Allow concatenation from within specific js and css files
110
+ # ----------------------------------------------------------------------
111
+
112
+ # e.g. Inside of script.combined.js you could have
113
+ # <!--#include file="jquery-1.4.4.js" -->
114
+ # <!--#include file="jquery.idletimer.js" -->
115
+ # and they would be included into this single file
116
+
117
+ # this is not in use in the boilerplate as it stands. you may
118
+ # choose to name your files in this way for this advantage
119
+ # or concatenate and minify them manually.
120
+ # Disabled by default.
121
+
122
+ # <FilesMatch "\.combined\.(js|css)$">
123
+ # Options +Includes
124
+ # SetOutputFilter INCLUDES
125
+ # </FilesMatch>
126
+
127
+
128
+
129
+ # ----------------------------------------------------------------------
130
+ # gzip compression
131
+ # ----------------------------------------------------------------------
132
+
133
+ <IfModule mod_deflate.c>
134
+
135
+
136
+ # force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
137
+ <IfModule mod_setenvif.c>
138
+ <IfModule mod_headers.c>
139
+ SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s,?\s(gzip|deflate)?|X{4,13}|~{4,13}|-{4,13})$ HAVE_Accept-Encoding
140
+ RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
141
+ </IfModule>
142
+ </IfModule>
143
+ # html, txt, css, js, json, xml, htc:
144
+ <IfModule filter_module>
145
+ FilterDeclare COMPRESS
146
+ FilterProvider COMPRESS DEFLATE resp=Content-Type /text/(html|css|javascript|plain|x(ml|-component))/
147
+ FilterProvider COMPRESS DEFLATE resp=Content-Type /application/(javascript|json|xml|x-javascript)/
148
+ FilterChain COMPRESS
149
+ FilterProtocol COMPRESS change=yes;byteranges=no
150
+ </IfModule>
151
+
152
+ <IfModule !mod_filter.c>
153
+ # Legacy versions of Apache
154
+ AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
155
+ AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript
156
+ AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
157
+ </IfModule>
158
+
159
+ # webfonts and svg:
160
+ <FilesMatch "\.(ttf|otf|eot|svg)$" >
161
+ SetOutputFilter DEFLATE
162
+ </FilesMatch>
163
+ </IfModule>
164
+
165
+
166
+
167
+ # ----------------------------------------------------------------------
168
+ # Expires headers (for better cache control)
169
+ # ----------------------------------------------------------------------
170
+
171
+ # these are pretty far-future expires headers
172
+ # they assume you control versioning with cachebusting query params like
173
+ # <script src="application.js?20100608">
174
+ # additionally, consider that outdated proxies may miscache
175
+ # www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
176
+
177
+ # if you don't use filenames to version, lower the css and js to something like
178
+ # "access plus 1 week" or so
179
+
180
+ <IfModule mod_expires.c>
181
+ ExpiresActive on
182
+
183
+ # Perhaps better to whitelist expires rules? Perhaps.
184
+ ExpiresDefault "access plus 1 month"
185
+
186
+ # cache.appcache needs re-requests in FF 3.6 (thx Remy ~Introducing HTML5)
187
+ ExpiresByType text/cache-manifest "access plus 0 seconds"
188
+
189
+ # your document html
190
+ ExpiresByType text/html "access plus 0 seconds"
191
+
192
+ # data
193
+ ExpiresByType text/xml "access plus 0 seconds"
194
+ ExpiresByType application/xml "access plus 0 seconds"
195
+ ExpiresByType application/json "access plus 0 seconds"
196
+
197
+ # rss feed
198
+ ExpiresByType application/rss+xml "access plus 1 hour"
199
+
200
+ # favicon (cannot be renamed)
201
+ ExpiresByType image/x-icon "access plus 1 week"
202
+
203
+ # media: images, video, audio
204
+ ExpiresByType image/gif "access plus 1 month"
205
+ ExpiresByType image/png "access plus 1 month"
206
+ ExpiresByType image/jpg "access plus 1 month"
207
+ ExpiresByType image/jpeg "access plus 1 month"
208
+ ExpiresByType video/ogg "access plus 1 month"
209
+ ExpiresByType audio/ogg "access plus 1 month"
210
+ ExpiresByType video/mp4 "access plus 1 month"
211
+ ExpiresByType video/webm "access plus 1 month"
212
+
213
+ # webfonts
214
+ ExpiresByType font/truetype "access plus 1 month"
215
+ ExpiresByType font/opentype "access plus 1 month"
216
+ ExpiresByType font/woff "access plus 1 month"
217
+ ExpiresByType image/svg+xml "access plus 1 month"
218
+ ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
219
+
220
+ # css and javascript
221
+ ExpiresByType text/css "access plus 2 months"
222
+ ExpiresByType application/javascript "access plus 2 months"
223
+ ExpiresByType text/javascript "access plus 2 months"
224
+ <IfModule mod_headers.c>
225
+ Header append Cache-Control "public"
226
+ </IfModule>
227
+ </IfModule>
228
+
229
+
230
+
231
+ # ----------------------------------------------------------------------
232
+ # ETag removal
233
+ # ----------------------------------------------------------------------
234
+
235
+ # Since we're sending far-future expires, we don't need ETags for
236
+ # static content.
237
+ # developer.yahoo.com/performance/rules.html#etags
238
+ FileETag None
239
+
240
+
241
+
242
+ # ----------------------------------------------------------------------
243
+ # Stop screen flicker in IE on CSS rollovers
244
+ # ----------------------------------------------------------------------
245
+
246
+ # The following directives stop screen flicker in IE on CSS rollovers - in
247
+ # combination with the "ExpiresByType" rules for images (see above). If
248
+ # needed, un-comment the following rules.
249
+
250
+ # BrowserMatch "MSIE" brokenvary=1
251
+ # BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1
252
+ # BrowserMatch "Opera" !brokenvary
253
+ # SetEnvIf brokenvary 1 force-no-vary
254
+
255
+
256
+
257
+ # ----------------------------------------------------------------------
258
+ # Cookie setting from iframes
259
+ # ----------------------------------------------------------------------
260
+
261
+ # Allow cookies to be set from iframes (for IE only)
262
+ # If needed, uncomment and specify a path or regex in the Location directive
263
+
264
+ # <IfModule mod_headers.c>
265
+ # <Location />
266
+ # Header set P3P "policyref=\"/w3c/p3p.xml\", CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\""
267
+ # </Location>
268
+ # </IfModule>
269
+
270
+
271
+
272
+ # ----------------------------------------------------------------------
273
+ # Start rewrite engine
274
+ # ----------------------------------------------------------------------
275
+
276
+ # Turning on the rewrite engine is necessary for the following rules and features.
277
+
278
+ <IfModule mod_rewrite.c>
279
+ RewriteEngine On
280
+ </IfModule>
281
+
282
+
283
+
284
+ # ----------------------------------------------------------------------
285
+ # Suppress or force the "www." at the beginning of URLs
286
+ # ----------------------------------------------------------------------
287
+
288
+ # The same content should never be available under two different URLs - especially not with and
289
+ # without "www." at the beginning, since this can cause SEO problems (duplicate content).
290
+ # That's why you should choose one of the alternatives and redirect the other one.
291
+
292
+ # By default option 1 (no "www.") is activated. Remember: Shorter URLs are sexier.
293
+ # no-www.org/faq.php?q=class_b
294
+
295
+ # If you rather want to use option 2, just comment out all option 1 lines
296
+ # and uncomment option 2.
297
+ # IMPORTANT: NEVER USE BOTH RULES AT THE SAME TIME!
298
+
299
+ # ----------------------------------------------------------------------
300
+
301
+ # Option 1:
302
+ # Rewrite "www.domain.com -> domain.com"
303
+
304
+ <IfModule mod_rewrite.c>
305
+ RewriteCond %{HTTPS} !=on
306
+ RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
307
+ RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
308
+ </IfModule>
309
+
310
+ # ----------------------------------------------------------------------
311
+
312
+ # Option 2:
313
+ # To rewrite "domain.com -> www.domain.com" uncomment the following lines.
314
+ # Be aware that the following rule might not be a good idea if you
315
+ # use "real" subdomains for certain parts of your website.
316
+
317
+ # <IfModule mod_rewrite.c>
318
+ # RewriteCond %{HTTPS} !=on
319
+ # RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
320
+ # RewriteCond %{HTTP_HOST} (.+)$ [NC]
321
+ # RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
322
+ # </IfModule>
323
+
324
+
325
+
326
+ # ----------------------------------------------------------------------
327
+ # Prevent SSL cert warnings
328
+ # ----------------------------------------------------------------------
329
+
330
+ # Rewrite secure requests properly to prevent SSL cert warnings, e.g. prevent
331
+ # https://www.domain.com when your cert only allows https://secure.domain.com
332
+ # Uncomment the following lines to use this feature.
333
+
334
+ # <IfModule mod_rewrite.c>
335
+ # RewriteCond %{SERVER_PORT} !^443
336
+ # RewriteRule (.*) https://example-domain-please-change.com.com/$1 [R=301,L]
337
+ # </IfModule>
338
+
339
+
340
+
341
+ # ----------------------------------------------------------------------
342
+ # Prevent 404 errors for non-existing redirected folders
343
+ # ----------------------------------------------------------------------
344
+
345
+ # without -MultiViews, Apache will give a 404 for a rewrite if a folder of the same name does not exist
346
+ # e.g. /blog/hello : webmasterworld.com/apache/3808792.htm
347
+
348
+ Options -MultiViews
349
+
350
+
351
+
352
+ # ----------------------------------------------------------------------
353
+ # custom 404 page
354
+ # ----------------------------------------------------------------------
355
+
356
+ ErrorDocument 404 /404.html
357
+
358
+
359
+
360
+ # ----------------------------------------------------------------------
361
+ # UTF-8 encoding
362
+ # ----------------------------------------------------------------------
363
+
364
+ # use utf-8 encoding for anything served text/plain or text/html
365
+ AddDefaultCharset utf-8
366
+
367
+ # force utf-8 for a number of file formats
368
+ AddCharset utf-8 .html .css .js .xml .json .rss
369
+
370
+
371
+
372
+ # ----------------------------------------------------------------------
373
+ # A little more security
374
+ # ----------------------------------------------------------------------
375
+
376
+
377
+ # Do we want to advertise the exact version number of Apache we're running?
378
+ # Probably not.
379
+ ## This can only be enabled if used in httpd.conf - It will not work in .htaccess
380
+ # ServerTokens Prod
381
+
382
+
383
+ # "-Indexes" will have Apache block users from browsing folders without a default document
384
+ # Usually you should leave this activated, because you shouldn't allow everybody to surf through
385
+ # every folder on your server (which includes rather private places like CMS system folders).
386
+ # Options -Indexes
387
+
388
+
389
+ # Block access to "hidden" directories whose names begin with a period. This
390
+ # includes directories used by version control systems such as Subversion or Git.
391
+ <IfModule mod_rewrite.c>
392
+ RewriteRule "(^|/)\." - [F]
393
+ </IfModule>
394
+
395
+
396
+ # If your server is not already configured as such, the following directive
397
+ # should be uncommented in order to set PHP's register_globals option to OFF.
398
+ # This closes a major security hole that is abused by most XSS (cross-site
399
+ # scripting) attacks. For more information: http://php.net/register_globals
400
+ #
401
+ # IF REGISTER_GLOBALS DIRECTIVE CAUSES 500 INTERNAL SERVER ERRORS :
402
+ #
403
+ # Your server does not allow PHP directives to be set via .htaccess. In that
404
+ # case you must make this change in your php.ini file instead. If you are
405
+ # using a commercial web host, contact the administrators for assistance in
406
+ # doing this. Not all servers allow local php.ini files, and they should
407
+ # include all PHP configurations (not just this one), or you will effectively
408
+ # reset everything to PHP defaults. Consult www.php.net for more detailed
409
+ # information about setting PHP directives.
410
+
411
+ # php_flag register_globals Off
412
+
413
+
414
+
415
+