jekyll-zybook-tag 0.1.1
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/LICENSE.txt +21 -0
- data/README.md +52 -0
- data/lib/jekyll-zybook-tag.rb +94 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: acf9da92e83954d65542a35b007bfaf14d48953afaa4a2cefa186ea1ddcecd87
|
4
|
+
data.tar.gz: 1440c068311b82d5f2e52e55e6c915e2db9f6365eb204113cf49b70340c5a9ff
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0ac9a7f636e231239ee186255c14dc4981edb4c82ff01734c88f4e590ed3418a8c75d9df4e438cc059a2fb9a3c9f7c28b16b178916f41c3c4cbc433f993e9dba
|
7
|
+
data.tar.gz: d1b6cff25a5a80f2d9ede503e37c7c4fde81ae2ea9340188cb9a038393d640f66f7716bc7d1b62a960eb17305ac201d35893eea019994df434680523ece878cf
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Colorado State University
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Zybooks Liquid Tag Plugin
|
2
|
+
|
3
|
+
|
4
|
+
This allows a link to the most recent version of zybooks, without having to
|
5
|
+
change links throughout the entire website. Instead the link updates based on the contents
|
6
|
+
of the _config.yml direction.
|
7
|
+
|
8
|
+
## Setup
|
9
|
+
Make sure the _config.yml includes the line zybook, and book-id
|
10
|
+
|
11
|
+
```yaml
|
12
|
+
zybook:
|
13
|
+
book_id: "COLOSTATECS1634Summer2020"
|
14
|
+
```
|
15
|
+
Replace COLOSTATE... with your latest book ID, that is find in the URL of the book. For example:
|
16
|
+
|
17
|
+
```
|
18
|
+
https://learn.zybooks.com/zybook/COLOSTATECS1634Summer2020/`
|
19
|
+
```
|
20
|
+
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
```
|
25
|
+
{% zybook chapter:x section:x %}Link text{% endzybook %}
|
26
|
+
```
|
27
|
+
|
28
|
+
For example:
|
29
|
+
```
|
30
|
+
{% zybook chapter:13 section:2 %}Loops{%endzybook%}
|
31
|
+
```
|
32
|
+
would create the following link (assuming Summer Book)
|
33
|
+
```html
|
34
|
+
<a href="https://learn.zybooks.com/zybook/COLOSTATECS1634Summer2020/chapter/13/section/2" target="_blank">Loops</a>
|
35
|
+
```
|
36
|
+
|
37
|
+
Arguments are optional, possible arguments are as follows:
|
38
|
+
|
39
|
+
* chapter
|
40
|
+
defaults to nothing, directing the link to the zybook TOC if omitted
|
41
|
+
* section
|
42
|
+
defaults to 1
|
43
|
+
* resource_id
|
44
|
+
for the content_resource_id in links, defaults to nothing
|
45
|
+
|
46
|
+
The text between the tag block is used for the link text.
|
47
|
+
|
48
|
+
## _config.yml options
|
49
|
+
All arguments can also be included in the _config.yml. They will
|
50
|
+
be used as default arguments, but local (placing in the tag) use overwrites
|
51
|
+
the _config.yml setting. In most cases, the only option
|
52
|
+
in _config.yml that makes sense is `book-id`.
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# Zybooks Link Plugin
|
2
|
+
#
|
3
|
+
# The following plugin creates a liquid tag that links to the most recent zybooks for the course
|
4
|
+
# it needs to have the zybook in the _config.yml file for it successfully link for students.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# example usage
|
8
|
+
# {% zybook chapter:x section:x %}{% endzybook %}
|
9
|
+
#
|
10
|
+
# For example:
|
11
|
+
# {% zybook chapter:13 section:2 %}Loops{%endzybook%}
|
12
|
+
# would create the following link (assuming Summer Book)
|
13
|
+
# <a href="http://https://learn.zybooks.com/zybook/COLOSTATECS1634Summer2020/chapter/13/section/2" target="_blank">Loops</a>
|
14
|
+
#
|
15
|
+
# All arguments are OPTIONAL the defaults are follows
|
16
|
+
# chapter = nothing
|
17
|
+
# section = 1 (if chapter is specified)
|
18
|
+
# resource_id = nothing
|
19
|
+
# So just putting in {% zybook %} would link to the TOC of your zybook.
|
20
|
+
#
|
21
|
+
#
|
22
|
+
#
|
23
|
+
module Jekyll
|
24
|
+
module CSU_Plugin_Zybook
|
25
|
+
class ZybookTag < Liquid::Block
|
26
|
+
|
27
|
+
|
28
|
+
@@DEFAULTS = {
|
29
|
+
:chapter => '',
|
30
|
+
:section => '1',
|
31
|
+
:book_base => 'https://learn.zybooks.com/zybook/',
|
32
|
+
:book_id => 'invalid',
|
33
|
+
:resource_id => ''
|
34
|
+
}
|
35
|
+
|
36
|
+
def self.DEFAULTS
|
37
|
+
return @@DEFAULTS
|
38
|
+
end
|
39
|
+
|
40
|
+
def initialize(tag_name, markup, tokens)
|
41
|
+
super
|
42
|
+
|
43
|
+
@config = {}
|
44
|
+
# set defaults
|
45
|
+
override_config(@@DEFAULTS)
|
46
|
+
|
47
|
+
# override configuration with values defined within _config.yml
|
48
|
+
|
49
|
+
if Jekyll.configuration({}).has_key?('zybook')
|
50
|
+
jek_config = Jekyll.configuration({})['zybook']
|
51
|
+
override_config(jek_config)
|
52
|
+
end
|
53
|
+
|
54
|
+
params = markup.split
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
if params.size > 0
|
59
|
+
# override configuration with parameters
|
60
|
+
pconfig = {} # reset local config
|
61
|
+
params.each do |param|
|
62
|
+
param = param.gsub /\s+/, '' # remove whitespaces
|
63
|
+
key, value = param.split(':',2) # split first occurrence of ':' only
|
64
|
+
pconfig[key.to_sym] = value
|
65
|
+
end
|
66
|
+
override_config(pconfig)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def override_config(config)
|
71
|
+
config.each{ |key,value| @config[key] = value }
|
72
|
+
end
|
73
|
+
|
74
|
+
def render(context)
|
75
|
+
content = super
|
76
|
+
|
77
|
+
rtn = ""
|
78
|
+
if @config[:chapter].empty?
|
79
|
+
rtn = "<a href='#{@config[:book_base]}/#{@config["book_id"]}/' target='_blank'>#{content}</a>".gsub(%r{/{2,}}, '/')
|
80
|
+
elsif @config[:resource_id].empty?
|
81
|
+
rtn = "<a href='#{@config[:book_base]}/#{@config["book_id"]}/chapter/#{@config[:chapter]}/section/#{@config[:section]}/' target='_blank'>#{content}</a>".gsub(%r{/{2,}}, '/')
|
82
|
+
else #content_resource_id was included
|
83
|
+
rtn = "<a href='#{@config[:book_base]}/#{@config["book_id"]}/chapter/#{@config[:chapter]}/section/#{@config[:section]}?content_resource_id=#{@config[:resource_id]}' target='_blank'>#{content}</a>".gsub(%r{/{2,}}, '/')
|
84
|
+
end
|
85
|
+
|
86
|
+
return rtn
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
Liquid::Template.register_tag('zybook', Jekyll::CSU_Plugin_Zybook::ZybookTag)
|
93
|
+
|
94
|
+
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-zybook-tag
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Albert Lionelle
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '12.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '12.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- Albert.Lionelle@colostate.edu
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files:
|
61
|
+
- README.md
|
62
|
+
- LICENSE.txt
|
63
|
+
files:
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- lib/jekyll-zybook-tag.rb
|
67
|
+
homepage: https://github.com/Dept-of-Computer-Science/jekyll-zybook-tag
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.7.6
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: Jekyll-zybook Tag for include zybooks content from Semester to Semester,
|
91
|
+
developed to work with Colorado State University Courses, but can be used for any
|
92
|
+
course that uses zybooks and jekyll.
|
93
|
+
test_files: []
|