jekyll_dynamic_assets 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 39b2333302ea07b39ecfa9bdf32356bbd4e9c1457bd84b278189d07997e53942
4
+ data.tar.gz: e27b36bf7e8841d81c84f02d43a33cc0506f4375ab9bbfb3ea924ffad23d97dc
5
+ SHA512:
6
+ metadata.gz: 5368cb65e7f886ce410b10e1ce434ff1c406750087d83cdb9960e544c477de25e7a756e2a68b2a4dba970c459b67b4822f9b94f0602ca202a097cd6121e324a1
7
+ data.tar.gz: a8b8f42968d7d63a4bac0947d639d8ac3377db24305eaa6dcecdca678c84bdfdbfe841314d8e9d206e9296a5b68c03cca5e166326b38db7db6a7aa2412518e14
data/.rubocop.yml ADDED
@@ -0,0 +1,20 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.2
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Style/StringLiteralsInInterpolation:
8
+ EnforcedStyle: double_quotes
9
+
10
+ Metrics/MethodLength:
11
+ Enabled: false
12
+
13
+ Layout/LineLength:
14
+ Enabled: false
15
+
16
+ Lint/ScriptPermission:
17
+ Enabled: false
18
+
19
+ Layout/EndOfLine:
20
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2025-06-05
4
+
5
+ - Test release
6
+
7
+ ## [Released]
8
+
9
+ ## [1.0.0] - 2025-06-05
10
+
11
+ - Initial release
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 M. Umar Shahbaz
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,83 @@
1
+ # JekyllDynamicAssets
2
+
3
+ JekyllDynamicAssets is a Jekyll plugin that allows you to dynamically manage and inject CSS, JS and other assets into your site using presets, per-page configuration, and flexible formatting.
4
+
5
+ ## Features
6
+ - Define global (master) assets and per-page assets
7
+ - Use asset presets for reusable asset groups
8
+ - Customizable HTML output for each asset type (CSS, JS, etc.)
9
+ - Liquid tag `{% assets %}` for easy asset injection in templates and includes
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ source 'https://rubygems.org'
17
+
18
+ gem "jekyll"
19
+
20
+
21
+ group :jekyll_plugins do
22
+ gem "jekyll_dynamic_assets"
23
+ # other gems
24
+ end
25
+ ```
26
+
27
+ Then add the following to your Jekyll site's `config.yml`:
28
+
29
+ ```yaml
30
+ plugins:
31
+ - jekyll_dynamic_assets
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ 1. **Configure your assets in `config.yml`:**
37
+
38
+ ```yaml
39
+ assets:
40
+ master:
41
+ - main.css
42
+ - main.js
43
+ formats:
44
+ css: "<link rel='stylesheet' href='%s'>"
45
+ js: "<script src='%s'></script>"
46
+ presets:
47
+ blog: [blog.css, blog.js]
48
+ project: [project.css, project.js]
49
+ ```
50
+
51
+ 2. **Per-page or per-collection configuration:**
52
+
53
+ In your page or post front matter:
54
+
55
+ ```yaml
56
+ assets:
57
+ files:
58
+ - custom.css
59
+ presets:
60
+ - blog
61
+ ```
62
+
63
+ 3. **Inject assets in your templates:**
64
+
65
+ Use the Liquid tag where you want the assets to appear:
66
+
67
+ ```liquid
68
+ {% assets %}
69
+ ```
70
+
71
+ This will output the appropriate HTML tags for all configured assets. This tag should generally be used inside your `<head>` tag but can be used anywhere else.
72
+
73
+ ## Contributing
74
+
75
+ Bug reports and pull requests are welcome on GitHub at https://github.com/MUmarShahbaz/jekyll_dynamic_assets. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/MUmarShahbaz/jekyll_dynamic_assets/blob/main/CODE_OF_CONDUCT.md).
76
+
77
+ ## License
78
+
79
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
80
+
81
+ ## Code of Conduct
82
+
83
+ Everyone interacting in the JekyllDynamicAssets project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/MUmarShahbaz/jekyll_dynamic_assets/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+ require "rubocop/rake_task"
6
+
7
+ Rake::TestTask.new(:test) do |t|
8
+ t.libs << "test"
9
+ t.test_files = FileList["test/test_*.rb"]
10
+ t.verbose = true
11
+ end
12
+
13
+ RuboCop::RakeTask.new(:rubocop)
14
+
15
+ task default: %i[test rubocop]
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "liquid"
4
+
5
+ module JekyllDynamicAssets
6
+ # {% assets %} tag
7
+ class AssetsTag < Liquid::Tag
8
+ def render(context)
9
+ site = context.registers[:site]
10
+ page = context.registers[:page]
11
+
12
+ # Initialize and run the processor
13
+ processor = Processor.new(site: site, page: page)
14
+ processor.assets.join("\n")
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JekyllDynamicAssets
4
+ # Asset link generator
5
+ class Processor
6
+ def initialize(site:, page:)
7
+ @config = site.config["assets"] || {}
8
+ @page = page
9
+ @page_config = page["assets"] || {}
10
+ end
11
+
12
+ def assets
13
+ all_assets = combined_assets
14
+ asset_insertions = []
15
+ all_assets.each do |asset|
16
+ extension = asset.split(".").last
17
+ asset_link = format_string(extension) % asset
18
+ asset_insertions << asset_link
19
+ end
20
+ asset_insertions
21
+ end
22
+
23
+ private
24
+
25
+ def format_string(extension)
26
+ formats = @config["formats"] || {}
27
+ formats[extension] || "%s"
28
+ end
29
+
30
+ def combined_assets
31
+ # Container
32
+ assets = []
33
+
34
+ # Add master assets and manual assets
35
+ assets.concat(Array(@config["master"]))
36
+ assets.concat(Array(preset_files))
37
+ assets.concat(Array(@page_config["files"]))
38
+
39
+ assets.uniq
40
+ end
41
+
42
+ def preset_files
43
+ preset_assets = []
44
+ bad_presets = []
45
+ selected_presets = Array(@page_config["presets"])
46
+ preset_map = @config["presets"] || {}
47
+ selected_presets.each do |preset|
48
+ if preset_map.key?(preset)
49
+ preset_assets.concat(Array(preset_map[preset]))
50
+ else
51
+ bad_presets << preset
52
+ end
53
+ end
54
+ remaining?(bad_presets)
55
+ preset_assets
56
+ end
57
+
58
+ def remaining?(remaining_presets)
59
+ # Display the undefined presets
60
+ return if remaining_presets.empty?
61
+
62
+ location = @page["path"] || @page["relative_path"] || "unknown"
63
+ missing_list = remaining_presets.to_a.join(", ")
64
+ raise "DynamicAssets: No preset(s) defined: #{missing_list} at: #{location}"
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JekyllDynamicAssets
4
+ VERSION = "1.0.0"
5
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "jekyll_dynamic_assets/version"
4
+ require_relative "jekyll_dynamic_assets/processor"
5
+ require_relative "jekyll_dynamic_assets/assets_tag"
6
+
7
+ module JekyllDynamicAssets
8
+ class Error < StandardError; end
9
+ end
10
+
11
+ Liquid::Template.register_tag("assets", JekyllDynamicAssets::AssetsTag)
@@ -0,0 +1,4 @@
1
+ module JekyllDynamicAssets
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll_dynamic_assets
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - M. Umar Shahbaz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-06-05 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.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: liquid
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '4.0'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '6.0'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '4.0'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '6.0'
53
+ description: Use simple variables to define your master files, presets and manual
54
+ insertion. Select your assets dynamically via page front matter and config.yml
55
+ email:
56
+ - m.umarshahbaz.2007@gmail.com
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - ".rubocop.yml"
62
+ - CHANGELOG.md
63
+ - CODE_OF_CONDUCT.md
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/jekyll_dynamic_assets.rb
68
+ - lib/jekyll_dynamic_assets/assets_tag.rb
69
+ - lib/jekyll_dynamic_assets/processor.rb
70
+ - lib/jekyll_dynamic_assets/version.rb
71
+ - sig/jekyll_dynamic_assets.rbs
72
+ homepage: https://github.com/MUmarShahbaz/jekyll_dynamic_assets
73
+ licenses:
74
+ - MIT
75
+ metadata:
76
+ homepage_uri: https://github.com/MUmarShahbaz/jekyll_dynamic_assets
77
+ source_code_uri: https://github.com/MUmarShahbaz/jekyll_dynamic_assets
78
+ changelog_uri: https://github.com/MUmarShahbaz/jekyll_dynamic_assets/blob/main/CHANGELOG.md
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: 3.2.0
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubygems_version: 3.5.22
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Dynamically include your asset files
98
+ test_files: []