jekyll-spaceship 0.4.4 → 0.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
2
  SHA256:
3
- metadata.gz: 818a9e35e951c1474e13a45823e77f9c8d3e4bafc8cd3d9917cf8bfa6b17aa9c
4
- data.tar.gz: 1353de14e12326338da7f354e5f0727b139b6ef2763e449b009b5844eca029c4
3
+ metadata.gz: a08a522ea05e563014b701af58028bf0f6afa4c1ee808fd207ad1d1651a5689d
4
+ data.tar.gz: ed466874e4feae0e0bb7970283beebb4bab72ecb5515bd09f6ee4ec67656eb6a
5
5
  SHA512:
6
- metadata.gz: af5a0908c50d7b6e0cd01e963d0b5d2ffe9f8d9c473c7bff2cd4c820fc479e8c109831091eece7a5af375424bf1db751b6e4d5858efae0007e707e60e0fd1010
7
- data.tar.gz: fe331223e9f9bb22dbf8c4915d09a5f1902cbffa4de1bf5045106512e6ccb2b3f62d6de5608b8636e444691a9903ea5113e9b6b1c7fcf5cc06d71fd879a5d8d0
6
+ metadata.gz: 931ed6e5b5b0d2a6047430106dced7882bc0e104f210eedbe6bf2870ecc74c8d39ccd201d55ac5bcf7171f29e7d5bf5da7d9d4043e24357c1c4f38be060bb0ae
7
+ data.tar.gz: c16c3ee95ea3dec0a415d9303af0b1c666156569289308774a63e559d58bc9372ed070783b20db6180837b63540383cf4941aad7b0fe34d61f2ecba937e5b710
@@ -0,0 +1,12 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4
+ patreon: jeffreytse
5
+ open_collective: # Replace with a single Open Collective username
6
+ ko_fi: jeffreytse
7
+ tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ liberapay: jeffreytse
10
+ issuehunt: # Replace with a single IssueHunt username
11
+ otechie: # Replace with a single Otechie username
12
+ custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
data/README.md CHANGED
@@ -1,11 +1,86 @@
1
- # jekyll-spaceship
2
-
3
- [![Build Status](https://travis-ci.org/jeffreytse/jekyll-spaceship.svg?branch=master)](https://travis-ci.org/jeffreytse/jekyll-spaceship)
4
- [![Gem Version](https://badge.fury.io/rb/jekyll-spaceship.svg)](http://badge.fury.io/rb/jekyll-spaceship)
5
- [![Code Climate](https://codeclimate.com/github/jeffreytse/jekyll-spaceship/badges/gpa.svg)](https://codeclimate.com/github/jeffreytse/jekyll-spaceship)
6
- [![Test Coverage](https://api.codeclimate.com/v1/badges/cd56b207f327603662a1/test_coverage)](https://codeclimate.com/github/jeffreytse/jekyll-spaceship/test_coverage)
7
-
8
- A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, youtube, vimeo, dailymotion, etc.
1
+ <h1 align="center">
2
+ <a href="https://github.com/jeffreytse/jekyll-spaceship">
3
+ <img alt="spaceship →~ jekyll" src="https://raw.githubusercontent.com/jeffreytse/jekyll-spaceship/master/logos/jekyll-spaceship-logo.png" width="400">
4
+ </a>
5
+ <br> 🚀 Jekyll Spaceship 🚀 <br>
6
+ </h1>
7
+
8
+ <h4 align="center">
9
+ <a href="https://jekyllrb.org" target="_blank"><code>Jekyll</code></a> plugin for Astronauts.
10
+ </h4>
11
+
12
+ <p align="center">
13
+
14
+ <a href="https://travis-ci.org/jeffreytse/jekyll-spaceship">
15
+ <img src="https://travis-ci.org/jeffreytse/jekyll-spaceship.svg?branch=master"
16
+ alt="CI Status" />
17
+ </a>
18
+
19
+ <a href="http://badge.fury.io/rb/jekyll-spaceship">
20
+ <img src="https://badge.fury.io/rb/jekyll-spaceship.svg"
21
+ alt="Gem Version" />
22
+ </a>
23
+
24
+ <a href="https://codeclimate.com/github/jeffreytse/jekyll-spaceship">
25
+ <img src="https://codeclimate.com/github/jeffreytse/jekyll-spaceship/badges/gpa.svg"
26
+ alt="Code Climate" />
27
+ </a>
28
+
29
+ <a href="https://codeclimate.com/github/jeffreytse/jekyll-spaceship/test_coverage">
30
+ <img src="https://api.codeclimate.com/v1/badges/cd56b207f327603662a1/test_coverage"
31
+ alt="Test Coverage" />
32
+ </a>
33
+
34
+ <a href="https://github.com/jeffreytse/jekyll-spaceship/blob/master/LICENSE.txt">
35
+ <img src="https://img.shields.io/badge/License-MIT-brightgreen.svg"
36
+ alt="License" />
37
+ </a>
38
+
39
+ <a href="http://badge.fury.io/rb/jekyll-spaceship">
40
+ <img src="https://img.shields.io/gem/dt/jekyll-spaceship"
41
+ alt="Download Data" />
42
+ </a>
43
+
44
+ </p>
45
+
46
+ <p align="center">
47
+
48
+ <a href="https://liberapay.com/jeffreytse">
49
+ <img src="http://img.shields.io/liberapay/goal/jeffreytse.svg?logo=liberapay"
50
+ alt="Donate (Liberapay)" />
51
+ </a>
52
+
53
+ <a href="https://patreon.com/jeffreytse">
54
+ <img src="https://img.shields.io/badge/support-patreon-F96854.svg?style=flat-square"
55
+ alt="Donate (Patreon)" />
56
+ </a>
57
+
58
+ <a href="https://ko-fi.com/jeffreytse">
59
+ <img height="20" src="https://www.ko-fi.com/img/githubbutton_sm.svg"
60
+ alt="Donate (Ko-fi)" />
61
+ </a>
62
+
63
+ </p>
64
+
65
+ <div align="center">
66
+ <h4>
67
+ <a href="#requirements">Requirements</a> |
68
+ <a href="#installation">Install</a> |
69
+ <a href="#usage">Usage</a> |
70
+ <a href="#credits">Credits</a> |
71
+ <a href="#license">License</a>
72
+ </h4>
73
+ </div>
74
+
75
+ <div align="center">
76
+ <sub>Built with ❤︎ by
77
+ <a href="https://jeffreytse.net">jeffreytse</a> and
78
+ <a href="https://github.com/jeffreytse/jekyll-spaceship/graphs/contributors">contributors </a>
79
+ </div>
80
+ <br>
81
+
82
+
83
+ A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, emoji, youtube, vimeo, dailymotion, etc.
9
84
 
10
85
  ## Table of Contents
11
86
 
@@ -29,6 +104,7 @@ A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, youtu
29
104
  - [5. Hybrid HTML with Markdown](#5-hybrid-html-with-markdown)
30
105
  - [6. Markdown Polyfill](#6-markdown-polyfill)
31
106
  - [6.1 Escape Ordered List](#escape-ordered-list)
107
+ - [7. Emoji Usage](#7-emoji-usage)
32
108
  - [Credits](#credits)
33
109
  - [Contributing](#contributing)
34
110
  - [License](#license)
@@ -480,7 +556,7 @@ the link as below:
480
556
  ```
481
557
 
482
558
  ```markdown
483
- ![](https://www.dailymotion.com/video/x7tfyq3?width=100%&height=400)
559
+ ![](https://www.dailymotion.com/video/x7tfyq3?width=100%&height=400&autoplay=1)
484
560
  ```
485
561
 
486
562
  #### Youtube Usage
@@ -589,11 +665,27 @@ Escaped:
589
665
  10. List item Cafe.
590
666
  ```
591
667
 
668
+ ### 7. Emoji Usage
669
+ GitHub-flavored emoji images and names would allow emojifying content such as: it's raining :cat:s and :dog:s!
670
+
671
+ Noted that emoji images are served from the GitHub.com CDN, with a base URL of [https://github.githubassets.com](https://github.githubassets.com), which results in emoji image URLs like [https://github.githubassets.com/images/icons/emoji/unicode/1f604.png](https://github.githubassets.com/images/icons/emoji/unicode/1f604.png).
672
+
673
+ In any page or post, use emoji as you would normally, e.g.
674
+
675
+ ```
676
+ I give this plugin two :+1:!
677
+ ```
678
+
679
+ **Code above would be parsed as:**
680
+
681
+ I give this plugin two :+1:!
682
+
592
683
  ## Credits
593
684
 
594
685
  - [Jekyll](https://github.com/jekyll/jekyll) - A blog-aware static site generator in Ruby.
595
686
  - [MultiMarkdown](https://fletcher.github.io/MultiMarkdown-6) - Lightweight markup processor to produce HTML, LaTeX, and more.
596
687
  - [markdown-it-multimd-table](https://github.com/RedBug312/markdown-it-multimd-table) - Multimarkdown table syntax plugin for markdown-it markdown parser.
688
+ - [jmoji](https://github.com/jekyll/jemoji) - GitHub-flavored emoji plugin for Jekyll.
597
689
 
598
690
  ## Contributing
599
691
 
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.version = Jekyll::Spaceship::VERSION
10
10
  spec.authors = ["jeffreytse"]
11
11
  spec.email = ["jeffreytse.mail@gmail.com"]
12
- spec.summary = "A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, youtube, vimeo, dailymotion, etc."
12
+ spec.summary = "A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, emoji, youtube, vimeo, dailymotion, etc."
13
13
  spec.homepage = "https://github.com/jeffreytse/jekyll-spaceship"
14
14
  spec.license = "MIT"
15
15
 
@@ -12,4 +12,5 @@ module Jekyll::Spaceship
12
12
  Register.use 'plantuml-processor'
13
13
  Register.use 'polyfill-processor'
14
14
  Register.use 'video-processor'
15
+ Register.use 'emoji-processor'
15
16
  end
@@ -4,6 +4,10 @@ require 'jekyll-spaceship/version'
4
4
 
5
5
  module Jekyll::Spaceship
6
6
  class Logger
7
+ def initialize(namespace)
8
+ @namespace = namespace
9
+ end
10
+
7
11
  def self.display_info
8
12
  self.log "Jekyll-Spaceship #{Jekyll::Spaceship::VERSION}"
9
13
  self.log 'A Jekyll plugin to provide powerful supports.'
@@ -17,5 +21,13 @@ module Jekyll::Spaceship
17
21
  def self.output(title, content)
18
22
  puts "#{title.rjust(18)}: #{content}"
19
23
  end
24
+
25
+ def log(content)
26
+ if @namespace.nil?
27
+ self.class.log content
28
+ else
29
+ self.class.log "[#{@namespace}] #{content}"
30
+ end
31
+ end
20
32
  end
21
33
  end
@@ -17,16 +17,21 @@ module Jekyll::Spaceship
17
17
  @@_priority = nil
18
18
 
19
19
  attr_reader :page
20
+ attr_reader :logger
20
21
  attr_reader :priority
21
22
  attr_reader :registers
22
23
  attr_reader :exclusions
23
24
  attr_accessor :handled
24
25
 
26
+ def name
27
+ self.class.name.split('::').last
28
+ end
29
+
25
30
  def initialize()
26
31
  self.initialize_priority
27
32
  self.initialize_register
28
33
  self.initialize_exclusions
29
- Manager.add self
34
+ @logger = Logger.new(self.name)
30
35
  end
31
36
 
32
37
  def initialize_priority
@@ -122,9 +127,8 @@ module Jekyll::Spaceship
122
127
  end
123
128
 
124
129
  def on_handled
125
- processor = self.class.name.split('::').last
126
130
  file = page.path.gsub(/.*_posts\//, '')
127
- Logger.log "[#{processor}] #{file}"
131
+ logger.log file
128
132
  end
129
133
 
130
134
  def pre_exclude(content)
@@ -34,7 +34,7 @@ module Jekyll::Spaceship
34
34
  _class = Jekyll::Spaceship.const_get(constants.first)
35
35
  next unless _class.is_a? Class
36
36
 
37
- _class.new
37
+ Manager.add _class.new
38
38
  end
39
39
  end
40
40
  end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'net/http'
4
+ require 'uri'
5
+ require 'json'
6
+
7
+ module Jekyll::Spaceship
8
+ class EmojiProcessor < Processor
9
+ EMOJI_MARKUP_HOST = 'https://api.github.com/emojis'
10
+ EMOJI_MARKUP_DATA = {}
11
+
12
+ def initialize
13
+ super()
14
+ self.initialize_emoji_data
15
+ end
16
+
17
+ def initialize_emoji_data
18
+ EMOJI_MARKUP_DATA.update get_emoji_markup_data
19
+ end
20
+
21
+ def on_handle_html(content)
22
+ return content if EMOJI_MARKUP_DATA.size.zero?
23
+ # handle emoji markup
24
+ content.scan(/:([\w+-]+):/) do |match_data|
25
+ emoji_markup = match_data[0]
26
+ emoji_image = EMOJI_MARKUP_DATA[emoji_markup]
27
+ next if emoji_image.nil?
28
+ self.handled = true
29
+
30
+ # convert hex string to unicode
31
+ unicode = emoji_image.match(/unicode\/([\d\w]+)/)
32
+ if unicode[1]
33
+ unicode = "0x#{unicode[1]}".to_i(16)
34
+ alt = [unicode].pack('U*')
35
+ end
36
+ alt = emoji_markup if alt.nil?
37
+
38
+ content = content.gsub(
39
+ ":#{emoji_markup}:",
40
+ "<image class=\"emoji\" \
41
+ title=\"#{emoji_markup}\" \
42
+ alt=\"#{alt}\" \
43
+ src=\"#{emoji_image}\" \
44
+ style=\"vertical-align: middle; \
45
+ max-width: 1em; visibility: hidden;\" \
46
+ onload=\"this.style.visibility='visible'\" \
47
+ onerror=\"this.replaceWith(this.alt)\"> \
48
+ </image>"
49
+ )
50
+ end
51
+ content
52
+ end
53
+
54
+ def get_emoji_markup_data
55
+ data = {}
56
+ begin
57
+ source = Net::HTTP.get URI(EMOJI_MARKUP_HOST)
58
+ data = JSON.parse(source)
59
+ rescue StandardError => msg
60
+ logger.log msg
61
+ end
62
+ data
63
+ end
64
+ end
65
+ end
@@ -112,20 +112,21 @@ module Jekyll::Spaceship
112
112
  end
113
113
 
114
114
  # handle colspan
115
- result = cell.content.match(/(\s*\|)+$/)
116
115
  if cell == cells.last and scope.row.colspan > 0
117
116
  range = (cells.count - scope.row.colspan)...cells.count
118
117
  for i in range do
119
118
  cells[i].remove
120
119
  end
121
120
  end
122
- if result
123
- result = result[0]
124
- colspan = result.scan(/\|/).count
125
- scope.row.colspan += colspan
126
- cell.content = cell.content.gsub(/(\s*\|)+$/, '')
127
- cell.set_attribute('colspan', colspan + 1)
128
- end
121
+
122
+ result = cell.content.match(/(\s*\|)+$/)
123
+ return if result.nil?
124
+
125
+ cell.content = cell.content.gsub(/(\s*\|)+$/, '')
126
+ result = result[0]
127
+ colspan = result.scan(/\|/).count
128
+ scope.row.colspan += colspan
129
+ cell.set_attribute('colspan', colspan + 1)
129
130
  end
130
131
 
131
132
  def handle_multi_rows(data)
@@ -188,7 +189,7 @@ module Jekyll::Spaceship
188
189
  else
189
190
  scope.table.span_row_cells[scope.row.col_index] = cell
190
191
  end
191
- scope.row.col_index += 1
192
+ scope.row.col_index += [cell.get_attribute('colspan').to_i, 1].max
192
193
  end
193
194
 
194
195
  def handle_text_align(data)
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'uri'
4
+
3
5
  module Jekyll::Spaceship
4
6
  class VideoProcessor < Processor
5
7
  def on_handle_markdown(content)
@@ -70,22 +72,26 @@ module Jekyll::Spaceship
70
72
  url = match_data[2]
71
73
  id = match_data[4]
72
74
  title = match_data[6]
73
- width = url.match(/(?<=width=)(\S*?)(?=&|$)/)
74
- height = url.match(/(?<=height=)(\S*?)(?=&|$)/)
75
+ qs = url.match(/(?<=\?)(\S*?)$/)
76
+ qs = Hash[URI.decode_www_form(qs.to_s)].reject do |k, v|
77
+ next true if v == id or v == ''
78
+ end
75
79
 
76
- data[:width] = 600 if data[:width].nil?
77
- data[:height] = 400 if data[:height].nil?
80
+ width = qs['width'] || data[:width] || 600
81
+ height = qs['height'] || data[:height] || 400
78
82
  style = "max-width: 100%" if width.nil?
79
- width = data[:width] if width.nil?
80
- height = data[:height] if height.nil?
81
83
 
82
- url = "#{iframe_url}#{id}"
84
+ url = URI("#{iframe_url}#{id}").tap do |v|
85
+ v.query = URI.encode_www_form(qs) if qs.size > 0
86
+ end
87
+
83
88
  html = "<iframe \
84
89
  src=\"#{url}\" \
85
90
  title=\"#{title}\" \
86
91
  width=\"#{width}\" \
87
92
  height=\"#{height}\" \
88
93
  style=\"#{style}\" \
94
+ allow=\"autoplay; encrypted-media\" \
89
95
  frameborder=\"0\" \
90
96
  allowfullscreen=\"\">\
91
97
  </iframe>"
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module Spaceship
5
- VERSION = "0.4.4"
5
+ VERSION = "0.5.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-spaceship
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jeffreytse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-14 00:00:00.000000000 Z
11
+ date: 2020-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -94,6 +94,7 @@ extensions: []
94
94
  extra_rdoc_files: []
95
95
  files:
96
96
  - ".codeclimate.yml"
97
+ - ".github/FUNDING.yml"
97
98
  - ".gitignore"
98
99
  - ".travis.yml"
99
100
  - Gemfile
@@ -107,6 +108,7 @@ files:
107
108
  - lib/jekyll-spaceship/cores/processor.rb
108
109
  - lib/jekyll-spaceship/cores/register.rb
109
110
  - lib/jekyll-spaceship/cores/type.rb
111
+ - lib/jekyll-spaceship/processors/emoji-processor.rb
110
112
  - lib/jekyll-spaceship/processors/mathjax-processor.rb
111
113
  - lib/jekyll-spaceship/processors/plantuml-processor.rb
112
114
  - lib/jekyll-spaceship/processors/polyfill-processor.rb
@@ -114,6 +116,7 @@ files:
114
116
  - lib/jekyll-spaceship/processors/video-processor.rb
115
117
  - lib/jekyll-spaceship/utils/plantuml/plantuml.jar
116
118
  - lib/jekyll-spaceship/version.rb
119
+ - logos/jekyll-spaceship-logo.png
117
120
  - script/cibuild
118
121
  - script/test
119
122
  homepage: https://github.com/jeffreytse/jekyll-spaceship
@@ -140,5 +143,5 @@ rubygems_version: 2.7.7
140
143
  signing_key:
141
144
  specification_version: 4
142
145
  summary: A Jekyll plugin to provide powerful supports for table, mathjax, plantuml,
143
- youtube, vimeo, dailymotion, etc.
146
+ emoji, youtube, vimeo, dailymotion, etc.
144
147
  test_files: []