Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chitter project #2201

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
3230616
Initial commit
snptrs Jun 1, 2023
a17dce5
Draft database and app designs
snptrs Jun 1, 2023
fd53bc8
Create Maker and Peep classes
snptrs Jun 1, 2023
2866cab
Create table schemas and seeds
snptrs Jun 1, 2023
8be6a4d
Passing test for MakerRepository.all
snptrs Jun 1, 2023
2cc341e
Passing test for MakerRepository.find
snptrs Jun 1, 2023
4ee0bef
Passing test for MakerRepository.create
snptrs Jun 1, 2023
ced0907
Passing test for PeepRepository.all
snptrs Jun 1, 2023
82c2932
Passing test for PeepRepository.find
snptrs Jun 1, 2023
e2cd8b2
Passing test for PeepRepository.create
snptrs Jun 1, 2023
d7ba677
Passing test for PeepRepository.find_by_maker
snptrs Jun 2, 2023
b7e8f3b
Updated Peep object to also include maker_name
snptrs Jun 2, 2023
45baace
Passing test for GET /
snptrs Jun 2, 2023
e439193
Update seeds
snptrs Jun 2, 2023
c6e736b
Updated SQL sort order and tests
snptrs Jun 2, 2023
d69311c
Add GET /peep/:id route and passing test
snptrs Jun 2, 2023
52122c6
Add GET /peep/new and POST /peep routes and tests
snptrs Jun 2, 2023
40e6761
Add some navigation links
snptrs Jun 2, 2023
6dde69e
Add Maker registration methods and tests
snptrs Jun 2, 2023
05bfd53
Add MakerRepository.find_by_email and passing tests
snptrs Jun 2, 2023
63aee47
Create GET and POST /maker/login and tests
snptrs Jun 2, 2023
36df892
Redirect to login form when trying to post new Peep
snptrs Jun 3, 2023
e466938
Tweaking support fles
snptrs Jun 3, 2023
0e245ab
Implement GET /maker/logout
snptrs Jun 3, 2023
24cd456
Change time formatting
snptrs Jun 3, 2023
2aea017
Add stylesheet and formatting tweaks
snptrs Jun 3, 2023
1adb3a4
Add error handling and input validation
snptrs Jun 3, 2023
3948364
Add production db reset method
snptrs Jun 3, 2023
358f2e1
Setup for deploy
snptrs Jun 3, 2023
39aee04
Change time format to 24-hour
snptrs Jun 4, 2023
304b86f
Create production SQL seeds
snptrs Jun 4, 2023
5ecaadf
Remove .reset_db method
snptrs Jun 4, 2023
ff4697e
Add tests for error output
snptrs Jun 4, 2023
ce3ff2f
Update production password hashes
snptrs Jun 4, 2023
cdabd69
Add MakerRepository.find_by_name method
snptrs Jun 4, 2023
30d91c2
Add Mentions class
snptrs Jun 4, 2023
fda74e6
Check new Peeps for mentions
snptrs Jun 4, 2023
b47f5c4
Add Mailgun gem
snptrs Jun 4, 2023
6e7ae49
Update seed email addresses
snptrs Jun 4, 2023
060a339
Add Notifications.send_notification
snptrs Jun 4, 2023
0219f30
Update notification message
snptrs Jun 4, 2023
a06c594
Mock Mailgun response in test environment
snptrs Jun 4, 2023
6a664c8
Update README
snptrs Jun 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

ruby '3.0.2'
ruby '3.2.1'

group :test do
gem 'rspec'
Expand All @@ -11,3 +11,19 @@ end
group :development, :test do
gem 'rubocop', '1.20'
end

gem "pg", "~> 1.3"

gem "rack-test", "~> 1.1"

gem "sinatra", "~> 2.2"

gem "webrick", "~> 1.7"

gem "sinatra-contrib", "~> 2.2"

gem "rackup", "~> 1.0"

gem "bcrypt", "~> 3.1"

