PhoenixKitWeb.Live.Modules.Blogging.Storage (phoenix_kit v1.5.1)
View SourceFilesystem storage helpers for blogging posts.
Content is stored under:
priv/blogging/<blog>/<YYYY-MM-DD>/<HH:MM>/<language>.phkWhere <language> is determined by the site's content language setting. Files use the .phk (PhoenixKit) format, which supports XML-style component markup for building pages with swappable design variants.
Summary
Functions
Returns the absolute path for a relative blogging path.
Adds a new language file to an existing post by copying metadata from an existing language.
Adds a new language file to a slug-mode post.
Creates a new post, returning its metadata and content. Creates only the primary language file. Additional languages can be added later.
Creates a slug-mode post, returning metadata and paths for the primary language.
Returns all enabled language codes for multi-language support. Falls back to content language if Languages module is disabled.
Ensures the folder for a blog exists.
Generates a unique slug based on title and optional preferred slug.
Gets language details (name, flag) for a given language code.
Returns the filename for language-specific posts based on the site's primary content language setting.
Returns the filename for a specific language code.
Lists posts for the given blog. Accepts optional preferred_language to show titles in user's language. Falls back to content language, then first available language.
Lists slug-mode posts for the given blog.
Moves a blog directory to trash by renaming it with a timestamp. The blog directory is moved to: trash/BLOGNAME-YYYY-MM-DD-HH-MM-SS
Moves slug-mode post files to a new slug directory.
Reads a post for a specific language.
Reads a slug-mode post, optionally for a specific language.
Renames a blog directory on disk when the slug changes.
Returns the blogging root directory, creating it if needed. Always uses the parent application's priv directory.
Checks if a slug already exists within the given blog.
Updates a post's metadata/content, moving files if needed. Preserves language and detects available languages.
Updates slug-mode posts without moving them (slug unchanged).
Updates slug-mode posts in-place or moves them when the slug changes.
Validates whether the given string is a slug.
Types
Functions
Returns the absolute path for a relative blogging path.
Adds a new language file to an existing post by copying metadata from an existing language.
@spec add_language_to_post_slug_mode(String.t(), String.t(), String.t()) :: {:ok, post()} | {:error, any()}
Adds a new language file to a slug-mode post.
Creates a new post, returning its metadata and content. Creates only the primary language file. Additional languages can be added later.
@spec create_post_slug_mode( String.t(), String.t() | nil, String.t() | nil, map() | keyword() ) :: {:ok, post()} | {:error, any()}
Creates a slug-mode post, returning metadata and paths for the primary language.
@spec enabled_language_codes() :: [String.t()]
Returns all enabled language codes for multi-language support. Falls back to content language if Languages module is disabled.
Ensures the folder for a blog exists.
Generates a unique slug based on title and optional preferred slug.
@spec get_language_info(String.t()) :: %{code: String.t(), name: String.t(), flag: String.t()} | nil
Gets language details (name, flag) for a given language code.
@spec language_filename() :: String.t()
Returns the filename for language-specific posts based on the site's primary content language setting.
Returns the filename for a specific language code.
Lists posts for the given blog. Accepts optional preferred_language to show titles in user's language. Falls back to content language, then first available language.
Lists slug-mode posts for the given blog.
Moves a blog directory to trash by renaming it with a timestamp. The blog directory is moved to: trash/BLOGNAME-YYYY-MM-DD-HH-MM-SS
Returns {:ok, new_name} on success or {:error, reason} on failure.
@spec move_post_to_new_slug(String.t(), post(), String.t(), map(), map() | keyword()) :: {:ok, post()} | {:error, any()}
Moves slug-mode post files to a new slug directory.
Reads a post for a specific language.
@spec read_post_slug_mode(String.t(), String.t(), String.t() | nil) :: {:ok, post()} | {:error, any()}
Reads a slug-mode post, optionally for a specific language.
Renames a blog directory on disk when the slug changes.
@spec root_path() :: String.t()
Returns the blogging root directory, creating it if needed. Always uses the parent application's priv directory.
Checks if a slug already exists within the given blog.
Updates a post's metadata/content, moving files if needed. Preserves language and detects available languages.
@spec update_post_slug_in_place(String.t(), post(), map(), map() | keyword()) :: {:ok, post()} | {:error, any()}
Updates slug-mode posts without moving them (slug unchanged).
@spec update_post_slug_mode(String.t(), post(), map(), map() | keyword()) :: {:ok, post()} | {:error, any()}
Updates slug-mode posts in-place or moves them when the slug changes.
Validates whether the given string is a slug.