jekyll 4.0.0.pre.alpha1 → 4.0.0.pre.beta1

Sign up to get free protection for your applications and to get access to all the features.
@@ -161,13 +161,15 @@ module Jekyll
161
161
 
162
162
  # Filter an array of objects
163
163
  #
164
- # input - the object array
165
- # property - property within each object to filter by
166
- # value - desired value
164
+ # input - the object array.
165
+ # property - the property within each object to filter by.
166
+ # value - the desired value.
167
+ # Cannot be an instance of Array nor Hash since calling #to_s on them returns
168
+ # their `#inspect` string object.
167
169
  #
168
170
  # Returns the filtered array of objects
169
171
  def where(input, property, value)
170
- return input if property.nil? || value.nil?
172
+ return input if !property || value.is_a?(Array) || value.is_a?(Hash)
171
173
  return input unless input.respond_to?(:select)
172
174
 
173
175
  input = input.values if input.is_a?(Hash)
@@ -182,8 +184,8 @@ module Jekyll
182
184
  # stash or retrive results to return
183
185
  @where_filter_cache[input_id][property][value] ||= begin
184
186
  input.select do |object|
185
- Array(item_property(object, property)).map!(&:to_s).include?(value.to_s)
186
- end || []
187
+ compare_property_vs_target(item_property(object, property), value)
188
+ end.to_a
187
189
  end
188
190
  end
189
191
 
@@ -323,6 +325,33 @@ module Jekyll
323
325
  .map!(&:last)
324
326
  end
325
327
 
328
+ # `where` filter helper
329
+ #
330
+ # rubocop:disable Metrics/CyclomaticComplexity
331
+ # rubocop:disable Metrics/PerceivedComplexity
332
+ def compare_property_vs_target(property, target)
333
+ case target
334
+ when NilClass
335
+ return true if property.nil?
336
+ when Liquid::Expression::MethodLiteral # `empty` or `blank`
337
+ target = target.to_s
338
+ return true if property == target || Array(property).join == target
339
+ else
340
+ target = target.to_s
341
+ if property.is_a? String
342
+ return true if property == target
343
+ else
344
+ Array(property).each do |prop|
345
+ return true if prop.to_s == target
346
+ end
347
+ end
348
+ end
349
+
350
+ false
351
+ end
352
+ # rubocop:enable Metrics/CyclomaticComplexity
353
+ # rubocop:enable Metrics/PerceivedComplexity
354
+
326
355
  def item_property(item, property)
327
356
  @item_property_cache ||= {}
328
357
  @item_property_cache[property] ||= {}
@@ -339,6 +368,7 @@ module Jekyll
339
368
  end
340
369
  end
341
370
 
371
+ # rubocop:disable Performance/RegexpMatch
342
372
  # return numeric values as numbers for proper sorting
343
373
  def parse_sort_input(property)
344
374
  number_like = %r!\A\s*-?(?:\d+\.?\d*|\.\d+)\s*\Z!
@@ -346,6 +376,7 @@ module Jekyll
346
376
 
347
377
  property
348
378
  end
379
+ # rubocop:enable Performance/RegexpMatch
349
380
 
350
381
  def as_liquid(item)
351
382
  case item
@@ -10,11 +10,10 @@ module Jekyll
10
10
  # Initializes a new instance.
11
11
  def initialize(site)
12
12
  @site = site
13
- reset
14
13
  end
15
14
 
16
15
  def reset
17
- @glob_cache = {}
16
+ @glob_cache = {} if @glob_cache
18
17
  end
19
18
 
20
19
  def update_deprecated_types(set)
@@ -112,7 +111,7 @@ module Jekyll
112
111
  if scope["path"].to_s.include?("*")
113
112
  glob_scope(sanitized_path, rel_scope_path)
114
113
  else
115
- path_is_subpath?(sanitized_path, strip_collections_dir(rel_scope_path))
114
+ path_is_subpath?(sanitized_path, strip_collections_dir(scope["path"]))
116
115
  end
117
116
  end
118
117
 
