postnhost 0.1.0 → 0.2.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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -0
  3. data/README.md +22 -9
  4. data/Rakefile +28 -0
  5. data/app/assets/builds/postnhost/application.css +1 -1
  6. data/app/assets/stylesheets/application.tailwind.css +5 -1
  7. data/app/controllers/postnhost/api/base_controller.rb +29 -0
  8. data/app/controllers/postnhost/api/v1/commands_controller.rb +27 -0
  9. data/app/controllers/postnhost/api/v1/mcp_controller.rb +49 -0
  10. data/app/controllers/postnhost/api_tokens_controller.rb +34 -0
  11. data/app/controllers/postnhost/articles/translations_controller.rb +2 -9
  12. data/app/controllers/postnhost/categories/translations_controller.rb +2 -9
  13. data/app/controllers/postnhost/management_preview_controller.rb +17 -0
  14. data/app/controllers/postnhost/pages/translations_controller.rb +2 -9
  15. data/app/helpers/postnhost/application_helper.rb +0 -11
  16. data/app/models/postnhost/api_token.rb +26 -0
  17. data/app/models/postnhost/user.rb +2 -0
  18. data/app/services/postnhost/api/v1/openapi.rb +27 -0
  19. data/app/services/postnhost/management/catalog.rb +151 -0
  20. data/app/services/postnhost/management/command.rb +174 -0
  21. data/app/services/postnhost/management/content_actions.rb +75 -0
  22. data/app/services/postnhost/management/input.rb +49 -0
  23. data/app/services/postnhost/management/mcp.rb +54 -0
  24. data/app/services/postnhost/management/preview.rb +25 -0
  25. data/app/services/postnhost/management/resources.rb +30 -0
  26. data/app/services/postnhost/management/schema_fields.rb +25 -0
  27. data/app/services/postnhost/management/serializer.rb +40 -0
  28. data/app/services/postnhost/management/settings_actions.rb +64 -0
  29. data/app/services/postnhost/management/upload.rb +18 -0
  30. data/app/services/postnhost/translation/enqueue.rb +59 -0
  31. data/app/views/layouts/postnhost/_sidebar.html.erb +7 -0
  32. data/app/views/layouts/postnhost/application.html.erb +2 -2
  33. data/app/views/layouts/postnhost/articles.html.erb +3 -3
  34. data/app/views/layouts/postnhost/product.html.erb +3 -3
  35. data/app/views/layouts/postnhost/public/templates/default.html.erb +2 -2
  36. data/app/views/layouts/postnhost/public/templates/swiss-editorial.html.erb +2 -2
  37. data/app/views/layouts/postnhost/public/templates/workspace-journal.html.erb +2 -2
  38. data/app/views/postnhost/api_tokens/index.html.erb +92 -0
  39. data/app/views/postnhost/onboarding/_post_install_checklist.html.erb +8 -8
  40. data/app/views/postnhost/pages/index.html.erb +1 -1
  41. data/app/views/postnhost/templates/edit.html.erb +1 -1
  42. data/config/routes.rb +12 -0
  43. data/db/migrate/20261008120000_create_api_tokens.rb +12 -0
  44. data/lib/generators/postnhost/install/install_generator.rb +11 -12
  45. data/lib/generators/postnhost/locale/locale_generator.rb +1 -1
  46. data/lib/generators/postnhost/static_pages/static_pages_generator.rb +1 -1
  47. data/lib/generators/postnhost/tailwindcss/install_generator.rb +28 -25
  48. data/lib/generators/postnhost/tailwindcss/templates/host.tailwind.css +0 -3
  49. data/lib/generators/postnhost/user/user_generator.rb +1 -1
  50. data/lib/generators/postnhost/views/views_generator.rb +5 -7
  51. data/lib/postnhost/css_build.rb +68 -0
  52. data/lib/postnhost/css_scope.rb +77 -0
  53. data/lib/postnhost/sample_data.rb +1 -1
  54. data/lib/postnhost/tailwind_compiler.rb +75 -0
  55. data/lib/postnhost/tailwind_input.rb +32 -0
  56. data/lib/postnhost/version.rb +1 -1
  57. data/lib/tasks/postnhost_tasks.rake +40 -65
  58. metadata +40 -2
  59. data/lib/generators/postnhost/tailwindcss/templates/tailwind.config.js +0 -8
