webgen 1.4.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d93b547db495a7469b8a3b038da5ab6eae16c083
4
- data.tar.gz: d634fdc3f669cde58f29346d2a769c1ecd1bdbf3
2
+ SHA256:
3
+ metadata.gz: c7503141411c417cebfe4ce07f0c73743cb0d3d8f1106df4c44c10c002b36e21
4
+ data.tar.gz: 27b7f63d682a006ad8d29708541abe0ad2684d83660d548ae4c133c025ae4137
5
5
  SHA512:
6
- metadata.gz: 8e82628dd6abefd5c7eee3266e77b0a435671486a0460e014c9ba46b6c7e29552cb9bdcbf152e1be3ee1dcc66501ec71a4c6a4434d311ab68bb785ff94ab0d81
7
- data.tar.gz: 838e654ae206a8a79554ac6c71d46daa4719758518c60a5e117f4068c07777fc6d0e0f917974081ed07dfbdbef1325fab144ec2442467820fd708f7ffad63f2b
6
+ metadata.gz: d48ff1a6abfd6fa03cb13da0fe4f65997049f93bdd4112cadbe877971e93cf6ad46a205db7ccc9bbc3cb3a5e978772f391a936e030804273dcfbcc9f60b51755
7
+ data.tar.gz: 8ddcc6251a2004df145341c3185d7d629f42c828ce3bc93dc5a85ef6e952f6baa46fcddc6ab586eebb44e8322bfe443d9b721115ded0c3a765557bbb7f7677c3
data/Rakefile CHANGED
@@ -123,6 +123,7 @@ EOF
123
123
  s.add_development_dependency('erubis', '~> 2.6')
124
124
  s.add_development_dependency('rdiscount', '~> 1.3')
125
125
  s.add_development_dependency('archive-tar-minitar', '~> 0.5')
126
+ s.add_development_dependency('cssminify', '~> 1.0')
126
127
 
127
128
  s.files = PKG_FILES.to_a
128
129
  s.require_path = 'lib'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.1
1
+ 1.5.0
@@ -22,6 +22,9 @@ extensions:
22
22
  content_processor.builder:
23
23
  author: *author
24
24
  summary: Allows one to programatically create valid XHTML/XML documents
25
+ content_processor.cssminify:
26
+ author: *author
27
+ summary: Compresses CSS files
25
28
  content_processor.erb:
26
29
  author: *author
27
30
  summary: Allows one to use ERB (embedded Ruby) in the content
@@ -63,6 +63,7 @@ require 'webgen/content_processor'
63
63
  website.ext.content_processor = content_processor = Webgen::ContentProcessor.new
64
64
  content_processor.register('Blocks')
65
65
  content_processor.register('Builder')
66
+ content_processor.register('CSSMinify', :name => 'cssminify')
66
67
  content_processor.register('Erb')
67
68
  option('content_processor.erb.trim_mode', '', &is_string)
68
69
 
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'webgen/content_processor'
4
+ webgen_require 'cssminify'
5
+
6
+ module Webgen
7
+ class ContentProcessor
8
+
9
+ # Minifies CSS files.
10
+ module CSSMinify
11
+
12
+ # Process the content of +context+ with CSSMinify (a CSS minifier).
13
+ def self.call(context)
14
+ context.content = ::CSSminify.compress(context.content)
15
+ context
16
+ end
17
+
18
+ end
19
+
20
+ end
21
+ end
@@ -161,7 +161,7 @@ module Webgen
161
161
  # exists, the language part is forced to be in the destination path and the resulting
162
162
  # destination path is returned.
163
163
  def dest_path(parent, path)
164
- path.meta_info['dest_path'] ||= '<parent><basename>(-<version>)(.<lang>)<ext>'
164
+ path.meta_info['dest_path'] ||= '<parent><basename>(-<version>)(-<modified_at>)(.<lang>)<ext>'
165
165
  dpath = construct_dest_path(parent, path, false)
166
166
  if (node = node_exists?(path, dpath)) && node.lang != path.meta_info['lang']
167
167
  dpath = construct_dest_path(parent, path, true)
@@ -216,6 +216,8 @@ module Webgen
216
216
  use_lang_part ? path.meta_info['lang'] : ''
217
217
  when "<version>"
218
218
  use_version_part ? path.meta_info['version'] : ''
219
+ when "<modified_at>"
220
+ path.meta_info['modified_at_in_dest_path'] ? path.meta_info['modified_at'].strftime('%Y%m%d%H%M%S') : ''
219
221
  when /<(year|month|day)>/