@@ -121,7 +120,7 @@ module Jekyll
121
120
  abs_scope_path = site_source.join(rel_scope_path).to_s
122
121
 
123
122
  glob_cache(abs_scope_path).each do |scope_path|
124
- scope_path = Pathname.new(scope_path).relative_path_from(site_source)
123
+ scope_path = Pathname.new(scope_path).relative_path_from(site_source).to_s
125
124
  scope_path = strip_collections_dir(scope_path)
126
125
  Jekyll.logger.debug "Globbed Scope Path:", scope_path
127
126
  return true if path_is_subpath?(sanitized_path, scope_path)
@@ -130,6 +129,7 @@ module Jekyll
130
129
  end
131
130
 
132
131
  def glob_cache(path)
132
+ @glob_cache ||= {}
133
133
  @glob_cache[path] ||= Dir.glob(path)
134
134
  end
135
135
 
@@ -143,7 +143,7 @@ module Jekyll
143
143
 
144
144
  def strip_collections_dir(path)
145
145
  collections_dir = @site.config["collections_dir"]
146
- slashed_coll_dir = "#{collections_dir}/"
146
+ slashed_coll_dir = collections_dir.empty? ? "/" : "#{collections_dir}/"
147
147
  return path if collections_dir.empty? || !path.to_s.start_with?(slashed_coll_dir)
148
148
 
149
149
  path.sub(slashed_coll_dir, "")
@@ -3,6 +3,8 @@
3
3
  module Jekyll
4
4
  class LiquidRenderer
5
5
  class Table
6
+ GAUGES = [:count, :bytes, :time].freeze
7
+
6
8
  def initialize(stats)
7
9
  @stats = stats
8
10
  end
@@ -19,6 +21,8 @@ module Jekyll
19
21
  str = +"\n"
20
22
 
21
23
  table_head = data.shift
24
+ table_foot = data.pop
25
+
22
26
  str << generate_row(table_head, widths)
23
27
  str << generate_table_head_border(table_head, widths)
24
28
 
@@ -26,6 +30,9 @@ module Jekyll
26
30
  str << generate_row(row_data, widths)
27
31
  end
28
32
 
33
+ str << generate_table_head_border(table_foot, widths)
34
+ str << generate_row(table_foot, widths).rstrip
35
+
29
36
  str << "\n"
30
37
  str
31
38
  end
@@ -71,13 +78,16 @@ module Jekyll
71
78
  widths
72
79
  end
73
80
 
81
+ # rubocop:disable Metrics/AbcSize
74
82
  def data_for_table(num_of_rows)
75
83
  sorted = @stats.sort_by { |_, file_stats| -file_stats[:time] }
76
84
  sorted = sorted.slice(0, num_of_rows)
77
85
 
78
- table = [%w(Filename Count Bytes Time)]
86
+ table = [header_labels]
87
+ totals = Hash.new { |hash, key| hash[key] = 0 }
79
88
 
80
89
  sorted.each do |filename, file_stats|
90
+ GAUGES.each { |gauge| totals[gauge] += file_stats[gauge] }
81
91
  row = []
82
92
  row << filename
83
93
  row << file_stats[:count].to_s
@@ -86,7 +96,17 @@ module Jekyll
86
96
  table << row
87
97
  end
88
98
 
89
- table
99
+ footer = []
100
+ footer << "TOTAL (for #{sorted.size} files)"
101
+ footer << totals[:count].to_s
102
+ footer << format_bytes(totals[:bytes])
103
+ footer << format("%.3f", totals[:time])
104
+ table << footer
105
+ end
106
+ # rubocop:enable Metrics/AbcSize
107
+
108
+ def header_labels
109
+ GAUGES.map { |gauge| gauge.to_s.capitalize }.unshift("Filename")
90
110
  end
91
111
 
92
112
  def format_bytes(bytes)
@@ -19,18 +19,17 @@ application/davmount+xml davmou
19
19
  application/docbook+xml dbk
20
20
  application/dssc+der dssc