@@ -1,94 +1,69 @@
1
- require "json"
1
+ require "fileutils"
2
+
3
+ require "postnhost/css_build"
4
+ require "postnhost/tailwind_compiler"
5
+ require "postnhost/tailwind_input"
2
6
 
3
7
  # rubocop:disable-next Metrics/BlockLength
4
8
  namespace :postnhost do
5
9
  namespace :tailwindcss do
6
10
  def postnhost_tailwind_enabled?
7
- Rails.root.join("postnhost.tailwind.config.js").exist? &&
8
- Rails.root.join("app/assets/stylesheets/postnhost/host.tailwind.css").exist?
9
- end
10
-
11
- def tailwindcss_rails_compile_command(watch: false)
12
- return unless Gem.loaded_specs.key?("tailwindcss-rails") || Gem.loaded_specs.key?("tailwindcss-ruby")
13
-
14
- begin
15
- require "tailwindcss/ruby"
16
- rescue LoadError
17
- return
18
- end
19
-
20
- executable = Tailwindcss::Ruby.executable
21
- return if executable.blank?
22
-
23
- command = [
24
- executable,
25
- "-i", Rails.root.join("app/assets/stylesheets/postnhost/host.tailwind.css").to_s,
26
- "-o", Rails.root.join("app/assets/builds/postnhost/host.css").to_s,
27
- "-c", Rails.root.join("postnhost.tailwind.config.js").to_s,
28
- "--minify"
29
- ]
30
- command << "-w" if watch
31
- command
11
+ Rails.root.join("app/assets/stylesheets/postnhost/host.tailwind.css").exist?
32
12
  end
33
13
 
34
- def package_json_scripts
35
- path = Rails.root.join("package.json")
36
- return {} unless path.exist?
37
-
38
- JSON.parse(File.read(path)).fetch("scripts", {})
39
- rescue JSON::ParserError
40
- {}
14
+ def host_tailwind_paths
15
+ {
16
+ input: Rails.root.join("tmp/postnhost/host.tailwind.css"),
17
+ unscoped: Rails.root.join("app/assets/builds/postnhost/application.unscoped.css"),
18
+ output: Rails.root.join("app/assets/builds/postnhost/application.css")
19
+ }
41
20
  end
42
21
 
43
- def npm_compile_command(watch: false)
44
- script = watch ? "postnhost:tailwindcss:watch" : "postnhost:tailwindcss"
45
- return unless package_json_scripts.key?(script)
22
+ def write_host_tailwind_input(path)
23
+ engine_source = Postnhost::Engine.root.join("app/assets/stylesheets/application.tailwind.css")
24
+ host_source = Rails.root.join("app/assets/stylesheets/postnhost/host.tailwind.css")
46
25
 
47
- ["yarn", script]
26
+ FileUtils.mkdir_p(path.dirname)
27
+ path.write(Postnhost::TailwindInput.build(engine_source:, host_source:))
48
28
  end
49
29
 
50
- def postnhost_tailwind_command(watch: false)
51
- tailwindcss_rails_compile_command(watch:) || npm_compile_command(watch:)
30
+ def build_host_tailwind(watch: false)
31
+ paths = host_tailwind_paths
32
+ write_host_tailwind_input(paths[:input])
33
+ command = Postnhost::TailwindCompiler.new(root: Rails.root).command(
34
+ input_path: paths[:input],
35
+ output_path: paths[:unscoped],
36
+ watch:
37
+ )
38
+
39
+ Postnhost::CssBuild.run(
40
+ command:,
41
+ unscoped_path: paths[:unscoped],
42
+ output_path: paths[:output],
43
+ watch:
44
+ )
45
+ ensure
46
+ FileUtils.rm_f(paths&.dig(:input))
52
47
  end
53
48
 
