jekyll-minifier 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d00e376595f2e5685bc9be878874112d47a82d2
4
- data.tar.gz: a68f57fcbe9d9733f5f3a9625e1649e822ce7dd8
3
+ metadata.gz: 24c96b07fb3e26348173ae093bc81fc13483b03a
4
+ data.tar.gz: 1fd88f8700c94438ce0967d7e05efe202ba66f01
5
5
  SHA512:
6
- metadata.gz: 982371f0137491ab8009081849b70498d2eddbd4d5fbe65ca472b4953be865da4114748ddfa9326b9975b54ae498a7317f89037fe798396e565e703252c2c766
7
- data.tar.gz: 6bc4674259083865d2b420da73318b84b7823dab13e2f1656f8bd94affbef8db9218942d155b200df2e3eade51845883c5eed937ec4b035d5f597399088977ee
6
+ metadata.gz: f6b402887539653eef6dd2cb450ac9f79fa09c3ef5c3450ce729dfff2305f5fb797581684754dbc698cbf354e2926b2e4070036d08e2786b9b4632f624c98720
7
+ data.tar.gz: 9425b6093c220edff326727c6a90aec9631092203ced3e7e973551cbcc12bd2e630c84fc2dfc2a69b75be633063f00962effb9c67ee1472120608a75edb012f2
@@ -0,0 +1,10 @@
1
+ spec/dest
2
+ *.gem
3
+ .bundle
4
+ Gemfile.lock
5
+ pkg/*
6
+ coverage
7
+ rdoc
8
+ doc
9
+ .yardoc
10
+ .rspec
@@ -0,0 +1,12 @@
1
+ deploy:
2
+ provider: rubygems
3
+ api_key:
4
+ secure: ZcuqwEzBM7IXmEoMnE3pJLNlmNqZ0XpCbMt/DWn/XqR24SrM2+OLKBIY1Nb5y5mIzzE1ipKxuDRxXnQJNsxyLYKKaAMZc9fax8n/uNN5c2gMU3oqQS0Dw3R44ynDmpuhr7hv9peCuh8Y0ca5WJxo1AG0GNckBrYXBQNrtK6TlnR6KlmTc2Vht30JW253W7BXREe+uQPLQA5g0V/s+Hc/qORLHp64qtEGUyShTSSBc5h2989vKVPvXrm5c6bUEyl48LH9jatOyll3prSYyka1pGNueWKYWTpjUdDDkAHVwdHr3rILTe7CD6wyVJkPLPjczga3IPHFLUGKSQN+tKevYZYbGmjtty1C4giUqu71HqYfYOgWNNUe9HGg86lvZjvo8PC9AENn5e10EvrqOPwIMl1ISkXcdA3zGkZvl9bAJ5AR7vGU8p33nzKbGahD9YBfg8hauiRehBV4EPaFK4uTOIOI9GwNjVqzOZ8azUDm3FFivlKcqtaO5IKVZb3XNxM3QkldnlPOmJzzZuF/9Z61RjqiWkbs8Fgkydzt9K3gmHmRvl73cxrZWAXqkOf45vIAMFY6P8lj7mIOJxFhlK/IkDm7HYwd5nbe9xe0D+G9Q20BqQ9MR8Zn2VFcc32V5f5U/P8mWXxRVSa6RPQomGosL8WpX1xLyQGA/+WzInSqzPo=
5
+ gem: jekyll-minifier
6
+ on:
7
+ tags: true
8
+ repo: digitalsparky/jekyll-minifier
9
+ language: ruby
10
+ rvm:
11
+ - 2.3.1
12
+ script: bundle exec rspec spec
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # jekyll-minifier [![Gem Version](https://badge.fury.io/rb/jekyll-minifier.svg)](http://badge.fury.io/rb/jekyll-minifier)
1
+ # jekyll-minifier [![Build Status](https://travis-ci.org/digitalsparky/jekyll-minifier.svg?branch=master)](https://travis-ci.org/digitalsparky/jekyll-minifier) [![Gem Version](https://badge.fury.io/rb/jekyll-minifier.svg)](http://badge.fury.io/rb/jekyll-minifier)
2
2
 
3
3
  Minifies HTML, XML, CSS, and Javascript both inline and as separate files utilising yui-compressor and htmlcompressor.
4
4
 
@@ -20,4 +20,27 @@ Optionally, you can also add exclusions using:
20
20
  <pre><code>jekyll-minifier:
21
21
  exclude: 'atom.xml' # Exclude files from processing - file name, glob pattern or array of file names and glob patterns
22
22
  </code></pre>
23
+ and toggle htmlcompressor features using:
24
+ <pre><code>jekyll-minifier:
25
+ preserve_php: true # Default: false
26
+ remove_spaces_inside_tags: true # Default: true
27
+ remove_multi_spaces: true # Default: true
28
+ remove_comments: true # Default: true
29
+ remove_intertag_spaces: true # Default: false
30
+ remove_quotes: false # Default: false
31
+ compress_css: true # Default: true
32
+ compress_javascript: true # Default: true
33
+ simple_doctype: false # Default: false
34
+ remove_script_attributes: false # Default: false
35
+ remove_style_attributes: false # Default: false
36
+ remove_link_attributes: false # Default: false
37
+ remove_form_attributes: false # Default: false
38
+ remove_input_attributes: false # Default: false
39
+ remove_javascript_protocol: false # Default: false
40
+ remove_http_protocol: false # Default: false
41
+ remove_https_protocol: false # Default: false
42
+ preserve_line_breaks: false # Default: false
43
+ simple_boolean_attributes: false # Default: false
44
+ compress_js_templates: false # Default: false
45
+ </code></pre>
23
46
 
@@ -19,12 +19,20 @@ Gem::Specification.new do |gem|
19
19
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
20
20
  gem.name = "jekyll-minifier"
21
21
  gem.require_paths = ["lib"]
22
- gem.version = Jekyll::Minifier::VERSION
23
-
22
+
23
+ if ENV['TRAVIS_TAG']
24
+ gem.version = "#{ENV['TRAVIS_TAG']}"
25
+ else
26
+ gem.version = Jekyll::Minifier::VERSION
27
+ end
28
+
24
29
  gem.add_dependency "jekyll", "~> 3.0"
25
30
  gem.add_dependency "uglifier", "~> 2.7"
26
31
  gem.add_dependency "htmlcompressor", "~> 0.3"
27
32
  gem.add_dependency "cssminify2", "~> 2.0"
28
33
 
29
34
  gem.add_development_dependency "rake", "~> 10.4"
35
+ gem.add_development_dependency "rspec", "~> 2.7"
36
+ gem.add_development_dependency "jekyll-paginate"
37
+ gem.add_development_dependency "redcarpet"
30
38
  end
@@ -30,7 +30,42 @@ module Jekyll
30
30
  end
31
31
 
32
32
  def output_html(path, content)
33
- compressor = HtmlCompressor::Compressor.new({ :remove_comments => true, :compress_css => true, :compress_javascript => true, :css_compressor => CSSminify2.new, :javascript_compressor => Uglifier.new })
33
+ args = { remove_comments: true, compress_css: true, compress_javascript: true, preserve_patterns: [] }
34
+ args[:css_compressor] = CSSminify2.new
35
+ args[:javascript_compressor] = Uglifier.new
36
+
37
+ opts = @site.config['jekyll-minifier']
38
+
39
+ if ( !opts.nil? )
40
+ # Convert keys to symboles
41
+ opts.keys.each { |key| opts[(key.to_sym rescue key) || key] = opts.delete(key) }
42
+
43
+ args[:remove_spaces_inside_tags] = opts[:remove_spaces_inside_tags] if opts.has_key?(:remove_spaces_inside_tags)
44
+ args[:remove_multi_spaces] = opts[:remove_multi_spaces] if opts.has_key?(:remove_multi_spaces)
45
+ args[:remove_comments] = opts[:remove_comments] if opts.has_key?(:remove_comments)
46
+ args[:remove_intertag_spaces] = opts[:remove_intertag_spaces] if opts.has_key?(:remove_intertag_spaces)
47
+ args[:remove_quotes] = opts[:remove_quotes] if opts.has_key?(:remove_quotes)
48
+ args[:compress_css] = opts[:compress_css] if opts.has_key?(:compress_css)
49
+ args[:compress_javascript] = opts[:compress_javascript] if opts.has_key?(:compress_javascript)
50
+ args[:simple_doctype] = opts[:simple_doctype] if opts.has_key?(:simple_doctype)
51
+ args[:remove_script_attributes] = opts[:remove_script_attributes] if opts.has_key?(:remove_script_attributes)
52
+ args[:remove_style_attributes] = opts[:remove_style_attributes] if opts.has_key?(:remove_style_attributes)
53
+ args[:remove_link_attributes] = opts[:remove_link_attributes] if opts.has_key?(:remove_link_attributes)
54
+ args[:remove_form_attributes] = opts[:remove_form_attributes] if opts.has_key?(:remove_form_attributes)
55
+ args[:remove_input_attributes] = opts[:remove_input_attributes] if opts.has_key?(:remove_input_attributes)
56
+ args[:remove_javascript_protocol] = opts[:remove_javascript_protocol] if opts.has_key?(:remove_javascript_protocol)
57
+ args[:remove_http_protocol] = opts[:remove_http_protocol] if opts.has_key?(:remove_http_protocol)
58
+ args[:remove_https_protocol] = opts[:remove_https_protocol] if opts.has_key?(:remove_https_protocol)
59
+ args[:preserve_line_breaks] = opts[:preserve_line_breaks] if opts.has_key?(:preserve_line_breaks)
60
+ args[:simple_boolean_attributes] = opts[:simple_boolean_attributes] if opts.has_key?(:simple_boolean_attributes)
61
+ args[:compress_js_templates] = opts[:compress_js_templates] if opts.has_key?(:compress_js_templates)
62
+ args[:preserve_patterns] += [/<\?php.*?\?>/im] if opts[:preserve_php] == true
63
+
64
+ # Potential to add patterns from YAML
65
+ #args[:preserve_patterns] += opts[:preserve_patterns].map { |pattern| Regexp.new(pattern)} if opts.has_key?(:preserve_patterns)
66
+ end
67
+
68
+ compressor = HtmlCompressor::Compressor.new(args)
34
69
  output_file(path, compressor.compress(content))
35
70
  end
36
71
 
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Minifier
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -0,0 +1,10 @@
1
+ ---
2
+ layout: default
3
+ title: "404: Page not found"
4
+ permalink: 404.html
5
+ ---
6
+
7
+ <div class="page">
8
+ <h1 class="page-title">404: Page not found</h1>
9
+ <p class="lead">Sorry, we've misplaced that URL or it's pointing to something that doesn't exist. <a href="{{ site.baseurl | prepend: site.url }}">Head back home</a> to try finding it again.</p>
10
+ </div>
@@ -0,0 +1,19 @@
1
+ markdown: redcarpet
2
+ highlighter: pygments
3
+ title: Example.com
4
+ tagline: 'Example!'
5
+ description: ''
6
+ url: https://example.com
7
+ paginate: 10
8
+ category_dir: /
9
+ category_title_prefix: ''
10
+ permalink: :categories/:title.html
11
+ timezone: Australia/Perth
12
+ author:
13
+ name: 'Example'
14
+ email: 'example@example.com'
15
+ menu:
16
+ - { url: 'https://www.github.com/example/', name: 'GitHub', nofollow: true, newwindow: true }
17
+ gems:
18
+ - jekyll-minifier
19
+ - jekyll-paginate
@@ -0,0 +1,24 @@
1
+ <input type="checkbox" class="sidebar-checkbox" id="sidebar-checkbox">
2
+ <div class="sidebar" id="sidebar">
3
+ <div class="sidebar-item">
4
+ <p>{{ site.description }}</p>
5
+ </div>
6
+
7
+ <nav class="sidebar-nav">
8
+ <a class="sidebar-nav-item{% if page.url == site.baseurl %} active{% endif %}" href="{{ site.baseurl | prepend: site.url }}">Home</a>
9
+ {% assign pages_list = site.pages | sort:"url" %}
10
+ {% for node in pages_list %}
11
+ {% if node.title != null %}
12
+ {% if node.layout == "page" %}
13
+ <a class="sidebar-nav-item{% if page.url == node.url %} active{% endif %}" href="{{ node.url | prepend: site.baseurl | prepend: site.url }}">{{ node.title | capitalize }}</a>
14
+ {% endif %}
15
+ {% endif %}
16
+ {% endfor %}
17
+
18
+ {% assign urls_list = site.menu | sort:"url" %}
19
+ {% for node in urls_list %}
20
+ <a class="sidebar-nav-item" href="{{ node.url }}"{% if node.nofollow == true %} rel="nofollow"{% endif %}{% if node.newwindow == true %} target="_blank"{% endif %}>{{ node.name }}</a>
21
+ {% endfor %}
22
+
23
+ </nav>
24
+ </div>
@@ -0,0 +1,13 @@
1
+ ---
2
+ layout: page
3
+ ---
4
+ <div class="page-content wc-container">
5
+ <table>
6
+ {% for post in site.categories[page.category] %}
7
+ <tr>
8
+ <td><i class="icon-clock"></i><time datetime="{{post.date|date:"%F"}}">{{post.date|date:"%b %d, %Y"}}</time></td>
9
+ <td><a href="{{ post.url | prepend: site.baseurl | prepend: site.url }}">{{ post.title }}</a></td>
10
+ </tr>
11
+ {% endfor %}
12
+ </table>
13
+ </div>
@@ -0,0 +1,64 @@
1
+ ---
2
+ layout: null
3
+ ---
4
+
5
+ <!DOCTYPE html>
6
+ <html lang="en-us">
7
+ <head>
8
+ <meta name="viewport" content="width=device-width, initial-scale=1">
9
+ <meta charset="utf-8">
10
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
11
+ <title>
12
+ {% if page.title == "Home" %}
13
+ {{ site.title }} &middot; {{ site.tagline }}
14
+ {% else %}
15
+ {% if page.title != "" %}{{ page.title }} &middot; {% endif %}{{ site.title }}
16
+ {% endif %}
17
+ </title>
18
+ <link rel="stylesheet" href="//cdn.jsdelivr.net/g/bootstrap@3.3(css/bootstrap-theme.min.css+css/bootstrap.min.css)" crossorigin="anonymous">
19
+ <!--[if lt IE 9]><script src="//cdn.jsdelivr.net/g/html5shiv@3.7.3,respond@1.4.2" crossorigin="anonymous"></script><![endif]-->
20
+ <link rel="stylesheet" href="{{ site.baseurl | prepend: site.url }}/assets/css/style.css">
21
+ <link rel="alternate" type="application/atom+xml" title="Example.com" href="{{ site.baseurl | prepend: site.url }}/atom.xml">
22
+
23
+ </head>
24
+ <body class="layout-reverse sidebar-overlay">
25
+ {% include sidebar.html %}
26
+ <div class="wrap">
27
+ <div class="masthead">
28
+ <div class="container">
29
+ <h3 class="masthead-title">
30
+ <a href="/" title="Home">Example.com</a>
31
+ <small>Example!</small>
32
+ </h3>
33
+ </div>
34
+ </div>
35
+ <div class="container content">
36
+ {{ content }}
37
+ </div>
38
+ </div>
39
+ <label for="sidebar-checkbox" class="sidebar-toggle"></label>
40
+ <footer class="footer">
41
+ <div class="container">
42
+ <p class="text-muted text-center">&copy; Copyright {{ site.time | date: '%Y' }} Example. All rights reserved.</p>
43
+ </div>
44
+ </footer>
45
+
46
+ <script>
47
+ (function(document) {
48
+ var toggle = document.querySelector('.sidebar-toggle');
49
+ var sidebar = document.querySelector('#sidebar');
50
+ var checkbox = document.querySelector('#sidebar-checkbox');
51
+
52
+ document.addEventListener('click', function(e) {
53
+ var target = e.target;
54
+
55
+ if(!checkbox.checked ||
56
+ sidebar.contains(target) ||
57
+ (target === checkbox || target === toggle)) return;
58
+
59
+ checkbox.checked = false;
60
+ }, false);
61
+ })(document);
62
+ </script>
63
+ </body>
64
+ </html>
@@ -0,0 +1,8 @@
1
+ ---
2
+ layout: default
3
+ ---
4
+
5
+ <div class="page">
6
+ <h1 class="page-title">{{ page.title | capitalize }}</h1>
7
+ {{ content }}
8
+ </div>
@@ -0,0 +1,25 @@
1
+ ---
2
+ layout: default
3
+ ---
4
+
5
+ <div class="post">
6
+ <h1 class="post-title">{{ page.title }}</h1>
7
+ <span class="post-date">{{ page.date | date_to_string }}</span>
8
+ {{ content }}
9
+ </div>
10
+
11
+ <div class="related">
12
+ <h2>Related Posts</h2>
13
+ <ul class="related-posts">
14
+ {% for post in site.related_posts limit:3 %}
15
+ <li>
16
+ <h3>
17
+ <a href="{{ post.url | prepend: site.baseurl | prepend: site.url }}">
18
+ {{ post.title }}
19
+ <small>{{ post.date | date_to_string }}</small>
20
+ </a>
21
+ </h3>
22
+ </li>
23
+ {% endfor %}
24
+ </ul>
25
+ </div>
@@ -0,0 +1,240 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Jekyll category page generator.
4
+ # http://recursive-design.com/projects/jekyll-plugins/
5
+ #
6
+ # Version: 0.2.4 (201210160037)
7
+ #
8
+ # Copyright (c) 2010 Dave Perrett, http://recursive-design.com/
9
+ # Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
10
+ #
11
+ # A generator that creates category pages for jekyll sites.
12
+ #
13
+ # To use it, simply drop this script into the _plugins directory of your Jekyll site. You should
14
+ # also create a file called 'category_index.html' in the _layouts directory of your jekyll site
15
+ # with the following contents (note: you should remove the leading '# ' characters):
16
+ #
17
+ # ================================== COPY BELOW THIS LINE ==================================
18
+ # ---
19
+ # layout: default
20
+ # ---
21
+ #
22
+ # <h1 class="category">{{ page.title }}</h1>
23
+ # <ul class="posts">
24
+ # {% for post in site.categories[page.category] %}
25
+ # <div>{{ post.date | date_to_html_string }}</div>
26
+ # <h2><a href="{{ post.url }}">{{ post.title }}</a></h2>
27
+ # <div class="categories">Filed under {{ post.categories | category_links }}</div>
28
+ # {% endfor %}
29
+ # </ul>
30
+ # ================================== COPY ABOVE THIS LINE ==================================
31
+ #
32
+ # You can alter the _layout_ setting if you wish to use an alternate layout, and obviously you
33
+ # can change the HTML above as you see fit.
34
+ #
35
+ # When you compile your jekyll site, this plugin will loop through the list of categories in your
36
+ # site, and use the layout above to generate a page for each one with a list of links to the
37
+ # individual posts.
38
+ #
39
+ # You can also (optionally) generate an atom.xml feed for each category. To do this, copy
40
+ # the category_feed.xml file to the _includes/custom directory of your own project
41
+ # (https://github.com/recurser/jekyll-plugins/blob/master/_includes/custom/category_feed.xml).
42
+ # You'll also need to copy the octopress_filters.rb file into the _plugins directory of your
43
+ # project as the category_feed.xml requires a couple of extra filters
44
+ # (https://github.com/recurser/jekyll-plugins/blob/master/_plugins/octopress_filters.rb).
45
+ #
46
+ # Included filters :
47
+ # - category_links: Outputs the list of categories as comma-separated <a> links.
48
+ # - date_to_html_string: Outputs the post.date as formatted html, with hooks for CSS styling.
49
+ #
50
+ # Available _config.yml settings :
51
+ # - category_dir: The subfolder to build category pages in (default is 'categories').
52
+ # - category_title_prefix: The string used before the category name in the page title (default is
53
+ # 'Category: ').
54
+ module Jekyll
55
+
56
+ # The CategoryIndex class creates a single category page for the specified category.
57
+ class CategoryPage < Page
58
+
59
+ # Initializes a new CategoryIndex.
60
+ #
61
+ # +template_path+ is the path to the layout template to use.
62
+ # +site+ is the Jekyll Site instance.
63
+ # +base+ is the String path to the <source>.
64
+ # +category_dir+ is the String path between <source> and the category folder.
65
+ # +category+ is the category currently being processed.
66
+ def initialize(template_path, name, site, base, category_dir, category)
67
+ @site = site
68
+ @base = base
69
+ @dir = category_dir
70
+ @name = name
71
+
72
+ self.process(name)
73
+
74
+ if File.exist?(template_path)
75
+ @perform_render = true
76
+ template_dir = File.dirname(template_path)
77
+ template = File.basename(template_path)
78
+ # Read the YAML data from the layout page.
79
+ self.read_yaml(template_dir, template)
80
+ self.data['category'] = category
81
+ # Set the title for this page.
82
+ title_prefix = site.config['category_title_prefix'] || 'Category: '
83
+ self.data['title'] = "#{title_prefix}#{category}"
84
+ # Set the meta-description for this page.
85
+ meta_description_prefix = site.config['category_meta_description_prefix'] || 'Category: '
86
+ self.data['description'] = "#{meta_description_prefix}#{category}"
87
+ else
88
+ @perform_render = false
89
+ end
90
+ end
91
+
92
+ def render?
93
+ @perform_render
94
+ end
95
+
96
+ end
97
+
98
+ # The CategoryIndex class creates a single category page for the specified category.
99
+ class CategoryIndex < CategoryPage
100
+
101
+ # Initializes a new CategoryIndex.
102
+ #
103
+ # +site+ is the Jekyll Site instance.
104
+ # +base+ is the String path to the <source>.
105
+ # +category_dir+ is the String path between <source> and the category folder.
106
+ # +category+ is the category currently being processed.
107
+ def initialize(site, base, category_dir, category)
108
+ template_path = File.join(base, '_layouts', 'category_index.html')
109
+ super(template_path, 'index.html', site, base, category_dir, category)
110
+ end
111
+
112
+ end
113
+
114
+ # The CategoryFeed class creates an Atom feed for the specified category.
115
+ class CategoryFeed < CategoryPage
116
+
117
+ # Initializes a new CategoryFeed.
118
+ #
119
+ # +site+ is the Jekyll Site instance.
120
+ # +base+ is the String path to the <source>.
121
+ # +category_dir+ is the String path between <source> and the category folder.
122
+ # +category+ is the category currently being processed.
123
+ def initialize(site, base, category_dir, category)
124
+ template_path = File.join(base, '_includes', 'custom', 'category_feed.xml')
125
+ super(template_path, 'atom.xml', site, base, category_dir, category)
126
+
127
+ # Set the correct feed URL.
128
+ self.data['feed_url'] = "#{category_dir}/#{name}" if render?
129
+ end
130
+
131
+ end
132
+
133
+ # The Site class is a built-in Jekyll class with access to global site config information.
134
+ class Site
135
+
136
+ # Creates an instance of CategoryIndex for each category page, renders it, and
137
+ # writes the output to a file.
138
+ #
139
+ # +category+ is the category currently being processed.
140
+ def write_category_index(category)
141
+ target_dir = GenerateCategories.category_dir(self.config['category_dir'], category)
142
+ index = CategoryIndex.new(self, self.source, target_dir, category)
143
+ if index.render?
144
+ index.render(self.layouts, site_payload)
145
+ index.write(self.dest)
146
+ # Record the fact that this pages has been added, otherwise Site::cleanup will remove it.
147
+ self.pages << index
148
+ end
149
+
150
+ # Create an Atom-feed for each index.
151
+ feed = CategoryFeed.new(self, self.source, target_dir, category)
152
+ if feed.render?
153
+ feed.render(self.layouts, site_payload)
154
+ feed.write(self.dest)
155
+ # Record the fact that this pages has been added, otherwise Site::cleanup will remove it.
156
+ self.pages << feed
157
+ end
158
+ end
159
+
160
+ # Loops through the list of category pages and processes each one.
161
+ def write_category_indexes
162
+ if self.layouts.key? 'category_index'
163
+ self.categories.keys.each do |category|
164
+ self.write_category_index(category)
165
+ end
166
+
167
+ # Throw an exception if the layout couldn't be found.
168
+ else
169
+ throw "No 'category_index' layout found."
170
+ end
171
+ end
172
+
173
+ end
174
+
175
+
176
+ # Jekyll hook - the generate method is called by jekyll, and generates all of the category pages.
177
+ class GenerateCategories < Generator
178
+ safe true
179
+ priority :low
180
+
181
+ CATEGORY_DIR = 'categories'
182
+
183
+ def generate(site)
184
+ site.write_category_indexes
185
+ end
186
+
187
+ # Processes the given dir and removes leading and trailing slashes. Falls
188
+ # back on the default if no dir is provided.
189
+ def self.category_dir(base_dir, category)
190
+ base_dir = (base_dir || CATEGORY_DIR).gsub(/^\/*(.*)\/*$/, '\1')
191
+ category = category.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase
192
+ File.join(base_dir, category)
193
+ end
194
+
195
+ end
196
+
197
+
198
+ # Adds some extra filters used during the category creation process.
199
+ module Filters
200
+
201
+ # Outputs a list of categories as comma-separated <a> links. This is used
202
+ # to output the category list for each post on a category page.
203
+ #
204
+ # +categories+ is the list of categories to format.
205
+ #
206
+ # Returns string
207
+ def category_links(categories)
208
+ base_dir = @context.registers[:site].config['category_dir']
209
+ categories = categories.sort!.map do |category|
210
+ category_dir = GenerateCategories.category_dir(base_dir, category)
211
+ # Make sure the category directory begins with a slash.
212
+ category_dir = "/#{category_dir}" unless category_dir =~ /^\//
213
+ "<a class='category' href='#{category_dir}/'>#{category}</a>"
214
+ end
215
+
216
+ case categories.length
217
+ when 0
218
+ ""
219
+ when 1
220
+ categories[0].to_s
221
+ else
222
+ categories.join(', ')
223
+ end
224
+ end
225
+
226
+ # Outputs the post.date as formatted html, with hooks for CSS styling.
227
+ #
228
+ # +date+ is the date object to format as HTML.
229
+ #
230
+ # Returns string
231
+ def date_to_html_string(date)
232
+ result = '<span class="month">' + date.strftime('%b').upcase + '</span> '
233
+ result += date.strftime('<span class="day">%d</span> ')
234
+ result += date.strftime('<span class="year">%Y</span> ')
235
+ result
236
+ end
237
+
238
+ end
239
+
240
+ end
@@ -0,0 +1,9 @@
1
+ ---
2
+ layout: post
3
+ title: "Test Review 1"
4
+ date: 03/04/2012 00:00:00
5
+ description: Test Review 1
6
+ categories: reviews
7
+ ---
8
+
9
+ Test Review 1
@@ -0,0 +1,9 @@
1
+ ---
2
+ layout: post
3
+ title: "Test Review 2"
4
+ date: 03/04/2013 00:00:00
5
+ description: Test Review 2
6
+ categories: reviews
7
+ ---
8
+
9
+ Test Review 2
@@ -0,0 +1,9 @@
1
+ ---
2
+ layout: post
3
+ title: "Random"
4
+ date: 01/01/2015 00:00:00
5
+ description: Random!
6
+ categories: random
7
+ ---
8
+
9
+ Random!
@@ -0,0 +1,36 @@
1
+ html {
2
+ position: relative;
3
+ min-height: 100%;
4
+ }
5
+ body {
6
+ margin-bottom: 60px;
7
+ }
8
+ .footer {
9
+ position: absolute;
10
+ bottom: 0;
11
+ width: 100%;
12
+ height: 60px;
13
+ background-color: #f5f5f5;
14
+ }
15
+
16
+ .footer .container .text-muted {
17
+ margin: 20px 0;
18
+ }
19
+
20
+ #brandServiceList li>a {
21
+ background-color:#fff !important;
22
+ }
23
+
24
+ a.outlink {
25
+ text-decoration: none;
26
+ font-color: #000;
27
+ }
28
+
29
+ .list-nobullet {
30
+ list-style-type: none;
31
+ }
32
+
33
+ #logo {
34
+ display: inline-block;
35
+ height: 100px;
36
+ }
@@ -0,0 +1,28 @@
1
+ ---
2
+ title : Atom Feed
3
+ ---
4
+
5
+ <?xml version="1.0" encoding="utf-8"?>
6
+ <feed xmlns="http://www.w3.org/2005/Atom">
7
+ <title type="text" xml:lang="en">{{ site.title }}</title>
8
+ <link type="application/atom+xml" href="{{ site.baseurl | prepend: site.url }}/atom.xml" rel="self"/>
9
+ <link href="{{ site.baseurl | prepend: site.url }}/"/>
10
+ <updated>{{ site.time | date: "%Y-%m-%dT%H:%M:%SZ" }}</updated>
11
+ <id>{{ site.baseurl | prepend: site.url }}/</id>
12
+ <author>
13
+ <name>{{ site.author.name }}</name>
14
+ <email>{{ site.author.email }}</email>
15
+ </author>
16
+ <rights type="text">Copyright © {{ site.time | date: "%Y" }} {{ site.author.name }}. All Rights Reserved.</rights>
17
+ {% for post in site.posts limit:10 %}
18
+ <entry>
19
+ <title>{{ post.title | xml_escape }}</title>
20
+ <link rel="alternate" type="text/html" href="{{ post.url | prepend: site.baseurl | prepend: site.url }}" />
21
+ <published>{{ post.date | date: "%Y-%m-%dT%H:%M:%SZ" }}</published>
22
+ <updated>{{ post.date | date_to_xmlschema }}</updated>
23
+ <id>{{ post.url | prepend: site.baseurl | prepend: site.url }}</id>
24
+ <content type="html"><![CDATA[ {{ post.content | markdownify }} ]]></content>
25
+ </entry>
26
+ {% endfor %}
27
+
28
+ </feed>
@@ -0,0 +1,45 @@
1
+ ---
2
+ layout: default
3
+ title: Home
4
+ ---
5
+
6
+ <div class="posts">
7
+ {% for post in paginator.posts %}
8
+ <div class="post">
9
+ <h1 class="post-title">
10
+ <a href="{{ post.url | prepend: site.baseurl | prepend: site.url }}">
11
+ {{ post.title }}
12
+ </a>
13
+ </h1>
14
+
15
+ <span class="post-date">{{ post.date | date_to_string }}</span>
16
+
17
+ <p>
18
+ {{ post.excerpt }}
19
+ </p>
20
+ <p>
21
+ <a href="{{ post.url | prepend: site.baseurl | prepend: site.url }}" title="{{ post.title }}">
22
+ Read More
23
+ </a>
24
+ </p>
25
+ </div>
26
+ {% endfor %}
27
+ </div>
28
+
29
+ <div class="pagination">
30
+ {% if paginator.next_page %}
31
+ <a class="pagination-item older" href="{{ site.baseurl | prepend: site.url }}page{{paginator.next_page}}">Older</a>
32
+ {% else %}
33
+ <span class="pagination-item older">Older</span>
34
+ {% endif %}
35
+ {% if paginator.previous_page %}
36
+ {% if paginator.page == 2 %}
37
+ <a class="pagination-item newer" href="{{ site.baseurl | prepend: site.url }}">Newer</a>
38
+ {% else %}
39
+ <a class="pagination-item newer" href="{{ site.baseurl | prepend: site.url }}page{{paginator.previous_page}}">Newer</a>
40
+ {% endif %}
41
+ {% else %}
42
+ <span class="pagination-item newer">Newer</span>
43
+ {% endif %}
44
+ </div>
45
+
@@ -0,0 +1,150 @@
1
+ require 'spec_helper'
2
+
3
+ describe "JekyllMinifier" do
4
+ let(:overrides) { Hash.new }
5
+ let(:config) do
6
+ Jekyll.configuration(Jekyll::Utils.deep_merge_hashes({
7
+ "full_rebuild" => true,
8
+ "source" => source_dir,
9
+ "destination" => dest_dir,
10
+ "show_drafts" => true,
11
+ "url" => "http://example.org",
12
+ "name" => "My awesome site",
13
+ "author" => {
14
+ "name" => "Dr. Jekyll"
15
+ },
16
+ "collections" => {
17
+ "my_collection" => { "output" => true },
18
+ "other_things" => { "output" => false }
19
+ }
20
+ }, overrides))
21
+ end
22
+ let(:site) { Jekyll::Site.new(config) }
23
+ let(:context) { make_context(site: site) }
24
+ before(:each) do
25
+ site.process
26
+ end
27
+
28
+ context "test_atom" do
29
+ it "creates a atom.xml file" do
30
+ expect(Pathname.new(dest_dir("atom.xml"))).to exist
31
+ end
32
+
33
+ let(:atom) { File.read(dest_dir("atom.xml")) }
34
+
35
+ it "puts all the posts in the atom.xml file" do
36
+ expect(atom).to match "http://example.org/random/random.html"
37
+ expect(atom).to match "http://example.org/reviews/test-review-1.html"
38
+ expect(atom).to match "http://example.org/reviews/test-review-2.html"
39
+ end
40
+
41
+ let(:feed) { RSS::Parser.parse(atom) }
42
+
43
+ it "outputs an RSS feed" do
44
+ expect(feed.feed_type).to eql("atom")
45
+ expect(feed.feed_version).to eql("1.0")
46
+ expect(feed.encoding).to eql("UTF-8")
47
+ end
48
+
49
+ it "outputs the link" do
50
+ expect(feed.link.href).to eql("http://example.org/atom.xml")
51
+ end
52
+ end
53
+
54
+ context "test_css" do
55
+ it "creates a assets/css/style.css file" do
56
+ expect(Pathname.new(dest_dir("assets/css/style.css"))).to exist
57
+ end
58
+
59
+ let(:file) { File.read(dest_dir("assets/css/style.css")) }
60
+
61
+ it "ensures assets/css/style.css file has length" do
62
+ expect(file.length).to be > 0
63
+ end
64
+ end
65
+
66
+ context "test_404" do
67
+ it "creates a 404.html file" do
68
+ expect(Pathname.new(dest_dir("404.html"))).to exist
69
+ end
70
+
71
+ let(:file) { File.read(dest_dir("404.html")) }
72
+
73
+ it "ensures 404.html file has length" do
74
+ expect(file.length).to be > 0
75
+ end
76
+ end
77
+
78
+ context "test_index" do
79
+ it "creates a index.html file" do
80
+ expect(Pathname.new(dest_dir("index.html"))).to exist
81
+ end
82
+
83
+ let(:file) { File.read(dest_dir("index.html")) }
84
+
85
+ it "ensures index.html file has length" do
86
+ expect(file.length).to be > 0
87
+ end
88
+ end
89
+
90
+ context "test_random_index" do
91
+ it "creates a random/index.html file" do
92
+ expect(Pathname.new(dest_dir("random/index.html"))).to exist
93
+ end
94
+
95
+ let(:file) { File.read(dest_dir("random/index.html")) }
96
+
97
+ it "ensures random/index.html file has length" do
98
+ expect(file.length).to be > 0
99
+ end
100
+ end
101
+
102
+ context "test_random_random" do
103
+ it "creates a random/random.html file" do
104
+ expect(Pathname.new(dest_dir("random/random.html"))).to exist
105
+ end
106
+
107
+ let(:file) { File.read(dest_dir("random/random.html")) }
108
+
109
+ it "ensures random/random.html file has length" do
110
+ expect(file.length).to be > 0
111
+ end
112
+ end
113
+
114
+ context "test_reviews_index" do
115
+ it "creates a reviews/index.html file" do
116
+ expect(Pathname.new(dest_dir("reviews/index.html"))).to exist
117
+ end
118
+
119
+ let(:file) { File.read(dest_dir("reviews/index.html")) }
120
+
121
+ it "ensures reviews/index.html file has length" do
122
+ expect(file.length).to be > 0
123
+ end
124
+ end
125
+
126
+ context "test_reviews_test-review-1" do
127
+ it "creates a reviews/test-review-1.html file" do
128
+ expect(Pathname.new(dest_dir("reviews/test-review-1.html"))).to exist
129
+ end
130
+
131
+ let(:file) { File.read(dest_dir("reviews/test-review-1.html")) }
132
+
133
+ it "ensures reviews/test-review-1.html file has length" do
134
+ expect(file.length).to be > 0
135
+ end
136
+ end
137
+
138
+ context "test_reviews_test-review-2" do
139
+ it "creates a reviews/test-review-2.html file" do
140
+ expect(Pathname.new(dest_dir("reviews/test-review-2.html"))).to exist
141
+ end
142
+
143
+ let(:file) { File.read(dest_dir("reviews/test-review-2.html")) }
144
+
145
+ it "ensures reviews/test-review-2.html file has length" do
146
+ expect(file.length).to be > 0
147
+ end
148
+ end
149
+
150
+ end
@@ -0,0 +1,24 @@
1
+ require 'jekyll'
2
+ require 'rss'
3
+ require 'rspec'
4
+ require File.expand_path('../lib/jekyll-minifier', File.dirname(__FILE__))
5
+
6
+ Jekyll.logger.log_level = :error
7
+
8
+ RSpec.configure do |config|
9
+
10
+ SOURCE_DIR = File.expand_path("../fixtures", __FILE__)
11
+ DEST_DIR = File.expand_path("../dest", __FILE__)
12
+
13
+ def source_dir(*files)
14
+ File.join(SOURCE_DIR, *files)
15
+ end
16
+
17
+ def dest_dir(*files)
18
+ File.join(DEST_DIR, *files)
19
+ end
20
+
21
+ def make_context(registers = {})
22
+ Liquid::Context.new({}, {}, { site: site }.merge(registers))
23
+ end
24
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-minifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - DigitalSparky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-14 00:00:00.000000000 Z
11
+ date: 2017-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -80,6 +80,48 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '10.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.7'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.7'
97
+ - !ruby/object:Gem::Dependency
98
+ name: jekyll-paginate
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: redcarpet
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
83
125
  description: Jekyll Minifier using htmlcompressor for html, uglifier for js and css
84
126
  email:
85
127
  - matthew@spurrier.com.au
@@ -87,6 +129,8 @@ executables: []
87
129
  extensions: []
88
130
  extra_rdoc_files: []
89
131
  files:
132
+ - ".gitignore"
133
+ - ".travis.yml"
90
134
  - Gemfile
91
135
  - LICENSE
92
136
  - README.md
@@ -94,6 +138,22 @@ files:
94
138
  - jekyll-minifier.gemspec
95
139
  - lib/jekyll-minifier.rb
96
140
  - lib/jekyll-minifier/version.rb
141
+ - spec/fixtures/404.html
142
+ - spec/fixtures/_config.yml
143
+ - spec/fixtures/_includes/sidebar.html
144
+ - spec/fixtures/_layouts/category_index.html
145
+ - spec/fixtures/_layouts/default.html
146
+ - spec/fixtures/_layouts/page.html
147
+ - spec/fixtures/_layouts/post.html
148
+ - spec/fixtures/_plugins/generate_categories.rb
149
+ - spec/fixtures/_posts/2012-04-03-test-review-1.markdown
150
+ - spec/fixtures/_posts/2013-04-03-test-review-2.markdown
151
+ - spec/fixtures/_posts/2015-01-01-random.markdown
152
+ - spec/fixtures/assets/css/style.css
153
+ - spec/fixtures/atom.xml
154
+ - spec/fixtures/index.html
155
+ - spec/jekyll-minifier_spec.rb
156
+ - spec/spec_helper.rb
97
157
  homepage: http://github.com/digitalsparky/jekyll-minifier
98
158
  licenses:
99
159
  - GPL-3.0
@@ -118,4 +178,20 @@ rubygems_version: 2.5.1
118
178
  signing_key:
119
179
  specification_version: 2
120
180
  summary: Jekyll Minifier for html, css, and javascript
121
- test_files: []
181
+ test_files:
182
+ - spec/fixtures/404.html
183
+ - spec/fixtures/_config.yml
184
+ - spec/fixtures/_includes/sidebar.html
185
+ - spec/fixtures/_layouts/category_index.html
186
+ - spec/fixtures/_layouts/default.html
187
+ - spec/fixtures/_layouts/page.html
188
+ - spec/fixtures/_layouts/post.html
189
+ - spec/fixtures/_plugins/generate_categories.rb
190
+ - spec/fixtures/_posts/2012-04-03-test-review-1.markdown
191
+ - spec/fixtures/_posts/2013-04-03-test-review-2.markdown
192
+ - spec/fixtures/_posts/2015-01-01-random.markdown
193
+ - spec/fixtures/assets/css/style.css
194
+ - spec/fixtures/atom.xml
195
+ - spec/fixtures/index.html
196
+ - spec/jekyll-minifier_spec.rb
197
+ - spec/spec_helper.rb