jekyll-aplayer 0.3.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 +7 -0
- data/.gitignore +56 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +119 -0
- data/History.markdown +4 -0
- data/LICENSE +21 -0
- data/README.md +145 -0
- data/Rakefile +3 -0
- data/jekyll-aplayer.gemspec +31 -0
- data/lib/jekyll-aplayer/cores/config.rb +73 -0
- data/lib/jekyll-aplayer/cores/extend.rb +41 -0
- data/lib/jekyll-aplayer/cores/generator.rb +55 -0
- data/lib/jekyll-aplayer/cores/logger.rb +38 -0
- data/lib/jekyll-aplayer/cores/manager.rb +119 -0
- data/lib/jekyll-aplayer/cores/processor.rb +306 -0
- data/lib/jekyll-aplayer/cores/register.rb +49 -0
- data/lib/jekyll-aplayer/cores/type.rb +71 -0
- data/lib/jekyll-aplayer/cores/util.rb +41 -0
- data/lib/jekyll-aplayer/processors/default.rb +7 -0
- data/lib/jekyll-aplayer/processors/netease.rb +11 -0
- data/lib/jekyll-aplayer/version.rb +7 -0
- data/lib/jekyll-aplayer.rb +17 -0
- data/script/bootstrap +4 -0
- data/script/cibuild +4 -0
- data/script/fmt +10 -0
- data/script/release +4 -0
- data/script/test +4 -0
- metadata +218 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: db9b2b79ff5d8cfd6f284b8f5539145354bb3346e63957231a77626a9f24a027
|
4
|
+
data.tar.gz: 14c6757407b4f254f1643ba27d72642c41075b61c9569bb53473e65b85fbaede
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 703ca5ca4a419ccace3cd4a66fb4773ecef26ec5cfe617433fa6dd31838bddc9046669b830f64b06307304f1150fc248d12292ea5d29aaa0df670966a06a9912
|
7
|
+
data.tar.gz: 85acd71e10b9c982eeebbd6194c5901c5090322ff8b73725ea3c1da550dc261fd7a43cde74ab29ace715e0e8de886fa4f4d08837dc5f0477d3a517255436b789
|
data/.gitignore
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
# Ignore Byebug command history file.
|
17
|
+
.byebug_history
|
18
|
+
|
19
|
+
## Specific to RubyMotion:
|
20
|
+
.dat*
|
21
|
+
.repl_history
|
22
|
+
build/
|
23
|
+
*.bridgesupport
|
24
|
+
build-iPhoneOS/
|
25
|
+
build-iPhoneSimulator/
|
26
|
+
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
28
|
+
#
|
29
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
30
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
31
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
32
|
+
#
|
33
|
+
# vendor/Pods/
|
34
|
+
|
35
|
+
## Documentation cache and generated files:
|
36
|
+
/.yardoc/
|
37
|
+
/_yardoc/
|
38
|
+
/doc/
|
39
|
+
/rdoc/
|
40
|
+
|
41
|
+
## Environment normalization:
|
42
|
+
/.bundle/
|
43
|
+
/vendor/bundle
|
44
|
+
/lib/bundler/man/
|
45
|
+
|
46
|
+
# for a library or gem, you might want to ignore these files since the code is
|
47
|
+
# intended to run in multiple environments; otherwise, check them in:
|
48
|
+
# Gemfile.lock
|
49
|
+
# .ruby-version
|
50
|
+
# .ruby-gemset
|
51
|
+
|
52
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
53
|
+
.rvmrc
|
54
|
+
|
55
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
56
|
+
# .rubocop-https?--*
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jekyll-aplayer (0.3.0)
|
5
|
+
deep_merge (~> 1.2, >= 1.2.1)
|
6
|
+
jekyll (>= 3.0, < 5.0)
|
7
|
+
json-next (~> 1.2, >= 1.2.1)
|
8
|
+
rainbow (~> 3.0)
|
9
|
+
string_to_boolean (~> 1.0, >= 1.0.2)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://rubygems.org/
|
13
|
+
specs:
|
14
|
+
addressable (2.7.0)
|
15
|
+
public_suffix (>= 2.0.2, < 5.0)
|
16
|
+
ast (2.4.2)
|
17
|
+
colorator (1.1.0)
|
18
|
+
concurrent-ruby (1.1.8)
|
19
|
+
deep_merge (1.2.1)
|
20
|
+
diff-lcs (1.4.4)
|
21
|
+
em-websocket (0.5.2)
|
22
|
+
eventmachine (>= 0.12.9)
|
23
|
+
http_parser.rb (~> 0.6.0)
|
24
|
+
eventmachine (1.2.7)
|
25
|
+
ffi (1.15.0)
|
26
|
+
forwardable-extended (2.6.0)
|
27
|
+
http_parser.rb (0.6.0)
|
28
|
+
i18n (1.8.10)
|
29
|
+
concurrent-ruby (~> 1.0)
|
30
|
+
jaro_winkler (1.5.4)
|
31
|
+
jekyll (4.2.0)
|
32
|
+
addressable (~> 2.4)
|
33
|
+
colorator (~> 1.0)
|
34
|
+
em-websocket (~> 0.5)
|
35
|
+
i18n (~> 1.0)
|
36
|
+
jekyll-sass-converter (~> 2.0)
|
37
|
+
jekyll-watch (~> 2.0)
|
38
|
+
kramdown (~> 2.3)
|
39
|
+
kramdown-parser-gfm (~> 1.0)
|
40
|
+
liquid (~> 4.0)
|
41
|
+
mercenary (~> 0.4.0)
|
42
|
+
pathutil (~> 0.9)
|
43
|
+
rouge (~> 3.0)
|
44
|
+
safe_yaml (~> 1.0)
|
45
|
+
terminal-table (~> 2.0)
|
46
|
+
jekyll-sass-converter (2.1.0)
|
47
|
+
sassc (> 2.0.1, < 3.0)
|
48
|
+
jekyll-watch (2.2.1)
|
49
|
+
listen (~> 3.0)
|
50
|
+
json-next (1.2.1)
|
51
|
+
kramdown (2.3.1)
|
52
|
+
rexml
|
53
|
+
kramdown-parser-gfm (1.1.0)
|
54
|
+
kramdown (~> 2.0)
|
55
|
+
liquid (4.0.3)
|
56
|
+
listen (3.5.1)
|
57
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
58
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
59
|
+
mercenary (0.4.0)
|
60
|
+
parallel (1.20.1)
|
61
|
+
parser (3.0.1.0)
|
62
|
+
ast (~> 2.4.1)
|
63
|
+
pathutil (0.16.2)
|
64
|
+
forwardable-extended (~> 2.6)
|
65
|
+
public_suffix (4.0.6)
|
66
|
+
rainbow (3.0.0)
|
67
|
+
rake (12.3.3)
|
68
|
+
rb-fsevent (0.10.4)
|
69
|
+
rb-inotify (0.10.1)
|
70
|
+
ffi (~> 1.0)
|
71
|
+
rexml (3.2.5)
|
72
|
+
rouge (3.26.0)
|
73
|
+
rspec (3.10.0)
|
74
|
+
rspec-core (~> 3.10.0)
|
75
|
+
rspec-expectations (~> 3.10.0)
|
76
|
+
rspec-mocks (~> 3.10.0)
|
77
|
+
rspec-core (3.10.1)
|
78
|
+
rspec-support (~> 3.10.0)
|
79
|
+
rspec-expectations (3.10.1)
|
80
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
81
|
+
rspec-support (~> 3.10.0)
|
82
|
+
rspec-mocks (3.10.2)
|
83
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
84
|
+
rspec-support (~> 3.10.0)
|
85
|
+
rspec-support (3.10.2)
|
86
|
+
rubocop (0.80.1)
|
87
|
+
jaro_winkler (~> 1.5.1)
|
88
|
+
parallel (~> 1.10)
|
89
|
+
parser (>= 2.7.0.1)
|
90
|
+
rainbow (>= 2.2.2, < 4.0)
|
91
|
+
rexml
|
92
|
+
ruby-progressbar (~> 1.7)
|
93
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
94
|
+
rubocop-jekyll (0.11.0)
|
95
|
+
rubocop (>= 0.68.0, < 0.81.0)
|
96
|
+
rubocop-performance (~> 1.2)
|
97
|
+
rubocop-performance (1.6.1)
|
98
|
+
rubocop (>= 0.71.0)
|
99
|
+
ruby-progressbar (1.11.0)
|
100
|
+
safe_yaml (1.0.5)
|
101
|
+
sassc (2.4.0)
|
102
|
+
ffi (~> 1.9)
|
103
|
+
string_to_boolean (1.0.2)
|
104
|
+
terminal-table (2.0.0)
|
105
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
106
|
+
unicode-display_width (1.6.1)
|
107
|
+
|
108
|
+
PLATFORMS
|
109
|
+
ruby
|
110
|
+
|
111
|
+
DEPENDENCIES
|
112
|
+
bundler
|
113
|
+
jekyll-aplayer!
|
114
|
+
rake (~> 12.0)
|
115
|
+
rspec (~> 3.0)
|
116
|
+
rubocop-jekyll (~> 0.4)
|
117
|
+
|
118
|
+
BUNDLED WITH
|
119
|
+
1.17.2
|
data/History.markdown
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2021 Oscaner Miao
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
# [Developing...]
|
2
|
+
|
3
|
+
# jekyll-aplayer
|
4
|
+
Embed aplayer in Jekyll posts/pages
|
5
|
+
|
6
|
+
## Table of Contents
|
7
|
+
|
8
|
+
...
|
9
|
+
|
10
|
+
## Requirements
|
11
|
+
|
12
|
+
- Ruby >= 2.3.0
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add jekyll-aplayer plugin in your site's `Gemfile`, and run `bundle install`.
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'jekyll-aplayer'
|
20
|
+
```
|
21
|
+
|
22
|
+
Add jekyll-aplayer to the `plugins:` section in your site's `_config.yml`
|
23
|
+
|
24
|
+
```yml
|
25
|
+
plugins:
|
26
|
+
- jekyll-aplayer
|
27
|
+
```
|
28
|
+
|
29
|
+
## Configuration
|
30
|
+
|
31
|
+
This plugin runs with the following configuration options by default.
|
32
|
+
|
33
|
+
Alternative settings for these options can be explicitly specified in the configuration file `_config.yml`.
|
34
|
+
|
35
|
+
You can check the [Aplayer Docs](https://aplayer.js.org/) to know how to use them.
|
36
|
+
|
37
|
+
```yml
|
38
|
+
# Where things are
|
39
|
+
jekyll-aplayer:
|
40
|
+
# default use 'default' processor
|
41
|
+
processor: 'default' # 'netease'
|
42
|
+
assets:
|
43
|
+
css:
|
44
|
+
- //unpkg.com/aplayer/dist/APlayer.min.css
|
45
|
+
js:
|
46
|
+
- //unpkg.com/aplayer/dist/APlayer.min.js
|
47
|
+
class: 'jekyll-aplayer'
|
48
|
+
fixed: false
|
49
|
+
mini: false
|
50
|
+
autoplay: false
|
51
|
+
theme: '#b7daff'
|
52
|
+
loop: 'all'
|
53
|
+
order: 'random'
|
54
|
+
preload: 'auto'
|
55
|
+
volume: 0.7
|
56
|
+
# audio:
|
57
|
+
# -
|
58
|
+
# name: 'name1',
|
59
|
+
# artist: 'artist1',
|
60
|
+
# url: 'url1.mp3',
|
61
|
+
# cover: 'cover1.jpg',
|
62
|
+
# lrc: 'lrc1.lrc',
|
63
|
+
# theme: '#ebd0c2'
|
64
|
+
# -
|
65
|
+
# name: 'name2',
|
66
|
+
# artist: 'artist2',
|
67
|
+
# url: 'url2.mp3',
|
68
|
+
# cover: 'cover2.jpg',
|
69
|
+
# lrc: 'lrc2.lrc',
|
70
|
+
# theme: '#46718b'
|
71
|
+
audio: []
|
72
|
+
mutex: true
|
73
|
+
lrcType: 3
|
74
|
+
listFolded: false
|
75
|
+
listMaxHeight: 90
|
76
|
+
storageName: 'aplayer-setting'
|
77
|
+
```
|
78
|
+
|
79
|
+
## Usage
|
80
|
+
|
81
|
+
### Markdown
|
82
|
+
|
83
|
+
#### default
|
84
|
+
|
85
|
+
````
|
86
|
+
```aplayer
|
87
|
+
{
|
88
|
+
"processor": "default",
|
89
|
+
// "id": "aplayer1", # Of course, you can set id byself, but i suggest not do it, because it will generate automatically.
|
90
|
+
"fixed": true,
|
91
|
+
"mini": false,
|
92
|
+
"audio": [
|
93
|
+
{
|
94
|
+
"name": "Hahah",
|
95
|
+
"artist": "artist",
|
96
|
+
"url": "/audios/hikarunara.mp3",
|
97
|
+
"cover": "/img/cover/hikarunara.jpg"
|
98
|
+
}
|
99
|
+
]
|
100
|
+
}
|
101
|
+
```
|
102
|
+
````
|
103
|
+
|
104
|
+
#### netease (NeteaseMusic)
|
105
|
+
|
106
|
+
````
|
107
|
+
```aplayer
|
108
|
+
{
|
109
|
+
"processor": "netease",
|
110
|
+
...
|
111
|
+
}
|
112
|
+
```
|
113
|
+
````
|
114
|
+
|
115
|
+
### Html
|
116
|
+
|
117
|
+
|
118
|
+
#### default
|
119
|
+
|
120
|
+
````html
|
121
|
+
<!-- Of course, you can set id byself, but i suggest not do it, because it will generate automatically. -->
|
122
|
+
<aplayer id="aplayer1" processor="default" fixed="true" mini="false" audio="[{ 'name': 'Hahah', 'artist': 'artist', 'url': '/audios/hikarunara.mp3', 'cover': '/img/cover/hikarunara.jpg' }]"></aplayer>
|
123
|
+
````
|
124
|
+
|
125
|
+
#### netease (NeteaseMusic)
|
126
|
+
|
127
|
+
````html
|
128
|
+
<aplayer id="aplayer1" processor="netease" ...></aplayer>
|
129
|
+
````
|
130
|
+
|
131
|
+
## Credits
|
132
|
+
|
133
|
+
- [Jekyll](https://github.com/jekyll/jekyll) - A blog-aware static site generator in Ruby.
|
134
|
+
- [APlayer](https://github.com/DIYgod/APlayer) - Wow, such a lovely HTML5 music player
|
135
|
+
- [Jekyll Spaceship](https://github.com/jeffreytse/jekyll-spaceship) - A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, mermaid, emoji, video, audio, youtube, vimeo, dailymotion, soundcloud, spotify, etc.
|
136
|
+
|
137
|
+
## Contributing
|
138
|
+
|
139
|
+
Issues and Pull Requests are greatly appreciated. If you've never contributed to an open source project before I'm more than happy to walk you through how to create a pull request.
|
140
|
+
|
141
|
+
You can start by [opening an issue](https://github.com/Oscaner/jekyll-aplayer/issues/new) describing the problem that you're looking to resolve and we'll go from there.
|
142
|
+
|
143
|
+
## License
|
144
|
+
|
145
|
+
This software is licensed under the [MIT license](https://opensource.org/licenses/mit-license.php) © Oscaner Miao.
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "jekyll-aplayer/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "jekyll-aplayer"
|
9
|
+
spec.version = Jekyll::Aplayer::VERSION
|
10
|
+
spec.authors = ["Oscaner"]
|
11
|
+
spec.email = "oscaner1997@github.com"
|
12
|
+
spec.summary = "HTML5-flavored aplayer plugin for Jekyll"
|
13
|
+
spec.homepage = "https://github.com/Oscaner/jekyll-aplayer"
|
14
|
+
spec.licenses = ["MIT"]
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.required_ruby_version = ">= 2.3.0"
|
20
|
+
|
21
|
+
spec.add_dependency "jekyll", ">= 3.0", "< 5.0"
|
22
|
+
spec.add_dependency "rainbow", "~> 3.0"
|
23
|
+
spec.add_dependency "deep_merge", "~> 1.2", ">= 1.2.1"
|
24
|
+
spec.add_dependency "string_to_boolean", "~> 1.0", ">= 1.0.2"
|
25
|
+
spec.add_dependency "json-next", "~> 1.2", ">= 1.2.1"
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler"
|
28
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
29
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
30
|
+
spec.add_development_dependency "rubocop-jekyll", "~> 0.4"
|
31
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'deep_merge'
|
4
|
+
|
5
|
+
module Jekyll::Aplayer
|
6
|
+
class Config
|
7
|
+
|
8
|
+
CONFIG_NAME = 'jekyll-aplayer'
|
9
|
+
|
10
|
+
DEFAULT_CONFIG = {
|
11
|
+
'processor' => 'default',
|
12
|
+
'assets' => {
|
13
|
+
'css' => ['//unpkg.com/aplayer/dist/APlayer.min.css'],
|
14
|
+
'js' => ['//unpkg.com/aplayer/dist/APlayer.min.js'],
|
15
|
+
},
|
16
|
+
'class' => 'jekyll-aplayer',
|
17
|
+
'fixed' => false,
|
18
|
+
'mini' => false,
|
19
|
+
'autoplay' => false,
|
20
|
+
'theme' => '#b7daff',
|
21
|
+
'loop' => 'all',
|
22
|
+
'order' => 'random',
|
23
|
+
'preload' => 'auto',
|
24
|
+
'volume' => 0.7,
|
25
|
+
'audio' => [],
|
26
|
+
'mutex' => true,
|
27
|
+
'lrcType' => 0,
|
28
|
+
'listFolded' => false,
|
29
|
+
'listMaxHeight' => 90,
|
30
|
+
'storageName' => 'aplayer-setting',
|
31
|
+
}
|
32
|
+
|
33
|
+
@@_site_config = {}
|
34
|
+
@@_store_config = {}
|
35
|
+
|
36
|
+
def self.normalize?(config)
|
37
|
+
cpy = config.without?('processor', 'assets', 'id', 'class', 'container', 'customAudioType')
|
38
|
+
# Convert string to real datatype.
|
39
|
+
cpy.map { |key, value|
|
40
|
+
method = 'to_' + Type.datatype?(key)
|
41
|
+
value.respond_to?(method) ? [key, value.send(method)] : [key, value]
|
42
|
+
}.to_h
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.get(uuid)
|
46
|
+
@@_store_config[uuid] if @@_store_config.key?(uuid)
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.store(uuid, config)
|
50
|
+
@@_store_config[uuid] = config
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.site_config()
|
54
|
+
@@_site_config
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.load(config = {})
|
58
|
+
config = {}.deep_merge!({
|
59
|
+
CONFIG_NAME => DEFAULT_CONFIG
|
60
|
+
}).deep_merge!(config)[CONFIG_NAME]
|
61
|
+
@@_site_config = config
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.load_config(&block)
|
65
|
+
# post load site config for `group :jekyll_plugin`
|
66
|
+
Jekyll::Hooks.register :site, :after_init do |site|
|
67
|
+
self.load(site.config)
|
68
|
+
block.call()
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json/next'
|
4
|
+
|
5
|
+
class String
|
6
|
+
|
7
|
+
def to_string
|
8
|
+
self.strip
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_array
|
12
|
+
HANSON.parse(self)
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_object
|
16
|
+
HANSON.parse(self)
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_float
|
20
|
+
self.to_f
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_integer
|
24
|
+
self.to_i
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
class Hash
|
30
|
+
|
31
|
+
def without?(*keys)
|
32
|
+
cpy = self.dup
|
33
|
+
keys.each { |key| cpy.delete(key) }
|
34
|
+
cpy
|
35
|
+
end
|
36
|
+
|
37
|
+
def without!(*keys)
|
38
|
+
keys.each { |key| self.delete(key) }
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll::Aplayer
|
4
|
+
class Generator
|
5
|
+
|
6
|
+
@@_generated = {}
|
7
|
+
|
8
|
+
def self.machine_id(id)
|
9
|
+
'app_' + id.gsub('-', '_')
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.has_generated(id)
|
13
|
+
@@_generated.key?(id)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.get_aplayer_regex(type)
|
17
|
+
return /(((?<!\\)`+)\s*(aplayer)((?:.|\n)*?)\2)/ if type == :code_aplayer
|
18
|
+
return /(<aplayer (.*)>\s*<\/aplayer>)/ if type == :html_aplayer
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.has_aplayer_placeholder?(content, type = :code_aplayer)
|
22
|
+
content.scan(self.get_aplayer_regex(type)) do |match_data|
|
23
|
+
return true
|
24
|
+
end
|
25
|
+
return false
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.asset_inject(type, url, doc)
|
29
|
+
doc.add_child("<link href=\"#{url}\" rel=\"stylesheet\" type=\"text/css\">") if type == :css and !doc.to_html.include?("<link href=\"#{url}\" rel=\"stylesheet\" type=\"text/css\">")
|
30
|
+
doc.add_child("<script src=\"#{url}\"></script>") if type == :js and !doc.to_html.include?("<script src=\"#{url}\"></script>")
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.generate_aplayer_instance(id, config, &block)
|
34
|
+
return @@_generated[id] if @@_generated.key?(id)
|
35
|
+
|
36
|
+
machine_id = self.machine_id(id)
|
37
|
+
|
38
|
+
content =
|
39
|
+
"""
|
40
|
+
const #{machine_id} = new APlayer(
|
41
|
+
Object.assign(
|
42
|
+
{
|
43
|
+
\"container\": document.getElementById('#{id}')
|
44
|
+
},
|
45
|
+
#{config.to_json}
|
46
|
+
)
|
47
|
+
);
|
48
|
+
"""
|
49
|
+
block.call(machine_id, content) if !block.nil?
|
50
|
+
|
51
|
+
return @@_generated[machine_id] = "<script>#{content}</script>"
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'jekyll-aplayer/version'
|
4
|
+
require 'rainbow/refinement'
|
5
|
+
|
6
|
+
using Rainbow
|
7
|
+
|
8
|
+
module Jekyll::Aplayer
|
9
|
+
class Logger
|
10
|
+
|
11
|
+
def initialize(namespace)
|
12
|
+
@namespace = namespace
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.display_info
|
16
|
+
self.log "🚀 Jekyll-Aplayer #{Jekyll::Aplayer::VERSION}"
|
17
|
+
self.log '🍭 A Jekyll plugin to beautiful HTML5 music player.'
|
18
|
+
self.log '👉 ' + 'https://github.com/Oscaner/jekyll-aplayer'.underline
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.log(content)
|
22
|
+
self.output 'Jekyll Aplayer', content.bright
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.output(title, content)
|
26
|
+
puts "#{title.rjust(18)}: #{content}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def log(content)
|
30
|
+
if @namespace.nil?
|
31
|
+
self.class.log content
|
32
|
+
else
|
33
|
+
self.class.log "[#{@namespace}] #{content}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|