Code Monkey home page Code Monkey logo

ember-realworld's Introduction

Ember.js Example App

RealWorld Frontend This project uses GitHub Actions for continuous integration. Netlify Status

Ember RealWorld example app

Ember.js codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

Prerequisites

You will need the following things properly installed on your computer.

Installation

  • git clone <repository-url> this repository
  • cd ember-realworld
  • yarn

Running / Development

Code Generators

Make use of the many generators for code, try ember help generate for more details

Running Tests

  • yarn test
  • yarn test --server

Linting

  • yarn lint
  • yarn lint:js --fix

Building

  • ember build (development)
  • ember build --environment production (production)

Deploying

This app is automatically deployed to Netlify.

Further Reading / Useful Links

ember-realworld's People

Contributors

alexlafroscia avatar alonski avatar delusioninabox avatar dependabot[bot] avatar ericsimons avatar gcheung55 avatar geromegrignon avatar ijlee2 avatar johpol avatar jonnii avatar mansona avatar marvinmarnold avatar patocallaghan avatar tylerturdenpants avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ember-realworld's Issues

[Error page] 404 etc

We currently have no error page and non-existent urls result in a blank page.

We should add an error route see like here and an error template like here (yes it looks awful)

Want to write a test?

  • Acceptance: nonsensical URL results in error page showing

[Article page] Delete article button (only shown to author)

Features

  • Button which deletes the article
  • Should only be shown if the current user is the article author

image

Want to write tests?

  • Integration: Button is only shown for the logged in article author
  • Acceptance: Clicking the button deletes the article and navigates to the homepage

API Domain change

Hello!

Due to governance changes, we are now using the realworld.io domain for the RealWorld demo (both client and API).
Requests from conduit.productionready.io are redirected to api.realworld.io, but such a redirection might lead to inconsistent responses.

We encourage domain change for the community.
If this repository is maintained anymore, we'll consider hosting a demo of your implementation in a few weeks with the domain change.

The demo link will be added to the RealWorld documentation.

No user id on creating a new article

Im using Ember Realworld with Adonis realworld as backend, When they registrate, login and edit their account it works ok, but when it creates a new article the server returns a 500 code with the following message

{ message: "insert into articles (author, body, createdAt, description, slug, title, updatedAt, user_id) values (NULL, 'This is the content', '2021-05-16 01:39:07.272', 'This is the subtitle', 'this-is-the-title', 'This is the title', '2021-05-16 01:39:07.272', 1) - SQLITE_ERROR: table articles has no column named author", name: "Error", status: 500, … }

It seems that the frontend doesn't send the user id (and neither the createdAt date) to the backend when inserts a new article
image

[Article form] Save article

Features

  • Disable button if the model isn't dirty
  • Save the article
  • If a successful save and it's a new article, redirect to the article edit page passing this model
  • Navigating away from an unsaved model warns the user they will lose unsaved changes. If confirmed either unload the record (i.e. new post) or rollback the changed attributes (i.e. existing article)

Want to write tests?

  • Integration: Submit button is disabled if model isn't dirty
  • Integration: Hitting submit makes the correct response to save the model
  • Acceptance: Saving a new post redirects to the editing article page

Separate concerns of the main user model

I'd like to propose that we split the main user model into two models: user and profile. They are very similar but serve two subtly different roles.

  • user - The current user. Can be used to tell if a user is logged in or not. Can be used on the settings page to edit a user's properties. Can grab the logged in user's article feed.
  • profile - Similar to a user but more to do with authors of articles. They can be followed, have their articles favorited/unfavorited.

My reasoning? While I initially tried to use the same model in the Octane version of the app, this abstraction broke down when I needed use the same model between the settings page and article list/profile pages. (Octane repo: Profile, User)

The profile model has the username as the primary key for identifying a user, they have no other unique identifier.

But then when editing the user we need to be able to edit the user's username. This is not possible as we are trying to treat this property as the primary key for the profile. Also the /user endpoint returns a unique integer identifier as well as the username.

Here are some sample payload responses from the API.

// User
{
  "user": {
    "id": 52999,
    "email": "[email protected]",
    "createdAt": "2019-03-31T00:15:23.573Z",
    "updatedAt": "2019-04-05T07:25:08.330Z",
    "username": "someusername",
    "bio": null,
    "image": "https://s3.amazonaws.com/uifaces/faces/twitter/yoyoyo/128.jpg",
    "token": "eyJ0eXAiOiJKV1..........."
  }
}

// Profile
{
  "username": "lifelonglearner123",
  "bio": null,
  "image": "https://static.productionready.io/images/wat-yo.jpg",
  "following": false
}

What do you folks think?

/cc @Alonski @mansona

Should we migrate this app to become an Ember Octane app?

Follow-up issue to #99 to allow us to discuss without having to focus on the code changes.

Originally it was discussed that Ember Realworld would show how to build a Ember Classic application. A new separate app was then spun up which outlined how to build the RealWorld app using Ember Octane.

But it has since been suggested that these Ember apps should not be separate and should just be merged into this Ember RealWorld app. The thinking is that Ember Octane is not a separate framework but rather just an updating of syntax and the programming model.

Conversation from Discord below:
image
image
image

/cc @mansona @Alonski @GCheung55 @trek

[Profile page] Follow/unfollow profile

We should able to follow/unfollow a user's profile

image

Features

  • Unfollowed state
    image

  • Followed state
    image


API

Follow user

POST /api/profiles/:username/follow

Authentication required, returns a Profile

No additional parameters required

Unfollow user

DELETE /api/profiles/:username/follow

Authentication required, returns a Profile

No additional parameters required

