PhoenixKit.Modules.Publishing (PhoenixKitPublishing v0.3.0)

Copy Markdown View Source

Publishing module for managing content groups and their posts.

Database-backed CMS for creating timestamped or slug-based posts with multi-language support and versioning.

This module acts as a facade, delegating to focused submodules:

  • Publishing.Groups — Group CRUD
  • Publishing.Posts — Post CRUD, reading, and listing
  • Publishing.Versions — Version create, publish, delete
  • Publishing.TranslationManager — Language/translation management
  • Publishing.StaleFixer — Stale value detection and repair

Summary

Functions

Returns true when the given post is a DB-backed post (has a UUID).

Resolves a variable name from og_variables/0 against the current post supplied in context.resource. Falls back to nil for unknown names so unwired slots stay visible rather than blowing up.

Variables this module makes available for OG template wiring. Each entry declares its type (:text / :image), which lets the OG assignment UI show only compatible variables for a given slot.

Dynamic children function for Publishing sidebar tabs.

Stub: always returns false. Versioning is opt-in via the editor's explicit "create new version" action, not implicit on every save — so this predicate is intentionally a no-op kept for API stability with older callers that branch on it.

Returns true when slugifying text would be shortened to fit the slug cap — i.e. the full title didn't fit. Auto-generation never errors (it truncates); this lets the editor warn that not all of the title became the slug.

Lowercases name, replaces non-alphanumeric runs with -, and trims leading/trailing hyphens. Pairs with valid_slug?/1 — callers should re-validate the result because slug-shape is enforced separately from generation (reserved language codes, empty results).

Returns true when the slug matches the allowed lowercase letters, numbers, and hyphen pattern, and is not a reserved language code.

Functions

add_group(name, opts \\ [])

See PhoenixKit.Modules.Publishing.Groups.add_group/2.

add_language_to_post(group_slug, post_uuid, language_code, version \\ nil)

See PhoenixKit.Modules.Publishing.TranslationManager.add_language_to_post/4.

add_language_to_post(group_slug, post_uuid, language_code, version, opts)

See PhoenixKit.Modules.Publishing.TranslationManager.add_language_to_post/5.

ai_translatables()

@spec ai_translatables() :: [{String.t(), module()}]

cache_exists?(group_slug)

See PhoenixKit.Modules.Publishing.ListingCache.exists?/1.

clear_translation(group_slug, post_uuid, language_code, version \\ nil)

See PhoenixKit.Modules.Publishing.TranslationManager.clear_translation/4.

clear_translation(group_slug, post_uuid, language_code, version, opts)

See PhoenixKit.Modules.Publishing.TranslationManager.clear_translation/5.

clear_url_slug_from_post(group_slug, post_slug, url_slug)

See PhoenixKit.Modules.Publishing.DBStorage.clear_url_slug_from_post/3.

count_posts_on_date(group_slug, date)

See PhoenixKit.Modules.Publishing.Posts.count_posts_on_date/2.

create_new_version(group_slug, source_post, params \\ %{}, opts \\ %{})

See PhoenixKit.Modules.Publishing.Versions.create_new_version/4.

create_post(group_slug, opts \\ %{})

See PhoenixKit.Modules.Publishing.Posts.create_post/2.

create_version_from(group_slug, post_uuid, source_version, params \\ %{}, opts \\ %{})

See PhoenixKit.Modules.Publishing.Versions.create_version_from/5.

db_post?(post)

@spec db_post?(map()) :: boolean()

Returns true when the given post is a DB-backed post (has a UUID).

default_language_no_prefix?()

See PhoenixKit.Modules.Publishing.LanguageHelpers.default_language_no_prefix?/0.

delete_language(group_slug, post_uuid, language_code, version \\ nil)

See PhoenixKit.Modules.Publishing.TranslationManager.delete_language/4.

delete_language(group_slug, post_uuid, language_code, version, opts)

See PhoenixKit.Modules.Publishing.TranslationManager.delete_language/5.

delete_version(group_slug, post_uuid, version)

See PhoenixKit.Modules.Publishing.Versions.delete_version/3.

delete_version(group_slug, post_uuid, version, opts)

See PhoenixKit.Modules.Publishing.Versions.delete_version/4.

enabled_language_codes()

See PhoenixKit.Modules.Publishing.LanguageHelpers.enabled_language_codes/0.

extract_slug_version_and_language(group_slug, identifier)

See PhoenixKit.Modules.Publishing.Posts.extract_slug_version_and_language/2.

find_by_previous_url_slug(group_slug, language, url_slug)

See PhoenixKit.Modules.Publishing.Posts.find_by_previous_url_slug/3.

find_by_url_slug(group_slug, language, url_slug)

