wytch 0.3.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: 7aa017b3a2d6ed1b64cde7b4a73f312222d64a630a365ad71db68f4babc28ce5
4
- data.tar.gz: fba837a626f3c4dfcc3525d03127ada6b62b30b367e31da4c5eef3721c7b264a
3
+ metadata.gz: 3adc6455846cef32252a24576fd40aafe237d26a688e131ee73a9c222827d0c6
4
+ data.tar.gz: 1409ff6165c88b35941cef1679c7fcd8f77d7e07950d7ec9601a504c89309a91
5
5
  SHA512:
6
- metadata.gz: b70258ec6436a644dee4ecb637dc0bcad929428c7803d4272b7eef34b8bb0620b024c683a2a77f41e1235c05f5c1713b188a374bc7d050bb77a571bd924db7f0
7
- data.tar.gz: 98a84928a3cf7bd5aff50e99225d6b944da43ca69a44c2bb94a10ee8bc5ba424365ca228378f2f2472757b25632f86b7b5bea0aaa458e075100e2b96f1f87985
6
+ metadata.gz: bfe7e1897b05b7017624a03b8659919383dde9f0aabc86f4e8afe86ea4835a092bc0c719be29a0f1b641de133702229aa9a07fa1b766f99bda2e091b5f20d699
7
+ data.tar.gz: 3c04f324a254bf565d47ac2039141ee596c3dc1f98f39c3c7001fa51bdbf90f968520a3e9ed9ee4a2274301ffcc9a07d732e44c1593f0eccf2af36aee082890c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.5.0] - 2025-12-7
4
+
5
+ - Documentation cleanup
6
+
7
+ ## [0.4.0] - 2025-12-7
8
+
9
+ - Move sitemap generation to Wytch core (`Wytch::SitemapView` and `Wytch::SitemapHelper`)
10
+
3
11
  ## [0.3.0] - 2025-12-7
4
12
 
5
13
  - Add YARD documentation to all classes and methods
data/lib/wytch/builder.rb CHANGED
@@ -3,28 +3,15 @@
3
3
  require "fileutils"
4
4
 
5
5
  module Wytch
6
- # Builds the static site by rendering all pages to the output directory.
7
- #
8
- # The Builder is responsible for the production build process:
9
- # 1. Loading site configuration and content
10
- # 2. Rendering each page to HTML
11
- # 3. Copying static files from public/
12
- # 4. Integrating Vite-built assets
6
+ # Builds the static site.
13
7
  #
14
8
  # @example Building via CLI
15
9
  # $ wytch build
16
- #
17
- # @example Building programmatically
18
- # Wytch::Builder.new.build
19
10
  class Builder
20
- # @return [String] the output directory for built files
21
11
  OUTPUT_DIR = "build"
22
12
 
23
13
  # Builds the entire site.
24
14
  #
25
- # Sets RACK_ENV to "production", loads the site configuration,
26
- # renders all pages to HTML files, and copies static assets.
27
- #
28
15
  # @return [void]
29
16
  def build
30
17
  ENV["RACK_ENV"] = "production"
@@ -51,19 +38,12 @@ module Wytch
51
38
 
52
39
  private
53
40
 
54
- # Copies files from public/ to the output directory.
55
- #
56
- # @return [void]
57
41
  def copy_public_files
58
42
  return unless Dir.exist?("public")
59
43
 
60
44
  FileUtils.cp_r "public/.", OUTPUT_DIR, verbose: true
61
45
  end
62
46
 
63
- # Reports on Vite assets in the output directory.
64
- # Vite builds directly to build/assets, so no copying is needed.
65
- #
66
- # @return [void]
67
47
  def copy_vite_assets
68
48
  vite_output = File.join(OUTPUT_DIR, "assets")
69
49
  return unless Dir.exist?(vite_output)
data/lib/wytch/cli.rb CHANGED
@@ -71,8 +71,6 @@ module Wytch
71
71
  template("src/site/home_view.rb.tt", "#{name}/src/#{@site_name}/home_view.rb")
72
72
  template("src/site/post_view.rb.tt", "#{name}/src/#{@site_name}/post_view.rb")
73
73
  template("src/site/post_helpers.rb.tt", "#{name}/src/#{@site_name}/post_helpers.rb")
74
- template("src/site/sitemap_view.rb.tt", "#{name}/src/#{@site_name}/sitemap_view.rb")
75
- template("src/site/sitemap_helper.rb.tt", "#{name}/src/#{@site_name}/sitemap_helper.rb")
76
74
  template("src/site/feed_view.rb.tt", "#{name}/src/#{@site_name}/feed_view.rb")