gem 'mailgun-ruby', '~>1.2.8'
107 changes: 81 additions & 26 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,56 @@ GEM
specs:
ansi (1.5.0)
ast (2.4.2)
diff-lcs (1.4.4)
bcrypt (3.1.18)
diff-lcs (1.5.0)
docile (1.4.0)
parallel (1.20.1)
parser (3.0.2.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
http-accept (1.7.0)
http-cookie (1.0.5)
domain_name (~> 0.5)
mailgun-ruby (1.2.8)
rest-client (>= 2.0.2)
mime-types (3.4.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2023.0218.1)
multi_json (1.15.0)
mustermann (2.0.2)
ruby2_keywords (~> 0.0.1)
netrc (0.11.0)
parallel (1.23.0)
parser (3.2.2.1)
ast (~> 2.4.1)
rainbow (3.0.0)
regexp_parser (2.1.1)
pg (1.5.3)
rack (2.2.7)
rack-protection (2.2.4)
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rackup (1.0.0)
rack (< 3)
webrick
rainbow (3.1.1)
regexp_parser (2.8.0)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.2.5)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.2)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.2)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
rubocop (1.20.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
Expand All @@ -33,10 +62,11 @@ GEM
rubocop-ast (>= 1.9.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.11.0)
parser (>= 3.0.1.1)
ruby-progressbar (1.11.0)
simplecov (0.21.2)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
Expand All @@ -45,22 +75,47 @@ GEM
simplecov
terminal-table
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.3)
terminal-table (3.0.1)
simplecov_json_formatter (0.1.4)
sinatra (2.2.4)
mustermann (~> 2.0)
rack (~> 2.2)
rack-protection (= 2.2.4)
tilt (~> 2.0)
sinatra-contrib (2.2.4)
multi_json
mustermann (~> 2.0)
rack-protection (= 2.2.4)
sinatra (= 2.2.4)
tilt (~> 2.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
unicode-display_width (2.0.0)
tilt (2.1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
unicode-display_width (2.4.2)
webrick (1.8.1)

PLATFORMS
ruby
arm64-darwin-22
x86_64-linux

DEPENDENCIES
bcrypt (~> 3.1)
mailgun-ruby (~> 1.2.8)
pg (~> 1.3)
rack-test (~> 1.1)
rackup (~> 1.0)
rspec
rubocop (= 1.20)
simplecov
simplecov-console
sinatra (~> 2.2)
sinatra-contrib (~> 2.2)
webrick (~> 1.7)

RUBY VERSION
ruby 3.0.2p107
ruby 3.2.1p31

BUNDLED WITH
2.2.26
2.4.13
136 changes: 25 additions & 111 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,123 +1,37 @@
Chitter Challenge
=================

* Feel free to use Google, your notes, books, etc. but work on your own
* If you refer to the solution of another coach or student, please put a link to that in your README
* If you have a partial solution, **still check in a partial solution**
* You must submit a pull request to this repo with your code by 10am Monday morning
This is the project for week 4 of the Makers bootcamp. It uses Ruby, Sinatra, PostgreSQL and Mailgun.

Challenge:
-------
A production version is available to use at https://chitter-gap8.onrender.com

As usual please start by forking this repo.
All RSpec tests are passing, and simplecov is reporting 97% test coverage.

We are going to write a small Twitter clone that will allow the users to post messages to a public stream.
There's some very basic `@mention` functionality which will send a notification to the tagged user. See `Notes` below for more on this.

Features:
-------
## Deploying

```
STRAIGHT UP
I've deployed this on [Render](https://render.com), but it should deploy anywhere that supports Ruby and Postgres (and Mailgun if you use the email notifications).

As a Maker
So that I can let people know what I am doing
I want to post a message (peep) to chitter
1. Clone the repo.
2. Create a Postgres database using `spec/table_schemas.sql`.
3. If you're testing it locally, you'll need to populate the database with `spec/seeds.sql` to make sure the RSpec tests continue to pass.
4. Set these environment variables:
- `ENV['DATABASE_URL']` should be set the the URL of your Postgres host.
- If using the email notification functionality, you'll need to set:
- `ENV["MAILGUN_API_KEY"]` is your Mailgun API key.
- `ENV["CHITTER_FROM"]` is the address that Chitter will send notifications from.
- `ENV["CHITTER_SENDING_DOMAIN"]` is your Mailgun sending domain.

As a maker
So that I can see what others are saying
I want to see all peeps in reverse chronological order
## Notes

As a Maker
So that I can better appreciate the context of a peep
I want to see the time at which it was made
- In this version, if you @mention another user, it will send a notification to their registered email address. This currently only works:
- If `@name` is at the start of the Peep.
- If the user has registered with a single name. If they registered with their full name, it won't work. To help with this, I need to add a separate username field to the database (it's currently just using name, email address and a unique user ID that isn't accessible to the user).
- If the capitalisation is exactly the same as the name the user registered with.

As a Maker
So that I can post messages on Chitter as me
I want to sign up for Chitter

HARDER

As a Maker
So that only I can post messages on Chitter as me
I want to log in to Chitter

As a Maker
So that I can avoid others posting messages on Chitter as me
I want to log out of Chitter

ADVANCED

As a Maker
So that I can stay constantly tapped in to the shouty box of Chitter
I want to receive an email if I am tagged in a Peep
```

Technical Approach:
-----

In the last two weeks, you integrated a database using the `pg` gem and Repository classes. You also implemented small web applications using Sinatra, RSpec, HTML and ERB views to make dynamic webpages. You can continue to use this approach when building Chitter Challenge.

You can refer to the [guidance on Modelling and Planning a web application](https://github.com/makersacademy/web-applications/blob/main/pills/modelling_and_planning_web_application.md), to help you in planning the different web pages you will need to implement this challenge. If you'd like to deploy your app to Heroku so other people can use it, [you can follow this guidance](https://github.com/makersacademy/web-applications/blob/main/html_challenges/07_deploying.md).

If you'd like more technical challenge now, try using an [Object Relational Mapper](https://en.wikipedia.org/wiki/Object-relational_mapping) as the database interface, instead of implementing your own Repository classes.

Some useful resources:
**Ruby Object Mapper**
- [ROM](https://rom-rb.org/)

**ActiveRecord**
- [ActiveRecord ORM](https://guides.rubyonrails.org/active_record_basics.html)
- [Sinatra & ActiveRecord setup](https://learn.co/lessons/sinatra-activerecord-setup)

Notes on functionality:
------

* You don't have to be logged in to see the peeps.
* Makers sign up to chitter with their email, password, name and a username (e.g. [email protected], password123, Sam Morgan, sjmog).
* The username and email are unique.
* Peeps (posts to chitter) have the name of the maker and their user handle.
* Your README should indicate the technologies used, and give instructions on how to install and run the tests.

Bonus:
-----

If you have time you can implement the following:

* In order to start a conversation as a maker I want to reply to a peep from another maker.

And/Or:

* Work on the CSS to make it look good.

Good luck and let the chitter begin!

Code Review
-----------

In code review we'll be hoping to see:

* All tests passing
* High [Test coverage](https://github.com/makersacademy/course/blob/main/pills/test_coverage.md) (>95% is good)
* The code is elegant: every class has a clear responsibility, methods are short etc.

Reviewers will potentially be using this [code review rubric](docs/review.md). Referring to this rubric in advance may make the challenge somewhat easier. You should be the judge of how much challenge you want at this moment.

Notes on test coverage
----------------------

Please ensure you have the following **AT THE TOP** of your spec_helper.rb in order to have test coverage stats generated
on your pull request:

```ruby
require 'simplecov'
require 'simplecov-console'

SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::Console,
# Want a nice code coverage website? Uncomment this next line!
# SimpleCov::Formatter::HTMLFormatter
])
SimpleCov.start
```

You can see your test coverage when you run your tests. If you want this in a graphical form, uncomment the `HTMLFormatter` line and see what happens!
## Todo
- Add a username field.
- Make the `@mention` parsing more robust.
- Implement threaded replies (will probably need to add a join table between Peeps and their replies for this).
- Add more robust input validation and sanisation.
Loading