ExportController - applebiter/gnatwriter GitHub Wiki

Export controller encapsulates export functionality.

export_story_to_json()

export_story_to_json(story_id: int) -> bool

Takes a Story id and returns True if the JSON export was successful. An export folder is defined in the configuration. Every user (including the default, system user) has an associated, 36-character long UUID with a corresponding subfolder in the export folder, named after said UUID. Within each user's export folder exists another set of subfolders. Each subfolder corresponds to top-level objects in the system. Namely, Stories, Characters, Events, and Locations. These objects are nested, hierarchical objects and contain a particular set of skills, or subcomponents, rather. The JSON export will be found in

{export folder}/
    {user UUID}/
        stories/
            {story_id}/
                story.json

Returns True on success.

export_story_to_text()

export_story_to_text(story_id: int) -> bool

This produces an unadorned text file designed to be ingested by the Assistant.rag_chat() method so that a user may discuss the Story with an LLM. No Links or Notes are included in this document. Only the following object attributes make it into this document:

  1. Story title
  2. Associated Author names
  3. Each Chapter's title (if any)
  4. Each Scene's title (if any)
  5. Each Scene's content

The text file is saved to

{export folder}/
    {user UUID}/
        stories/
            {story_id}/
                story.txt

Returns True on success.

export_character_to_json()

export_character_to_json(character_id: int) -> bool

Takes a Character id and then exports the entire, nested contents to a JSON representation. The JSON file is saved at

{export folder}/
    {user UUID}/
        characters/
            {character_id}/
                character.json

Returns True on success.

export_character_to_text()

export_character_to_text(character_id: int) -> bool

Takes a Character id and exports it contents to a text file. Returns True when the JSON is written to file. Links and Notes are not included in the text file. Character relationships and character traits, along with full name and description, constitute this unadorned report. It is designed to be ingested by the Assistant.rag_chat() method so that a user may discuss the Character with an LLM.

The Character text file is saved at

{export folder}/
    {user UUID}/
        characters/
            {character_id}/
                character.txt

Returns True on success.

export_event_to_json()

export_event_to_json(event_id: int) -> bool

Takes an Event id and exports its entire contents to a JSON file located at

{export folder}/
    {user UUID}/
        events/
            {event_id}/
                event.json

Returns True on success.

export_event_to_text()

export_event_to_text(event_id: int) -> bool

Takes an Event id and exports it to a plain text file containing only the following attributes:

  1. Title
  2. Starting datetime # yyyy-mm-dd hh:mm:ss.f
  3. Ending datetime # yyyy-mm-dd hh:mm:ss.f
  4. Description

The file is save to

{export folder}/
    {user UUID}/
        events/
            {event_id}/
                event.txt

Returns True on success.