jekyll-spaceship 0.4.0 → 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: f948e78348f6b74d101dff999356e1188dc973cdc7e1eb697f74777406755ce0
4
- data.tar.gz: cfae2fbfc444d4db48c1c68824c96fd6d8c4cf4ca1f3b01c5c987fff252673a0
3
+ metadata.gz: a08a522ea05e563014b701af58028bf0f6afa4c1ee808fd207ad1d1651a5689d
4
+ data.tar.gz: ed466874e4feae0e0bb7970283beebb4bab72ecb5515bd09f6ee4ec67656eb6a
5
5
  SHA512:
6
- metadata.gz: 65e2c45a6b175cb712c4900644537d53fa6fd73632c8a7f685dcd83d4e1a019adfcb5c7e3ee6f5b7053de16556cf5e73d9ffee0f07bd908a9f2565f1843dbc11
7
- data.tar.gz: 68f7e48bc2f10217c99a2bf7f75530dedceb1cf90a062d1bdfe80d6c0951af058ca5708059ceca03c9206a6c253eb71334ca11efa2fff4a69135101d5941b56b
6
+ metadata.gz: 931ed6e5b5b0d2a6047430106dced7882bc0e104f210eedbe6bf2870ecc74c8d39ccd201d55ac5bcf7171f29e7d5bf5da7d9d4043e24357c1c4f38be060bb0ae
7
+ data.tar.gz: c16c3ee95ea3dec0a415d9303af0b1c666156569289308774a63e559d58bc9372ed070783b20db6180837b63540383cf4941aad7b0fe34d61f2ecba937e5b710
@@ -0,0 +1,38 @@
1
+ version: "2"
2
+ checks:
3
+ argument-count:
4
+ enabled: true
5
+ config:
6
+ threshold: 5
7
+ file-lines:
8
+ enabled: true
9
+ config:
10
+ threshold: 300
11
+ method-complexity:
12
+ enabled: true
13
+ config:
14
+ threshold: 15
15
+ method-count:
16
+ enabled: true
17
+ config:
18
+ threshold: 50
19
+ method-lines:
20
+ enabled: true
21
+ config:
22
+ threshold: 30
23
+ plugins:
24
+ fixme:
25
+ enabled: false
26
+
27
+ exclude_patterns:
28
+ - "*.*"
29
+ - ".*"
30
+
31
+ - Gemfile
32
+ - LICENSE.txt
33
+ - Rakefile
34
+
35
+ - rake/
36
+ - script/
37
+ - spec/
38
+ - test/
@@ -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']
@@ -0,0 +1,32 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 2.7
5
+ - 2.3
6
+ env:
7
+ global:
8
+ - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
9
+ matrix:
10
+ - JEKYLL_VERSION="~> 3.8"
11
+ matrix:
12
+ include:
13
+ - rvm: 2.7
14
+ env: JEKYLL_VERSION="~> 3.8.6"
15
+ - rvm: 2.7
16
+ env: JEKYLL_VERSION=">= 4.0.0"
17
+ before_install:
18
+ - gem update --system
19
+ - gem install bundler
20
+ before_script: bundle update
21
+ script: script/cibuild
22
+ notifications:
23
+ email: false
24
+ deploy:
25
+ provider: rubygems
26
+ api_key:
27
+ secure: AqjHemFJsIxFuudjWzYbUGBpA5wpAB9Ate6oDZMGMnpaoSD2VgfkBDklyFfEh5uuHrh+rU6U9MPv4wknXVIV7gTTY18ATgzciLa+JCVjhAaSoPGSkORT15/kKpVp4IXIoEytj5T9D+8Wc8czd/B1+lMGGu7n7d7gMvg0HsjOLzJtAOYPrRUTaTXDLeIA+rPnsI1IzbvfHzcZvuD70XkBJWN9kiu0djlI6o51XQNumWMJrFAD/NDD3h3tZ0kkI0TalAYbWVRkZ/ZeABKAod3IRAXGt4L2MM2eYqE5KaXb/GE5wISib3I/iTCjjwrNlM+wM9a+mnOkC+elaCJm1LENqP5Ocy9wbOLYmC8i1VpPDXm2bskbj32oy1wf5zeQUf6bnPB+wDmwgCirYb7z2jQlV4BzRRkDCTftfNTa8FIi03kf+i7phjHuj18j/JC3Ww1ApRq71JAuqEnUY0wBaaN3M5abrJsYOxCRnYVPcBn/w8gfkXuhv9xvDG2OgwqIjDiECPjmbeK8Apo9kgKSrfjBQ43q62Ore6SuVCS+PZOOxVnHmfphfT4xc1atyVeMLkSvnWOa/sWTwgOSXqt1TYAEEhb734AsfXeRMzxU/LN1Y4nZ0otuEv+HVHA/XeHLA1Skq9vHhtZaORhJ58Jmwv5oMwA8KC/wPrn0gGtSBPe8zxw=
28
+ gem: jekyll-spaceship
29
+ on:
30
+ tags: true
31
+ repo: jeffreytse/jekyll-spaceship
32
+ cleanup: false
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, 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
 
