Module: Crm::SiteMapsHelper
- Defined in:
- app/helpers/crm/site_maps_helper.rb
Overview
View helper: site maps.
Constant Summary collapse
- EXPECTED_SCHEMAS =
Expected schema types based on page category
{ 'post' => %w[BlogPosting], 'faqs' => %w[FAQPage], 'product' => %w[Product], 'product_line' => %w[Product], 'showcase' => %w[Article] }.freeze
Instance Method Summary collapse
- #expected_schema_types(category) ⇒ Object
-
#site_map_ai_score_badge_class(score) ⇒ String
Badge class for AI analysis overall_score (0–100) in index table Matches Crm::SeoDashboardComponent#score_badge_class.
-
#site_map_crawl_status(sm) ⇒ String
Compact display of last crawl time + content presence indicator.
-
#site_map_resource_icon(site_map) ⇒ String
Returns an icon class for the resource type.
-
#site_map_resource_name(site_map) ⇒ String
Returns a display name for the resource.
-
#site_map_resource_path(site_map) ⇒ String?
Returns the CRM URL path for a SiteMap's linked resource.
-
#site_map_resource_type_label(site_map) ⇒ String
Returns a human-readable label for the resource type Handles Article subtypes (blog_post -> Blog Post, faq -> FAQ, etc.).
-
#site_map_schema_badges(sm) ⇒ String
Schema types as small Bootstrap badges.
-
#site_map_schema_health(sm) ⇒ String
Health indicator icon based on expected schemas for the page category.
-
#site_map_seo_commands(site_map) ⇒ Array<String>
Builds the link array for render_combo_drop_down.
-
#suggested_keyword_target(site_map, keyword, search_volume: nil) ⇒ Object
Intent-based suggestion (desired / undesired / ignore) for display and apply-to-selected.
- #suggestion_badge_class(suggestion) ⇒ Object
- #suggestion_label(suggestion) ⇒ Object
-
#url_path_only(site_map_or_url) ⇒ String
Returns the path portion for display Now that SiteMap stores path directly, this is a simple accessor.
Instance Method Details
#expected_schema_types(category) ⇒ Object
343 344 345 |
# File 'app/helpers/crm/site_maps_helper.rb', line 343 def expected_schema_types(category) EXPECTED_SCHEMAS[category] || [] end |
#site_map_ai_score_badge_class(score) ⇒ String
Badge class for AI analysis overall_score (0–100) in index table
Matches Crm::SeoDashboardComponent#score_badge_class
352 353 354 355 356 357 358 359 360 361 |
# File 'app/helpers/crm/site_maps_helper.rb', line 352 def site_map_ai_score_badge_class(score) return 'bg-secondary' unless score case score when 80..100 then 'bg-success' when 60..79 then 'bg-primary' when 40..59 then 'bg-warning text-dark' else 'bg-danger' end end |
#site_map_crawl_status(sm) ⇒ String
Compact display of last crawl time + content presence indicator
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'app/helpers/crm/site_maps_helper.rb', line 243 def site_map_crawl_status(sm) crawl_time = sm.try(:rendered_schema_at) || sm.last_status_datetime return content_tag(:span, 'never', class: 'text-muted fst-italic') if crawl_time.nil? parts = [] parts << content_tag(:span, "#{time_ago_in_words(crawl_time)} ago", title: crawl_time.to_fs(:short), class: crawl_time < 7.days.ago ? 'text-warning' : 'text-body-secondary') # Content indicator if sm.extracted_content.present? parts << fa_icon('file-lines', family: :solid, class: 'fa-sm text-success ms-1', title: "Content extracted (#{sm.extracted_content.length} chars)") end safe_join(parts) end |
#site_map_resource_icon(site_map) ⇒ String
Returns an icon class for the resource type
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'app/helpers/crm/site_maps_helper.rb', line 138 def site_map_resource_icon(site_map) return 'fa-solid fa-file' if site_map.resource.blank? resource = site_map.resource resource_type = site_map.resource_type case resource_type when 'Article' case resource.class.name when 'Post' then 'fa-solid fa-pen-fancy' when 'ArticleFaq' then 'fa-solid fa-circle-question' when 'ArticleTechnical' then 'fa-solid fa-screwdriver-wrench' when 'ArticleTraining' then 'fa-solid fa-graduation-cap' when 'ArticleProcedure' then 'fa-solid fa-file-lines' else 'fa-solid fa-file-lines' end when 'DigitalAsset' if resource.is_a?(Image) 'fa-solid fa-image' elsif resource.is_a?(Video) 'fa-solid fa-video' else 'fa-solid fa-photo-film' end when 'Showcase' 'fa-solid fa-images' when 'FloorPlanDisplay' 'fa-solid fa-map' when 'Item' 'fa-solid fa-box' when 'ProductLine' 'fa-solid fa-boxes-stacked' when 'CatalogItem' 'fa-solid fa-tag' else 'fa-solid fa-file' end end |
#site_map_resource_name(site_map) ⇒ String
Returns a display name for the resource
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/helpers/crm/site_maps_helper.rb', line 78 def site_map_resource_name(site_map) return nil if site_map.resource.blank? resource = site_map.resource resource_type = site_map.resource_type case resource_type when 'Article' resource.subject.presence || "#{site_map_resource_type_label(site_map)} ##{resource.id}" when 'DigitalAsset' resource.title.presence || resource.name.presence || "#{site_map_resource_type_label(site_map)} ##{resource.id}" else resource.try(:name) || resource.try(:title) || resource.try(:subject) || "#{resource_type} ##{resource.id}" end end |
#site_map_resource_path(site_map) ⇒ String?
Returns the CRM URL path for a SiteMap's linked resource
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/helpers/crm/site_maps_helper.rb', line 48 def site_map_resource_path(site_map) return nil if site_map.resource.blank? resource = site_map.resource resource_type = site_map.resource_type case resource_type when 'Article' article_resource_path(resource) when 'DigitalAsset' digital_asset_resource_path(resource) when 'Showcase' showcase_path(resource) when 'FloorPlanDisplay' floor_plan_display_path(resource) when 'Item' item_path(resource) when 'ProductLine' product_line_path(resource) when 'CatalogItem' catalog_item_path(resource) end rescue StandardError nil end |
#site_map_resource_type_label(site_map) ⇒ String
Returns a human-readable label for the resource type
Handles Article subtypes (blog_post -> Blog Post, faq -> FAQ, etc.)
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'app/helpers/crm/site_maps_helper.rb', line 99 def site_map_resource_type_label(site_map) return nil if site_map.resource.blank? resource = site_map.resource resource_type = site_map.resource_type case resource_type when 'Article' case resource.class.name when 'Post' then 'Blog Post' when 'ArticleFaq' then 'FAQ' when 'ArticleTechnical' then 'Technical Article' when 'ArticleTraining' then 'Training Article' when 'ArticleProcedure' then 'Procedure' else 'Article' end when 'DigitalAsset' if resource.is_a?(Image) 'Image' elsif resource.is_a?(Video) 'Video' else 'Digital Asset' end when 'ProductLine' 'Product Line' when 'FloorPlanDisplay' 'Floor Plan' when 'CatalogItem' 'Catalog Item' else resource_type.titleize end end |
#site_map_schema_badges(sm) ⇒ String
Schema types as small Bootstrap badges
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'app/helpers/crm/site_maps_helper.rb', line 266 def site_map_schema_badges(sm) types = sm.rendered_schema_types if types.blank? count_label = content_tag(:span, '0', class: 'text-muted') return safe_join([content_tag(:span, "\u2014", class: 'text-muted me-1'), count_label]) end # Short display names for common schema types short_names = { 'BlogPosting' => 'Blog', 'FAQPage' => 'FAQ', 'HowTo' => 'HowTo', 'Article' => 'Article', 'Product' => 'Product', 'BreadcrumbList' => 'Bread', 'Organization' => 'Org', 'LocalBusiness' => 'Biz', 'WebPage' => 'Page', 'CollectionPage' => 'Coll', 'OnlineStore' => 'Store', 'VideoObject' => 'Video', 'ImageObject' => 'Image' } badges = types.map do |type| label = short_names[type] || type.truncate(10) content_tag(:span, label, class: 'badge text-bg-info badge-sm me-1', title: type) end count = content_tag(:span, "(#{types.size})", class: 'text-muted ms-1') safe_join(badges + [count]) end |
#site_map_schema_health(sm) ⇒ String
Health indicator icon based on expected schemas for the page category
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
# File 'app/helpers/crm/site_maps_helper.rb', line 304 def site_map_schema_health(sm) if sm.rendered_schema_at.nil? return fa_icon('minus', family: :solid, class: 'fa-sm text-muted', title: 'Not yet crawled for schema') end types = sm.rendered_schema_types expected = expected_schema_types(sm.category) if expected.blank? # No specific expectation for this category — neutral if types.any? fa_icon('circle-check', family: :solid, class: 'fa-sm text-success', title: "#{types.size} schema type(s) found") else fa_icon('minus', family: :solid, class: 'fa-sm text-muted', title: 'No schemas (none expected)') end else missing = expected - types if missing.empty? fa_icon('circle-check', family: :solid, class: 'fa-sm text-success', title: "All expected schemas present: #{expected.join(', ')}") else fa_icon('triangle-exclamation', family: :solid, class: 'fa-sm text-warning', title: "Missing expected: #{missing.join(', ')}") end end end |
#site_map_seo_commands(site_map) ⇒ Array<String>
Builds the link array for render_combo_drop_down.
Primary action: full SEO analysis. Dropdown: individual sync steps.
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'app/helpers/crm/site_maps_helper.rb', line 186 def site_map_seo_commands(site_map) cmds = [] # Primary action (becomes the main button) cmds << link_to(analyze_site_map_path(site_map), data: { turbo_method: :post }) do fa_icon('wand-magic-sparkles', family: :solid, class: 'me-1') + ' Run Full Analysis' end # Individual sync steps (become dropdown items) cmds << link_to(analyze_only_site_map_path(site_map), data: { turbo_method: :post }) do fa_icon('brain', family: :solid, class: 'me-1') + ' Analysis Only' end cmds << link_to(analyze_premium_site_map_path(site_map), data: { turbo_method: :post }) do fa_icon('gem', family: :solid, class: 'me-1') + ' Premium Analysis (Opus)' end cmds << link_to(sync_visits_site_map_path(site_map), data: { turbo_method: :post }) do fa_icon('eye', family: :solid, class: 'me-1') + ' Sync Visits Only' end cmds << link_to(sync_gsc_site_map_path(site_map), data: { turbo_method: :post }) do fa_icon('google', family: :brands, class: 'me-1') + ' Sync GSC Only' end cmds << link_to(sync_ga4_site_map_path(site_map), data: { turbo_method: :post }) do fa_icon('chart-bar', family: :solid, class: 'me-1') + ' Sync GA4 Only' end cmds << link_to(sync_keywords_site_map_path(site_map), data: { turbo_method: :post }) do fa_icon('key', family: :solid, class: 'me-1') + ' Sync Keywords Only' end cmds << link_to(recrawl_site_map_path(site_map), data: { turbo_method: :post, turbo_confirm: 'Recrawl this page? This will fetch the latest content and schema.' }) do fa_icon('rotate', family: :solid, class: 'me-1') + ' Recrawl Page' end cmds end |
#suggested_keyword_target(site_map, keyword, search_volume: nil) ⇒ Object
Intent-based suggestion (desired / undesired / ignore) for display and apply-to-selected.
6 7 8 |
# File 'app/helpers/crm/site_maps_helper.rb', line 6 def suggested_keyword_target(site_map, keyword, search_volume: nil) site_map.suggested_keyword_target_for(keyword, search_volume: search_volume) end |
#suggestion_badge_class(suggestion) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'app/helpers/crm/site_maps_helper.rb', line 10 def suggestion_badge_class(suggestion) case suggestion when 'desired' then 'bg-success' when 'undesired' then 'bg-warning text-dark' when 'ignore' then 'bg-secondary' else 'bg-light text-dark' end end |
#suggestion_label(suggestion) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'app/helpers/crm/site_maps_helper.rb', line 19 def suggestion_label(suggestion) case suggestion when 'desired' then 'Desired' when 'undesired' then 'Not desired' when 'ignore' then 'Ignore' else '—' end end |
#url_path_only(site_map_or_url) ⇒ String
Returns the path portion for display
Now that SiteMap stores path directly, this is a simple accessor
33 34 35 36 37 38 39 40 41 42 |
# File 'app/helpers/crm/site_maps_helper.rb', line 33 def url_path_only(site_map_or_url) case site_map_or_url when SiteMap site_map_or_url.path.presence || '/' when String SiteMap.extract_path_from_url(site_map_or_url) else '/' end end |