See PhoenixKit.Modules.Publishing.Posts.find_by_url_slug/3.

find_cached_post(group_slug, post_slug)

See PhoenixKit.Modules.Publishing.ListingCache.find_post/2.

find_cached_post_by_path(group_slug, date, time)

See PhoenixKit.Modules.Publishing.ListingCache.find_post_by_path/3.

fix_all_stale_values()

See PhoenixKit.Modules.Publishing.StaleFixer.fix_all_stale_values/0.

fix_stale_content(content)

See PhoenixKit.Modules.Publishing.StaleFixer.fix_stale_content/1.

fix_stale_group(group)

See PhoenixKit.Modules.Publishing.StaleFixer.fix_stale_group/1.

fix_stale_post(post)

See PhoenixKit.Modules.Publishing.StaleFixer.fix_stale_post/1.

fix_stale_version(version)

See PhoenixKit.Modules.Publishing.StaleFixer.fix_stale_version/1.

generate_unique_slug(group_slug, title)

See PhoenixKit.Modules.Publishing.SlugHelpers.generate_unique_slug/2.

generate_unique_slug(group_slug, title, preferred_slug)

See PhoenixKit.Modules.Publishing.SlugHelpers.generate_unique_slug/3.

generate_unique_slug(group_slug, title, preferred_slug, opts)

See PhoenixKit.Modules.Publishing.SlugHelpers.generate_unique_slug/4.

get_display_code(language_code, enabled_languages)

See PhoenixKit.Modules.Publishing.LanguageHelpers.get_display_code/2.

get_group(slug)

See PhoenixKit.Modules.Publishing.Groups.get_group/1.

get_group_mode(group_slug)

See PhoenixKit.Modules.Publishing.Groups.get_group_mode/1.

get_language_info(language_code)

See PhoenixKit.Modules.Publishing.LanguageHelpers.get_language_info/1.

get_primary_language()

See PhoenixKit.Modules.Publishing.LanguageHelpers.get_primary_language/0.

get_primary_language_base()

See PhoenixKit.Modules.Publishing.LanguageHelpers.get_primary_language_base/0.

get_published_version(group_slug, post_slug)

See PhoenixKit.Modules.Publishing.Versions.get_published_version/2.

get_version_metadata(group_slug, post_slug, version_number, language)

See PhoenixKit.Modules.Publishing.Versions.get_version_metadata/4.

get_version_status(group_slug, post_slug, version_number, language)

See PhoenixKit.Modules.Publishing.Versions.get_version_status/4.

group_name(slug)

See PhoenixKit.Modules.Publishing.Groups.group_name/1.

invalidate_cache(group_slug)

See PhoenixKit.Modules.Publishing.ListingCache.invalidate/1.

language_enabled?(language_code, enabled_languages)

See PhoenixKit.Modules.Publishing.LanguageHelpers.language_enabled?/2.

list_groups()

See PhoenixKit.Modules.Publishing.Groups.list_groups/0.

list_groups(status)

See PhoenixKit.Modules.Publishing.Groups.list_groups/1.

list_posts(group_slug, preferred_language \\ nil)

See PhoenixKit.Modules.Publishing.Posts.list_posts/2.

list_posts_by_status(group_slug, status)

See PhoenixKit.Modules.Publishing.Posts.list_posts_by_status/2.

list_raw_posts(group_slug, status \\ nil)

See PhoenixKit.Modules.Publishing.Posts.list_raw_posts/2.

list_times_on_date(group_slug, date)

See PhoenixKit.Modules.Publishing.Posts.list_times_on_date/2.

list_trashed_groups()

See PhoenixKit.Modules.Publishing.Groups.list_trashed_groups/0.

list_versions(group_slug, post_slug)

See PhoenixKit.Modules.Publishing.Versions.list_versions/2.

og_resolve(arg1, context)

Resolves a variable name from og_variables/0 against the current post supplied in context.resource. Falls back to nil for unknown names so unwired slots stay visible rather than blowing up.

og_variables()

Variables this module makes available for OG template wiring. Each entry declares its type (:text / :image), which lets the OG assignment UI show only compatible variables for a given slot.

order_languages_for_display(available_languages, enabled_languages)

See PhoenixKit.Modules.Publishing.LanguageHelpers.order_languages_for_display/2.

order_languages_for_display(available_languages, enabled_languages, primary)

See PhoenixKit.Modules.Publishing.LanguageHelpers.order_languages_for_display/3.

preset_types()

See PhoenixKit.Modules.Publishing.Groups.preset_types/0.

publish_version(group_slug, post_uuid, version, opts \\ [])

See PhoenixKit.Modules.Publishing.Versions.publish_version/4.

publishing_children(scope)

Dynamic children function for Publishing sidebar tabs.

