distorted-jekyll 0.5.6 → 0.5.7

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +661 -0
  3. data/README.md +6 -10
  4. data/lib/distorted-jekyll.rb +79 -0
  5. data/lib/distorted-jekyll/13th-style.rb +58 -0
  6. data/lib/distorted-jekyll/_config_default.yml +79 -0
  7. data/lib/distorted-jekyll/blocks.rb +16 -0
  8. data/lib/distorted-jekyll/error_code.rb +24 -0
  9. data/lib/distorted-jekyll/floor.rb +148 -0
  10. data/lib/distorted-jekyll/injection_of_love.rb +305 -0
  11. data/lib/distorted-jekyll/invoker.rb +400 -0
  12. data/lib/distorted-jekyll/molecule/abstract.rb +238 -0
  13. data/lib/distorted-jekyll/molecule/font.rb +29 -0
  14. data/lib/distorted-jekyll/molecule/image.rb +105 -0
  15. data/lib/distorted-jekyll/molecule/last-resort.rb +54 -0
  16. data/lib/distorted-jekyll/molecule/pdf.rb +88 -0
  17. data/lib/distorted-jekyll/molecule/svg.rb +59 -0
  18. data/lib/distorted-jekyll/molecule/text.rb +74 -0
  19. data/lib/distorted-jekyll/molecule/video.rb +43 -0
  20. data/lib/distorted-jekyll/monkey_business/jekyll/cleaner.rb +54 -0
  21. data/lib/distorted-jekyll/static/font.rb +42 -0
  22. data/lib/distorted-jekyll/static/image.rb +55 -0
  23. data/lib/distorted-jekyll/static/lastresort.rb +28 -0
  24. data/lib/distorted-jekyll/static/pdf.rb +53 -0
  25. data/lib/distorted-jekyll/static/state.rb +141 -0
  26. data/lib/distorted-jekyll/static/svg.rb +52 -0
  27. data/lib/distorted-jekyll/static/text.rb +57 -0
  28. data/lib/distorted-jekyll/static/video.rb +90 -0
  29. data/lib/distorted-jekyll/template/13th-style.css +78 -0
  30. data/lib/distorted-jekyll/template/error_code.liquid +3 -0
  31. data/lib/distorted-jekyll/template/font.liquid +32 -0
  32. data/lib/distorted-jekyll/template/image.liquid +32 -0
  33. data/lib/distorted-jekyll/template/lastresort.liquid +20 -0
  34. data/lib/distorted-jekyll/template/pdf.liquid +14 -0
  35. data/lib/distorted-jekyll/template/svg.liquid +32 -0
  36. data/lib/distorted-jekyll/template/text.liquid +32 -0
  37. data/lib/distorted-jekyll/template/video.liquid +11 -0
  38. metadata +41 -6
