jekyll-press 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jekyll-press.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Slavik Vysokinskiy
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # jekyll-press
2
+ Minifier plugin for jekyll. Minifies all html, js, css files. Simple just drop it in solution. No Java required.
3
+
4
+ This plugin:
5
+ - compress html with the help of html_press
6
+ - compress JavaScript files with the help of uglifier
7
+ - compress css files with the help of css_press
8
+
9
+ ## Installation
10
+
11
+ ### Bundler
12
+ Add this line to your application's `Gemfile`:
13
+ ```ruby
14
+ gem 'jekyll-press'
15
+ ```
16
+
17
+ And then execute:
18
+ ```bash
19
+ $ bundle
20
+ ```
21
+
22
+ ### Standalone
23
+ Execute:
24
+ ```bash
25
+ $ gem install jekyll-press
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ### With Bundler (recomended)
31
+ Create the following plugin in your projects _plugins directory.
32
+
33
+ ```ruby
34
+ # _plugins/bundler.rb
35
+ require "rubygems"
36
+ require "bundler/setup"
37
+ Bundler.require(:default)
38
+ ```
39
+
40
+ This will automatically require all of the gems specified in your Gemfile.
41
+
42
+ ### Standalone
43
+ Create the following plugin in your projects _plugins directory.
44
+
45
+ ```ruby
46
+ # _plugins/jekyll-press-plugin.rb
47
+ require 'jekyll-press'
48
+ ```
49
+
50
+ ## TODO
51
+ - Minify JPEGs with [`jpegtran`](/cmer/jpegtran) or `smush.it` ([smusher](/grosser/smusher))
52
+ - Minify PNGs with [`optipng`](/martinkozak/optipng) or `smush.it` ([smusher](/grosser/smusher))
53
+ - Auto CSS sprites (for example [sprite factory](/jakesgordon/sprite-factory/))
54
+
55
+ ## Contributing
56
+ 1. Fork it
57
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
58
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
59
+ 4. Push to the branch (`git push origin my-new-feature`)
60
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/jekyll-press/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["sterebooster"]
6
+ gem.email = ["stereobooster@gmail.com"]
7
+ gem.description = %q{Minifier plugin for jekyll. Minifies all html, js, css files. Simple just drop it in solution. No Java required}
8
+ gem.summary = %q{Minifier plugin for jekyll. This plugin compress html with the help of html_press, compress JavaScript files with the help of uglifier, compress css files with the help of css_press}
9
+ gem.homepage = "http://github.com/stereobooster/jekyl-press"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "jekyll-press"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Jekyll::Press::VERSION
17
+
18
+ gem.add_dependency 'jekyll'
19
+ gem.add_dependency "html_press"
20
+ gem.add_dependency "css_press"
21
+ gem.add_dependency "uglifier"
22
+ end
@@ -0,0 +1,91 @@
1
+ require "jekyll-press/version"
2
+
3
+ require 'html_press'
4
+ require 'css_press'
5
+ require 'uglifier'
6
+
7
+ module Jekyll
8
+ module Compressor
9
+ def output_file(dest, content)
10
+ FileUtils.mkdir_p(File.dirname(dest))
11
+ File.open(dest, 'w') do |f|
12
+ f.write(content)
13
+ end
14
+ end
15
+
16
+ def output_html(path, content)
17
+ self.output_file(path, HtmlPress.press(content))
18
+ end
19
+
20
+ def output_js(path, content)
21
+ self.output_file(path, Uglifier.new.compile(content))
22
+ rescue Uglifier::Error => e
23
+ warn "parse error occurred while processing: #{path}"
24
+ warn "details: #{e.message.strip}"
25
+ warn "copying initial file"
26
+ self.output_file(path, content)
27
+ end
28
+
29
+ def output_css(path, content)
30
+ self.output_file(path, CssPress.press(content))
31
+ rescue Racc::ParseError => e
32
+ warn "parse error occurred while processing: #{path}"
33
+ warn "details: #{e.message.strip}"
34
+ warn "copying initial file"
35
+ self.output_file(path, content)
36
+ end
37
+ end
38
+
39
+ class Post
40
+ include Compressor
41
+
42
+ def write(dest)
43
+ dest_path = self.destination(dest)
44
+ self.output_html(dest_path, self.output)
45
+ end
46
+ end
47
+
48
+ class Page
49
+ include Compressor
50
+
51
+ def write(dest)
52
+ dest_path = self.destination(dest)
53
+ self.output_html(dest_path, self.output)
54
+ end
55
+ end
56
+
57
+ class StaticFile
58
+ include Compressor
59
+
60
+ def copy_file(path, dest_path)
61
+ FileUtils.mkdir_p(File.dirname(dest_path))
62
+ FileUtils.cp(path, dest_path)
63
+ end
64
+
65
+ def write(dest)
66
+ dest_path = self.destination(dest)
67
+
68
+ return false if File.exist?(dest_path) and !self.modified?
69
+ @@mtimes[path] = mtime
70
+
71
+ case File.extname(dest_path)
72
+ when '.js'
73
+ if dest_path =~ /.min.js$/
74
+ copy_file(path, dest_path)
75
+ else
76
+ self.output_js(dest_path, File.read(path))
77
+ end
78
+ when '.css'
79
+ if dest_path =~ /.min.css$/
80
+ copy_file(path, dest_path)
81
+ else
82
+ self.output_css(dest_path, File.read(path))
83
+ end
84
+ else
85
+ copy_file(path, dest_path)
86
+ end
87
+
88
+ true
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module Press
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-press
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - sterebooster
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: jekyll
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: html_press
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: css_press
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: uglifier
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Minifier plugin for jekyll. Minifies all html, js, css files. Simple
79
+ just drop it in solution. No Java required
80
+ email:
81
+ - stereobooster@gmail.com
82
+ executables: []
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - .gitignore
87
+ - Gemfile
88
+ - LICENSE
89
+ - README.md
90
+ - Rakefile
91
+ - jekyll-press.gemspec
92
+ - lib/jekyll-press.rb
93
+ - lib/jekyll-press/version.rb
94
+ homepage: http://github.com/stereobooster/jekyl-press
95
+ licenses: []
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ! '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 1.8.24
115
+ signing_key:
116
+ specification_version: 3
117
+ summary: Minifier plugin for jekyll. This plugin compress html with the help of html_press,
118
+ compress JavaScript files with the help of uglifier, compress css files with the
119
+ help of css_press
120
+ test_files: []