54
- def print_missing_tailwind_runner_message
55
- puts <<~MSG
56
- [postnhost] No Tailwind runner found for host mode.
57
- - Option 1: add the `tailwindcss-rails` gem to your host app.
58
- - Option 2: add package.json script `postnhost:tailwindcss:watch` (and `postnhost:tailwindcss` for build).
59
- MSG
60
- end
61
-
62
- desc "Build host Tailwind CSS for Postnhost overrides"
49
+ desc "Build host Tailwind CSS for PostnHost overrides"
63
50
  task build: :environment do
64
51
  unless postnhost_tailwind_enabled?
65
- puts "[postnhost] Skipping host Tailwind build (missing postnhost.tailwind.config.js or app/assets/stylesheets/postnhost/host.tailwind.css)"
66
- next
67
- end
68
-
69
- command = postnhost_tailwind_command
70
- unless command
71
- print_missing_tailwind_runner_message
52
+ puts "[postnhost] Skipping host Tailwind build (missing app/assets/stylesheets/postnhost/host.tailwind.css)"
72
53
  next
73
54
  end
74
55
 
75
- system(*command, exception: true)
56
+ build_host_tailwind
76
57
  end
77
58
 
78
- desc "Watch host Tailwind CSS for Postnhost overrides"
59
+ desc "Watch host Tailwind CSS for PostnHost overrides"
79
60
  task watch: :environment do
80
61
  unless postnhost_tailwind_enabled?
81
- puts "[postnhost] Missing host Tailwind files. Run: rails g postnhost:tailwindcss:install"
82
- next
83
- end
84
-
85
- command = postnhost_tailwind_command(watch: true)
86
- unless command
87
- print_missing_tailwind_runner_message
62
+ puts "[postnhost] Missing host Tailwind files. Run: bin/rails g postnhost:tailwindcss:install"
88
63
  next
89
64
  end
90
65
 
91
- system(*command, exception: true)
66
+ build_host_tailwind(watch: true)
92
67
  end
93
68
  end
94
69
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postnhost
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Shevchenko
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: crass
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: nokogiri
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -309,6 +323,10 @@ files:
309
323
  - app/controllers/concerns/postnhost/settings/navigation_manageable.rb
310
324
  - app/controllers/concerns/postnhost/settings/schema_manageable.rb
311
325
  - app/controllers/concerns/postnhost/users/schema_manageable.rb
326
+ - app/controllers/postnhost/api/base_controller.rb
327
+ - app/controllers/postnhost/api/v1/commands_controller.rb
328
+ - app/controllers/postnhost/api/v1/mcp_controller.rb
329
+ - app/controllers/postnhost/api_tokens_controller.rb
312
330
  - app/controllers/postnhost/application_controller.rb
313
331
  - app/controllers/postnhost/article_variants_controller.rb
314
332
  - app/controllers/postnhost/articles/cover_images_controller.rb
@@ -319,6 +337,7 @@ files:
319
337
  - app/controllers/postnhost/categories_controller.rb
320
338
  - app/controllers/postnhost/category_variants_controller.rb
321
339
  - app/controllers/postnhost/languages_controller.rb
340
+ - app/controllers/postnhost/management_preview_controller.rb
322
341
  - app/controllers/postnhost/onboarding_controller.rb
323
342
  - app/controllers/postnhost/page_variants_controller.rb
324
343
  - app/controllers/postnhost/pages/images_controller.rb
@@ -385,6 +404,7 @@ files:
385
404
  - app/models/concerns/postnhost/primary_language_guard.rb
386
405
  - app/models/concerns/postnhost/public_revision_touch.rb
387
406
  - app/models/concerns/postnhost/schema_localizable.rb
407
+ - app/models/postnhost/api_token.rb
388
408
  - app/models/postnhost/application_record.rb
389
409
  - app/models/postnhost/article.rb
390
410
  - app/models/postnhost/article_author.rb
@@ -412,9 +432,21 @@ files:
412
432
  - app/models/postnhost/template.rb
413
433
  - app/models/postnhost/user.rb
414
434
  - app/models/postnhost/version.rb
435
+ - app/services/postnhost/api/v1/openapi.rb
415
436
  - app/services/postnhost/base_service.rb
416
437
  - app/services/postnhost/constraints/public_locale_constraint.rb
417
438
  - app/services/postnhost/constraints/public_route_constraint.rb