21
21
  application/dssc+xml xdssc
22
- application/ecmascript ecma
22
+ application/ecmascript ecma es
23
23
  application/emma+xml emma
24
24
  application/epub+zip epub
25
25
  application/exi exi
26
26
  application/font-tdpfr pfr
27
- application/font-woff woff
28
- application/font-woff2 woff2
29
27
  application/geo+json geojson
30
28
  application/gml+xml gml
31
29
  application/gpx+xml gpx
32
30
  application/gxf gxf
33
31
  application/gzip gz
32
+ application/hjson hjson
34
33
  application/hyperstudio stk
35
34
  application/inkml+xml ink inkml
36
35
  application/ipfix ipfix
@@ -61,6 +60,8 @@ application/mp21 m21 mp
61
60
  application/mp4 mp4s m4p
62
61
  application/msword doc dot
63
62
  application/mxf mxf
63
+ application/n-quads nq
64
+ application/n-triples nt
64
65
  application/octet-stream bin dms lrf mar so dist distz pkg bpk dump elc deploy exe dll deb dmg iso img msi msp msm buffer
65
66
  application/oda oda
66
67
  application/oebps-package+xml opf
@@ -86,7 +87,8 @@ application/pls+xml pls
86
87
  application/postscript ai eps ps
87
88
  application/prs.cww cww
88
89
  application/pskc+xml pskcxml
89
- application/rdf+xml rdf
90
+ application/raml+yaml raml
91
+ application/rdf+xml rdf owl
90
92
  application/reginfo+xml rif
91
93
  application/relax-ng-compact-syntax rnc
92
94
  application/resource-lists+xml rl
@@ -107,6 +109,7 @@ application/sdp sdp
107
109
  application/set-payment-initiation setpay
108
110
  application/set-registration-initiation setreg
109
111
  application/shf+xml shf
112
+ application/sieve siv sieve
110
113
  application/smil+xml smi smil
111
114
  application/sparql-query rq
112
115
  application/sparql-results+xml srx
@@ -143,7 +146,10 @@ application/vnd.anser-web-certificate-issue-initiation cii
143
146
  application/vnd.anser-web-funds-transfer-initiation fti
144
147
  application/vnd.antix.game-component atx
145
148
  application/vnd.apple.installer+xml mpkg
149
+ application/vnd.apple.keynote keynote
146
150
  application/vnd.apple.mpegurl m3u8
151
+ application/vnd.apple.numbers numbers
152
+ application/vnd.apple.pages pages
147
153
  application/vnd.apple.pkpass pkpass
148
154
  application/vnd.aristanetworks.swi swi
149
155
  application/vnd.astraea-software.iota iota
@@ -154,6 +160,7 @@ application/vnd.businessobjects rep
154
160
  application/vnd.chemdraw+xml cdxml
155
161
  application/vnd.chipnuts.karaoke-mmd mmd
156
162
  application/vnd.cinderella cdy
163
+ application/vnd.citationstyles.style+xml csl
157
164
  application/vnd.claymore cla
158
165
  application/vnd.cloanto.rp9 rp9
159
166
  application/vnd.clonk.c4group c4g c4d c4f c4p c4u
@@ -482,6 +489,7 @@ application/vnd.yellowriver-custom-menu cmp
482
489
  application/vnd.zul zir zirz
483
490
  application/vnd.zzazz.deck+xml zaz
484
491
  application/voicexml+xml vxml
492
+ application/wasm wasm
485
493
  application/widget wgt
486
494
  application/winhlp hlp
487
495
  application/wsdl+xml wsdl
@@ -521,10 +529,8 @@ application/x-eva eva
521
529
  application/x-font-bdf bdf
522
530
  application/x-font-ghostscript gsf
523
531
  application/x-font-linux-psf psf
524
- application/x-font-otf otf
525
532
  application/x-font-pcf pcf
526
533
  application/x-font-snf snf
527
- application/x-font-ttf ttf ttc
528
534
  application/x-font-type1 pfa pfb pfm afm
529
535
  application/x-freearc arc
