postnhost 0.0.0 → 0.1.1
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 +4 -4
- data/CHANGELOG.md +33 -0
- data/{LICENSE.txt → LICENSE} +6 -6
- data/README.md +343 -15
- data/Rakefile +66 -6
- data/app/assets/builds/postnhost/application.css +2 -0
- data/app/assets/builds/postnhost/application.js +50190 -0
- data/app/assets/config/postnhost_manifest.js +2 -0
- data/app/assets/images/postnhost/demo.webp +0 -0
- data/app/assets/images/postnhost/icons/alert-circle.svg +3 -0
- data/app/assets/images/postnhost/icons/arrow-left-long.svg +3 -0
- data/app/assets/images/postnhost/icons/arrow-left.svg +3 -0
- data/app/assets/images/postnhost/icons/arrow-right-end-on-rectangle.svg +3 -0
- data/app/assets/images/postnhost/icons/arrow-right-long.svg +3 -0
- data/app/assets/images/postnhost/icons/arrow-right.svg +3 -0
- data/app/assets/images/postnhost/icons/bars.svg +3 -0
- data/app/assets/images/postnhost/icons/bluesky.svg +3 -0
- data/app/assets/images/postnhost/icons/check-circle.svg +3 -0
- data/app/assets/images/postnhost/icons/chevron-down-small.svg +3 -0
- data/app/assets/images/postnhost/icons/chevron-down.svg +3 -0
- data/app/assets/images/postnhost/icons/chevron-left.svg +3 -0
- data/app/assets/images/postnhost/icons/chevron-right.svg +3 -0
- data/app/assets/images/postnhost/icons/clock.svg +3 -0
- data/app/assets/images/postnhost/icons/close.svg +3 -0
- data/app/assets/images/postnhost/icons/code-bracket.svg +3 -0
- data/app/assets/images/postnhost/icons/document-text.svg +3 -0
- data/app/assets/images/postnhost/icons/drag-handle.svg +8 -0
- data/app/assets/images/postnhost/icons/edit.svg +3 -0
- data/app/assets/images/postnhost/icons/external-link.svg +3 -0
- data/app/assets/images/postnhost/icons/eye.svg +4 -0
- data/app/assets/images/postnhost/icons/facebook.svg +3 -0
- data/app/assets/images/postnhost/icons/folder.svg +3 -0
- data/app/assets/images/postnhost/icons/image.svg +3 -0
- data/app/assets/images/postnhost/icons/info-circle.svg +3 -0
- data/app/assets/images/postnhost/icons/instagram.svg +3 -0
- data/app/assets/images/postnhost/icons/language.svg +3 -0
- data/app/assets/images/postnhost/icons/layers.svg +3 -0
- data/app/assets/images/postnhost/icons/lightning.svg +3 -0
- data/app/assets/images/postnhost/icons/linkedin.svg +3 -0
- data/app/assets/images/postnhost/icons/logout.svg +3 -0
- data/app/assets/images/postnhost/icons/magnifying-glass.svg +3 -0
- data/app/assets/images/postnhost/icons/mastodon.svg +3 -0
- data/app/assets/images/postnhost/icons/menu.svg +3 -0
- data/app/assets/images/postnhost/icons/plus.svg +3 -0
- data/app/assets/images/postnhost/icons/schedule.svg +3 -0
- data/app/assets/images/postnhost/icons/settings.svg +4 -0
- data/app/assets/images/postnhost/icons/sparkles.svg +3 -0
- data/app/assets/images/postnhost/icons/spinner.svg +4 -0
- data/app/assets/images/postnhost/icons/threads.svg +3 -0
- data/app/assets/images/postnhost/icons/tiktok.svg +3 -0
- data/app/assets/images/postnhost/icons/tiptap/align-center.svg +3 -0
- data/app/assets/images/postnhost/icons/tiptap/align-left.svg +3 -0
- data/app/assets/images/postnhost/icons/tiptap/align-right.svg +3 -0
- data/app/assets/images/postnhost/icons/tiptap/apply-link.svg +3 -0
- data/app/assets/images/postnhost/icons/tiptap/blockquote.svg +3 -0
- data/app/assets/images/postnhost/icons/tiptap/bold.svg +3 -0
- data/app/assets/images/postnhost/icons/tiptap/bullet-list.svg +3 -0
- data/app/assets/images/postnhost/icons/tiptap/code-block.svg +3 -0
- data/app/assets/images/postnhost/icons/tiptap/code.svg +3 -0
- data/app/assets/images/postnhost/icons/tiptap/heading-2.svg +3 -0
- data/app/assets/images/postnhost/icons/tiptap/heading-3.svg +3 -0
- data/app/assets/images/postnhost/icons/tiptap/image-add.svg +3 -0
- data/app/assets/images/postnhost/icons/tiptap/italic.svg +3 -0
- data/app/assets/images/postnhost/icons/tiptap/link.svg +3 -0
- data/app/assets/images/postnhost/icons/tiptap/ordered-list.svg +3 -0
- data/app/assets/images/postnhost/icons/tiptap/redo.svg +3 -0
- data/app/assets/images/postnhost/icons/tiptap/remove-link.svg +3 -0
- data/app/assets/images/postnhost/icons/tiptap/strike.svg +3 -0
- data/app/assets/images/postnhost/icons/tiptap/table.svg +3 -0
- data/app/assets/images/postnhost/icons/tiptap/underline.svg +3 -0
- data/app/assets/images/postnhost/icons/tiptap/undo.svg +3 -0
- data/app/assets/images/postnhost/icons/tiptap/youtube.svg +4 -0
- data/app/assets/images/postnhost/icons/translate.svg +3 -0
- data/app/assets/images/postnhost/icons/trash.svg +3 -0
- data/app/assets/images/postnhost/icons/user.svg +4 -0
- data/app/assets/images/postnhost/icons/users.svg +3 -0
- data/app/assets/images/postnhost/icons/warning.svg +3 -0
- data/app/assets/images/postnhost/icons/x.svg +3 -0
- data/app/assets/images/postnhost/icons/youtube.svg +3 -0
- data/app/assets/images/postnhost/logo.webp +0 -0
- data/app/assets/images/postnhost/og-image.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/08-how-to-control-suggested-articles-and-top-picks-01-discovery-controls.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/09-all-about-authors-in-postnhost-01-author-profile.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/09-all-about-authors-in-postnhost-02-multiple-authors.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/11-how-to-schedule-an-article-for-publication-01-timezone.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/11-how-to-schedule-an-article-for-publication-02-scheduled-article.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/12-how-article-version-history-and-restores-work-01-version-history.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/13-how-to-add-and-manage-languages-01-language-management.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/14-how-to-translate-articles-pages-and-categories-01-translation-options.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/14-how-to-translate-articles-pages-and-categories-02-ai-language-selection.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/16-how-to-add-navigation-links-01-navigation-builder.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/16-how-to-add-navigation-links-02-external-link-settings.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/17-how-to-add-a-logo-and-default-og-image-01-assets-settings.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/19-how-to-customize-public-text-for-each-language-01-i18n-overrides.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/20-how-to-configure-structured-data-and-sitemap-seo-01-site-schema.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/20-how-to-configure-structured-data-and-sitemap-seo-02-author-schema-defaults.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/20-how-to-configure-structured-data-and-sitemap-seo-03-author-schema-advanced-fields.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/covers/08-suggested-articles-and-top-picks.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/covers/09-authors.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/covers/11-scheduling.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/covers/12-version-history.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/covers/13-languages.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/covers/14-translations.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/covers/16-navigation-links.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/covers/17-logo-and-default-og-image.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/covers/19-public-text-for-each-language.webp +0 -0
- data/app/assets/images/postnhost/sample-docs/covers/20-structured-data-and-sitemap-seo.webp +0 -0
- data/app/assets/stylesheets/application.tailwind.css +347 -0
- data/app/assets/stylesheets/postnhost/application.css +15 -0
- data/app/assets/xsl/sitemap.xsl +64 -0
- data/app/controllers/concerns/postnhost/authentication.rb +59 -0
- data/app/controllers/concerns/postnhost/canonical_first_page_redirect.rb +14 -0
- data/app/controllers/concerns/postnhost/language_switcher.rb +42 -0
- data/app/controllers/concerns/postnhost/onboarding/access_control.rb +57 -0
- data/app/controllers/concerns/postnhost/onboarding/step_assignment.rb +55 -0
- data/app/controllers/concerns/postnhost/public_footer_data.rb +103 -0
- data/app/controllers/concerns/postnhost/public_http_caching.rb +35 -0
- data/app/controllers/concerns/postnhost/public_page_size.rb +17 -0
- data/app/controllers/concerns/postnhost/public_template_resolvable.rb +44 -0
- data/app/controllers/concerns/postnhost/settings/i18n_manageable.rb +61 -0
- data/app/controllers/concerns/postnhost/settings/navigation_manageable.rb +118 -0
- data/app/controllers/concerns/postnhost/settings/schema_manageable.rb +140 -0
- data/app/controllers/concerns/postnhost/users/schema_manageable.rb +119 -0
- data/app/controllers/postnhost/application_controller.rb +37 -0
- data/app/controllers/postnhost/article_variants_controller.rb +138 -0
- data/app/controllers/postnhost/articles/cover_images_controller.rb +35 -0
- data/app/controllers/postnhost/articles/images_controller.rb +28 -0
- data/app/controllers/postnhost/articles/translations_controller.rb +26 -0
- data/app/controllers/postnhost/articles_controller.rb +130 -0
- data/app/controllers/postnhost/categories/translations_controller.rb +24 -0
- data/app/controllers/postnhost/categories_controller.rb +59 -0
- data/app/controllers/postnhost/category_variants_controller.rb +69 -0
- data/app/controllers/postnhost/languages_controller.rb +66 -0
- data/app/controllers/postnhost/onboarding_controller.rb +70 -0
- data/app/controllers/postnhost/page_variants_controller.rb +136 -0
- data/app/controllers/postnhost/pages/images_controller.rb +28 -0
- data/app/controllers/postnhost/pages/translations_controller.rb +26 -0
- data/app/controllers/postnhost/pages_controller.rb +95 -0
- data/app/controllers/postnhost/public/articles_controller.rb +135 -0
- data/app/controllers/postnhost/public/authors_controller.rb +57 -0
- data/app/controllers/postnhost/public/categories_controller.rb +61 -0
- data/app/controllers/postnhost/public/static_pages_controller.rb +77 -0
- data/app/controllers/postnhost/public_controller.rb +32 -0
- data/app/controllers/postnhost/sessions_controller.rb +37 -0
- data/app/controllers/postnhost/settings/site_scripts_controller.rb +61 -0
- data/app/controllers/postnhost/settings_controller.rb +63 -0
- data/app/controllers/postnhost/sitemap_controller.rb +17 -0
- data/app/controllers/postnhost/templates_controller.rb +26 -0
- data/app/controllers/postnhost/users_controller.rb +112 -0
- data/app/helpers/postnhost/application_helper.rb +236 -0
- data/app/helpers/postnhost/article_helper.rb +41 -0
- data/app/helpers/postnhost/category_helper.rb +52 -0
- data/app/helpers/postnhost/common_css_helper.rb +97 -0
- data/app/helpers/postnhost/navigation_helper.rb +148 -0
- data/app/helpers/postnhost/pagy_helper.rb +103 -0
- data/app/helpers/postnhost/public_pages_helper.rb +287 -0
- data/app/helpers/postnhost/schema_helper.rb +102 -0
- data/app/helpers/postnhost/seo_helper.rb +428 -0
- data/app/helpers/postnhost/settings_helper.rb +79 -0
- data/app/javascript/application.js +3 -0
- data/app/javascript/controllers/ai_translation_controller.js +42 -0
- data/app/javascript/controllers/application.js +9 -0
- data/app/javascript/controllers/author_manager_controller.js +96 -0
- data/app/javascript/controllers/auto_save_controller.js +244 -0
- data/app/javascript/controllers/bulk_selection_controller.js +74 -0
- data/app/javascript/controllers/burger_controller.js +20 -0
- data/app/javascript/controllers/category_manager_controller.js +99 -0
- data/app/javascript/controllers/collapsible_sidebar_controller.js +87 -0
- data/app/javascript/controllers/cover_image_upload_controller.js +164 -0
- data/app/javascript/controllers/dropdown_controller.js +38 -0
- data/app/javascript/controllers/editor_mobile_sidebars_controller.js +36 -0
- data/app/javascript/controllers/file_auto_submit_controller.js +23 -0
- data/app/javascript/controllers/flash_message_controller.js +40 -0
- data/app/javascript/controllers/index.js +71 -0
- data/app/javascript/controllers/navigation_builder_controller.js +463 -0
- data/app/javascript/controllers/public_mobile_nav_controller.js +26 -0
- data/app/javascript/controllers/publish_guard_controller.js +47 -0
- data/app/javascript/controllers/reading_progress_controller.js +38 -0
- data/app/javascript/controllers/schedule_manager_controller.js +87 -0
- data/app/javascript/controllers/suggestion_manager_controller.js +99 -0
- data/app/javascript/controllers/template_preview_controller.js +34 -0
- data/app/javascript/controllers/tiptap_editor_controller.js +812 -0
- data/app/javascript/controllers/title_field_controller.js +17 -0
- data/app/javascript/helpers/auto_save_state.js +47 -0
- data/app/javascript/helpers/code_highlighting.js +48 -0
- data/app/javascript/helpers/dom_helpers.js +109 -0
- data/app/javascript/helpers/style_helpers.js +168 -0
- data/app/jobs/postnhost/application_job.rb +9 -0
- data/app/jobs/postnhost/scheduled_article_job.rb +13 -0
- data/app/jobs/postnhost/translation/article_variant_job.rb +17 -0
- data/app/jobs/postnhost/translation/category_variant_job.rb +17 -0
- data/app/jobs/postnhost/translation/page_variant_job.rb +17 -0
- data/app/models/concerns/postnhost/article/image_uploadable.rb +11 -0
- data/app/models/concerns/postnhost/excerpt_optimizable.rb +57 -0
- data/app/models/concerns/postnhost/inline_image_uploadable.rb +40 -0
- data/app/models/concerns/postnhost/page/image_uploadable.rb +11 -0
- data/app/models/concerns/postnhost/primary_language_guard.rb +18 -0
- data/app/models/concerns/postnhost/public_revision_touch.rb +15 -0
- data/app/models/concerns/postnhost/schema_localizable.rb +28 -0
- data/app/models/postnhost/application_record.rb +5 -0
- data/app/models/postnhost/article.rb +142 -0
- data/app/models/postnhost/article_author.rb +20 -0
- data/app/models/postnhost/article_category.rb +8 -0
- data/app/models/postnhost/article_suggestion.rb +19 -0
- data/app/models/postnhost/article_variant.rb +28 -0
- data/app/models/postnhost/category.rb +34 -0
- data/app/models/postnhost/category_variant.rb +24 -0
- data/app/models/postnhost/language.rb +38 -0
- data/app/models/postnhost/navigation.rb +76 -0
- data/app/models/postnhost/navigation_item.rb +100 -0
- data/app/models/postnhost/page.rb +63 -0
- data/app/models/postnhost/page_variant.rb +26 -0
- data/app/models/postnhost/public_site_revision.rb +24 -0
- data/app/models/postnhost/published_cover_image.rb +28 -0
- data/app/models/postnhost/setting.rb +116 -0
- data/app/models/postnhost/site_script.rb +11 -0
- data/app/models/postnhost/snapshot/article.rb +142 -0
- data/app/models/postnhost/snapshot/article_author.rb +11 -0
- data/app/models/postnhost/snapshot/article_category.rb +10 -0
- data/app/models/postnhost/snapshot/article_suggestion.rb +11 -0
- data/app/models/postnhost/snapshot/article_variant.rb +60 -0
- data/app/models/postnhost/snapshot/page.rb +33 -0
- data/app/models/postnhost/snapshot/page_variant.rb +41 -0
- data/app/models/postnhost/template.rb +20 -0
- data/app/models/postnhost/user.rb +63 -0
- data/app/models/postnhost/version.rb +7 -0
- data/app/services/postnhost/base_service.rb +17 -0
- data/app/services/postnhost/constraints/public_locale_constraint.rb +9 -0
- data/app/services/postnhost/constraints/public_route_constraint.rb +19 -0
- data/app/services/postnhost/onboarding/step_processor.rb +27 -0
- data/app/services/postnhost/onboarding/steps/base.rb +52 -0
- data/app/services/postnhost/onboarding/steps/choose_languages.rb +66 -0
- data/app/services/postnhost/onboarding/steps/complete_post_install_checklist.rb +12 -0
- data/app/services/postnhost/onboarding/steps/create_admin_account.rb +28 -0
- data/app/services/postnhost/onboarding/steps/finish_setup.rb +27 -0
- data/app/services/postnhost/onboarding/steps/set_site_metadata.rb +70 -0
- data/app/services/postnhost/public_navigation_targets.rb +67 -0
- data/app/services/postnhost/public_request_context.rb +101 -0
- data/app/services/postnhost/publishing/article_variants/publish.rb +26 -0
- data/app/services/postnhost/publishing/article_variants/publish_many.rb +23 -0
- data/app/services/postnhost/publishing/article_variants/snapshot_writer.rb +44 -0
- data/app/services/postnhost/publishing/article_variants/unpublish.rb +27 -0
- data/app/services/postnhost/publishing/article_variants/unpublish_many.rb +23 -0
- data/app/services/postnhost/publishing/articles/publish.rb +25 -0
- data/app/services/postnhost/publishing/articles/publish_scheduled.rb +42 -0
- data/app/services/postnhost/publishing/articles/snapshot_writer.rb +84 -0
- data/app/services/postnhost/publishing/articles/unpublish.rb +26 -0
- data/app/services/postnhost/publishing/bulk_transition.rb +63 -0
- data/app/services/postnhost/publishing/error.rb +12 -0
- data/app/services/postnhost/publishing/page_variants/publish.rb +26 -0
- data/app/services/postnhost/publishing/page_variants/publish_many.rb +23 -0
- data/app/services/postnhost/publishing/page_variants/snapshot_writer.rb +41 -0
- data/app/services/postnhost/publishing/page_variants/unpublish.rb +27 -0
- data/app/services/postnhost/publishing/page_variants/unpublish_many.rb +23 -0
- data/app/services/postnhost/publishing/pages/publish.rb +25 -0
- data/app/services/postnhost/publishing/pages/snapshot_writer.rb +38 -0
- data/app/services/postnhost/publishing/pages/unpublish.rb +26 -0
- data/app/services/postnhost/publishing/revision.rb +37 -0
- data/app/services/postnhost/publishing/route_validator.rb +41 -0
- data/app/services/postnhost/publishing/versions/restore_draft.rb +64 -0
- data/app/services/postnhost/service_result.rb +7 -0
- data/app/services/postnhost/sitemap_builder.rb +395 -0
- data/app/services/postnhost/translation/article_variant_translator.rb +102 -0
- data/app/services/postnhost/translation/category_variant_translator.rb +92 -0
- data/app/services/postnhost/translation/content_translator.rb +119 -0
- data/app/services/postnhost/translation/openai_llm_client.rb +30 -0
- data/app/services/postnhost/translation/page_variant_translator.rb +55 -0
- data/app/uploaders/base_uploader.rb +26 -0
- data/app/uploaders/cover_image_uploader.rb +31 -0
- data/app/uploaders/postnhost/avatar_uploader.rb +17 -0
- data/app/uploaders/postnhost/inline_article_image_uploader.rb +38 -0
- data/app/uploaders/postnhost/inline_page_image_uploader.rb +38 -0
- data/app/uploaders/postnhost/setting_asset_uploader.rb +18 -0
- data/app/views/layouts/postnhost/_favicon.html.erb +6 -0
- data/app/views/layouts/postnhost/_footer.html.erb +67 -0
- data/app/views/layouts/postnhost/_header.html.erb +89 -0
- data/app/views/layouts/postnhost/_sidebar.html.erb +72 -0
- data/app/views/layouts/postnhost/application.html.erb +23 -0
- data/app/views/layouts/postnhost/articles.html.erb +34 -0
- data/app/views/layouts/postnhost/product.html.erb +36 -0
- data/app/views/layouts/postnhost/public/templates/default.html.erb +110 -0
- data/app/views/layouts/postnhost/public/templates/swiss-editorial.html.erb +213 -0
- data/app/views/layouts/postnhost/public/templates/workspace-journal.html.erb +231 -0
- data/app/views/layouts/postnhost/public_header/_dashboard_sign_in.html.erb +14 -0
- data/app/views/layouts/postnhost/public_header/_language_switcher.html.erb +43 -0
- data/app/views/layouts/postnhost/public_header/_logo.html.erb +9 -0
- data/app/views/postnhost/article_variants/_variants_list.html.erb +82 -0
- data/app/views/postnhost/article_variants/edit.html.erb +48 -0
- data/app/views/postnhost/article_variants/index.html.erb +128 -0
- data/app/views/postnhost/article_variants/publish.turbo_stream.erb +3 -0
- data/app/views/postnhost/article_variants/unpublish.turbo_stream.erb +3 -0
- data/app/views/postnhost/article_variants/update.turbo_stream.erb +3 -0
- data/app/views/postnhost/articles/_author_manager.html.erb +38 -0
- data/app/views/postnhost/articles/_category_manager.html.erb +42 -0
- data/app/views/postnhost/articles/_cover_image_upload.html.erb +82 -0
- data/app/views/postnhost/articles/_suggestion_manager.html.erb +43 -0
- data/app/views/postnhost/articles/_version_snapshot.html.erb +10 -0
- data/app/views/postnhost/articles/edit.html.erb +51 -0
- data/app/views/postnhost/articles/index.html.erb +132 -0
- data/app/views/postnhost/articles/publish.turbo_stream.erb +3 -0
- data/app/views/postnhost/articles/unpublish.turbo_stream.erb +3 -0
- data/app/views/postnhost/articles/update.turbo_stream.erb +3 -0
- data/app/views/postnhost/articles/version_preview.html.erb +17 -0
- data/app/views/postnhost/articles/versions.html.erb +68 -0
- data/app/views/postnhost/categories/edit.html.erb +77 -0
- data/app/views/postnhost/categories/index.html.erb +80 -0
- data/app/views/postnhost/categories/new.html.erb +50 -0
- data/app/views/postnhost/categories/show.html.erb +99 -0
- data/app/views/postnhost/category_variants/_category_variants_list.html.erb +67 -0
- data/app/views/postnhost/category_variants/_form.html.erb +29 -0
- data/app/views/postnhost/category_variants/edit.html.erb +21 -0
- data/app/views/postnhost/category_variants/index.html.erb +82 -0
- data/app/views/postnhost/category_variants/new.html.erb +21 -0
- data/app/views/postnhost/languages/edit.html.erb +45 -0
- data/app/views/postnhost/languages/index.html.erb +86 -0
- data/app/views/postnhost/languages/new.html.erb +45 -0
- data/app/views/postnhost/languages/show.html.erb +156 -0
- data/app/views/postnhost/onboarding/_post_install_checklist.html.erb +40 -0
- data/app/views/postnhost/onboarding/_step_1.html.erb +42 -0
- data/app/views/postnhost/onboarding/_step_2.html.erb +38 -0
- data/app/views/postnhost/onboarding/_step_3.html.erb +62 -0
- data/app/views/postnhost/onboarding/_step_4.html.erb +26 -0
- data/app/views/postnhost/onboarding/show.html.erb +51 -0
- data/app/views/postnhost/page_variants/_variants_list.html.erb +82 -0
- data/app/views/postnhost/page_variants/edit.html.erb +50 -0
- data/app/views/postnhost/page_variants/index.html.erb +128 -0
- data/app/views/postnhost/page_variants/publish.turbo_stream.erb +3 -0
- data/app/views/postnhost/page_variants/unpublish.turbo_stream.erb +3 -0
- data/app/views/postnhost/page_variants/update.turbo_stream.erb +3 -0
- data/app/views/postnhost/pages/edit.html.erb +50 -0
- data/app/views/postnhost/pages/index.html.erb +110 -0
- data/app/views/postnhost/pages/publish.turbo_stream.erb +3 -0
- data/app/views/postnhost/pages/unpublish.turbo_stream.erb +3 -0
- data/app/views/postnhost/public/articles/content_for/_index.html.erb +30 -0
- data/app/views/postnhost/public/articles/content_for/_preview.html.erb +9 -0
- data/app/views/postnhost/public/articles/content_for/_show.html.erb +24 -0
- data/app/views/postnhost/public/authors/content_for/_show.html.erb +24 -0
- data/app/views/postnhost/public/categories/content_for/_index.html.erb +29 -0
- data/app/views/postnhost/public/static_pages/content_for/_show.html.erb +19 -0
- data/app/views/postnhost/public/templates/default/articles/_article_card.html.erb +37 -0
- data/app/views/postnhost/public/templates/default/articles/_search_form.html.erb +12 -0
- data/app/views/postnhost/public/templates/default/articles/_suggestions.html.erb +44 -0
- data/app/views/postnhost/public/templates/default/articles/_top_picks.html.erb +42 -0
- data/app/views/postnhost/public/templates/default/articles/index.html.erb +53 -0
- data/app/views/postnhost/public/templates/default/articles/preview.html.erb +102 -0
- data/app/views/postnhost/public/templates/default/articles/show.html.erb +111 -0
- data/app/views/postnhost/public/templates/default/authors/_article_card.html.erb +28 -0
- data/app/views/postnhost/public/templates/default/authors/_profile_block.html.erb +29 -0
- data/app/views/postnhost/public/templates/default/authors/show.html.erb +36 -0
- data/app/views/postnhost/public/templates/default/categories/_article_card.html.erb +34 -0
- data/app/views/postnhost/public/templates/default/categories/index.html.erb +48 -0
- data/app/views/postnhost/public/templates/default/shared/_article_authors.html.erb +24 -0
- data/app/views/postnhost/public/templates/default/shared/_author_avatar.html.erb +9 -0
- data/app/views/postnhost/public/templates/default/shared/_hero_cover_image.html.erb +11 -0
- data/app/views/postnhost/public/templates/default/shared/_pagination.html.erb +35 -0
- data/app/views/postnhost/public/templates/default/shared/_thumbnail_cover_image.html.erb +9 -0
- data/app/views/postnhost/public/templates/default/static_pages/show.html.erb +22 -0
- data/app/views/postnhost/public/templates/swiss-editorial/articles/_article_card.html.erb +28 -0
- data/app/views/postnhost/public/templates/swiss-editorial/articles/_search_form.html.erb +19 -0
- data/app/views/postnhost/public/templates/swiss-editorial/articles/_suggestions.html.erb +42 -0
- data/app/views/postnhost/public/templates/swiss-editorial/articles/_top_picks.html.erb +38 -0
- data/app/views/postnhost/public/templates/swiss-editorial/articles/index.html.erb +133 -0
- data/app/views/postnhost/public/templates/swiss-editorial/articles/preview.html.erb +42 -0
- data/app/views/postnhost/public/templates/swiss-editorial/articles/show.html.erb +100 -0
- data/app/views/postnhost/public/templates/swiss-editorial/authors/_article_card.html.erb +27 -0
- data/app/views/postnhost/public/templates/swiss-editorial/authors/_profile_block.html.erb +32 -0
- data/app/views/postnhost/public/templates/swiss-editorial/authors/show.html.erb +31 -0
- data/app/views/postnhost/public/templates/swiss-editorial/categories/_article_card.html.erb +28 -0
- data/app/views/postnhost/public/templates/swiss-editorial/categories/index.html.erb +88 -0
- data/app/views/postnhost/public/templates/swiss-editorial/shared/_article_authors.html.erb +26 -0
- data/app/views/postnhost/public/templates/swiss-editorial/shared/_author_avatar.html.erb +9 -0
- data/app/views/postnhost/public/templates/swiss-editorial/shared/_hero_cover_image.html.erb +11 -0
- data/app/views/postnhost/public/templates/swiss-editorial/shared/_pagination.html.erb +35 -0
- data/app/views/postnhost/public/templates/swiss-editorial/shared/_thumbnail_cover_image.html.erb +9 -0
- data/app/views/postnhost/public/templates/swiss-editorial/static_pages/show.html.erb +17 -0
- data/app/views/postnhost/public/templates/workspace-journal/articles/_article_card.html.erb +44 -0
- data/app/views/postnhost/public/templates/workspace-journal/articles/_search_form.html.erb +19 -0
- data/app/views/postnhost/public/templates/workspace-journal/articles/_suggestions.html.erb +49 -0
- data/app/views/postnhost/public/templates/workspace-journal/articles/_top_picks.html.erb +34 -0
- data/app/views/postnhost/public/templates/workspace-journal/articles/index.html.erb +69 -0
- data/app/views/postnhost/public/templates/workspace-journal/articles/preview.html.erb +113 -0
- data/app/views/postnhost/public/templates/workspace-journal/articles/show.html.erb +120 -0
- data/app/views/postnhost/public/templates/workspace-journal/authors/_article_card.html.erb +1 -0
- data/app/views/postnhost/public/templates/workspace-journal/authors/_profile_block.html.erb +32 -0
- data/app/views/postnhost/public/templates/workspace-journal/authors/show.html.erb +33 -0
- data/app/views/postnhost/public/templates/workspace-journal/categories/_article_card.html.erb +1 -0
- data/app/views/postnhost/public/templates/workspace-journal/categories/index.html.erb +58 -0
- data/app/views/postnhost/public/templates/workspace-journal/shared/_article_authors.html.erb +27 -0
- data/app/views/postnhost/public/templates/workspace-journal/shared/_article_card.html.erb +44 -0
- data/app/views/postnhost/public/templates/workspace-journal/shared/_author_avatar.html.erb +9 -0
- data/app/views/postnhost/public/templates/workspace-journal/shared/_category_navigation.html.erb +10 -0
- data/app/views/postnhost/public/templates/workspace-journal/shared/_hero_cover_image.html.erb +11 -0
- data/app/views/postnhost/public/templates/workspace-journal/shared/_pagination.html.erb +35 -0
- data/app/views/postnhost/public/templates/workspace-journal/shared/_thumbnail_cover_image.html.erb +9 -0
- data/app/views/postnhost/public/templates/workspace-journal/static_pages/show.html.erb +17 -0
- data/app/views/postnhost/sessions/new.html.erb +59 -0
- data/app/views/postnhost/settings/edit.html.erb +68 -0
- data/app/views/postnhost/settings/sections/_assets.html.erb +40 -0
- data/app/views/postnhost/settings/sections/_feature_flags.html.erb +43 -0
- data/app/views/postnhost/settings/sections/_i18n.html.erb +57 -0
- data/app/views/postnhost/settings/sections/_navigation.html.erb +98 -0
- data/app/views/postnhost/settings/sections/_schema.html.erb +253 -0
- data/app/views/postnhost/settings/sections/_scripts.html.erb +79 -0
- data/app/views/postnhost/settings/sections/_site.html.erb +41 -0
- data/app/views/postnhost/settings/sections/_timezone.html.erb +19 -0
- data/app/views/postnhost/shared/_ai_translation_modal.html.erb +85 -0
- data/app/views/postnhost/shared/_flash_messages.html.erb +27 -0
- data/app/views/postnhost/shared/_form_errors.html.erb +22 -0
- data/app/views/postnhost/shared/_seo_meta_tags.html.erb +70 -0
- data/app/views/postnhost/shared/_structured_data.html.erb +5 -0
- data/app/views/postnhost/shared/articles/_action_buttons.html.erb +87 -0
- data/app/views/postnhost/shared/articles/_cover_image_preview.html.erb +30 -0
- data/app/views/postnhost/shared/articles/_editor_column.html.erb +15 -0
- data/app/views/postnhost/shared/articles/_editor_column_preview.html.erb +33 -0
- data/app/views/postnhost/shared/articles/_error_messages.html.erb +23 -0
- data/app/views/postnhost/shared/articles/_meta_sidebar.html.erb +322 -0
- data/app/views/postnhost/shared/articles/_meta_sidebar_preview.html.erb +29 -0
- data/app/views/postnhost/shared/articles/_post_actions.html.erb +105 -0
- data/app/views/postnhost/shared/articles/_schedule_actions.html.erb +51 -0
- data/app/views/postnhost/shared/articles/_tiptap_editor.html.erb +225 -0
- data/app/views/postnhost/shared/articles/_title_field.html.erb +9 -0
- data/app/views/postnhost/shared/articles/_version_action_buttons.html.erb +35 -0
- data/app/views/postnhost/shared/elements/_button.html.erb +20 -0
- data/app/views/postnhost/shared/elements/_button_link.html.erb +24 -0
- data/app/views/postnhost/shared/elements/_empty_state.html.erb +22 -0
- data/app/views/postnhost/shared/elements/_error_messages.html.erb +28 -0
- data/app/views/postnhost/shared/elements/_form_card.html.erb +10 -0
- data/app/views/postnhost/shared/elements/_form_page_header.html.erb +21 -0
- data/app/views/postnhost/shared/elements/_icon_button.html.erb +17 -0
- data/app/views/postnhost/shared/elements/_page_header.html.erb +40 -0
- data/app/views/postnhost/shared/elements/_table_container.html.erb +23 -0
- data/app/views/postnhost/shared/pages/_action_buttons.html.erb +84 -0
- data/app/views/postnhost/shared/pages/_meta_sidebar.html.erb +132 -0
- data/app/views/postnhost/shared/pages/_post_actions.html.erb +69 -0
- data/app/views/postnhost/templates/edit.html.erb +83 -0
- data/app/views/postnhost/users/_avatar.html.erb +9 -0
- data/app/views/postnhost/users/_form.html.erb +160 -0
- data/app/views/postnhost/users/edit.html.erb +26 -0
- data/app/views/postnhost/users/index.html.erb +91 -0
- data/app/views/postnhost/users/new.html.erb +9 -0
- data/app/views/postnhost/users/schema_edit.html.erb +175 -0
- data/config/locales/de.yml +55 -0
- data/config/locales/en.yml +88 -0
- data/config/locales/es.yml +58 -0
- data/config/locales/fr.yml +55 -0
- data/config/locales/ja.yml +55 -0
- data/config/locales/ko.yml +55 -0
- data/config/locales/pl.yml +55 -0
- data/config/locales/pt.yml +55 -0
- data/config/locales/ru.yml +55 -0
- data/config/routes.rb +112 -0
- data/db/migrate/20250822213820_create_users.rb +29 -0
- data/db/migrate/20250822214046_create_categories.rb +15 -0
- data/db/migrate/20250822214106_create_languages.rb +16 -0
- data/db/migrate/20250822214148_create_articles.rb +34 -0
- data/db/migrate/20250822214217_create_article_variants.rb +24 -0
- data/db/migrate/20250929091137_create_article_categories.rb +12 -0
- data/db/migrate/20251013204200_create_versions.rb +40 -0
- data/db/migrate/20260106074532_create_article_suggestions.rb +13 -0
- data/db/migrate/20260108110506_create_category_variants.rb +15 -0
- data/db/migrate/20260308130000_create_settings.rb +23 -0
- data/db/migrate/20260323113000_create_pages.rb +19 -0
- data/db/migrate/20260414100000_create_article_authors.rb +14 -0
- data/db/migrate/20260512100000_create_templates.rb +9 -0
- data/db/migrate/20260520110001_create_navigations.rb +9 -0
- data/db/migrate/20260520110002_create_navigation_items.rb +22 -0
- data/db/migrate/20260528000002_create_page_variants.rb +20 -0
- data/db/migrate/20260709090000_create_snapshots.rb +154 -0
- data/db/migrate/20260726130000_create_site_scripts.rb +11 -0
- data/lib/generators/postnhost/install/install_generator.rb +55 -0
- data/lib/generators/postnhost/install/templates/carrierwave.rb +17 -0
- data/lib/generators/postnhost/install/templates/postnhost.rb +36 -0
- data/lib/generators/postnhost/locale/locale_generator.rb +36 -0
- data/lib/generators/postnhost/static_pages/static_pages_generator.rb +47 -0
- data/lib/generators/postnhost/tailwindcss/install_generator.rb +100 -0
- data/lib/generators/postnhost/tailwindcss/templates/host.tailwind.css +4 -0
- data/lib/generators/postnhost/user/user_generator.rb +36 -0
- data/lib/generators/postnhost/views/views_generator.rb +140 -0
- data/lib/postnhost/configuration.rb +64 -0
- data/lib/postnhost/css_build.rb +68 -0
- data/lib/postnhost/css_scope.rb +77 -0
- data/lib/postnhost/engine.rb +57 -0
- data/lib/postnhost/sample_data.rb +865 -0
- data/lib/postnhost/settings/i18n_overrides.rb +137 -0
- data/lib/postnhost/settings/i18n_patch.rb +18 -0
- data/lib/postnhost/tailwind_compiler.rb +75 -0
- data/lib/postnhost/tailwind_input.rb +32 -0
- data/lib/postnhost/version.rb +1 -3
- data/lib/postnhost.rb +26 -3
- data/lib/tasks/postnhost_snapshots.rake +77 -0
- data/lib/tasks/postnhost_tasks.rake +71 -0
- metadata +679 -21
- data/.github/workflows/main.yml +0 -27
- data/.gitignore +0 -11
- data/.rspec +0 -3
- data/.rubocop.yml +0 -8
- data/Gemfile +0 -13
- data/bin/console +0 -11
- data/bin/setup +0 -8
- data/postnhost.gemspec +0 -31
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
module Postnhost
|
|
2
|
+
module Settings
|
|
3
|
+
module I18nOverrides
|
|
4
|
+
module_function
|
|
5
|
+
|
|
6
|
+
CACHE_KEY = "postnhost/settings/i18n_overrides"
|
|
7
|
+
TRANSLATION_NAMESPACE = "postnhost."
|
|
8
|
+
TRANSLATION_CONTROL_KEYS = %i[default scope locale raise throw separator fallback format resolve object].freeze
|
|
9
|
+
|
|
10
|
+
def locale_keys(overrides, allowed_locales: nil)
|
|
11
|
+
locales = (all_locales + normalize_overrides(overrides).keys).uniq.sort
|
|
12
|
+
locales &= allowed_locales.map(&:to_s) unless allowed_locales.nil?
|
|
13
|
+
return locales unless locales.include?("en")
|
|
14
|
+
|
|
15
|
+
["en"] + locales.reject { |locale| locale == "en" }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def editable_translations_for_locale(locale, overrides)
|
|
19
|
+
return {} if locale.blank?
|
|
20
|
+
|
|
21
|
+
locale_key = locale.to_s
|
|
22
|
+
base_translations = namespaced_translations(base_flat_translations(locale_key))
|
|
23
|
+
override_translations = namespaced_translations(normalize_overrides(overrides).fetch(locale_key, {}))
|
|
24
|
+
base_translations.merge(override_translations)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def merge_locale_overrides(current_overrides, locale, edited_translations)
|
|
28
|
+
locale_key = locale.to_s
|
|
29
|
+
normalized = normalize_overrides(current_overrides)
|
|
30
|
+
base = base_flat_translations(locale_key)
|
|
31
|
+
|
|
32
|
+
compacted = edited_translations.each_with_object({}) do |(key, value), result|
|
|
33
|
+
key_path = key.to_s
|
|
34
|
+
next unless key_path.start_with?(TRANSLATION_NAMESPACE)
|
|
35
|
+
|
|
36
|
+
text = value.to_s
|
|
37
|
+
next if text.blank?
|
|
38
|
+
next if base[key_path] == text
|
|
39
|
+
|
|
40
|
+
result[key_path] = text
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
normalized[locale_key] = compacted
|
|
44
|
+
normalized.delete(locale_key) if compacted.empty?
|
|
45
|
+
normalized
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def lookup_override(key, locale: I18n.locale, scope: nil, separator: I18n.default_separator, overrides: nil)
|
|
49
|
+
keys = I18n.normalize_keys(locale, key, scope, separator)[1..]
|
|
50
|
+
return nil if keys.blank?
|
|
51
|
+
|
|
52
|
+
translation_key = keys.join(".")
|
|
53
|
+
return nil unless translation_key.start_with?(TRANSLATION_NAMESPACE)
|
|
54
|
+
|
|
55
|
+
source_overrides = overrides.nil? ? cached_overrides : normalize_overrides(overrides)
|
|
56
|
+
source_overrides.dig(locale.to_s, translation_key)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def interpolate(value, options)
|
|
60
|
+
return value unless value.is_a?(String)
|
|
61
|
+
|
|
62
|
+
interpolation_options = options.except(*TRANSLATION_CONTROL_KEYS)
|
|
63
|
+
return value if interpolation_options.blank?
|
|
64
|
+
|
|
65
|
+
value % interpolation_options.symbolize_keys
|
|
66
|
+
rescue KeyError
|
|
67
|
+
value
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def cached_overrides
|
|
71
|
+
Rails.cache.fetch(CACHE_KEY) do
|
|
72
|
+
normalize_overrides(Postnhost::Setting.current.locale_overrides)
|
|
73
|
+
end
|
|
74
|
+
rescue ActiveRecord::NoDatabaseError, ActiveRecord::StatementInvalid
|
|
75
|
+
{}
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def clear_cache!
|
|
79
|
+
Rails.cache.delete(CACHE_KEY)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def all_locales
|
|
83
|
+
@all_locales ||= locale_file_paths.map { |path| File.basename(path, ".yml") }.uniq
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def base_flat_translations(locale)
|
|
87
|
+
base_flat_translations_by_locale.fetch(locale.to_s, base_flat_translations_by_locale.fetch(I18n.default_locale.to_s, {}))
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def base_flat_translations_by_locale
|
|
91
|
+
@base_flat_translations_by_locale ||= locale_file_paths.each_with_object({}) do |path, result|
|
|
92
|
+
locale = File.basename(path, ".yml")
|
|
93
|
+
document = YAML.safe_load_file(path, aliases: true) || {}
|
|
94
|
+
flattened = flatten_hash(normalize_hash(document[locale] || {}))
|
|
95
|
+
result[locale] = (result[locale] || {}).merge(flattened)
|
|
96
|
+
end.freeze
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def locale_file_paths
|
|
100
|
+
engine_root = defined?(Postnhost::Engine) ? Postnhost::Engine.root : nil
|
|
101
|
+
return engine_root.glob("config/locales/*.yml") if engine_root
|
|
102
|
+
|
|
103
|
+
Rails.root.glob("config/locales/*.yml")
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def normalize_overrides(overrides)
|
|
107
|
+
return {} unless overrides.is_a?(Hash)
|
|
108
|
+
|
|
109
|
+
overrides.each_with_object({}) do |(locale, translations), result|
|
|
110
|
+
next unless translations.is_a?(Hash)
|
|
111
|
+
|
|
112
|
+
result[locale.to_s] = normalize_hash(translations)
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def normalize_hash(hash)
|
|
117
|
+
hash.deep_stringify_keys
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def flatten_hash(hash, prefix = nil, result = {})
|
|
121
|
+
hash.each do |key, value|
|
|
122
|
+
path = [prefix, key.to_s].compact.join(".")
|
|
123
|
+
if value.is_a?(Hash)
|
|
124
|
+
flatten_hash(value, path, result)
|
|
125
|
+
else
|
|
126
|
+
result[path] = value.to_s
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
result
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def namespaced_translations(translations)
|
|
133
|
+
translations.select { |key, _| key.to_s.start_with?(TRANSLATION_NAMESPACE) }
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Postnhost
|
|
2
|
+
module Settings
|
|
3
|
+
module I18nPatch
|
|
4
|
+
def translate(locale, key, options = {})
|
|
5
|
+
separator = options[:separator] || I18n.default_separator
|
|
6
|
+
override = Postnhost::Settings::I18nOverrides.lookup_override(
|
|
7
|
+
key,
|
|
8
|
+
locale: locale,
|
|
9
|
+
scope: options[:scope],
|
|
10
|
+
separator: separator
|
|
11
|
+
)
|
|
12
|
+
return super if override.nil?
|
|
13
|
+
|
|
14
|
+
Postnhost::Settings::I18nOverrides.interpolate(override, options)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
require "pathname"
|
|
3
|
+
require "rubygems/version"
|
|
4
|
+
|
|
5
|
+
module Postnhost
|
|
6
|
+
class TailwindCompiler
|
|
7
|
+
REQUIRED_MAJOR = 4
|
|
8
|
+
|
|
9
|
+
class MissingCompiler < StandardError; end
|
|
10
|
+
class IncompatibleVersion < StandardError; end
|
|
11
|
+
|
|
12
|
+
def initialize(root:, loaded_specs: Gem.loaded_specs)
|
|
13
|
+
@root = Pathname.new(root)
|
|
14
|
+
@loaded_specs = loaded_specs
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def command(input_path:, output_path:, watch: false)
|
|
18
|
+
command = npm_command(input_path:, output_path:) || ruby_command(input_path:, output_path:)
|
|
19
|
+
raise MissingCompiler, missing_compiler_message unless command
|
|
20
|
+
|
|
21
|
+
command << "--watch" if watch
|
|
22
|
+
command
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
attr_reader :root, :loaded_specs
|
|
28
|
+
|
|
29
|
+
def ruby_command(input_path:, output_path:)
|
|
30
|
+
spec = loaded_specs["tailwindcss-ruby"]
|
|
31
|
+
return unless spec
|
|
32
|
+
|
|
33
|
+
validate_version!(spec.version, "tailwindcss-ruby")
|
|
34
|
+
require "tailwindcss/ruby"
|
|
35
|
+
executable = Tailwindcss::Ruby.executable
|
|
36
|
+
return if executable.to_s.empty?
|
|
37
|
+
|
|
38
|
+
[executable, "-i", input_path.to_s, "-o", output_path.to_s, "--minify"]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def npm_command(input_path:, output_path:)
|
|
42
|
+
executable = root.join("node_modules/.bin/tailwindcss")
|
|
43
|
+
return unless executable.file?
|
|
44
|
+
|
|
45
|
+
validate_package_version!("tailwindcss")
|
|
46
|
+
validate_package_version!("@tailwindcss/cli")
|
|
47
|
+
|
|
48
|
+
[executable.to_s, "-i", input_path.to_s, "-o", output_path.to_s, "--minify"]
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def validate_package_version!(package_name)
|
|
52
|
+
package_path = root.join("node_modules", package_name, "package.json")
|
|
53
|
+
raise MissingCompiler, "[postnhost] Missing #{package_name}. Install Tailwind CSS 4 and @tailwindcss/cli 4." unless package_path.file?
|
|
54
|
+
|
|
55
|
+
version = JSON.parse(package_path.read).fetch("version")
|
|
56
|
+
validate_version!(version, package_name)
|
|
57
|
+
rescue JSON::ParserError, KeyError
|
|
58
|
+
raise MissingCompiler, "[postnhost] Cannot read the installed #{package_name} version."
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def validate_version!(version, source)
|
|
62
|
+
return if Gem::Version.new(version.to_s).segments.first == REQUIRED_MAJOR
|
|
63
|
+
|
|
64
|
+
raise IncompatibleVersion,
|
|
65
|
+
"[postnhost] Host CSS requires Tailwind CSS 4; found #{source} #{version}."
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def missing_compiler_message
|
|
69
|
+
<<~MESSAGE.strip
|
|
70
|
+
[postnhost] No Tailwind CSS 4 compiler found for host customization.
|
|
71
|
+
Add tailwindcss-ruby 4, or install tailwindcss 4 and @tailwindcss/cli 4.
|
|
72
|
+
MESSAGE
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require "pathname"
|
|
2
|
+
|
|
3
|
+
module Postnhost
|
|
4
|
+
class TailwindInput
|
|
5
|
+
SOURCE_PATTERN = /@source\s+"([^"]+)";/
|
|
6
|
+
|
|
7
|
+
class << self
|
|
8
|
+
def build(engine_source:, host_source:)
|
|
9
|
+
[
|
|
10
|
+
expand_sources(engine_source),
|
|
11
|
+
expand_sources(host_source)
|
|
12
|
+
].join("\n\n")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def expand_sources(path)
|
|
18
|
+
source_path = Pathname.new(path)
|
|
19
|
+
|
|
20
|
+
source_path.read.gsub(SOURCE_PATTERN) do
|
|
21
|
+
relative_source = Regexp.last_match(1)
|
|
22
|
+
absolute_source = source_path.dirname.join(relative_source).expand_path
|
|
23
|
+
%(@source "#{css_path(absolute_source)}";)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def css_path(path)
|
|
28
|
+
Pathname.new(path).expand_path.to_s.tr("\\", "/").gsub('"', '\\"')
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
data/lib/postnhost/version.rb
CHANGED
data/lib/postnhost.rb
CHANGED
|
@@ -1,8 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
require "bcrypt"
|
|
2
|
+
require "carrierwave"
|
|
3
|
+
require "carrierwave-aws"
|
|
4
|
+
require "nokogiri"
|
|
5
|
+
require "openai"
|
|
6
|
+
require "pagy"
|
|
7
|
+
require "paper_trail"
|
|
8
|
+
require "ruby-vips"
|
|
2
9
|
|
|
3
10
|
require_relative "postnhost/version"
|
|
11
|
+
require_relative "postnhost/configuration"
|
|
12
|
+
require_relative "postnhost/settings/i18n_overrides"
|
|
13
|
+
require_relative "postnhost/sample_data"
|
|
14
|
+
require_relative "postnhost/settings/i18n_patch"
|
|
15
|
+
require_relative "postnhost/engine" if defined?(Rails::Engine)
|
|
4
16
|
|
|
5
17
|
module Postnhost
|
|
6
|
-
class
|
|
7
|
-
|
|
18
|
+
class << self
|
|
19
|
+
attr_accessor :configuration
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.configure
|
|
23
|
+
self.configuration ||= Configuration.new
|
|
24
|
+
yield(configuration) if block_given?
|
|
25
|
+
configuration
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.config
|
|
29
|
+
configuration || configure
|
|
30
|
+
end
|
|
8
31
|
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# rubocop:disable-next Metrics/BlockLength
|
|
2
|
+
namespace :postnhost do
|
|
3
|
+
namespace :snapshots do
|
|
4
|
+
desc "Audit snapshots for hard-cutover integrity"
|
|
5
|
+
task audit: :environment do
|
|
6
|
+
errors = []
|
|
7
|
+
check = lambda do |snapshot, label|
|
|
8
|
+
version = snapshot.paper_trail_version
|
|
9
|
+
errors << "#{label}: missing paper-trail version" unless version
|
|
10
|
+
errors << "#{label}: language is missing" unless snapshot.language
|
|
11
|
+
expected_type = {
|
|
12
|
+
Postnhost::Snapshot::Article => "Postnhost::Article",
|
|
13
|
+
Postnhost::Snapshot::Page => "Postnhost::Page",
|
|
14
|
+
Postnhost::Snapshot::ArticleVariant => "Postnhost::ArticleVariant",
|
|
15
|
+
Postnhost::Snapshot::PageVariant => "Postnhost::PageVariant"
|
|
16
|
+
}.fetch(snapshot.class)
|
|
17
|
+
expected_id = case snapshot
|
|
18
|
+
when Postnhost::Snapshot::Article
|
|
19
|
+
snapshot.article_id
|
|
20
|
+
when Postnhost::Snapshot::Page
|
|
21
|
+
snapshot.page_id
|
|
22
|
+
when Postnhost::Snapshot::ArticleVariant
|
|
23
|
+
snapshot.article_variant_id
|
|
24
|
+
when Postnhost::Snapshot::PageVariant
|
|
25
|
+
snapshot.page_variant_id
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
if version
|
|
29
|
+
errors << "#{label}: version item_type mismatch (#{version.item_type})" unless version.item_type == expected_type
|
|
30
|
+
errors << "#{label}: version item_id mismatch (#{version.item_id})" unless version.item_id == expected_id
|
|
31
|
+
end
|
|
32
|
+
rescue StandardError => e
|
|
33
|
+
errors << "#{label}: #{e.message}"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
Postnhost::Snapshot::Article.includes(:article, :language, :paper_trail_version).find_each do |snapshot|
|
|
37
|
+
check.call(snapshot, "Snapshot::Article #{snapshot.id}")
|
|
38
|
+
errors << "Snapshot::Article #{snapshot.id}: article missing" unless snapshot.article
|
|
39
|
+
if snapshot.cover_image_identifier.present?
|
|
40
|
+
image = Postnhost::PublishedCoverImage.new(article_id: snapshot.article_id, identifier: snapshot.cover_image_identifier)
|
|
41
|
+
errors << "Snapshot::Article #{snapshot.id}: cover image #{snapshot.cover_image_identifier} is missing" unless image.send(:uploader).file&.exists?
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
Postnhost::Snapshot::Page.includes(:page, :language, :paper_trail_version).find_each do |snapshot|
|
|
46
|
+
check.call(snapshot, "Snapshot::Page #{snapshot.id}")
|
|
47
|
+
errors << "Snapshot::Page #{snapshot.id}: page missing" unless snapshot.page
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
Postnhost::Snapshot::ArticleVariant.includes(:article_variant, :language, :paper_trail_version).find_each do |snapshot|
|
|
51
|
+
check.call(snapshot, "Snapshot::ArticleVariant #{snapshot.id}")
|
|
52
|
+
errors << "Snapshot::ArticleVariant #{snapshot.id}: article missing" unless snapshot.article
|
|
53
|
+
errors << "Snapshot::ArticleVariant #{snapshot.id}: article_variant missing" unless snapshot.article_variant
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
Postnhost::Snapshot::PageVariant.includes(:page_variant, :language, :paper_trail_version).find_each do |snapshot|
|
|
57
|
+
check.call(snapshot, "Snapshot::PageVariant #{snapshot.id}")
|
|
58
|
+
errors << "Snapshot::PageVariant #{snapshot.id}: page missing" unless snapshot.page
|
|
59
|
+
errors << "Snapshot::PageVariant #{snapshot.id}: page_variant missing" unless snapshot.page_variant
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
article_slugs = Postnhost::Snapshot::Article.pluck(:slug)
|
|
63
|
+
page_slugs = Postnhost::Snapshot::Page.pluck(:slug)
|
|
64
|
+
(article_slugs & page_slugs).each { |slug| errors << "Published article/page slug collision: #{slug}" }
|
|
65
|
+
|
|
66
|
+
default_languages = Postnhost::Language.where(default: true).count
|
|
67
|
+
errors << "Expected exactly one default language, found #{default_languages}" unless default_languages == 1
|
|
68
|
+
|
|
69
|
+
if errors.none?
|
|
70
|
+
puts "Snapshot audit passed."
|
|
71
|
+
else
|
|
72
|
+
warn errors.map { |error| "- #{error}" }.join("\n")
|
|
73
|
+
abort "Snapshot audit failed with #{errors.count} error(s)."
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
require "fileutils"
|
|
2
|
+
|
|
3
|
+
require "postnhost/css_build"
|
|
4
|
+
require "postnhost/tailwind_compiler"
|
|
5
|
+
require "postnhost/tailwind_input"
|
|
6
|
+
|
|
7
|
+
# rubocop:disable-next Metrics/BlockLength
|
|
8
|
+
namespace :postnhost do
|
|
9
|
+
namespace :tailwindcss do
|
|
10
|
+
def postnhost_tailwind_enabled?
|
|
11
|
+
Rails.root.join("app/assets/stylesheets/postnhost/host.tailwind.css").exist?
|
|
12
|
+
end
|
|
13
|
+
|
|
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
|
+
}
|
|
20
|
+
end
|
|
21
|
+
|
|
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")
|
|
25
|
+
|
|
26
|
+
FileUtils.mkdir_p(path.dirname)
|
|
27
|
+
path.write(Postnhost::TailwindInput.build(engine_source:, host_source:))
|
|
28
|
+
end
|
|
29
|
+
|
|
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))
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
desc "Build host Tailwind CSS for PostnHost overrides"
|
|
50
|
+
task build: :environment do
|
|
51
|
+
unless postnhost_tailwind_enabled?
|
|
52
|
+
puts "[postnhost] Skipping host Tailwind build (missing app/assets/stylesheets/postnhost/host.tailwind.css)"
|
|
53
|
+
next
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
build_host_tailwind
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
desc "Watch host Tailwind CSS for PostnHost overrides"
|
|
60
|
+
task watch: :environment do
|
|
61
|
+
unless postnhost_tailwind_enabled?
|
|
62
|
+
puts "[postnhost] Missing host Tailwind files. Run: bin/rails g postnhost:tailwindcss:install"
|
|
63
|
+
next
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
build_host_tailwind(watch: true)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
Rake::Task["assets:precompile"].enhance(["postnhost:tailwindcss:build"]) if Rake::Task.task_defined?("assets:precompile")
|