439
+ - app/services/postnhost/management/catalog.rb
440
+ - app/services/postnhost/management/command.rb
441
+ - app/services/postnhost/management/content_actions.rb
442
+ - app/services/postnhost/management/input.rb
443
+ - app/services/postnhost/management/mcp.rb
444
+ - app/services/postnhost/management/preview.rb
445
+ - app/services/postnhost/management/resources.rb
446
+ - app/services/postnhost/management/schema_fields.rb
447
+ - app/services/postnhost/management/serializer.rb
448
+ - app/services/postnhost/management/settings_actions.rb
449
+ - app/services/postnhost/management/upload.rb
418
450
  - app/services/postnhost/onboarding/step_processor.rb
419
451
  - app/services/postnhost/onboarding/steps/base.rb
420
452
  - app/services/postnhost/onboarding/steps/choose_languages.rb
@@ -451,6 +483,7 @@ files:
451
483
  - app/services/postnhost/translation/article_variant_translator.rb
452
484
  - app/services/postnhost/translation/category_variant_translator.rb
453
485
  - app/services/postnhost/translation/content_translator.rb
486
+ - app/services/postnhost/translation/enqueue.rb
454
487
  - app/services/postnhost/translation/openai_llm_client.rb
455
488
  - app/services/postnhost/translation/page_variant_translator.rb
456
489
  - app/uploaders/base_uploader.rb
@@ -472,6 +505,7 @@ files:
472
505
  - app/views/layouts/postnhost/public_header/_dashboard_sign_in.html.erb
473
506
  - app/views/layouts/postnhost/public_header/_language_switcher.html.erb
474
507
  - app/views/layouts/postnhost/public_header/_logo.html.erb
508
+ - app/views/postnhost/api_tokens/index.html.erb
475
509
  - app/views/postnhost/article_variants/_variants_list.html.erb
476
510
  - app/views/postnhost/article_variants/edit.html.erb
477
511
  - app/views/postnhost/article_variants/index.html.erb
@@ -655,6 +689,7 @@ files:
655
689
  - db/migrate/20260528000002_create_page_variants.rb
656
690
  - db/migrate/20260709090000_create_snapshots.rb
657
691
  - db/migrate/20260726130000_create_site_scripts.rb
692
+ - db/migrate/20261008120000_create_api_tokens.rb
658
693
  - lib/generators/postnhost/install/install_generator.rb
659
694
  - lib/generators/postnhost/install/templates/carrierwave.rb
660
695
  - lib/generators/postnhost/install/templates/postnhost.rb
@@ -662,15 +697,18 @@ files:
662
697
  - lib/generators/postnhost/static_pages/static_pages_generator.rb
663
698
  - lib/generators/postnhost/tailwindcss/install_generator.rb
664
699
  - lib/generators/postnhost/tailwindcss/templates/host.tailwind.css
665
- - lib/generators/postnhost/tailwindcss/templates/tailwind.config.js
666
700
  - lib/generators/postnhost/user/user_generator.rb
667
701
  - lib/generators/postnhost/views/views_generator.rb
668
702
  - lib/postnhost.rb
669
703
  - lib/postnhost/configuration.rb
704
+ - lib/postnhost/css_build.rb
705
+ - lib/postnhost/css_scope.rb
670
706
  - lib/postnhost/engine.rb
671
707
  - lib/postnhost/sample_data.rb
672
708
  - lib/postnhost/settings/i18n_overrides.rb
673
709
  - lib/postnhost/settings/i18n_patch.rb
710
+ - lib/postnhost/tailwind_compiler.rb
711
+ - lib/postnhost/tailwind_input.rb
674
712
  - lib/postnhost/version.rb
675
713
  - lib/tasks/postnhost_snapshots.rake
676
714
  - lib/tasks/postnhost_tasks.rake
@@ -1,8 +0,0 @@
1
- module.exports = {
2
- content: [
3
- "./app/views/postnhost/**/*.erb",
4
- "./app/views/layouts/postnhost/**/*.erb",
5
- "./app/helpers/**/*.rb",
6
- "./app/javascript/**/*.js"
7
- ]
8
- }