jekyll_file_wizard 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,86 @@
1
+ # Data Integration Examples for JekyllFileWizard
2
+
3
+ This folder contains examples demonstrating how JekyllFileWizard can be used to integrate data from Jekyll's `_data` directory into various sections of a website.
4
+
5
+ ## Example 1: Team Members Page
6
+
7
+ **Scenario**: You want to create a "Team" page that dynamically populates information about each team member from a YAML file in the `_data` directory.
8
+
9
+ ### Steps:
10
+
11
+ 1. **Data File**:
12
+ - Location: `_data/team.yml`
13
+ - Content: YAML structure containing details of team members (name, role, bio, image, etc.).
14
+
15
+ 2. **Team Template**:
16
+ - File: `team_section.html`
17
+ - Content: HTML template for the team section with Liquid placeholders for team data.
18
+
19
+ 3. **Configuration File** (`config.yml`):
20
+ ```yaml
21
+ updates:
22
+ - target: "about/team.html"
23
+ template: "team_section.html"
24
+ data_file: "team.yml"
25
+ ```
26
+
27
+ 4. **Run JekyllFileWizard**:
28
+ ```bash
29
+ jekyll_file_wizard
30
+ ```
31
+
32
+ ## Example 2: Product Catalog
33
+
34
+ **Scenario**: Automatically generate a product catalog page using product data stored in a YAML file.
35
+
36
+ ### Steps:
37
+
38
+ 1. **Data File**:
39
+ - Location: `_data/products.yml`
40
+ - Content: YAML structure with details of products (name, description, price, image, etc.).
41
+
42
+ 2. **Product Catalog Template**:
43
+ - File: `product_catalog.html`
44
+ - Content: HTML template for displaying products with Liquid placeholders for product data.
45
+
46
+ 3. **Configuration File** (`config.yml`):
47
+ ```yaml
48
+ updates:
49
+ - target: "products/index.html"
50
+ template: "product_catalog.html"
51
+ data_file: "products.yml"
52
+ ```
53
+
54
+ 4. **Run JekyllFileWizard**:
55
+ ```bash
56
+ jekyll_file_wizard
57
+ ```
58
+
59
+ ## Example 3: Client Testimonials
60
+
61
+ **Scenario**: Populate a testimonials section on your site using data from a YAML file.
62
+
63
+ ### Steps:
64
+
65
+ 1. **Data File**:
66
+ - Location: `_data/testimonials.yml`
67
+ - Content: YAML structure containing client testimonials (client name, testimonial text, image, etc.).
68
+
69
+ 2. **Testimonials Template**:
70
+ - File: `testimonials_section.html`
71
+ - Content: HTML template for displaying testimonials with Liquid placeholders for testimonials data.
72
+
73
+ 3. **Configuration File** (`config.yml`):
74
+ ```yaml
75
+ updates:
76
+ - target: "index.html"
77
+ template: "testimonials_section.html"
78
+ data_file: "testimonials.yml"
79
+ ```
80
+
81
+ 4. **Run JekyllFileWizard**:
82
+ ```bash
83
+ jekyll_file_wizard
84
+ ```
85
+
86
+ These examples illustrate the powerful data integration capabilities of JekyllFileWizard, allowing for dynamic content generation and easy updates to your Jekyll site. By leveraging YAML data files, you can create more dynamic and maintainable site sections, such as team pages, product catalogs, and client testimonials.
@@ -0,0 +1,28 @@
1
+ # JekyllFileWizard.gemspec
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "jekyll_file_wizard"
5
+ spec.version = "0.1.0"
6
+ spec.authors = ["Thaddeus Thomas"]
7
+ spec.email = ["thaddeus.r.thomas@gmail.com"]
8
+
9
+ spec.summary = "Automate and enhance Jekyll site file management and updates with JekyllFileWizard."
10
+ spec.description = <<-DESC
11
+ JekyllFileWizard is a comprehensive gem designed to streamline the management and dynamic updating of Jekyll site structures. It automates the process of checking, creating, and updating various files in a Jekyll project, including HTML files, data files, and more. The gem offers features like dynamic HTML structure handling, integration with Jekyll's data files, template management, robust error handling, an interactive command-line interface, and automated testing and validation. It's ideal for Jekyll site developers looking to enhance their site's functionality and maintainability, making it easier to manage large and complex Jekyll sites.
12
+ DESC
13
+ spec.homepage = "https://visionary-code-works.github.io/JekyllFileWizard"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ # Specify dependencies:
22
+ spec.add_runtime_dependency "nokogiri", "~> 1.11"
23
+ # Add other dependencies here
24
+
25
+ spec.add_development_dependency "bundler", "~> 2.0"
26
+ spec.add_development_dependency "rake", "~> 13.0"
27
+ # Add other development dependencies here
28
+ end
@@ -0,0 +1,31 @@
1
+ require 'yaml'
2
+
3
+ module JekyllFileWizard
4
+ class Configuration
5
+ attr_accessor :sections_to_update, :feature_toggles
6
+
7
+ def initialize
8
+ # Default values
9
+ @sections_to_update = []
10
+ @feature_toggles = {}
11
+ end
12
+
13
+ def load_from_file(file_path)
14
+ if File.exist?(file_path)
15
+ config = YAML.load_file(file_path)
16
+
17
+ @sections_to_update = config['sections_to_update'] if config['sections_to_update']
18
+ @feature_toggles = config['feature_toggles'] if config['feature_toggles']
19
+ else
20
+ raise "Configuration file not found at #{file_path}"
21
+ end
22
+ end
23
+
24
+ def apply_command_line_options(options)
25
+ # Assuming options is a hash with keys as configuration attributes
26
+ options.each do |key, value|
27
+ send("#{key}=", value) if respond_to?("#{key}=")
28
+ end
29
+ end
30
+ end
31
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1,42 @@
1
+ require 'nokogiri'
2
+ require 'jekyll_file_wizard/configuration'
3
+
4
+ class JekyllFileWizard
5
+ def initialize(index_path)
6
+ @index_path = index_path
7
+ @doc = parse_index_html
8
+ end
9
+
10
+ def parse_index_html
11
+ html = File.read(@index_path)
12
+ Nokogiri::HTML(html)
13
+ end
14
+
15
+ def update_section(identifier, new_content)
16
+ section = find_section(identifier)
17
+ return unless section
18
+
19
+ section.inner_html = new_content
20
+ save_changes
21
+ end
22
+
23
+ private
24
+
25
+ def find_section(identifier)
26
+ # This can be an ID, class, or any other attribute
27
+ # Adjust the logic here based on how you want to identify sections
28
+ if identifier[:id]
29
+ @doc.at_css("##{identifier[:id]}")
30
+ elsif identifier[:class]
31
+ @doc.at_css(".#{identifier[:class]}")
32
+ elsif identifier[:tag]
33
+ @doc.at_css(identifier[:tag])
34
+ else
35
+ nil
36
+ end
37
+ end
38
+
39
+ def save_changes
40
+ File.open(@index_path, 'w') { |file| file.write(@doc.to_html) }
41
+ end
42
+ end
data/lib/main.rb ADDED
@@ -0,0 +1,23 @@
1
+ require_relative 'jekyll_file_wizard'
2
+ require_relative 'configuration'
3
+
4
+ module JekyllFileWizard
5
+ class Main
6
+ def initialize(config_path, html_file_path)
7
+ @config = Configuration.new
8
+ @config.load_from_file(config_path)
9
+ @jekyll_wizard = JekyllFileWizard.new(html_file_path)
10
+ end
11
+
12
+ def update_html_structure
13
+ @config.sections_to_update.each do |section|
14
+ identifier = section['identifier']
15
+ new_content = section['content']
16
+
17
+ @jekyll_wizard.update_section(identifier, new_content)
18
+ end
19
+ end
20
+
21
+ # Other methods as needed
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ <section class="blog-section">
2
+ <h2>Latest Blog Posts</h2>
3
+ <!-- Blog posts will be inserted here -->
4
+ </section>
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll_file_wizard
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Thaddeus Thomas
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-12-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
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: '13.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '13.0'
55
+ description: 'JekyllFileWizard is a comprehensive gem designed to streamline the management
56
+ and dynamic updating of Jekyll site structures. It automates the process of checking,
57
+ creating, and updating various files in a Jekyll project, including HTML files,
58
+ data files, and more. The gem offers features like dynamic HTML structure handling,
59
+ integration with Jekyll''s data files, template management, robust error handling,
60
+ an interactive command-line interface, and automated testing and validation. It''s
61
+ ideal for Jekyll site developers looking to enhance their site''s functionality
62
+ and maintainability, making it easier to manage large and complex Jekyll sites.
63
+
64
+ '
65
+ email:
66
+ - thaddeus.r.thomas@gmail.com
67
+ executables: []
68
+ extensions: []
69
+ extra_rdoc_files: []
70
+ files:
71
+ - ".gitignore"
72
+ - ".vscode/settings.json"
73
+ - Gemfile
74
+ - LICENSE
75
+ - README.md
76
+ - Rakefile
77
+ - bin/jekyll_file_wizard
78
+ - docs/advanced_features.md
79
+ - docs/api_reference.md
80
+ - docs/configuration.md
81
+ - docs/examples.md
82
+ - docs/getting_started.md
83
+ - docs/troubleshooting.md
84
+ - docs/usage.md
85
+ - examples/advanced_example/advanced_examples.md
86
+ - examples/basic_example/basic_example.md
87
+ - examples/config.yml
88
+ - examples/data_integration_example/data_integration_example.md
89
+ - jekyll_file_wizard.gemspec
90
+ - lib/jekyll_file_wizard.rb
91
+ - lib/jekyll_file_wizard/configuration.rb
92
+ - lib/jekyll_file_wizard/data_integrator.rb
93
+ - lib/jekyll_file_wizard/html_updater.rb
94
+ - lib/jekyll_file_wizard/version.rb
95
+ - lib/main.rb
96
+ - templates/blog_section.html
97
+ homepage: https://visionary-code-works.github.io/JekyllFileWizard
98
+ licenses:
99
+ - MIT
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubygems_version: 3.4.22
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: Automate and enhance Jekyll site file management and updates with JekyllFileWizard.
120
+ test_files: []