@@ -19,6 +94,8 @@ A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, youtu
19
94
  - [1.4 Cell Alignment](#cell-alignment)
20
95
  - [1.5 Cell Markdown](#cell-markdown)
21
96
  - [2. MathJax Usage](#2-mathjax-usage)
97
+ - [2.1 Performance Optimization](#21-performance-optimization)
98
+ - [2.2 How to use?](#22-how-to-use)
22
99
  - [3. PlantUML Usage](#3-plantuml-usage)
23
100
  - [4. Video Usage](#4-video-usage)
24
101
  - [4.1 Youtube Usage](#youtube-usage)
@@ -27,6 +104,7 @@ A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, youtu
27
104
  - [5. Hybrid HTML with Markdown](#5-hybrid-html-with-markdown)
28
105
  - [6. Markdown Polyfill](#6-markdown-polyfill)
29
106
  - [6.1 Escape Ordered List](#escape-ordered-list)
107
+ - [7. Emoji Usage](#7-emoji-usage)
30
108
  - [Credits](#credits)
31
109
  - [Contributing](#contributing)
32
110
  - [License](#license)
@@ -384,7 +462,7 @@ Rowspan is 4
384
462
 
385
463
  [MathJax](http://www.mathjax.org/) is an open-source JavaScript display engine for LaTeX, MathML, and AsciiMath notation that works in all modern browsers.
386
464
 
387
- **Some of the main features of MathJax include:**
465
+ Some of the main features of MathJax include:
388
466
 
389
467
  - High-quality display of LaTeX, MathML, and AsciiMath notation in HTML pages
390
468
  - Supported in most browsers with no plug-ins, extra fonts, or special
@@ -394,7 +472,13 @@ Rowspan is 4
394
472
  advanced functionality
395
473
  - Powerful API for integration with other web applications
396
474
 
397
- Put your math expression within \\\\\\\\\$...\$
475
+ #### 2.1 Performance optimization
476
+
477
+ At building stage, the MathJax engine script will be added by automatically checking whether there is a math expression in the page, this feature can help you improve the page performance on loading speed.
478
+
479
+ #### 2.2 How to use?
480
+
481
+ Put your math expression within \$...\$
398
482
 
399
483
  ```markdown
400
484
  $ a * b = c ^ b $
@@ -472,7 +556,7 @@ the link as below:
472
556
  ```
473
557
 
474
558
  ```markdown
475
- ![](https://www.dailymotion.com/video/x7tfyq3?width=100%&height=400)
559
+ ![](https://www.dailymotion.com/video/x7tfyq3?width=100%&height=400&autoplay=1)
476
560
  ```
477
561
 
478
562
  #### Youtube Usage
@@ -581,11 +665,27 @@ Escaped:
581
665
  10. List item Cafe.
582
666
  ```
583
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
+
584
683
  ## Credits
585
684
 
586
685
  - [Jekyll](https://github.com/jekyll/jekyll) - A blog-aware static site generator in Ruby.
587
686
  - [MultiMarkdown](https://fletcher.github.io/MultiMarkdown-6) - Lightweight markup processor to produce HTML, LaTeX, and more.
588
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.
589
689
 
590
690
  ## Contributing
591
691
 
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
@@ -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, 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
 
@@ -18,10 +18,10 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.required_ruby_version = ">= 2.3.0"
20
20
 
21
- spec.add_runtime_dependency "nokogiri", "~> 1.6"
21
+ spec.add_dependency "jekyll", ">= 3.6", "< 5.0"
22
+ spec.add_dependency "nokogiri", "~> 1.6"
22
23
 
23
- spec.add_development_dependency "jekyll", "~> 3.7"
24
- spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "bundler"
25
25
  spec.add_development_dependency "rake", "~> 12.0"
26
26
  spec.add_development_dependency "rspec", "~> 3.0"
27
27
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'jekyll-spaceship/cores/logger'
4
+ require 'jekyll-spaceship/cores/manager'
4
5
  require 'jekyll-spaceship/cores/processor'
5
6
  require 'jekyll-spaceship/cores/register'
6
7
 
@@ -11,4 +12,5 @@ module Jekyll::Spaceship
11
12
  Register.use 'plantuml-processor'
12
13
  Register.use 'polyfill-processor'
13
14
  Register.use 'video-processor'
15
+ Register.use 'emoji-processor'
14
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
@@ -0,0 +1,118 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'nokogiri'
4
+ require __dir__ + '/type'
5
+
6
+ module Jekyll::Spaceship
7
+ class Manager
8
+ @@_hooks = {}
9
+ @@_processers = []
10
+
11
+ def self.add(processor)
12
+ # register for listening event
13
+ processor.registers.each do |_register|
14
+ container = _register.first
15
+ events = _register.last.uniq
16
+ events = events.select do |event|
17
+ next true if event.match(/^post/)
18
+ next !events.any?(event.to_s.gsub(/^pre/, 'post').to_sym)
19
+ end
20
+ events.each do |event|
21
+ self.hook container, event
22
+ end
23
+ end
24
+ @@_processers.push(processor)
25
+ @@_processers = @@_processers.sort { |a, b| b.priority <=> a.priority }
26
+ end
27
+
28
+ def self.hook(container, event, &block)
29
+ return if not is_hooked? container, event
30
+
31
+ handler = ->(page) {
32
+ self.dispatch page, container, event
33
+ block.call if block
34
+ }
35
+
36
+ if event.to_s.start_with?('after')
37
+ Jekyll::Hooks.register container, event do |page|
38
+ handler.call page
39
+ end
40
+ elsif event.to_s.start_with?('post')
41
+ Jekyll::Hooks.register container, event do |page|
42
+ handler.call page
43
+ end
44
+ # auto add pre-event
45
+ self.hook container, event.to_s.sub('post', 'pre').to_sym
46
+ elsif event.to_s.start_with?('pre')
47
+ Jekyll::Hooks.register container, event do |page|
48
+ handler.call page
49
+ end
50
+ end
51
+ end
52
+
53
+ def self.is_hooked?(container, event)
54
+ hook_name = "#{container}_#{event}".to_sym
55
+ return false if @@_hooks.has_key? hook_name
56
+ @@_hooks[hook_name] = true
57
+ end
58
+
59
+ def self.dispatch(page, container, event)
60
+ @@_processers.each do |processor|
61
+ processor.dispatch page, container, event
62
+ end
63
+ if event.to_s.start_with?('post') and Type.html? output_ext(page)
64
+ self.dispatch_html_block(page)
65
+ end
66
+ @@_processers.each do |processor|
67
+ processor.on_handled if processor.handled
68
+ end
69
+ end
70
+
71
+ def self.ext(page)
72
+ page.data['ext']
73
+ end
74
+
75
+ def self.output_ext(page)
76
+ page.url_placeholders[:output_ext]
77
+ end
78
+
79
+ def self.converter(page, name)
80
+ page.site.converters.each do |converter|
81
+ class_name = converter.class.to_s.downcase
82
+ return converter if class_name.end_with?(name.downcase)
83
+ end
84
+ end
85
+
86
+ def self.dispatch_html_block(page)
87
+ doc = Nokogiri::HTML(page.output)
88
+ doc.css('script').each do |node|
89
+ type = Type.html_block_type node['type']
90
+ content = node.content
91
+ next if type.nil?
92
+
93
+ # dispatch to on_handle_html_block
94
+ @@_processers.each do |processor|
95
+ next unless processor.process?
96
+ content = processor.on_handle_html_block content, type
97
+ # dispatch to type handlers
98
+ method = "on_handle_#{type}"
99
+ next unless processor.respond_to? method
100
+ content = processor.pre_exclude content
101
+ content = processor.send method, content
102
+ content = processor.after_exclude content
103
+ end
104
+
105
+ cvter = self.converter page, type
106
+ content = cvter.convert content unless cvter.nil?
107
+
108
+ # dispatch to on_handle_html
109
+ @@_processers.each do |processor|
110
+ next unless processor.process?
111
+ content = processor.on_handle_html content
112
+ end
113
+ node.replace Nokogiri::HTML.fragment content
114
+ end
115
+ page.output = doc.to_html
116
+ end
117
+ end
118
+ end