530
536
  application/x-futuresplash spl
@@ -661,20 +667,41 @@ chemical/x-cmdf cmdf
661
667
  chemical/x-cml cml
662
668
  chemical/x-csml csml
663
669
  chemical/x-xyz xyz
670
+ font/collection ttc
671
+ font/otf otf
672
+ font/ttf ttf
673
+ font/woff woff
674
+ font/woff2 woff2
675
+ image/aces exr
664
676
  image/apng apng
665
677
  image/bmp bmp
666
678
  image/cgm cgm
679
+ image/dicom-rle drle
680
+ image/fits fits
667
681
  image/g3fax g3
668
682
  image/gif gif
683
+ image/heic heic
684
+ image/heic-sequence heics
685
+ image/heif heif
686
+ image/heif-sequence heifs
669
687
  image/ief ief
688
+ image/jls jls
689
+ image/jp2 jp2 jpg2
670
690
  image/jpeg jpeg jpg jpe
691
+ image/jpm jpm
692
+ image/jpx jpx jpf
693
+ image/jxr jxr
671
694
  image/ktx ktx
672
695
  image/png png
673
696
  image/prs.btif btif
697
+ image/prs.pti pti
674
698
  image/sgi sgi
675
699
  image/svg+xml svg svgz
676
- image/tiff tiff tif
700
+ image/t38 t38
701
+ image/tiff tif tiff
702
+ image/tiff-fx tfx
677
703
  image/vnd.adobe.photoshop psd
704
+ image/vnd.airzip.accelerator.azv azv
678
705
  image/vnd.dece.graphic uvi uvvi uvg uvvg
679
706
  image/vnd.djvu djvu djv
680
707
  image/vnd.dvb.subtitle sub
@@ -685,20 +712,22 @@ image/vnd.fpx fpx
685
712
  image/vnd.fst fst
686
713
  image/vnd.fujixerox.edmics-mmr mmr
687
714
  image/vnd.fujixerox.edmics-rlc rlc
715
+ image/vnd.microsoft.icon ico
688
716
  image/vnd.ms-modi mdi
689
717
  image/vnd.ms-photo wdp
690
718
  image/vnd.net-fpx npx
719
+ image/vnd.tencent.tap tap
720
+ image/vnd.valve.source.texture vtf
691
721
  image/vnd.wap.wbmp wbmp
692
722
  image/vnd.xiff xif
723
+ image/vnd.zbrush.pcx pcx
693
724
  image/webp webp
694
725
  image/x-3ds 3ds
695
726
  image/x-cmu-raster ras
696
727
  image/x-cmx cmx
697
728
  image/x-freehand fh fhc fh4 fh5 fh7
698
- image/x-icon ico
699
729
  image/x-jng jng
700
730
  image/x-mrsid-image sid
701
- image/x-pcx pcx
702
731
  image/x-pict pic pct
703
732
  image/x-portable-anymap pnm
704
733
  image/x-portable-bitmap pbm
@@ -709,7 +738,14 @@ image/x-tga tga
709
738
  image/x-xbitmap xbm
710
739
  image/x-xpixmap xpm
711
740
  image/x-xwindowdump xwd
741
+ message/disposition-notification disposition-notification
742
+ message/global u8msg
743
+ message/global-delivery-status u8dsn
744
+ message/global-disposition-notification u8mdn
745
+ message/global-headers u8hdr
712
746
  message/rfc822 eml mime
747
+ message/vnd.wfa.wsc wsc
748
+ model/3mf 3mf
713
749
  model/gltf+json gltf
714
750
  model/gltf-binary glb
715
751
  model/iges igs iges
@@ -719,6 +755,11 @@ model/vnd.dwf dwf
719
755
  model/vnd.gdl gdl
720
756
  model/vnd.gtw gtw
721
757
  model/vnd.mts mts
758
+ model/vnd.opengex ogex
759
+ model/vnd.parasolid.transmit.binary x_b
760
+ model/vnd.parasolid.transmit.text x_t
761
+ model/vnd.usdz+zip usdz
762
+ model/vnd.valve.source.compiled-map bsp
722
763
  model/vnd.vtu vtu
