Giter Club home page Giter Club logo

blog_dev's Introduction

Steps:

  1. mix phx.new blog
  • check DB username, password and other settings
  1. mix ecto.create
  2. iex -S mix phx.server
  • to test if everything is working fine for now
  • check by typing "localhost:4000" in browser
  1. mix phx.gen.auth Accounts User users
  • to create user authentication
  1. mix deps.get
  2. mix ecto.migrate
  3. mix test
  • make sure there is a postgres superuser account in the postgres installation
  • homebrew might now have it as default
  1. mix phx.gen.live Stories Story stories title:string body:text user_id:references:users
  2. copy the routes from the terminal into the authentication routes in router.ex
  3. add "setup :register_and_log_in_user" in story_live_test.exs Adding user_id into the DB story entries
  4. add the user_id into the live component in index.html.heex
  • user_id = {@current_user.id}
  1. add user_id in the story.ex changeset for ecto
  2. map user_id into the story_params
  3. Enforce Authencation
  • created new def with added variables in list_stories within story.ex in blog
  • created new getstory! within story.ex in blog
  • added a variable when mounting in story_live/index.ex
  • added a variable when editing and deleting in story_live/index.ex
  1. Copy the index.ex and index.html.heex from story_live folder to paste inside story_live folder
  2. Change the copied index.ex and index.html.heex to home.ex and home.html.heex
  3. Change the home route in router.ex to a live end point - StoryLive.home
  4. Modify home.ex to get all stories without parameters
  5. Modify home.ex to :home instead of :index
  6. Modify home.html.heex to remove unnecessary buttons
  7. Disable show/edit in router.ex
  8. Clean up show.html.heex in story_live to disable editing modal
  9. Add navigation to root.html.heeex in layouts
  10. Move the show endpoint to the public route in router.ex
  • Ensure that this line is after the authencated new story line so that there is no error
  1. add the field name in blog>accounts>user.ex
  2. mix ecto.gen.migration add_name
  3. alter (not create) the user table and add the field name in the migration file
  4. update blog>accounts>user.ex in the registration_changeset to include the name parameter
  5. Go to blog_web>live>user_registration_live to include name field
  6. Associate user table to stories table by modifying blog>stories>story.ex by changing field to belongs_to
  7. Modify blog_web>live>home.html.heex to display user name
  8. Add preload into stories.ex so that users are loaded when listing stories
  9. OPTIONAL: clean up database
  • mix ecto.drop
  • mix ecto.create
  • mix ecto.migrate
  1. Add preload into stories.ex so that we can see the name when we get(read) a story
  2. mix phx.gen.live Comments Comment comments message:text story_id:references:stories
  3. mix ecto.migrate
  4. OPTIONAL: create the test.ex and test.html.heex to demo heex in heex in comment_live
  5. Add test.html.heex into show.html.heex in story_live by using the correct html tag
  6. steal the form component from comment index and put into story_live show.ex
  7. mount comment in show.ex using a comment struct
  8. edit the comment form in show.ex to allow only new comments
  • i.e. no need for edit
  1. assosciate comment to stories
  • add story.id into the form component in show.ex
  • add the field for story.id in the comment form_component
    • make sure the value is written (@story_id)
  • change the story_id field and changeset in comment.ex
  • add has_many to stories so that there is a resolution for the deletion of stories for comments
  1. Optional: Creating an index page for users
  • create the def list_accounts using Repo all in accounts.ex
  • create the folder account_live folder in blog_web/live
  • create the index.ex and the index.html.heex
  1. enhance show.ex in stories to show comments
  2. add list of comments
  3. preload the comments in stories in stories.ex
  4. associate comments to users
  • add belongs_to :user in comment.ex
  • mix ecto.gen.migration comment_has_user
  • mix ecto.migrate
  1. Only users can comment, so add the if statement in show.html.heex
  2. Preload users who made the comments in stories
  3. Allow anonymous comments by using conditional statements when mounting
  4. Ensure that the variables are passed between show.ex and show.html.heex
  5. Copy and paste tailwind templates into the html.heex file
  6. Pass tests (not really, fails story_id validation in the comment tests)
  7. End

user and user passwords [email protected] - testtesttest

blog_dev's People

Contributors

adrianlimcy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.