read_post(group_slug, identifier, language \\ nil, version \\ nil)

See PhoenixKit.Modules.Publishing.Posts.read_post/4.

read_post_by_datetime(group_slug, date, time)

See PhoenixKit.Modules.Publishing.DBStorage.read_post_by_datetime/3.

read_post_by_uuid(post_uuid, language \\ nil, version \\ nil)

See PhoenixKit.Modules.Publishing.Posts.read_post_by_uuid/3.

reconcile_post_status(post)

See PhoenixKit.Modules.Publishing.StaleFixer.reconcile_post_status/1.

regenerate_cache(group_slug)

See PhoenixKit.Modules.Publishing.ListingCache.regenerate/1.

remove_group(slug)

See PhoenixKit.Modules.Publishing.Groups.remove_group/1.

remove_group(slug, opts)

See PhoenixKit.Modules.Publishing.Groups.remove_group/2.

restore_group(slug)

See PhoenixKit.Modules.Publishing.Groups.restore_group/1.

restore_group(slug, opts)

See PhoenixKit.Modules.Publishing.Groups.restore_group/2.

restore_post(group_slug, post_uuid)

See PhoenixKit.Modules.Publishing.Posts.restore_post/2.

restore_post(group_slug, post_uuid, opts)

See PhoenixKit.Modules.Publishing.Posts.restore_post/3.

set_translation_status(group_slug, post_identifier, version, language, status)

See PhoenixKit.Modules.Publishing.TranslationManager.set_translation_status/5.

should_create_new_version?(post, params, editing_language)

@spec should_create_new_version?(map(), map(), String.t()) :: false

Stub: always returns false. Versioning is opt-in via the editor's explicit "create new version" action, not implicit on every save — so this predicate is intentionally a no-op kept for API stability with older callers that branch on it.

slug_exists?(group_slug, post_slug)

See PhoenixKit.Modules.Publishing.SlugHelpers.slug_exists?/2.

slug_truncated?(text)

@spec slug_truncated?(String.t() | nil) :: boolean()

Returns true when slugifying text would be shortened to fit the slug cap — i.e. the full title didn't fit. Auto-generation never errors (it truncates); this lets the editor warn that not all of the title became the slug.

slugify(name)

@spec slugify(String.t()) :: String.t()

Lowercases name, replaces non-alphanumeric runs with -, and trims leading/trailing hyphens. Pairs with valid_slug?/1 — callers should re-validate the result because slug-shape is enforced separately from generation (reserved language codes, empty results).

Examples

iex> PhoenixKit.Modules.Publishing.slugify("My First Post!")
"my-first-post"

iex> PhoenixKit.Modules.Publishing.slugify("  spaces & ampersands  ")
"spaces-ampersands"

translate_post_to_all_languages(group_slug, post_uuid, opts \\ [])

See PhoenixKit.Modules.Publishing.TranslationManager.translate_post_to_all_languages/3.

trash_group(slug)

See PhoenixKit.Modules.Publishing.Groups.trash_group/1.

trash_group(slug, opts)

See PhoenixKit.Modules.Publishing.Groups.trash_group/2.

trash_post(group_slug, post_uuid)

See PhoenixKit.Modules.Publishing.Posts.trash_post/2.

trash_post(group_slug, post_uuid, opts)

See PhoenixKit.Modules.Publishing.Posts.trash_post/3.

unpublish_post(group_slug, post_uuid, opts \\ [])

See PhoenixKit.Modules.Publishing.Versions.unpublish_post/3.

update_group(slug, params)

See PhoenixKit.Modules.Publishing.Groups.update_group/2.

update_group(slug, params, opts)

See PhoenixKit.Modules.Publishing.Groups.update_group/3.

update_post(group_slug, post, params, opts \\ %{})

See PhoenixKit.Modules.Publishing.Posts.update_post/4.

url_language_code(language_code)

See PhoenixKit.Modules.Publishing.LanguageHelpers.url_language_code/1.

use_language_prefix?(language_code)

See PhoenixKit.Modules.Publishing.LanguageHelpers.use_language_prefix?/1.

valid_slug?(slug)

@spec valid_slug?(any()) :: boolean()

Returns true when the slug matches the allowed lowercase letters, numbers, and hyphen pattern, and is not a reserved language code.

Group slugs cannot be language codes (like 'en', 'es', 'fr') to prevent routing ambiguity.

valid_types()

See PhoenixKit.Modules.Publishing.Groups.valid_types/0.

validate_slug(slug)

See PhoenixKit.Modules.Publishing.SlugHelpers.validate_slug/1.

validate_url_slug(group_slug, url_slug, language, exclude)

See PhoenixKit.Modules.Publishing.SlugHelpers.validate_url_slug/4.