al_comments 0.1.1 → 0.1.2

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/lib/al_comments.rb +34 -17
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48a78c929e423ff284d9ddb31ad8c7ee322f50394452c42bdabe0bb543b92c02
4
- data.tar.gz: 7d5ff7dd4a7ea88fe64d782b6228398c23aafd1ad4bea83f484e961f0663e910
3
+ metadata.gz: b21be4d1edaba6ece5ead7b8a4a367d44f8931ba71e789923d5420a3edc88958
4
+ data.tar.gz: 378e2a1016b2e1775665ab3ff6ade1bf21fd4cc9c37ba24d31efcba5f7b56ae1
5
5
  SHA512:
6
- metadata.gz: 7cef6fcfdf238069a461a198a2deddb9610238b4fed2671f458a9214a07444e106549ec26864d955bd7c9e35efd8134bceb2c341aeac31e9619c3097a1e24c93
7
- data.tar.gz: 6d2f0e1b0207ebef63884c4ad23f30975eff9b45a304073fc1504f8152033d28335e716e0d52e41492e73419c26b4e27283a52b9d862dd3a0a8131e8e1d73afd
6
+ metadata.gz: 458b7d6f979287163ccdc1ee7a59be3d8989aace5cf526bb6826809e4a0fbacba2e9255f8796d4045eb703dc9a7982e4454109b30f377171b93da38b2def58d1
7
+ data.tar.gz: 3eb9b4fc9c64fc6414d5411635503a37ee8fff72edcc8d9e26498f4eb5959874f5d435fc450fcbabb9b7503cda215e772f579aef559af6a678d94c959a8948a8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.2 - 2026-02-07
4
+ - Aligned giscus activation behavior with al-folio main branch expectations:
5
+ - Removed fallback from `site.repository` / `site.github.repository_nwo` to avoid partially configured giscus injection.
6
+ - Requires `repo`, `repo_id`, `category`, and `category_id` before loading giscus client script.
7
+ - Shows theme-side warning with missing required keys when configuration is incomplete.
8
+ - Expanded tests for incomplete giscus config handling.
9
+
3
10
  ## 0.1.1 - 2026-02-07
4
11
  - Improved config compatibility for comment rendering:
5
12
  - Supports both string and symbol keys for nested config values.
data/lib/al_comments.rb CHANGED
@@ -81,20 +81,42 @@ module AlComments
81
81
  nested.is_a?(Hash) ? nested : {}
82
82
  end
83
83
 
84
- def resolve_giscus_repo(site, giscus)
84
+ def resolve_giscus_repo(_site, giscus)
85
85
  repo = fetch_key(giscus, 'repo', 'repository', 'repo_name')
86
- return repo.to_s unless value_blank?(repo)
86
+ return '' if value_blank?(repo)
87
87
 
88
- repository = fetch_key(site.config, 'repository')
89
- return repository.to_s unless value_blank?(repository)
88
+ repo.to_s
89
+ end
90
+
91
+ def missing_giscus_fields(giscus, repo)
92
+ required = {
93
+ 'repo' => repo,
94
+ 'repo_id' => fetch_key(giscus, 'repo_id'),
95
+ 'category' => fetch_key(giscus, 'category'),
96
+ 'category_id' => fetch_key(giscus, 'category_id')
97
+ }
90
98
 
91
- github = fetch_key(site.config, 'github')
92
- if github.is_a?(Hash)
93
- repository_nwo = fetch_key(github, 'repository_nwo')
94
- return repository_nwo.to_s unless value_blank?(repository_nwo)
99
+ required.each_with_object([]) do |(name, value), missing|
100
+ missing << name if value_blank?(value)
95
101
  end
102
+ end
103
+
104
+ def giscus_warning_html(style, spacer, missing_fields)
105
+ details = if missing_fields.empty?
106
+ ''
107
+ else
108
+ "<p>Missing required keys: <code>#{missing_fields.join(', ')}</code>.</p>"
109
+ end
110
+
111
+ warning = <<~HTML
112
+ <blockquote class="block-danger">
113
+ <h5>giscus comments misconfigured</h5>
114
+ <p>Please follow instructions at <a href="http://giscus.app">http://giscus.app</a> and update your giscus configuration.</p>
115
+ #{details}
116
+ </blockquote>
117
+ HTML
96
118
 
97
- ''
119
+ %(<div id="giscus_thread"#{style}>#{spacer}\n#{warning}</div>)
98
120
  end
99
121
 
100
122
  def disqus_html(site, page, disqus_shortname)
@@ -127,15 +149,10 @@ module AlComments
127
149
  max_width = fetch_key(site.config, 'max_width')
128
150
  style = post_layout?(page) ? " style=\"max-width: #{max_width}; margin: 0 auto;\"" : ''
129
151
  spacer = post_layout?(page) ? "\n <br>" : ''
152
+ missing_fields = missing_giscus_fields(giscus, repo)
130
153
 
131
- if repo.to_s.strip.empty?
132
- warning = <<~HTML
133
- <blockquote class="block-danger">
134
- <h5>giscus comments misconfigured</h5>
135
- <p>Please follow instructions at <a href="http://giscus.app">http://giscus.app</a> and update your giscus configuration.</p>
136
- </blockquote>
137
- HTML
138
- return %(<div id="giscus_thread"#{style}>#{spacer}\n#{warning}</div>)
154
+ unless missing_fields.empty?
155
+ return giscus_warning_html(style, spacer, missing_fields)
139
156
  end
140
157
 
141
158
  <<~HTML
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: al_comments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - al-org