@@ -0,0 +1,52 @@
1
+ require 'fileutils'
2
+ require 'set'
3
+
4
+
5
+ require 'distorted-jekyll/static/image'
6
+
7
+ module Jekyll
8
+ module DistorteD
9
+ module Static
10
+ class SVG < Jekyll::DistorteD::Static::Image
11
+
12
+ DRIVER = Cooltrainer::DistorteD::SVG
13
+
14
+ MEDIA_TYPE = DRIVER::MEDIA_TYPE
15
+ SUB_TYPE = DRIVER::SUB_TYPE
16
+ MIME_TYPES = DRIVER::MIME_TYPES
17
+
18
+ ATTRS = DRIVER::ATTRS
19
+ ATTRS_DEFAULT = DRIVER::ATTRS_DEFAULT
20
+ ATTRS_VALUES = DRIVER::ATTRS_VALUES
21
+
22
+
23
+ # dest: string realpath to `_site_` directory
24
+ def write(dest)
25
+ return false if File.exist?(path) && !modified?
26
+ self.class.mtimes[path] = mtime
27
+
28
+ # Create any directories to the depth of the intended destination.
29
+ FileUtils.mkdir_p(dd_dest(dest))
30
+
31
+ for variation in files
32
+ if DRIVER::MIME_TYPES.include?(variation[:type])
33
+ svg_dest_path = File.join(dd_dest(dest), variation[:name])
34
+
35
+ if true # TODO: Make this configurable
36
+ Jekyll.logger.debug(@tag_name, "Optimizing #{@name} and copying to #{dd_dest(dest)}")
37
+ DRIVER::optimize(path, svg_dest_path)
38
+ else
39
+ Jekyll.logger.debug(@tag_name, "Copying #{@name} to #{dd_dest(dest)}")
40
+ FileUtils.cp(path, svg_dest_path)
41
+ end
42
+ end
43
+ end
44
+
45
+ super # Generate raster Image variations
46
+ true
47
+ end
48
+
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,57 @@
1
+ require 'fileutils'
2
+ require 'set'
3
+
4
+ require 'distorted/text'
5
+ require 'distorted-jekyll/static/image'
6
+
7
+ module Jekyll
8
+ module DistorteD
9
+ module Static
10
+ class Text < Image
11
+
12
+ DRIVER = Cooltrainer::DistorteD::Text
13
+
14
+ MEDIA_TYPE = DRIVER::MEDIA_TYPE
15
+ MIME_TYPES = DRIVER::MIME_TYPES
16
+
17
+ ATTRS = DRIVER::ATTRS
18
+ ATTRS_DEFAULT = DRIVER::ATTRS_DEFAULT
19
+ ATTRS_VALUES = DRIVER::ATTRS_VALUES
20
+
21
+
22
+ # dest: String realpath to `_site` directory
23
+ def write(dest)
24
+ orig_dest = destination(dest)
25
+
26
+ return false if !modified?
27
+ self.class.mtimes[path] = mtime
28
+
29
+ unless defined? @distorted
30
+ @distorted = DRIVER.new(
31
+ path,
32
+ encoding: attr_value(:encoding),
33
+ font: attr_value(:font),
34
+ spacing: attr_value(:spacing),
35
+ dpi: attr_value(:dpi),
36
+ )
37
+ end
38
+ # Write any actual-text output variations.
39
+ # Images will be written by `super`.
40
+ for variation in files
41
+ if DRIVER::MIME_TYPES.include?(variation&.dig(:type))
42
+ filename = File.join(dd_dest(dest), variation&.dig(:name) || @name)
43
+ Jekyll.logger.debug('DistorteD Writing:', filename)
44
+ # TODO: For now this is just copying the file, but we should
45
+ # probably support some sort of UTF conversion or something here.
46
+ FileUtils.cp(path, filename)
47
+ end
48
+ end
49
+
50
+ super
51
+
52
+ end
53
+
54
+ end # Text
55
+ end # Static
56
+ end # DistorteD
57
+ end # Jekyll
@@ -0,0 +1,90 @@
1
+ require 'set'
2
+
3
+ require 'distorted/video'
4
+ require 'distorted-jekyll/static/state'
5
+
6
+ module Jekyll
7
+ module DistorteD
8
+ module Static
9
+ class Video < Jekyll::DistorteD::Static::State
10
+
11
+ DRIVER = Cooltrainer::DistorteD::Video
12
+
13
+ MEDIA_TYPE = DRIVER::MEDIA_TYPE
14
+ MIME_TYPES = DRIVER::MIME_TYPES
15
+
16
+ ATTRS = DRIVER::ATTRS
17
+ ATTRS_DEFAULT = DRIVER::ATTRS_DEFAULT
18
+ ATTRS_VALUES = DRIVER::ATTRS_VALUES
19
+
20
+
21
+ # dest: string realpath to `_site_` directory
22
+ def write(dest)
23
+ orig_dest = destination(dest)
24
+
25
+ # TODO: Make this smarter. Need to see if there's an easy way to
26
+ # get a list of would-be-generated filenames from GStreamer.
27
+ return false if File.exist?(path) && !modified?
28
+ self.class.mtimes[path] = mtime
29
+
30
+ distorted = DRIVER.new(path, orig_dest, basename)
31
+
32
+ distorted.generate
33
+ end
34
+
35
+ # Return a Set of extant video variations due to inability/unwillingness
36
+ # to exactly predict GStreamer's HLS/DASH segment output naming
37
+ # even if we are controlling all variables like segment length etc.
38
+ # This implementation may give stale segments but will at least speed
39
+ # up site generation by not having to regenerate the video every time.
40
+ def destinations(dest)
41
+ wanted = Set[]
42
+ if Dir.exist?(dd_dest(dest))
43
+ hls_dir = File.join(dd_dest(dest), "#{basename}.hls")
44
+ if Dir.exist?(hls_dir)
45
+ wanted.merge(Dir.entries(hls_dir).to_set.map{|f| File.join(hls_dir, f)})
46
+ end
47
+ end
48
+ wanted
49
+ end
50
+
51
+ def modified?
52
+ # We can't use the standard Static::State#modified? here until
53
+ # I figure out how to cleanly get a duplicate of what would be
54
+ # the generated filenames from GStreamer's sink.
55
+ #
56
+ # For now for the sake of speeding up my site generation
57
+ # I'll assume not-modified that if the output variant (e.g. DASH/HLS)
58
+ # container dir exists and contains at least two files:
59
+ # the playlist and at least one segment.
60
+ #
61
+ # Hacky HLS-only right now until dashsink2 lands in upstream Gst.
62
+ #
63
+ # Assume modified for the sake of freshness :)
64
+ modified = true
65
+
66
+ site_dest = Jekyll::DistorteD::Floor::config(:destination).to_s
67
+ if Dir.exist?(site_dest)
68
+
69
+ dd_dest = dd_dest(site_dest)
70
+ if Dir.exist?(dd_dest)
71
+
72
+ hls_dir = File.join(dd_dest, "#{basename}.hls")
73
+ if Dir.exist?(hls_dir)
74
+ need_filez = Set["#{basename}.m3u8"]
75
+ var_filez = Dir.entries(hls_dir).to_set
76
+ if need_filez.subset?(var_filez) and var_filez.count > 2
77
+ modified = false
78
+ end
79
+ end
80
+
81
+ end
82
+ end
83
+ Jekyll.logger.debug("#{@name} modified?", modified)
84
+ modified
85
+ end
86
+
87
+ end # Video
88
+ end # Static
89
+ end # DistorteD
90
+ end # Jekyll
@@ -0,0 +1,78 @@
1
+ div.distorted {text-align: center;}
2
+ div.distorted::after {
3
+ content: '';
4
+ display: block;
5
+ clear: left;
6
+ }
7
+ div.distorted.svg {background-color: #fbfbf8;}
8
+ div.distorted.pdf > object {min-height: 76vh;}
9
+ div.distorted-caption {
10
+ color: #8888888;
11
+ margin-top: 0.5em;
12
+ }
13
+ div.distorted-block {
14
+ width: 100%;
15
+ clear: both;
16
+ }
17
+ div.distorted-block > div.distorted {
18
+ display: block;
19
+ box-sizing: border-box;
20
+ float: left;
21
+ border: 4px solid transparent;
22
+ margin: 0px;
23
+ text-align: center;
24
+ width: 100%;
25
+ }
26
+ @media screen and (min-width: 40em) {
27
+ div.distorted-block > div.distorted {
28
+ width: 50%;
29
+ }
30
+ div.distorted-block > div.distorted:only-child {
31
+ width: 100%;
32
+ }
33
+ div.distorted-block > div.distorted:first-child:nth-last-child(3),
34
+ div.distorted-block > div.distorted:first-child:nth-last-child(3) ~ div.distorted,
35
+ div.distorted-block > div.distorted:first-child:nth-last-child(6),
36
+ div.distorted-block > div.distorted:first-child:nth-last-child(6) ~ div.distorted,
37
+ div.distorted-block > div.distorted:first-child:nth-last-child(9),
38
+ div.distorted-block > div.distorted:first-child:nth-last-child(9) ~ div.distorted {
39
+ width: 33.3333%;
40
+ }
41
+ div.distorted-block > div.distorted:first-child:nth-last-child(5),
42
+ div.distorted-block > div.distorted:first-child:nth-last-child(5) ~ div.distorted:nth-child(2) {
43
+ width: 50%;
44
+ }
45
+ div.distorted-block > div.distorted:first-child:nth-last-child(5) ~ div.distorted {
46
+ width: 33.3333%;
47
+ }
48
+ div.distorted-block > div.distorted:first-child:nth-last-child(7) ~ div.distorted:nth-child(3),
49
+ div.distorted-block > div.distorted:first-child:nth-last-child(7) ~ div.distorted:nth-child(4),
50
+ div.distorted-block > div.distorted:first-child:nth-last-child(7) ~ div.distorted:nth-child(5) {
51
+ width: 33.3333%;
52
+ }
53
+ }
54
+ @media screen and (min-width: 76em) {
55
+ div.distorted-block > div.distorted:first-child:nth-last-child(4),
56
+ div.distorted-block > div.distorted:first-child:nth-last-child(4) ~ div.distorted,
57
+ div.distorted-block > div.distorted:first-child:nth-last-child(8),
58
+ div.distorted-block > div.distorted:first-child:nth-last-child(8) ~ div.distorted {
59
+ width: 25%;
60
+ }
61
+ div.distorted-block > div.distorted:first-child:nth-last-child(5),
62
+ div.distorted-block > div.distorted:first-child:nth-last-child(5) ~ div.distorted:nth-child(2),
63
+ div.distorted-block > div.distorted:first-child:nth-last-child(5) ~ div.distorted,
64
+ div.distorted-block > div.distorted:first-child:nth-last-child(10),
65
+ div.distorted-block > div.distorted:first-child:nth-last-child(10) ~ div.distorted {
66
+ width: 20%;
67
+ }
68
+ div.distorted-block > div.distorted:first-child:nth-last-child(7),
69
+ div.distorted-block > div.distorted:first-child:nth-last-child(7) ~ div.distorted:nth-child(2),
70
+ div.distorted-block > div.distorted:first-child:nth-last-child(7) ~ div.distorted:nth-child(3) {
71
+ width: 33.3333%;
72
+ }
73
+ div.distorted-block > div.distorted:first-child:nth-last-child(7) ~ div.distorted,
74
+ div.distorted-block > div.distorted:first-child:nth-last-child(7) ~ div.distorted:nth-child(4),
75
+ div.distorted-block > div.distorted:first-child:nth-last-child(7) ~ div.distorted:nth-child(5) {
76
+ width: 25%;
77
+ }
78
+ }
@@ -0,0 +1,3 @@
1
+ <div class="distorted error">
2
+ <p>{{ message }}</p>
3
+ </div>
@@ -0,0 +1,32 @@
1
+ <div class="distorted font">
2
+ {%- if href != true %}
3
+ {%- capture href %}{{ path }}{{ name }}{%- endcapture -%}
4
+ {%- endif %}
5
+ {%- if alt != nil and alt != "" %}
6
+ {%- capture attr_alt %} alt="{{ alt }}"{%- endcapture -%}
7
+ {%- endif %}
8
+ {%- if title != nil and title != "" %}
9
+ {%- capture attr_title %} title="{{ title }}"{%- endcapture -%}
10
+ {%- endif %}
11
+ {%- if loading != nil and loading != "" %}
12
+ {%- capture attr_loading %} loading="{{ loading }}"{%- endcapture -%}
13
+ {%- endif %}
14
+ <a href="{{ href }}"{{ attr_title }} target="_blank">
15
+ <picture>
16
+ {%- if sources %}
17
+ {%- for source in sources %}
18
+ {%- if source.media != nil and source.media != "" %}
19
+ {%- capture attr_media %} media="{{ source.media }}"{%- endcapture -%}
20
+ {%- else %}
21
+ {%- capture attr_media %}{%- endcapture -%}
22
+ {%- endif %}
23
+ <source srcset="{{ path }}{{ source.name }}" type="{{ source.type }}"{{ attr_media }}/>
24
+ {%- endfor %}
25
+ {%- endif %}
26
+ <img src="{{ path }}{{ fallback_img }}"{{ attr_alt }}{{ attr_title }}{{ attr_loading }}/>
27
+ </picture>
28
+ </a>
29
+ {%- if caption != nil and caption != "" %}
30
+ <p class="distorted-caption">{{ caption }}</p>
31
+ {%- endif %}
32
+ </div>
@@ -0,0 +1,32 @@
1
+ <div class="distorted image">
2
+ {%- if href != true %}
3
+ {%- capture href %}{{ path }}{{ name }}{%- endcapture -%}
4
+ {%- endif %}
5
+ {%- if alt != nil and alt != "" %}
6
+ {%- capture attr_alt %} alt="{{ alt }}"{%- endcapture -%}
7
+ {%- endif %}
8
+ {%- if title != nil and title != "" %}
9
+ {%- capture attr_title %} title="{{ title }}"{%- endcapture -%}
10
+ {%- endif %}
11
+ {%- if loading != nil and loading != "" %}
12
+ {%- capture attr_loading %} loading="{{ loading }}"{%- endcapture -%}
13
+ {%- endif %}
14
+ <a href="{{ href }}"{{ attr_title }} target="_blank">
15
+ <picture>
16
+ {%- if sources %}
17
+ {%- for source in sources %}
18
+ {%- if source.media != nil and source.media != "" %}
19
+ {%- capture attr_media %} media="{{ source.media }}"{%- endcapture -%}
20
+ {%- else %}
21
+ {%- capture attr_media %}{%- endcapture -%}
22
+ {%- endif %}
23
+ <source srcset="{{ path }}{{ source.name }}" type="{{ source.type }}"{{ attr_media }}/>
24
+ {%- endfor %}
25
+ {%- endif %}
26
+ <img src="{{ path }}{{ fallback_img }}"{{ attr_alt }}{{ attr_title }}{{ attr_loading }}/>
27
+ </picture>
28
+ </a>
29
+ {%- if caption != nil and caption != "" %}
30
+ <p class="distorted-caption">{{ caption }}</p>
31
+ {%- endif %}
32
+ </div>
@@ -0,0 +1,20 @@
1
+ <div class="distorted lastresort">
2
+ {%- if href != true %}
3
+ {%- capture href %}{{ path }}{{ name }}{%- endcapture -%}
4
+ {%- endif %}
5
+ {%- if alt != nil and alt != "" %}
6
+ {%- capture attr_alt %} alt="{{ alt }}"{%- endcapture -%}
7
+ {%- endif %}
8
+ {%- if title != nil and title != "" %}
9
+ {%- capture attr_title %} title="{{ title }}"{%- endcapture -%}
10
+ {%- endif %}
11
+ {%- if loading != nil and loading != "" %}
12
+ {%- capture attr_loading %} loading="{{ loading }}"{%- endcapture -%}
13
+ {%- endif %}
14
+ <a href="{{ href }}"{{ attr_title }} target="_blank">
15
+ <img src="{{ path }}{{ name }}"{{ attr_alt }}{{ attr_title }}{{ attr_loading }}/>
16
+ </a>
17
+ {%- if caption != nil and caption != "" %}
18
+ <p class="distorted-caption">{{ caption }}</p>
19
+ {%- endif %}
20
+ </div>
@@ -0,0 +1,14 @@
1
+ <div class="distorted pdf">
2
+ {%- if title != nil and title != "" %}
3
+ {%- capture pdf_link %}{{ title }}{%- endcapture -%}
4
+ {%- elsif alt != nil and alt != "" %}
5
+ {%- capture pdf_link %}{{ alt }}{%- endcapture -%}
6
+ {%- endif %}
7
+ <object data="{{ path }}{{ name }}#{{ pdf_open_params }}" type="application/pdf" width="{{ width }}" height="{{ height }}">
8
+ <embed src="{{ path }}{{ name }}#{{ pdf_open_params }}" type="application/pdf" width="{{ width }}" height="{{ height }}"/>
9
+ <a href="{{ path }}{{ name }}#{{ pdf_open_params }}">{{ pdf_link }} [PDF]</a>
10
+ </object>
11
+ {%- if caption != nil and caption != "" %}
12
+ <p class="distorted-caption">{{ caption }}</p>
13
+ {%- endif %}
14
+ </div>
@@ -0,0 +1,32 @@
1
+ <div class="distorted svg">
2
+ {%- if href != true %}
3
+ {%- capture href %}{{ path }}{{ name }}{%- endcapture -%}
4
+ {%- endif %}
5
+ {%- if alt != nil and alt != "" %}
6
+ {%- capture attr_alt %} alt="{{ alt }}"{%- endcapture -%}
7
+ {%- endif %}
8
+ {%- if title != nil and title != "" %}
9
+ {%- capture attr_title %} title="{{ title }}"{%- endcapture -%}
10
+ {%- endif %}
11
+ {%- if loading != nil and loading != "" %}
12
+ {%- capture attr_loading %} loading="{{ loading }}"{%- endcapture -%}
13
+ {%- endif %}
14
+ <a href="{{ href }}"{{ attr_title }} target="_blank">
15
+ <picture>
16
+ {%- if sources %}
17
+ {%- for source in sources %}
18
+ {%- if source.media != nil and source.media != "" %}
19
+ {%- capture attr_media %} media="{{ source.media }}"{%- endcapture -%}
20
+ {%- else %}
21
+ {%- capture attr_media %}{%- endcapture -%}
22
+ {%- endif %}
23
+ <source srcset="{{ path }}{{ source.name }}" type="{{ source.type }}"{{ attr_media }}/>
24
+ {%- endfor %}
25
+ {%- endif %}
26
+ <img src="{{ path }}{{ fallback_img }}"{{ attr_alt }}{{ attr_title }}{{ attr_loading }}/>
27
+ </picture>
28
+ </a>
29
+ {%- if caption != nil and caption != "" %}
30
+ <p class="distorted-caption">{{ caption }}</p>
31
+ {%- endif %}
32
+ </div>
@@ -0,0 +1,32 @@
1
+ <div class="distorted text">
2
+ {%- if href != true %}
3
+ {%- capture href %}{{ path }}{{ name }}{%- endcapture -%}
4
+ {%- endif %}
5
+ {%- if alt != nil and alt != "" %}
6
+ {%- capture attr_alt %} alt="{{ alt }}"{%- endcapture -%}
7
+ {%- endif %}
8
+ {%- if title != nil and title != "" %}
9
+ {%- capture attr_title %} title="{{ title }}"{%- endcapture -%}
10
+ {%- endif %}
11
+ {%- if loading != nil and loading != "" %}
12
+ {%- capture attr_loading %} loading="{{ loading }}"{%- endcapture -%}
13
+ {%- endif %}
14
+ <a href="{{ href }}"{{ attr_title }} target="_blank">
15
+ <picture>
16
+ {%- if sources %}
17
+ {%- for source in sources %}
18
+ {%- if source.media != nil and source.media != "" %}
19
+ {%- capture attr_media %} media="{{ source.media }}"{%- endcapture -%}
20
+ {%- else %}
21
+ {%- capture attr_media %}{%- endcapture -%}
22
+ {%- endif %}
23
+ <source srcset="{{ path }}{{ source.name }}" type="{{ source.type }}"{{ attr_media }}/>
24
+ {%- endfor %}
25
+ {%- endif %}
26
+ <img src="{{ path }}{{ fallback_img }}"{{ attr_alt }}{{ attr_title }}{{ attr_loading }}/>
27
+ </picture>
28
+ </a>
29
+ {%- if caption != nil and caption != "" %}
30
+ <p class="distorted-caption">{{ caption }}</p>
31
+ {%- endif %}
32
+ </div>