723
764
  model/vrml wrl vrml
724
765
  model/x3d+binary x3db x3dbz
@@ -729,18 +770,19 @@ text/calendar ics if
729
770
  text/coffeescript coffee litcoffee
730
771
  text/css css
731
772
  text/csv csv
732
- text/hjson hjson
733
773
  text/html html htm shtml
734
774
  text/jade jade
735
775
  text/jsx jsx
736
776
  text/less less
737
777
  text/markdown markdown md
738
778
  text/mathml mml
779
+ text/mdx mdx
739
780
  text/n3 n3
740
781
  text/plain txt text conf def list log in ini
741
782
  text/prs.lines.tag dsc
742
783
  text/richtext rtx
743
784
  text/sgml sgml sgm
785
+ text/shex shex
744
786
  text/slim slim slm
745
787
  text/stylus stylus styl
746
788
  text/tab-separated-values tsv
@@ -788,7 +830,7 @@ video/h261 h261
788
830
  video/h263 h263
789
831
  video/h264 h264
790
832
  video/jpeg jpgv
791
- video/jpm jpm jpgm
833
+ video/jpm jpgm
792
834
  video/mj2 mj2 mjp2
793
835
  video/mp2t ts
794
836
  video/mp4 mp4 mp4v mpg4
@@ -47,7 +47,7 @@ module Jekyll
47
47
  end
48
48
 
49
49
  process(name)
50
- read_yaml(File.join(base, dir), name)
50
+ read_yaml(PathManager.join(base, dir), name)
51
51
 
52
52
  data.default_proc = proc do |_, key|
53
53
  site.frontmatter_defaults.find(relative_path, type, key)
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ # A singleton class that caches frozen instances of path strings returned from its methods.
5
+ #
6
+ # NOTE:
7
+ # This class exists because `File.join` allocates an Array and returns a new String on every
8
+ # call using **the same arguments**. Caching the result means reduced memory usage.
9
+ # However, the caches are never flushed so that they can be used even when a site is
10
+ # regenerating. The results are frozen to deter mutation of the cached string.
11
+ #
12
+ # Therefore, employ this class only for situations where caching the result is necessary
13
+ # for performance reasons.
14
+ #
15
+ class PathManager
16
+ # This class cannot be initialized from outside
17
+ private_class_method :new
18
+
19
+ # Wraps `File.join` to cache the frozen result.
20
+ # Reassigns `nil`, empty strings and empty arrays to a frozen empty string beforehand.
21
+ #
22
+ # Returns a frozen string.
23
+ def self.join(base, item)
24
+ base = "" if base.nil? || base.empty?
25
+ item = "" if item.nil? || item.empty?
26
+ @join ||= {}
27
+ @join[base] ||= {}
28
+ @join[base][item] ||= File.join(base, item).freeze
29
+ end
30
+ end
31
+ end
@@ -85,7 +85,7 @@ module Jekyll
85
85
  def retrieve_dirs(_base, dir, dot_dirs)
86
86
  dot_dirs.each do |file|
87
87
  dir_path = site.in_source_dir(dir, file)
88
- rel_path = File.join(dir, file)
88
+ rel_path = PathManager.join(dir, file)
89
89
  @site.reader.read_directories(rel_path) unless @site.dest.chomp("/") == dir_path
90
90
  end
91
91
  end
@@ -161,11 +161,14 @@ module Jekyll
161
161
  end
162
162
 
163
163
  def read_included_excludes
164
+ entry_filter = EntryFilter.new(site)
165
+
164
166
  site.include.each do |entry|
165
167
  next if entry == ".htaccess"
166
168
 
167
169
  entry_path = site.in_source_dir(entry)
168
170
  next if File.directory?(entry_path)
171
+ next if entry_filter.symlink?(entry_path)
169
172
 
170
173
  read_included_file(entry_path) if File.file?(entry_path)
171
174
  end