Tests

  • Integration - Initial follow/unfollowed state
  • Integration - Follow profile and state should change
  • Integration - Unfollow profile and state should change

Can ember-concurrency be removed?

Ember.js is often called out on having a large filesize. I'm wondering if ember-concurrency can be removed in order to reduce the vendor.js filesize.

I understand that it's useful for dropping tasks to prevent multiple executes of a task when a task is already being performed. Perhaps there's an alternative to using a task that can be leveraged?

[Home page] Your feed

Implement the "Your feed" section on the article list on the Homepage.

image

Features:

  • Hidden when logged out
  • Appears when when logged in
  • Active/disabled state
  • ?feed=your query param
  • User feed endpoint

Want to write tests?

  • Acceptance: Logged in it shows
  • Acceptance: Logged out it doesn't
  • Acceptance: Switching from global feed to your feed should 1) work 2) make the right request 3) render the right content 4) have the correct url

[Home page] Favoriting/unfavoriting

We should have the ability to favorite/unfavorite articles

Features:

  • Unfavorited state
  • Favorited state
  • Click to favorite
  • Click to unfavorite
  • Count should increment/decrement when you favorite/unfavorite

Unfavorited

image

Favorited

image

Want to write tests?

  • Integration: Click to favorite, state change, count increments
  • Integration: Click to unfavorite, state change, count increments

Question: Can we turn off Mirage for local development?

While I understand the value-add of Mirage in the development environment, especially when APIs are not built, in my opinion we don't really need it here. The API provided by gothinkster is feature-complete and I've never had any issues with it in development.

I find in my own development in this repo I'm always disabling it but reverting that change before committing.

Upsides:

  • gothinkster API is feature complete
  • Working against a live API so we won't miss anything in our mocks

Downsides:

  • Can't develop if network is down
  • We need to create the mocks anyway for testing

I'd be interested in hearing your thoughts.

/cc @Alonski @delusioninabox @mansona

[Settings page] Make the settings form work

Features

image


API

Update user

PUT /api/user

Example request body:

{
  "user":{
    "email": "[email protected]",
    "bio": "I like to skateboard",
    "image": "https://i.stack.imgur.com/xHWG8.jpg"
  }
}

Authentication required, returns the User

Accepted fields: email, username, password, image, bio

This should be handled by user.save().


Tests

  • Integration - Submit button is disabled until content is changed
  • Integration - Updating content sends the correct http requests

Octane example: https://github.com/patocallaghan/realworld-starter-kit/blob/4611cda2c1b9f391f976b111e2e23a833d3dd00c/app/templates/components/settings-form.hbs

[Settings page] Log out & redirect to homepage

Features

  • Make the log out button work, i.e. this.session.logOut()
  • Redirect to the homepage afterwards on a successful response

Tests

  • Acceptance - log out and redirects to the homepage

[Article form] Title, description, post, tags

Features

  • Component with form fields and submit button
  • Title, description, content (markdown), tags
  • Form should work in two scenarios
    • article model passed in i.e. editing an existing article
    • no article passed in, create record on init if none passed in, i.e. new article
  • Tag list can be entered as a space separated list
  • Form should appear on the "New article" and "Edit article" pages

image

[Article page] Render markdown from server

Features

  • Render the markdown from the article as HTML
  • Use marked npm library to render the markdown
  • Sanitize the content and then use htmlSafe. See Octane version here

For better encapsulation we should add this behaviour to the article model.

Want to write tests?

  • Model unit: marked computed property generates the correct HTML
  • Integration: Markdown is rendered as HTML on the page correctly

image

[Profile page] Favorite/unfavorite article

On an author's profile page we should be able to favorite/unfavorite articles

This should just start working when this is made to work in #46 from the homepage.

But worth calling out to verify that is actually the case

[Article form] Errors

Features

  • Display submit errors

image

Want to write tests?

  • Integration: displays errors if save returns errors

[Task] Setup CI

It would be great to be able to turn on CI for our tests/linting. I believe there may be issues due to the repo being in the gothinkster org but we can see.

/cc @Alonski

Enable CI?

@Alonski I noticed in #112 that we don't have CI enabled. We had a linting error but the status checks were 🟢

image

Any chance you could enable it please or is that something I can do?

[Article page] Post comment (only shown to logged in)

Feature

  • Comment field
  • disable 'post comment' button when textarea is empty
  • It is only shown to logged in users

image

API

Add Comments to an Article
POST /api/articles/:slug/comments

Example request body:

{
  "comment": {
    "body": "His name was my name too."
  }
}

Authentication required, returns the created Comment

Required field: body

Want to write tests?

  • Integration: button is disabled when no content
  • Integration: Posting comment sends the correct HTTP request
  • Integration: Comment form is only visible when logged in

[Article page] Edit article button (only shown to author)

Features

  • Button which links to the article edit page
  • Should only be shown if the current user is the article author

image

Want to write tests?

  • Integration: Button is only shown for logged in users
  • Acceptance: Clicking the button navigates to the edit article page

[Nav] Logo link to homepage

Currently the logo in the top left is linking to index.html.

It should be converted to a link-to and link to 'home'. The link should also set the default query params, i.e. tag=null, page=1 etc

Tags list should only show what's popular

Currently the tag list is showing tags from all articles loaded. This is due to the tag-list finding all tags, which returns a live array.

An article has a hasMany relationship with tags, so every time an article is fetched and it has tags, the live array will include it.

Build Article Route + Page

Need to get the article Data and use it to dynamically show the page.
Currently is a static template.

Build Profile Route + Page

Currently points to a static template.
Need to build to get the Data for the specific profile and show everything related to it

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.