diff --git a/app/controllers/archetypes_controller.rb b/app/controllers/archetypes_controller.rb new file mode 100644 index 0000000..7b68677 --- /dev/null +++ b/app/controllers/archetypes_controller.rb @@ -0,0 +1,15 @@ +class ArchetypesController < MetaController + def index + scope = set_scope + where = set_where + @component_list = @component_klass.send('where', where).send(scope).order(created_at: :asc).page params[:page] + end + + def component_name + 'Archetypes' + end + + def component_class + 'Archetype'.constantize + end +end diff --git a/app/helpers/archetypes_helper.rb b/app/helpers/archetypes_helper.rb new file mode 100644 index 0000000..07dedf8 --- /dev/null +++ b/app/helpers/archetypes_helper.rb @@ -0,0 +1,2 @@ +module ArchetypesHelper +end diff --git a/app/models/archetype.rb b/app/models/archetype.rb new file mode 100644 index 0000000..df9c2fa --- /dev/null +++ b/app/models/archetype.rb @@ -0,0 +1,14 @@ +# == Schema Information +# +# Table name: archetypes +# +# id :bigint not null, primary key +# name :string +# traits :text +# examples :text +# created_at :datetime not null +# updated_at :datetime not null +# +class Archetype < ApplicationRecord + max_paginates_per 100 +end diff --git a/app/views/archetypes/index.html.slim b/app/views/archetypes/index.html.slim new file mode 100644 index 0000000..3ccdc35 --- /dev/null +++ b/app/views/archetypes/index.html.slim @@ -0,0 +1,30 @@ +=r ux.container + =r ux.row + =r ux.column width: 16 + = turbo_frame_tag 'crud_frame' + =r ux.component_container + =r ux.component_header + =@component_name.pluralize + =r ux.component_divider + + =r ux.div 'text-center' + = paginate @component_list + + =r ux.table class: 'relaxed celled striped structured' + =r ux.thead + =r ux.tr + =r ux.th text: 'Name' + =r ux.th text: 'Description' + - @component_list.each do |component| + =r ux.tr + =r ux.td '!pr-4 !border-b-4 border-solid' + =r ux.h4 text: component.name + =r ux.td '!border-b-4 border-solid' + =r ux.segment '!mt-3 !bg-blue-100' + =r ux.h4 text: "Traits" + = component.traits + - YAML.load(component.examples).each do |example| + =r ux.label text: example, class: '!mb-3 !bg-violet-500 !text-white !font-normal' + + =r ux.div 'text-center' + = paginate @component_list diff --git a/app/views/layouts/application.html.slim b/app/views/layouts/application.html.slim index a542eb8..2bcfbdc 100644 --- a/app/views/layouts/application.html.slim +++ b/app/views/layouts/application.html.slim @@ -48,6 +48,10 @@ html lang="en" =r ux.icon 'user tie' | Perspectives + = link_to archetypes_path, class: "item #{menu_active?(archetypes_path)}" + =r ux.icon 'mask' + | Archetypes + / / diff --git a/blueprints/archetypes.yml b/blueprints/archetypes.yml new file mode 100644 index 0000000..46ab090 --- /dev/null +++ b/blueprints/archetypes.yml @@ -0,0 +1,240 @@ +archetypes: + - name: Hero + traits: Courageous, brave, often on a quest + examples: [King Arthur, Luke Skywalker, Frodo Baggins] + + - name: Mentor + traits: Wise, guiding, older, often helps the hero + examples: [Yoda, Dumbledore, Gandalf] + + - name: Outlaw + traits: Defies authority, challenges the status quo + examples: [Robin Hood, Han Solo, Jack Sparrow] + + - name: Innocent + traits: Pure, optimistic, seeks happiness + examples: [Dorothy Gale, Forrest Gump, Snow White] + + - name: Caregiver + traits: Compassionate, nurturing, self-sacrificing + examples: [Mary Poppins, Samwise Gamgee, Marmee] + + - name: Ruler + traits: Power-hungry, seeks control + examples: [Darth Vader, Queen Cersei, Scar] + + - name: Lover + traits: Passionate, emotionally driven + examples: [Romeo & Juliet, Jack & Rose, Gatsby] + + - name: Jester + traits: Playful, humorous, uses wit + examples: [The Joker, Puck, Tyrion Lannister] + + - name: Sage + traits: Seeks truth and wisdom + examples: [Sherlock Holmes, The Oracle, Obi-Wan Kenobi] + + - name: Magician + traits: Seeks to transform the world, visionary + examples: [Merlin, Doctor Strange, Willy Wonka] + + - name: Creator + traits: Imaginative, inventive + examples: [Tony Stark, Leonardo da Vinci, Walt Disney] + + - name: Everyman + traits: Relatable, humble, grounded + examples: [Bilbo Baggins, John McClane, Katniss Everdeen] + + - name: Shadow + traits: Represents the darker side of the hero + examples: [Voldemort, Sauron, The Wicked Witch of the West] + + - name: Explorer + traits: Adventurous, curious + examples: [Indiana Jones, Lara Croft, Moana] + + - name: Shape-shifter + traits: Unpredictable, can change sides + examples: [Mystique, Severus Snape, Loki] + + - name: Martyr + traits: Sacrifices for a greater cause + examples: [Joan of Arc, Sydney Carton, Neo] + + - name: Trickster + traits: Mischievous, challenges the natural order + examples: [Loki, Bugs Bunny, Hermes] + + - name: Anti-Hero + traits: Flawed, morally ambiguous + examples: [Deadpool, Walter White, Tony Soprano] + + - name: Damsel in Distress + traits: Helpless, needs rescue + examples: [Princess Leia, Rapunzel, Andromeda] + + - name: Temptress + traits: Seductive, manipulative + examples: [Circe, Helen of Troy, The Sirens] + + - name: Destroyer + traits: Brings destruction and chaos + examples: [Hades, Shiva, The Terminator] + + - name: Prophet + traits: Foretells the future, speaks truth to power + examples: [Cassandra, Tiresias, The Oracle] + + - name: Herald + traits: Brings important news or calls to action + examples: [R2-D2, Gandalf, Hermes] + + - name: Guardian + traits: Protects important people or places + examples: [Cerberus, Heimdall, The Sphinx] + + - name: Companion + traits: Loyal friend or ally + examples: [Samwise Gamgee, Ron Weasley, Chewbacca] + + - name: Scapegoat + traits: Takes blame for others + examples: [Jesus Christ, Piggy, The Hunchback of Notre Dame] + + - name: Avenger + traits: Seeks justice or revenge + examples: [Batman, The Bride, Edmond Dantès] + + - name: Monster + traits: Represents primal fears + examples: [Frankenstein’s creature, Grendel, The Demogorgon] + + - name: Seducer + traits: Uses charm and allure for self-gain + examples: [Don Juan, James Bond, Casanova] + + - name: Seeker + traits: In search of truth or self-discovery + examples: [Siddhartha, Odysseus, Mulder] + + - name: Fool + traits: Naïve, can possess hidden wisdom + examples: [The Fool, Forrest Gump, Don Quixote] + + - name: Healer + traits: Nurturing, seeks to restore balance + examples: [Florence Nightingale, Doctor McCoy, Katara] + + - name: Judge + traits: Focuses on fairness and justice + examples: [Solomon, Judge Dredd, Atticus Finch] + + - name: Warrior + traits: Strong, disciplined, focused on victory + examples: [Achilles, Wonder Woman, Aragorn] + + - name: Innocent Fool + traits: Lacks experience but shows bravery + examples: [Donkey, LeFou, Luna Lovegood] + + - name: Dreamer + traits: Idealistic, lost in fantasies + examples: [Don Quixote, Amélie, Luna Lovegood] + + - name: Survivor + traits: Resilient, endures hardship + examples: [Katniss Everdeen, Ellen Ripley, Max Rockatansky] + + - name: Rival + traits: Competitive, seeks to outdo the hero + examples: [Draco Malfoy, Vegeta, Apollo Creed] + + - name: Peacemaker + traits: Mediates conflicts, seeks harmony + examples: [Friar Lawrence, Katara, Gandhi] + + - name: Sycophant + traits: Seeks to please those in power + examples: [Wormtongue, Peter Pettigrew, Smithers] + + - name: Loyalist + traits: Faithful, dedicated to a cause + examples: [Brienne of Tarth, Alfred Pennyworth, Samwise Gamgee] + + - name: Sedentary + traits: Prefers comfort, avoids risk + examples: [Hobbits, Winnie the Pooh, Bilbo Baggins] + + - name: Pioneer + traits: Ventures into new territories + examples: [Christopher Columbus, Neil Armstrong, Lewis & Clark] + + - name: Leader + traits: Commanding presence, takes charge + examples: [Aragorn, Julius Caesar, Katniss Everdeen] + + - name: Paragon + traits: Represents the ideal, symbol of purity + examples: [Superman, Captain America, Galadriel] + + - name: Rebel Leader + traits: Charismatic, stands against authority + examples: [Spartacus, Leia Organa, Morpheus] + + - name: Cynic + traits: Disillusioned, critical + examples: [Dr. House, Rick, Holden Caulfield] + + - name: Stoic + traits: Unemotional, endures hardship calmly + examples: [Mr. Spock, Marcus Aurelius, Geralt] + + - name: Outsider + traits: Alienated, different from the majority + examples: [Frankenstein’s Monster, Edward Scissorhands, The Hunchback] + + - name: Visionary + traits: Sees possibilities, often an innovator + examples: [Steve Jobs, Nikola Tesla, Elon Musk] + + - name: Crusader + traits: Passionate about a cause, willing to fight + examples: [Joan of Arc, V, Malcolm X] + + - name: Loner + traits: Prefers solitude, independent + examples: [Clint Eastwood’s Man, John Wick, Lisbeth Salander] + + - name: Tyrant + traits: Desires power, rules through fear + examples: [Commodus, The Emperor, Lord Voldemort] + + - name: Altruist + traits: Selflessly concerned for others + examples: [Mother Teresa, Atticus Finch, Neville Longbottom] + + - name: Opportunist + traits: Seizes chances for personal gain + examples: [Littlefinger, Frank Underwood, Jordan Belfort] + + - name: Puppet Master + traits: Manipulates others from behind the scenes + examples: [Palpatine, Lex Luthor, Petyr Baelish] + + - name: Lost Soul + traits: Searching for purpose or identity + examples: [Holden Caulfield, The Narrator, Don Draper] + + - name: Villainess + traits: Cunning, ambitious, ruthless + examples: [Cruella de Vil, Maleficent, Cersei Lannister] + + - name: Puppet + traits: Controlled by others, lacks agency + examples: [The Borg, Pinocchio, Gollum] + + - name: Doppelgänger + traits: Duplicate or mirror image, symbolizes duality + examples: [Dr. Jekyll and Mr. Hyde, Tyler Durden, Black Swan] diff --git a/config/routes.rb b/config/routes.rb index 3d00dc0..ac7e3ec 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -30,6 +30,7 @@ end resources :perspectives + resources :archetypes resources :unauthorized, only: %i[index] resources :settings, only: [:index, :edit] diff --git a/db/migrate/20240922195043_create_archetypes.rb b/db/migrate/20240922195043_create_archetypes.rb new file mode 100644 index 0000000..782aa8b --- /dev/null +++ b/db/migrate/20240922195043_create_archetypes.rb @@ -0,0 +1,11 @@ +class CreateArchetypes < ActiveRecord::Migration[7.2] + def change + create_table :archetypes do |t| + t.string :name + t.text :traits + t.text :examples + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 7b264b3..73705d3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,12 +10,20 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2024_09_22_183431) do +ActiveRecord::Schema[7.2].define(version: 2024_09_22_195043) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" enable_extension "vector" + create_table "archetypes", force: :cascade do |t| + t.string "name" + t.text "traits" + t.text "examples" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "books", force: :cascade do |t| t.text "title" t.bigint "writing_style_id", null: false diff --git a/lib/tasks/blueprints.rake b/lib/tasks/blueprints.rake deleted file mode 100644 index 1f1de9d..0000000 --- a/lib/tasks/blueprints.rake +++ /dev/null @@ -1,45 +0,0 @@ -require 'json' - -namespace :blueprints do - desc 'Updating blueprints' - task update: :environment do - topics_file = Rails.root.join('blueprints/topics.yml') - topics = YAML.load(File.read(topics_file))["topics"] - - topic_names = topics.map { |sub_topic| sub_topic["name"] } - dead_topics = Topic.where.not(name: topic_names) - - # set subtopics for dead topics to inactive - dead_topics.each do |dead_topic| - dead_topic.sub_topics.update_all(active: false) - end - - topics.each do |topic| - current_topic = Topic.find_or_create_by name: topic["name"] - sub_topic_names = topic["sub_topics"].map { |sub_topic| sub_topic["name"] } - - # Set sub_topics not present in the topics.yml to inactive - current_topic.sub_topics.where.not(name: sub_topic_names).update_all(active: false) - - topic["sub_topics"].each do |sub_topic| - current_sub_topic_topic = SubTopic.find_or_create_by! name: sub_topic["name"], - topic_id: current_topic.id - current_sub_topic_topic.update!(stream_id: sub_topic["stream_id"], - min_tags_for_story: sub_topic["min_tags_for_story"], - max_stories_per_day: sub_topic["max_stories_per_day"], - storypro_category_id: sub_topic["storypro_category_id"], - storypro_user_id: sub_topic["storypro_user_id"], - ai_disclaimer: sub_topic["ai_disclaimer"], - prompts: sub_topic["prompts"], - active: true) - end - end - - # delete unprocessed stories with inactive subtopics - dead_stories = Story.unprocessed.joins(:sub_topic).where(sub_topics: { active: false }) - dead_stories.destroy_all - - # Retroactively disapprove of tweets with disabled subtopic - # Story.joins(:sub_topic).where(sub_topic: { active: false }).joins(discussion: :tweet).each { |s| s.discussion.tweet.update(approved: false) } - end -end diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake new file mode 100644 index 0000000..90bfd84 --- /dev/null +++ b/lib/tasks/import.rake @@ -0,0 +1,48 @@ +namespace :import do + desc "Import perspectives from a YAML file" + task perspectives: :environment do + yaml_file = Rails.root.join("blueprints/perspectives.yml") + perspectives = YAML.load_file(yaml_file)['perspectives'] + + perspectives.each do |perspective_data| + perspective = Perspective.find_or_initialize_by(name: perspective_data['name']) + perspective.narrator = perspective_data['narrator'] + perspective.pronouns = perspective_data['pronouns'] + perspective.effect = perspective_data['effect'] + perspective.example = perspective_data['example'] + + if perspective.save + puts "Successfully imported: #{perspective.name}" + else + puts "Failed to import: #{perspective.name}" + puts perspective.errors.full_messages + end + end + end + + desc "Import archetypes from YAML file" + task archetypes: :environment do + file_path = Rails.root.join("blueprints/archetypes.yml") + + if File.exist?(file_path) + archetypes_data = YAML.load_file(file_path)['archetypes'] + + archetypes_data.each do |archetype_data| + archetype = Archetype.find_or_initialize_by(name: archetype_data['name']) + archetype.traits = archetype_data['traits'] + archetype.examples = archetype_data['examples'] + + if archetype.save + puts "Successfully imported: #{archetype.name}" + else + puts "Failed to import: #{archetype.name}" + puts archetype.errors.full_messages + end + end + + puts "Archetypes import completed." + else + puts "File not found: #{file_path}" + end + end +end diff --git a/lib/tasks/import_perspectives.rake b/lib/tasks/import_perspectives.rake deleted file mode 100644 index b800f5f..0000000 --- a/lib/tasks/import_perspectives.rake +++ /dev/null @@ -1,22 +0,0 @@ -namespace :import do - desc "Import perspectives from a YAML file" - task perspectives: :environment do - yaml_file = Rails.root.join('blueprints', 'perspectives.yml') - perspectives = YAML.load_file(yaml_file)['perspectives'] - - perspectives.each do |perspective_data| - perspective = Perspective.find_or_initialize_by(name: perspective_data['name']) - perspective.narrator = perspective_data['narrator'] - perspective.pronouns = perspective_data['pronouns'] - perspective.effect = perspective_data['effect'] - perspective.example = perspective_data['example'] - - if perspective.save - puts "Successfully imported: #{perspective.name}" - else - puts "Failed to import: #{perspective.name}" - puts perspective.errors.full_messages - end - end - end -end diff --git a/lib/tasks/stories.rake b/lib/tasks/stories.rake deleted file mode 100644 index 3868561..0000000 --- a/lib/tasks/stories.rake +++ /dev/null @@ -1,20 +0,0 @@ -namespace :stories do - desc 'Resetting stories' - task reset: :environment do - puts 'resetting stories' - - Feed.update_all(processed: false) - StoryTag.delete_all - Assignment.delete_all - Story.delete_all - Tagging.delete_all - FeedItem.delete_all - Tag.delete_all - end - - # We need this to approve stories that were created prior to the approval process being implemented - desc 'Approve stories that already have discussions' - task approve_stories_with_discussions: :environment do - Story.joins(:discussion).update_all(approved: true) - end -end