220
222
  ctime = path.meta_info['created_at']
221
223
  if !ctime.kind_of?(Time)
@@ -3,6 +3,6 @@
3
3
  module Webgen
4
4
 
5
5
  # The version of webgen.
6
- VERSION = '1.4.1'
6
+ VERSION = '1.5.0'
7
7
 
8
8
  end
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'webgen/test_helper'
4
+ require 'webgen/content_processor/css_minify'
5
+
6
+ class TestContentProcessorCSSMinify < Minitest::Test
7
+
8
+ include Webgen::TestHelper
9
+
10
+ def test_static_call
11
+ setup_context
12
+ cp = Webgen::ContentProcessor::CSSMinify
13
+
14
+ @context.content = "a \n{ border: 1px solid #000000\n}"
15
+ assert_equal("a{border:1px solid #000}", cp.call(@context).content)
16
+ end
17
+
18
+ end
@@ -60,7 +60,7 @@ class TestPathHandlerBase < Minitest::Test
60
60
  assert_equal(expected, @obj.dest_path(parent, Webgen::Path.new(path, mi)))
61
61
  end
62
62
 
63
- mi = {'dest_path' => '<parent><basename>(-<version>)(.<lang>)<ext>'}
63
+ mi = {'dest_path' => '<parent><basename>(-<version>)(-<modified_at>)(.<lang>)<ext>'}
64
64
 
65
65
  config['path_handler.lang_code_in_dest_path'] = true
66
66
  check_dest_path.call('/path.html', mi, '/path.html')
@@ -128,6 +128,10 @@ class TestPathHandlerBase < Minitest::Test
128
128
  check_dest_path.call('/path.html', {'dest_path' => "webgen:this is not changed"},
129
129
  'this is not changed')
130
130
 
131
+ check_dest_path.call('/path.css', mi.merge('modified_at_in_dest_path' => true,
132
+ 'modified_at' => Time.parse('2018-05-06 08:30:05')),
133
+ '/path-20180506083005.css')
134
+
131
135
  assert_raises(Webgen::NodeCreationError) do
132
136
  check_dest_path.call('/path.html', {'dest_path' => "<hallo>"}, 'unused')
133
137
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webgen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Leitner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-26 00:00:00.000000000 Z
11
+ date: 2018-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cmdparse
@@ -240,6 +240,20 @@ dependencies:
240
240
  - - "~>"
241
241
  - !ruby/object:Gem::Version
242
242
  version: '0.5'
243
+ - !ruby/object:Gem::Dependency
244
+ name: cssminify
245
+ requirement: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - "~>"
248
+ - !ruby/object:Gem::Version
249
+ version: '1.0'
250
+ type: :development
251
+ prerelease: false
252
+ version_requirements: !ruby/object:Gem::Requirement
253
+ requirements:
254
+ - - "~>"
255
+ - !ruby/object:Gem::Version
256
+ version: '1.0'
243
257
  description: |
244
258
  webgen is used to generate static websites from templates and content
245
259
  files (which can be written in a markup language). It can generate
@@ -303,6 +317,7 @@ files:
303
317
  - lib/webgen/content_processor.rb
304
318
  - lib/webgen/content_processor/blocks.rb
305
319
  - lib/webgen/content_processor/builder.rb
320
+ - lib/webgen/content_processor/css_minify.rb
306
321
  - lib/webgen/content_processor/erb.rb
307
322
  - lib/webgen/content_processor/erubis.rb
308
323
  - lib/webgen/content_processor/fragments.rb
@@ -392,6 +407,7 @@ files:
392
407
  - test/webgen/cli/test_logger.rb
393
408
  - test/webgen/content_processor/test_blocks.rb
394
409
  - test/webgen/content_processor/test_builder.rb
410
+ - test/webgen/content_processor/test_css_minify.rb
395
411
  - test/webgen/content_processor/test_erb.rb
396
412
  - test/webgen/content_processor/test_erubis.rb
397
413
  - test/webgen/content_processor/test_fragments.rb
@@ -501,7 +517,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
501
517
  version: '0'
502
518
  requirements: []
503
519
  rubyforge_project:
504
- rubygems_version: 2.6.8
520
+ rubygems_version: 2.7.3
505
521
  signing_key:
506
522
  specification_version: 4
507
523
  summary: webgen is a fast, powerful, and extensible static website generator.