77
75
  template("src/site/feed_helper.rb.tt", "#{name}/src/#{@site_name}/feed_helper.rb")
78
76
 
@@ -116,10 +114,6 @@ module Wytch
116
114
 
117
115
  private
118
116
 
119
- # Converts a snake_case name to PascalCase.
120
- #
121
- # @param name [String] the name to classify
122
- # @return [String] the PascalCase version
123
117
  def classify(name)
124
118
  name.split("_").map(&:capitalize).join
125
119
  end
@@ -29,24 +29,14 @@ module Wytch
29
29
 
30
30
  private
31
31
 
32
- # Creates a Page instance from a content file.
33
- #
34
- # @param file_path [String] path to the content file, relative to content_dir
35
- # @return [Page] the loaded page
36
32
  def load_page(file_path)
37
33
  page_class.new(file_path:)
38
34
  end
39
35
 
40
- # Returns the configured page class.
41
- #
42
- # @return [Class] the page class to instantiate
43
36
  def page_class
44
37
  Object.const_get(Wytch.site.page_class)
45
38
  end
46
39
 
47
- # Returns the content directory path.
48
- #
49
- # @return [String] the content directory
50
40
  def content_dir
51
41
  Wytch.site.content_dir
52
42
  end
data/lib/wytch/server.rb CHANGED
@@ -55,9 +55,6 @@ module Wytch
55
55
 
56
56
  private
57
57
 
58
- # Builds the Rack application stack.
59
- #
60
- # @return [Rack::Builder] the configured Rack app
61
58
  def app
62
59
  base_app = lambda { |env|
63
60
  path = env["PATH_INFO"]
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Wytch
4
+ # Helper module for sitemap pages.
5
+ #
6
+ # This module provides methods to configure a page as a sitemap.
7
+ # It sets the correct path, build path, and excludes the sitemap
8
+ # itself from appearing in the sitemap.
9
+ #
10
+ # @example Using in a content file (content/sitemap.rb)
11
+ # view Wytch::SitemapView
12
+ # add Wytch::SitemapHelper
13
+ module SitemapHelper
14
+ # Returns the URL path for the sitemap.
15
+ #
16
+ # @return [String] "/sitemap.xml"
17
+ def path
18
+ "/sitemap.xml"
19
+ end
20
+
21
+ # Returns the build path for the sitemap.
22
+ #
23
+ # @return [String] "sitemap.xml"
24
+ def build_path
25
+ "sitemap.xml"
26
+ end
27
+
28
+ # Excludes the sitemap from appearing in the sitemap.
29
+ #
30
+ # @return [Boolean] false
31
+ def include_in_sitemap?
32
+ false
33
+ end
34
+ end
35
+ end
@@ -1,15 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module <%= @site_module %>
3
+ module Wytch
4
+ # Generates an XML sitemap for the site.
5
+ #
6
+ # This view renders a sitemap.xml file listing all pages that have
7
+ # `include_in_sitemap?` returning true.
8
+ #
9
+ # @example Using in a content file (content/sitemap.rb)
10
+ # view Wytch::SitemapView
11
+ # add Wytch::SitemapHelper
4
12
  class SitemapView
13
+ # Creates a new sitemap view.
14
+ #
15
+ # @param page [Page] the page object (not used but required for interface)
5
16
  def initialize(page)
6
17
  @page = page
7
18
  end
8
19
 
20
+ # Renders the sitemap XML.
21
+ #
22
+ # @return [String] XML sitemap content
9
23
  def call
10
24
  require "builder"
11
25
 
12
- xml = Builder::XmlMarkup.new(indent: 2)
26
+ xml = ::Builder::XmlMarkup.new(indent: 2)
13
27
  xml.instruct! :xml, version: "1.0", encoding: "UTF-8"
14
28
  xml.urlset xmlns: "http://www.sitemaps.org/schemas/sitemap/0.9" do
15
29
  Wytch.site.pages.values.each do |page|
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- add <%= @site_module %>::SitemapHelper
4
- view <%= @site_module %>::SitemapView
3
+ add Wytch::SitemapHelper
4
+ view Wytch::SitemapView
data/lib/wytch/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Wytch
4
4
  # The current version of Wytch.
5
- VERSION = "0.3.0"
5
+ VERSION = "0.5.0"
6
6
  end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ view WytchSite::ApiClassView
4
+
5
+ @metadata[:title] = "Wytch::SitemapView"
6
+ @metadata[:yard_path] = "Wytch::SitemapView"