jekyll-press 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Slavik Vysokinskiy
1
+ Copyright (c) 2012 Stereobooster
2
2
 
3
3
  MIT License
4
4
 
@@ -47,6 +47,16 @@ Create the following plugin in your projects _plugins directory.
47
47
  require 'jekyll-press'
48
48
  ```
49
49
 
50
+ ### Settings
51
+ If you want to exclude some jekyll pages from processing (for example `atom.xml`) you can add following to the `_config.yml`:
52
+
53
+ ```yaml
54
+ jekyll-press:
55
+ exclude: 'atom.xml'
56
+ ```
57
+
58
+ `exclude` can be file name, glob pattern or array of file names and glob patterns.
59
+
50
60
  ## TODO
51
61
  - Minify JPEGs with [`jpegtran`](/cmer/jpegtran) or `smush.it` ([smusher](/grosser/smusher))
52
62
  - Minify PNGs with [`optipng`](/martinkozak/optipng) or `smush.it` ([smusher](/grosser/smusher))
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Press
3
- VERSION = "0.0.1"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
data/lib/jekyll-press.rb CHANGED
@@ -6,6 +6,24 @@ require 'uglifier'
6
6
 
7
7
  module Jekyll
8
8
  module Compressor
9
+ def exclude?(dest, dest_path)
10
+ res = false
11
+ file_name = dest_path.slice(dest.length+1..dest_path.length)
12
+ exclude = @site.config['jekyll-press'] && @site.config['jekyll-press']['exclude']
13
+ if exclude
14
+ if exclude.is_a? String
15
+ exclude = [exclude]
16
+ end
17
+ exclude.each do |e|
18
+ if e == file_name || File.fnmatch(e, file_name)
19
+ res = true
20
+ break
21
+ end
22
+ end
23
+ end
24
+ res
25
+ end
26
+
9
27
  def output_file(dest, content)
10
28
  FileUtils.mkdir_p(File.dirname(dest))
11
29
  File.open(dest, 'w') do |f|
@@ -14,25 +32,23 @@ module Jekyll
14
32
  end
15
33
 
16
34
  def output_html(path, content)
17
- self.output_file(path, HtmlPress.press(content))
35
+ output_file(path, HtmlPress.press(content))
18
36
  end
19
37
 
20
38
  def output_js(path, content)
21
- self.output_file(path, Uglifier.new.compile(content))
39
+ output_file(path, Uglifier.new.compile(content))
22
40
  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)
41
+ warn "Warning: parse error in #{path}. Don't panic - copying initial file"
42
+ warn "Details: #{e.message.strip}"
43
+ output_file(path, content)
27
44
  end
28
45
 
29
46
  def output_css(path, content)
30
- self.output_file(path, CssPress.press(content))
47
+ output_file(path, CssPress.press(content))
31
48
  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)
49
+ warn "Warning: parse error in #{path}. Don't panic - copying initial file"
50
+ warn "Details: #{e.message.strip}"
51
+ output_file(path, content)
36
52
  end
37
53
  end
38
54
 
@@ -40,8 +56,8 @@ module Jekyll
40
56
  include Compressor
41
57
 
42
58
  def write(dest)
43
- dest_path = self.destination(dest)
44
- self.output_html(dest_path, self.output)
59
+ dest_path = destination(dest)
60
+ output_html(dest_path, output)
45
61
  end
46
62
  end
47
63
 
@@ -49,8 +65,12 @@ module Jekyll
49
65
  include Compressor
50
66
 
51
67
  def write(dest)
52
- dest_path = self.destination(dest)
53
- self.output_html(dest_path, self.output)
68
+ dest_path = destination(dest)
69
+ if exclude?(dest, dest_path)
70
+ output_file(dest_path, output)
71
+ else
72
+ output_html(dest_path, output)
73
+ end
54
74
  end
55
75
  end
56
76
 
@@ -63,9 +83,9 @@ module Jekyll
63
83
  end
64
84
 
65
85
  def write(dest)
66
- dest_path = self.destination(dest)
86
+ dest_path = destination(dest)
67
87
 
68
- return false if File.exist?(dest_path) and !self.modified?
88
+ return false if File.exist?(dest_path) and !modified?
69
89
  @@mtimes[path] = mtime
70
90
 
71
91
  case File.extname(dest_path)
@@ -73,13 +93,13 @@ module Jekyll
73
93
  if dest_path =~ /.min.js$/
74
94
  copy_file(path, dest_path)
75
95
  else
76
- self.output_js(dest_path, File.read(path))
96
+ output_js(dest_path, File.read(path))
77
97
  end
78
98
  when '.css'
79
99
  if dest_path =~ /.min.css$/
80
100
  copy_file(path, dest_path)
81
101
  else
82
- self.output_css(dest_path, File.read(path))
102
+ output_css(dest_path, File.read(path))
83
103
  end
84
104
  else
85
105
  copy_file(path, dest_path)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-press
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-20 00:00:00.000000000 Z
12
+ date: 2012-11-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jekyll
@@ -86,8 +86,8 @@ files:
86
86
  - .gitignore
87
87
  - Gemfile
88
88
  - LICENSE
89
- - README.md
90
89
  - Rakefile
90
+ - Readme.md
91
91
  - jekyll-press.gemspec
92
92
  - lib/jekyll-press.rb
93
93
  - lib/jekyll-press/version.rb