91 |
92 | Slacker allows users to Sign Up and Log in using intuitive modals on the splash page. The application has front end and back end authorization to safely store the password for old and new users. On the backend, the password is put through a hashing function and stored in the database under 'password_digest'. When a user then goes to sign in, the password is put through the same hashing function (BCrpyt) and if the two password_digests are equal the user will be logged in. Upon logging in, the users session_token is attached to the browser so that the user can refresh the page and not have to tediously log in another time.
93 |
94 | ## Channels and Subscriptions
95 |
96 |
97 |
98 |
99 | On Slacker, the demo accounts (George Washington and Theodore Roosevelt) begin with memberships to several channels in addition to the ability to create more. Because users have many channels and channels have many users I employed a through table called 'Memberships' to handle the relationship of channels and users. Upon creating a channel, the selected users will have a 'Membership' created with that specific channel.
100 |
101 | There are two types of channels in Slacker - public Public Channels and Direct Messages. Both are created in the left column of the application. Upon clicking the plus sign, a modal will appear showing the names of every user in the database. The user can click the the names of the users they would like in the new channel or direct message.
102 |
103 |
104 | ## Messages
105 |
106 |
107 |
108 |
109 | Messages are created when the user submits content in the most bottom part of middle column. Upon submitting, the message is immediately displayed and the bottom of the chat will come into screen. Messages are stored in the database and only called upon the clicking of the channel they belong to. This keeps the initial rendering of the application quick.
110 |
111 |
112 | ## Live Chat
113 |
114 |
115 |
116 |
117 | Live chat is available using the pusher api. When a message is sent and validated on the on the backend, pusher's 'trigger' method is called with the event 'message_published' and the specific channel's id with which it was saved. The channels, which listening for 'message_published', will fetch the new message when this event is received.
118 |
119 | Using the publish and subscribe model users enjoy live group chat in all channels where they have a membership.
120 |
121 |
122 | ## Replies
123 |
124 |
125 |
126 |
127 | In addition to responding to messages in the channel, users can directly respond to messages in the reply thread. When messages are sent to the frontend using jBuilder, they hold their replies as an object in the state. This allows for fast look up on the frontend.
128 |
129 |
130 | ## Responsiveness
131 |
132 |
133 |
134 |
135 | The width of browser determines how long, how big, and which of the elements will appear on the application. By using media queries, the messages and replies adjust so that the content of each can be seen in any circumstance.
136 |
137 | ## Future Directions for the Project
138 |
139 | As for future directions, following are desired features for Slick:
140 |
141 | 1. Persisting emoticon data
142 | 2. Notifications
143 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | # Add your own tasks in files placed in lib/tasks ending in .rake,
2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3 |
4 | require_relative 'config/application'
5 |
6 | Rails.application.load_tasks
7 |
--------------------------------------------------------------------------------
/app/assets/config/manifest.js:
--------------------------------------------------------------------------------
1 | //= link_tree ../images
2 | //= link_directory ../javascripts .js
3 | //= link_directory ../stylesheets .css
4 |
--------------------------------------------------------------------------------
/app/assets/gifs/auth-gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/gifs/auth-gif.gif
--------------------------------------------------------------------------------
/app/assets/gifs/channel-gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/gifs/channel-gif.gif
--------------------------------------------------------------------------------
/app/assets/gifs/live-chat-gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/gifs/live-chat-gif.gif
--------------------------------------------------------------------------------
/app/assets/gifs/login-gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/gifs/login-gif.gif
--------------------------------------------------------------------------------
/app/assets/gifs/new-message-gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/gifs/new-message-gif.gif
--------------------------------------------------------------------------------
/app/assets/gifs/replies-gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/gifs/replies-gif.gif
--------------------------------------------------------------------------------
/app/assets/gifs/responsive-gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/gifs/responsive-gif.gif
--------------------------------------------------------------------------------
/app/assets/images/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/images/.DS_Store
--------------------------------------------------------------------------------
/app/assets/images/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/images/.keep
--------------------------------------------------------------------------------
/app/assets/images/Hamilton.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/images/Hamilton.jpg
--------------------------------------------------------------------------------
/app/assets/images/detailed-wh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/images/detailed-wh.png
--------------------------------------------------------------------------------
/app/assets/images/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/images/favicon.ico
--------------------------------------------------------------------------------
/app/assets/images/george.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/images/george.jpg
--------------------------------------------------------------------------------
/app/assets/images/hoover.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/images/hoover.jpg
--------------------------------------------------------------------------------
/app/assets/images/jfk.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/images/jfk.jpeg
--------------------------------------------------------------------------------
/app/assets/images/lake.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/images/lake.jpeg
--------------------------------------------------------------------------------
/app/assets/images/lincoln.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/images/lincoln.jpeg
--------------------------------------------------------------------------------
/app/assets/images/obama.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/images/obama.jpeg
--------------------------------------------------------------------------------
/app/assets/images/rwb-stars2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/images/rwb-stars2.jpg
--------------------------------------------------------------------------------
/app/assets/images/teddy.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/images/teddy.jpg
--------------------------------------------------------------------------------
/app/assets/images/yosemite.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/images/yosemite.jpg
--------------------------------------------------------------------------------
/app/assets/images/yosemitesmall.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/images/yosemitesmall.jpg
--------------------------------------------------------------------------------
/app/assets/javascripts/application.js:
--------------------------------------------------------------------------------
1 | // This is a manifest file that'll be compiled into application.js, which will include all the files
2 | // listed below.
3 | //
4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5 | // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6 | //
7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8 | // compiled file. JavaScript code in this file should be added after the last require_* statement.
9 | //
10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11 | // about supported directives.
12 | //
13 | //= require jquery
14 | //= require jquery_ujs
15 | //= require_tree .
16 |
--------------------------------------------------------------------------------
/app/assets/javascripts/cable.js:
--------------------------------------------------------------------------------
1 | // Action Cable provides the framework to deal with WebSockets in Rails.
2 | // You can generate new channels where WebSocket features live using the rails generate channel command.
3 | //
4 | //= require action_cable
5 | //= require_self
6 | //= require_tree ./channels
7 |
8 | (function() {
9 | this.App || (this.App = {});
10 |
11 | App.cable = ActionCable.createConsumer();
12 |
13 | }).call(this);
14 |
--------------------------------------------------------------------------------
/app/assets/javascripts/channels/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/assets/javascripts/channels/.keep
--------------------------------------------------------------------------------
/app/assets/stylesheets/application.css:
--------------------------------------------------------------------------------
1 | /*
2 | * This is a manifest file that'll be compiled into application.css, which will include all the files
3 | * listed below.
4 | *
5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6 | * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7 | *
8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10 | * files in this directory. Styles in this file should be added after the last require_* statement.
11 | * It is generally better to create a new file per style scope.
12 | *
13 | *= require_tree .
14 | *= require_self
15 | */
16 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/channel_list.css.scss:
--------------------------------------------------------------------------------
1 | .fa-plus-circle:hover {
2 | color: white !important;
3 | }
4 |
5 | .direct-message-space-holder {
6 | height: 80px;
7 | width: 400px;
8 | }
9 |
10 | .channel-space-holder {
11 | height: 20px;
12 | }
13 |
14 | .channel-list {
15 | display: flex;
16 | flex-direction: column;
17 | }
18 |
19 | .new-channel-form {
20 | justify-content: center;
21 | display: flex;
22 | flex-direction: column;
23 | width: 500px;
24 | font-size: 24px;
25 | border: none;
26 | outline: none;
27 | font-family: 'Nunito', sans-serif;
28 | overflow: hidden;
29 | }
30 |
31 | .channel-form-input {
32 | color: #eee;
33 | width: 480px;
34 | height: 48px;
35 | border-radius: 10px;
36 | border: 2px solid;
37 | padding: 5px;
38 | margin-top: 16px;
39 | font-size: 26px;
40 | padding-left: 10px;
41 | outline: none;
42 | }
43 |
44 | .channel-form-input:focus{
45 | color: black;
46 | }
47 |
48 | .channel-list-item a {
49 | display: block;
50 | border-bottom: none;
51 | text-decoration: none;
52 | color: inherit;
53 | size: inherit;
54 | padding-top: 3px;
55 | padding-bottom: 2px;
56 | text-overflow: ellipsis;
57 | height: 14px;
58 | width: -1px;
59 | padding-left: 8px;
60 | border-radius: 5px;
61 | }
62 |
63 | .selector {
64 | background-color: #4c9689 !important;
65 | color: white !important;
66 | border-radius: 5px !important;
67 | }
68 |
69 |
70 | .channel-list-item {
71 | margin-bottom: 10px;
72 | color: #9e8e9c;
73 | font-size: 14px;
74 | text-overflow: ellipsis;
75 | height: 19px;
76 | overflow: hidden;
77 | text-overflow: ellipsis;
78 | white-space: nowrap;
79 | overflow-x: hidden;
80 | width: 195px;
81 |
82 | a:hover {
83 | background-color: #231221;
84 | }
85 | }
86 |
87 |
88 | channel-list-item:hover{
89 | color: #555459;
90 | }
91 |
92 | .open-channel {
93 | }
94 |
95 | .closed-channel {
96 |
97 | }
98 |
99 | .big-text-nav-bar {
100 | font-size: 13px;
101 | color: #ab9ba9;
102 | margin-left: 5px;
103 | color: #9e8e9c;
104 | }
105 |
106 | .channel-submit {
107 | margin-top: 10px;
108 | margin-right: 20px;
109 | background-color: #2ab27b;
110 | background-repeat: #2ab27b;
111 | border: none;
112 | overflow: hidden;
113 | outline: none;
114 | cursor: pointer;
115 | font-size: 26px;
116 | color: white;
117 | opacity: .99;
118 | color: white;
119 | width: 500px;
120 | justify-content: center;
121 | font-family: 'Nunito', sans-serif;
122 | height: 64px;
123 | border-radius: 7px;
124 | }
125 |
126 | .channel-and-form {
127 | display: flex;
128 | justify-content: space-between;
129 | align-items: center;
130 | }
131 |
132 | .channel-intro {
133 | position: relative;
134 | left: 38px;
135 | }
136 |
137 | .channel-label {
138 | font-size:14px;
139 | color: #9e8e9c;
140 | font-size: 14px;
141 | color: #9e8e9c;
142 | position: relative;
143 | left: 13px;
144 | margin-bottom: 8px;
145 | }
146 |
147 | .direct-message-label {
148 | position: relative;
149 | left: 9px;
150 | margin-bottom: 8px;
151 | }
152 |
153 | .direct-message-intro {
154 | position: relative;
155 | top: 68px;
156 | left: 35px;
157 | }
158 |
159 | .whole-direct-message-list {
160 | margin-top: 22px;
161 | }
162 |
163 | .button {
164 | padding-right: 11px;
165 | font-size: 16px;
166 | color: #9e8e9c;
167 | position: relative;
168 | bottom: 7px;
169 | }
170 |
171 | .button:hover {
172 | cursor: pointer;
173 | }
174 |
175 | .fa-circle {
176 | font-size: 12px;
177 | color: #38978d;
178 | padding-right: 5px;
179 | }
180 |
181 | .time-stamp {
182 | font-size: 11px;
183 | margin-left: 10px;
184 | font-weight: 200;
185 |
186 | }
187 |
188 | .selected-users-box {
189 | border-bottom: 1px solid;
190 | height: 110px;
191 | font-size: 18px;
192 | overflow-y: scroll;
193 | padding-bottom: 50px;
194 | margin-top: 30px;
195 | }
196 |
197 | .unselected-users-box {
198 | height: 110px;
199 | font-size: 18px;
200 | overflow-y: scroll;
201 | margin-top: 35px;
202 | margin-bottom: 20px;
203 | padding-bottom: 30px;
204 | }
205 |
206 | .selecting-users-label {
207 | margin-bottom: 10px;
208 | position: fixed;
209 | left: 193px;
210 | margin-top: 5px;
211 | top: 130px;
212 | }
213 |
214 | .unselecting-users-label {
215 | margin-bottom: 10px;
216 | position: fixed;
217 | left: 184px;
218 | margin-top: 5px;
219 | top: 318px;
220 | }
221 |
222 | .search-list-item {
223 | font-size: 16px;
224 | display: flex;
225 | position: relative;
226 | bottom: 5px;
227 | left: 17%;
228 | padding-bottom: 4px;
229 | border-radius: 20px;
230 | }
231 |
232 | .search-list-item:hover {
233 | cursor: pointer;
234 | // background: #f5f5ef;
235 | font-weight:bolder;
236 | }
237 |
238 | .search-list-item img {
239 | height: 40px !important;
240 | width: 40px !important;
241 | position: relative;
242 | top: 15px;
243 | }
244 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/homepage.css.scss:
--------------------------------------------------------------------------------
1 | body {
2 | overflow-x: hidden;
3 | overflow-y: hidden;
4 | }
5 |
6 |
7 | .homepage {
8 | display: flex;
9 | font-family: 'Nunito', sans-serif;
10 | }
11 |
12 |
13 | .left-col {
14 | display: flex;
15 | flex-direction: column;
16 | height: auto;
17 | background-color: #4d394b;
18 | color: gray;
19 | width: 220px;
20 | height: 100vh;
21 | position: fixed;
22 | }
23 | // display: flex;
24 | // flex-direction: column;
25 | // height: auto;
26 | // background-color: #4d394b;
27 | // color: gray;
28 | // width: 220px;
29 | // height: 100vh;
30 |
31 | .col-header {
32 | height: 60px;
33 | }
34 |
35 | .selected-header {
36 | height: 61px;
37 | position: absolute;
38 | position: absolute;
39 | left: 220px;
40 | top: 0px;
41 | width: 100%;
42 | height: 61px;
43 | background: white;
44 | border-bottom: 1px solid;
45 | z-index: 1;
46 | }
47 |
48 | .selected-channel {
49 | display: flex;
50 | flex-direction: column;
51 | justify-content: flex-end;
52 | width: 100%;
53 | }
54 |
55 | .header-message-list {
56 | justify-content: space-between;
57 | }
58 |
59 | .selected-channel-header {
60 | }
61 |
62 | .selected-header-text {
63 | padding-top: 20px;
64 | padding-left: 5px;
65 | }
66 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/landing_page.css.scss:
--------------------------------------------------------------------------------
1 | #landing-text {
2 | display: flex;
3 | margin-top: 551px;
4 | margin-left: 25px;
5 | font-size: 56px;
6 | color: black;
7 | font-family: 'Nunito', sans-serif;
8 | z-index: 3;
9 | position: fixed;
10 | bottom: 40px;
11 | left: 40px;
12 | }
13 |
14 |
15 |
16 | .landing-block {
17 | display: flex;
18 | flex-direction: row;
19 | font-family: 'Merriweather', serif;
20 | position: relative;
21 | top: 100px;
22 | left: 50px;
23 | max-width: 1000px;
24 | }
25 |
26 | .overall-description {
27 | // font-size: 32px;
28 | color: #b92e2e;
29 | position: relative;
30 | bottom: 15px;
31 | // left: 50px;
32 | font-family: 'Poiret One', cursive;
33 | font-size: 28px;
34 | }
35 |
36 |
37 | #rwb-background {
38 | background-image: image-url("rwb-stars2.jpg");
39 | // height: 100vh;
40 | // width: 100vw;
41 | width: 100%;
42 | height: 100%;
43 | opacity: .040;
44 | position:absolute;
45 | }
46 |
47 | #background-div {
48 | background-image: image-url("detailed-wh.png");
49 | background-size: 500px 350px;
50 | font-family: 'Nunito', sans-serif;
51 | // height: 100vh;
52 | background-repeat: no-repeat;
53 | height: 440px;
54 | width: 900px;
55 | left: 69px;
56 | font-family: 'Nunito', sans-serif;
57 | background-repeat:no-repeat;
58 | height: 440px;
59 | width: 900px;
60 | opacity: 1 !important;
61 | }
62 |
63 |
64 | .landing-intro {
65 | display: flex;
66 | flex-direction: column;
67 | font-size: 20px;
68 | // z-index 3;
69 | opacity: 1;
70 | width: 450px;
71 | position: relative;
72 | top: 74px;
73 | left: 10px;
74 | }
75 |
76 | .landing-intro .intro-name {
77 | font-size: 62px;
78 | color: #b92e2e;
79 | }
80 |
81 | .landing-intro .intro-description {
82 | font-size: 22px;
83 | color: #272992;
84 | margin-top: 20px;
85 | line-height: 30px;
86 | }
87 |
88 | html {
89 | height: 100vh;
90 | }
91 |
92 |
93 | .nav {
94 | display: flex;
95 | flex-direction: row-reverse;
96 | border-bottom: solid;
97 | background-color: #1e297b;
98 | // opacity: .5;
99 | }
100 |
101 | .auth {
102 | margin: 10px;
103 | background-color: Transparent;
104 | background-repeat:no-repeat;
105 | border: none;
106 | overflow: hidden;
107 | cursor:pointer;
108 | font-size: 24px;
109 | font-family: 'Nunito', sans-serif;
110 | color: white;
111 | opacity: .99;
112 | }
113 |
114 | .login-form-container {
115 | font-size: 18px;
116 | }
117 |
118 | .submit {
119 | margin-top: 10px;
120 | margin-right: 20px;
121 | background-color: #2ab27b;
122 | background-repeat: #2ab27b;
123 | border: none;
124 | overflow: hidden;
125 | outline: none;
126 | cursor: pointer;
127 | font-size: 18px;
128 | color: white;
129 | opacity: .99;
130 | color: white;
131 | width: 407px;
132 | justify-content: center;
133 | font-family: 'Nunito', sans-serif;
134 | height: 38px;
135 | }
136 |
137 | .auth-input {
138 | width: 400px;
139 | height: 30px;
140 | margin-top: 15px;
141 | color: lightgray;
142 | font-size: 18px;
143 | font-family: 'Nunito', sans-serif;
144 | }
145 |
146 | .auth-input:focus{
147 | color: black;
148 | }
149 |
150 | .entry-message {
151 | font-size: 14px;
152 | font-family: 'Nunito', sans-serif;
153 | }
154 |
155 | .entry-greeting {
156 | margin-bottom: 6px;
157 | font-size: 24px;
158 | font-family: 'Nunito', sans-serif;
159 | }
160 |
161 | .whole-greeting {
162 | justify-content: center;
163 | text-align: center;
164 | }
165 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/leftcol.css.scss:
--------------------------------------------------------------------------------
1 |
2 | .col-header h4 {
3 | color: white;
4 | font-size: 28px;
5 | font-style: oblique;
6 | }
7 |
8 | .col-header {
9 | display: flex;
10 | flex-direction: row;
11 | margin-bottom: 10px;
12 | position: relative;
13 | left: 13px;
14 | top: 6px;
15 | }
16 |
17 | .current-user-greeting {
18 | font-size: 13px;
19 | color: #a291a0;
20 | display: flex;
21 | }
22 |
23 | .logout {
24 | outline: none;
25 | border: 1px solid;
26 | background: #4d394b;
27 | color: #aa9aa8;
28 | border-radius: 5px;
29 | font-family: 'Nunito', sans-serif;
30 | font-size: 14px;
31 | height: 25px;
32 | align-items: center;
33 | position: relative;
34 | left: 22px;
35 | top: 3px;
36 | justify-content: center;
37 | padding-bottom: 6px;
38 | }
39 |
40 | .fa-sign-out:hover {
41 | cursor: pointer;
42 | font-size: 20px;
43 |
44 | }
45 |
46 | .fa-sign-out {
47 | color: white;
48 | position: fixed;
49 | left: 197px;
50 | top: 13px;
51 | }
52 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/reset.css:
--------------------------------------------------------------------------------
1 | html, body, div, span, applet, object, iframe,
2 | h1, h2, h3, h4, h5, h6, p, blockquote, pre,
3 | a, abbr, acronym, address, big, cite, code,
4 | del, dfn, em, img, ins, kbd, q, s, samp,
5 | small, strike, strong, sub, sup, tt, var,
6 | b, u, i, center,
7 | dl, dt, dd, ol, ul, li,
8 | fieldset, form, label, legend,
9 | table, caption, tbody, tfoot, thead, tr, th, td,
10 | article, aside, canvas, details, embed,
11 | figure, figcaption, footer, header, hgroup,
12 | menu, nav, output, ruby, section, summary,
13 | time, mark, audio, video {
14 | margin: 0;
15 | padding: 0;
16 | border: 0;
17 | font-size: 100%;
18 | font: inherit;
19 | vertical-align: baseline;
20 | }
21 | /* HTML5 display-role reset for older browsers */
22 | article, aside, details, figcaption, figure,
23 | footer, header, hgroup, menu, nav, section {
24 | display: block;
25 | }
26 | body {
27 | line-height: 1;
28 | }
29 | ol, ul {
30 | list-style: none;
31 | }
32 | blockquote, q {
33 | quotes: none;
34 | }
35 | blockquote:before, blockquote:after,
36 | q:before, q:after {
37 | content: '';
38 | content: none;
39 | }
40 | table {
41 | border-collapse: collapse;
42 | border-spacing: 0;
43 | }
44 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/selected_input.css.scss:
--------------------------------------------------------------------------------
1 | .selected-input-div {
2 | display: flex;
3 | min-height: 21px;
4 | box-sizing: border-box;
5 | cursor: text;
6 | line-height: 1.42;
7 | outline: 0;
8 | overflow-y: auto;
9 | padding: 12px 15px;
10 | tab-size: 4;
11 | -moz-tab-size: 4;
12 | text-align: left;
13 | white-space: pre-wrap;
14 | word-wrap: break-word;
15 | padding-bottom: 20px;
16 | padding-top: 0px;
17 | overflow: hidden;
18 | position: absolute;
19 | z-index: 3;
20 | bottom: -9px;
21 | left: 224px;
22 | width: 78%;
23 | }
24 | // display: flex;
25 | // min-height: 21px;
26 | // box-sizing: border-box;
27 | // cursor: text;
28 | // line-height: 1.42;
29 | // outline: 0;
30 | // overflow-y: auto;
31 | // padding: 12px 15px;
32 | // tab-size: 4;
33 | // -moz-tab-size: 4;
34 | // text-align: left;
35 | // white-space: pre-wrap;
36 | // word-wrap: break-word;
37 | // padding-bottom: 20px;
38 | // padding-top: 0px;
39 | // overflow:hidden;
40 |
41 | .selected-input-form {
42 | height: 40px;
43 | width: 100%;
44 | border: none;
45 | input{
46 | &:focus {
47 | border-color: #bbbdbf;
48 | outline: none;
49 | color: black
50 | }
51 | padding-left: 12px;
52 | width: 100%;
53 | height: 40px;
54 | border: 2px solid #E0E0E0;
55 | border-radius: 8px;
56 | font-size: 14px;
57 | font-family: 'Nunito', sans-serif;
58 | color: #a0a0a0
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/selected_messages.css.scss:
--------------------------------------------------------------------------------
1 |
2 |
3 | /* ------- REPLY Input CSS */
4 |
5 | .reply-input-div {
6 | display: flex;
7 | min-height: 21px;
8 | box-sizing: border-box;
9 | cursor: text;
10 | line-height: 1.42;
11 | outline: 0;
12 | overflow-y: scroll;
13 | padding: 12px 15px;
14 | /* overflow-x: scroll; */
15 | tab-size: 4;
16 | -moz-tab-size: 4;
17 | text-align: left;
18 | white-space: pre-wrap;
19 | word-wrap: break-word;
20 | padding-bottom: 20px;
21 | padding-top: 0px;
22 | overflow: hidden;
23 | position: absolute;
24 | /* z-index: 3; */
25 | width: 93%;
26 | bottom: 10px;
27 | }
28 |
29 | .reply-input-form {
30 | height: 40px;
31 | width: 98%;
32 | border: none;
33 | input{
34 | &:focus {
35 | border-color: #bbbdbf;
36 | outline: none;
37 | color: black
38 | }
39 | padding-left: 12px;
40 | width: 100%;
41 | height: 40px;
42 | border: 2px solid #E0E0E0;
43 | border-radius: 8px;
44 | font-size: 14px;
45 | font-family: 'Nunito', sans-serif;
46 | color: #a0a0a0
47 | }
48 | }
49 |
50 | /* ------- end REPLY Input CSS */
51 |
52 |
53 |
54 |
55 | /* ------- REPLY ITEM CSS */
56 |
57 | @media only screen and (max-width: 870px) {
58 | .reply-item {
59 | width: 110px !important;
60 | // background: red;
61 | font-size: 12px;
62 | }
63 |
64 | .reply-author-name {
65 | font-size: 0px !important;
66 | // background: yellow;
67 | }
68 |
69 | .selected-message-item {
70 | width: 35% !important;
71 | }
72 |
73 | .all-replies {
74 | height: 55% !important;
75 | width: 110px !important;
76 | }
77 |
78 | .original-avatar {
79 | margin-left: 8px !important;
80 | }
81 |
82 | .original-thread {
83 | font-size: 12px !important;
84 | }
85 |
86 | .reply-content {
87 | width: 55px !important;
88 | }
89 | }
90 |
91 |
92 | .reply-item {
93 | width: 1% !important;
94 | padding-left: 8px !important;
95 | display: flex;
96 | flex-direction: row;
97 | padding-top: 4px;
98 | border-left: 3px solid transparent;
99 | }
100 |
101 | .reply-item:hover {
102 | // background: #f9f9f9;
103 | border-left: 3px solid #aaacad;
104 | }
105 |
106 | .reply-pic {
107 | width: 30px;
108 | height: 30px;
109 | border-radius: 15px;
110 | margin-right: 5px;
111 | }
112 |
113 | .reply-item-div {
114 | display: flex;
115 | flex-direction: column;
116 | }
117 |
118 | .reply-author-name {
119 | font-size: 12px;
120 | font-weight: bold;
121 | }
122 |
123 |
124 | .reply-time-stamp {
125 | font-size: 8px;
126 | color: gray;
127 | }
128 |
129 | .reply-content {
130 | width: 160px;
131 | position: relative;
132 | bottom: 14px;
133 | left: 3px;
134 |
135 | }
136 |
137 | /* END of Reply item CSS */
138 |
139 | .all-replies {
140 | overflow-y: scroll;
141 | height: 63%;
142 | max-height: 376px;
143 | }
144 |
145 | @media only screen and (max-height: 640px) {
146 | .all-replies {
147 | height: 59%
148 | }
149 | }
150 |
151 |
152 |
153 | .small-reply-avatar {
154 | height: 20px;
155 | width: 20px;
156 | border-radius: 10px;
157 | }
158 |
159 | .reply-label {
160 | color: black;
161 | padding-left: 13px;
162 | }
163 |
164 | .reply-box {
165 | display: none;
166 | padding-top: 3px;
167 | padding-bottom: 3px;
168 | padding-left: 5px;
169 | border: 1px solid black;
170 | border-radius: 30px;
171 | width: 75px;
172 | position: relative;
173 | bottom: 5px;
174 | }
175 |
176 | .reply-thread-value {
177 | position: relative;
178 | left: 3%;
179 | font-size: 30px;
180 | color: #e2d6d6;
181 | margin-top: 10px;
182 | }
183 |
184 | @media only screen and (min-width: 960px) {
185 | .reply-thread-value {
186 | left: 10%;
187 | }
188 | }
189 |
190 | @media only screen and (min-width: 1050px) {
191 | .reply-thread-value {
192 | left: 13%;
193 | }
194 | }
195 |
196 | @media only screen and (min-width: 1100px) {
197 | .reply-thread-value {
198 | left: 16%;
199 | }
200 | }
201 |
202 |
203 |
204 | .original-avatar {
205 | height: 35px;
206 | width: 35px;
207 | margin-right: 5px;
208 | border-radius: 15px;
209 | margin-left: 20px;
210 | }
211 |
212 |
213 | .original-thread {
214 | font-weight: 100;
215 | border-bottom: solid 2px #4d3a4b;
216 | padding-bottom: 20px;
217 | padding-top: 5px;
218 | padding-left: 16px;
219 | font-weight: 100;
220 | font-size: 16px;
221 | display: flex;
222 | justify-content: space-between;
223 | padding-top: 16px;
224 | background: #f3eeee;
225 | border-radius: 8px;
226 | margin-bottom: 12px;
227 | }
228 |
229 | .reply-box:hover {
230 | cursor: pointer;
231 | }
232 |
233 | .replies-label {
234 | position: relative;
235 | bottom: 3px;
236 | }
237 |
238 | .replies-box {
239 | display: block;
240 | padding-top: 3px;
241 | // padding-bottom: 3px;
242 | padding-left: 5px;
243 | border: 1px solid gray;
244 | border-radius: 30px;
245 | width: 125px;
246 | position: relative;
247 | bottom: 14px;
248 | }
249 |
250 | .one-reply-box {
251 | display: block;
252 | padding-top: 3px;
253 | // padding-bottom: 3px;
254 | padding-left: 5px;
255 | border: 1px solid gray;
256 | border-radius: 30px;
257 | width: 90px;
258 | position: relative;
259 | bottom: 14px;
260 | }
261 |
262 | .one-reply-box:hover {
263 | cursor: pointer;
264 | }
265 |
266 |
267 | .replies-box:hover {
268 | cursor: pointer;
269 | }
270 |
271 | .selected-message-item:hover .reply-box {
272 | display: block;
273 | }
274 |
275 | .original-message-container {
276 | align-items: center;
277 | }
278 |
279 | .big {
280 | position: absolute;
281 | top: 69px;
282 | height: 77%;
283 | width: 400px;
284 | right: 15px;
285 | width: 23%;
286 | border-radius: 18px;
287 | border: solid 5px #4d3a4b;
288 | background: white;
289 | }
290 |
291 | @media only screen and (max-width: 870px) {
292 | .big {
293 | width: 130px;
294 | }
295 | }
296 |
297 | .selected-message-item {
298 | background-color: white;
299 | /* height: 46px; */
300 | margin-left: 27px;
301 | margin-top: 5px;
302 | display: flex;
303 | flex-direction: row;
304 | width: 47%;
305 |
306 | -moz-transition: padding-bottom .15s ease-in;
307 | -o-transition: padding-bottom .15s ease-in;
308 | -webkit-transition: padding-bottom .15s ease-in;
309 | transition: padding-bottom .15s ease-in;
310 | }
311 |
312 | .selected-message-item:hover {
313 | background: #f9f9f9;
314 | padding-bottom:10px;
315 | }
316 |
317 |
318 |
319 | .reply-offer {
320 | font-size: 10px;
321 | }
322 |
323 | .selected-message-item-div:hover .reply-box {
324 | display: block;
325 | }
326 |
327 | .selected-message-list {
328 | background-color: white;
329 | height: 45px;
330 | }
331 |
332 | .unordered-message-list {
333 | overflow: scroll;
334 | max-height: calc(100% - 124px);
335 | white-space: pre-wrap;
336 | padding-top: 63px;
337 | position: absolute;
338 | top: 14px;
339 | left: 217px;
340 | /* bottom: 00px; */
341 | width: 100%;
342 | }
343 |
344 |
345 | // overflow: scroll;
346 | // max-height: 100%;
347 | // white-space: pre-wrap;
348 | // padding-top: 63px;
349 |
350 | .authorPic {
351 | height: 40px !important;
352 | width: 40px !important;
353 | border-radius: 3px;
354 | margin-right: 7px;
355 | }
356 |
357 | .search-list-item img {
358 | height: 40px !important;
359 | width: 40px !important;
360 | }
361 |
362 | .selected-message-item-div {
363 | display: flex;
364 | flex-direction: column;
365 | }
366 |
367 | .message-author-name {
368 | font-size: 12px;
369 | font-weight: bold;
370 | font-family: sans-serif;
371 | display: flex;
372 | flex-direction: row;
373 | }
374 |
375 |
376 | .message-content {
377 | font-size: 14px;
378 | font-style: oblique;
379 | margin-bottom: 0px;
380 | position: relative;
381 | bottom: 22px;
382 | margin-top: 10px;
383 | }
384 |
--------------------------------------------------------------------------------
/app/channels/application_cable/channel.rb:
--------------------------------------------------------------------------------
1 | module ApplicationCable
2 | class Channel < ActionCable::Channel::Base
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/app/channels/application_cable/connection.rb:
--------------------------------------------------------------------------------
1 | module ApplicationCable
2 | class Connection < ActionCable::Connection::Base
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/app/controllers/api/channels_controller.rb:
--------------------------------------------------------------------------------
1 | class Api::ChannelsController < ApplicationController
2 |
3 | def index
4 | user_id = current_user.id
5 | user = User.find_by(id: user_id)
6 | @channels = user.channels
7 | render "api/channels/index"
8 | end
9 |
10 | def create
11 | @channel = Channel.new(name: params[:channel][:name],
12 | private:params[:channel][:secret])
13 | user_ids = params[:user_ids]
14 | if @channel.save
15 | user_ids.each { |user_id| Membership.create(channel_id: @channel.id, user_id: user_id) }
16 | render "api/channels/show"
17 | else
18 | render json: @channel.errors.full_messages, status: 422
19 | end
20 | end
21 |
22 | def show
23 |
24 | @channel = Channel.find_by(id: channel_params[:channel])
25 | if @channel
26 |
27 | render "api/channels/show"
28 | else
29 | render json: @channel.errors.full_messages, status: 422
30 | end
31 | end
32 |
33 | def destroy
34 |
35 | end
36 |
37 |
38 | def channel_params
39 | params.require(:channel).permit(:name, :secret)
40 | # , :user_ids, :channel_id)
41 | end
42 |
43 | end
44 |
--------------------------------------------------------------------------------
/app/controllers/api/memberships_controller.rb:
--------------------------------------------------------------------------------
1 | class Api::MembershipsController < ApplicationController
2 |
3 | def create
4 |
5 | @channel = Channel.create(name: params[:channel][:name],
6 | private:params[:channel][:secret])
7 | arr = params[:user_ids].split(",")
8 |
9 | arr.each do |user_id|
10 | Membership.create(user_id: user_id, channel_id: @channel.id)
11 | end
12 | render "api/memberships/show"
13 | end
14 |
15 |
16 |
17 |
18 |
19 | end
20 |
21 | # user_id: user_id, channel_id: @channel.id)
22 |
--------------------------------------------------------------------------------
/app/controllers/api/messages_controller.rb:
--------------------------------------------------------------------------------
1 | class Api::MessagesController < ApplicationController
2 |
3 | def index
4 | channel = Channel.find_by(id: params[:channel])
5 | @messages = channel.messages
6 | render "api/messages/index"
7 | end
8 |
9 | def show
10 | @message = Message.find(params[:id])
11 | end
12 |
13 | def create
14 | @message = Message.new(message_params)
15 | channel = @message.channel
16 | if @message.save
17 | Pusher.trigger('channel_' + channel.id.to_s, 'message_published', {})
18 | render "api/messages/show"
19 | else
20 | render json: @message.errors.full_messages, status: 422
21 | end
22 |
23 | end
24 |
25 | def update
26 | @message = Message.find_by(id: params[:id])
27 | if @message.update_attributes(message_params)
28 | render "api/messages/show"
29 | else
30 | render json: @message.errors.full_messages, status: 422
31 | end
32 | end
33 |
34 | def destroy
35 | @message = Message.find_by(id: params[:message_id])
36 | if @message
37 | @message.destroy
38 | render json: @message.id
39 | else
40 | render(
41 | json: ["Message not found"],
42 | status: 404
43 | )
44 | end
45 | end
46 |
47 | def message_params
48 | params.require(:message).permit(:content, :user_id, :channel_id)
49 | end
50 | end
51 |
--------------------------------------------------------------------------------
/app/controllers/api/replies_controller.rb:
--------------------------------------------------------------------------------
1 | class Api::RepliesController < ApplicationController
2 |
3 |
4 | def create
5 | @reply = Reply.new(reply_params)
6 | @reply.user_id = current_user.id
7 | if @reply.save
8 | @message = Message.find(reply_params['message_id'].to_i)
9 | render "api/messages/show", status: 200
10 | else
11 | render json: ["can't be added"], status: 422
12 | end
13 | end
14 |
15 |
16 | def index
17 | message = Message.find_by(id: params[:message_id])
18 | @replies = message.replies
19 | render "api/replies/index"
20 | end
21 |
22 |
23 | def reply_params
24 | params.require(:reply).permit(:content, :message_id, :current_user_avatar)
25 | end
26 |
27 | end
28 |
--------------------------------------------------------------------------------
/app/controllers/api/sessions_controller.rb:
--------------------------------------------------------------------------------
1 | class Api::SessionsController < ApplicationController
2 |
3 | def create
4 | @user = User.find_by_credentials(
5 | params[:user][:username],
6 | params[:user][:password]
7 | )
8 |
9 | if @user
10 | login(@user)
11 | render "api/users/show"
12 | else
13 |
14 | render(
15 | json: ["Invalid username/password combination"],
16 | status: 401
17 | )
18 | end
19 | end
20 |
21 | def destroy
22 | @user = current_user
23 | if @user
24 | logout
25 | render "api/users/show"
26 | else
27 | render(
28 | json: ["Nobody signed in"],
29 | status: 404
30 | )
31 | end
32 | end
33 |
34 | end
35 |
--------------------------------------------------------------------------------
/app/controllers/api/users_controller.rb:
--------------------------------------------------------------------------------
1 | class Api::UsersController < ApplicationController
2 |
3 | def create
4 | @user = User.new(user_params)
5 |
6 | if @user.save
7 | login(@user)
8 | render "api/users/show"
9 | else
10 | render json: @user.errors.full_messages, status: 422
11 | end
12 | end
13 |
14 | def index
15 |
16 | @users = User.all
17 | render "api/users/index"
18 | end
19 |
20 | private
21 |
22 | def user_params
23 | params.require(:user).permit(:username, :password)
24 | end
25 |
26 | end
27 |
--------------------------------------------------------------------------------
/app/controllers/application_controller.rb:
--------------------------------------------------------------------------------
1 | class ApplicationController < ActionController::Base
2 |
3 | ### UNCOMMENT!!!
4 | # protect_from_forgery with: :exception
5 | helper_method :current_user, :logged_in?
6 |
7 | private
8 |
9 | def current_user
10 | return nil unless session[:session_token]
11 | @current_user ||= User.find_by(session_token: session[:session_token])
12 | end
13 |
14 | def logged_in?
15 | !!current_user
16 | end
17 |
18 | def login(user)
19 | user.reset_session_token!
20 | session[:session_token] = user.session_token
21 | @current_user = user
22 | end
23 |
24 | def logout
25 | current_user.reset_session_token!
26 | session[:session_token] = nil
27 | @current_user = nil
28 | end
29 |
30 | def require_logged_in
31 | render json: {base: ['invalid credentials']}, status: 401 if !current_user
32 | end
33 |
34 | end
35 |
--------------------------------------------------------------------------------
/app/controllers/concerns/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/controllers/concerns/.keep
--------------------------------------------------------------------------------
/app/controllers/static_pages_controller.rb:
--------------------------------------------------------------------------------
1 | class StaticPagesController < ApplicationController
2 | def root
3 |
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/app/helpers/application_helper.rb:
--------------------------------------------------------------------------------
1 | module ApplicationHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/jobs/application_job.rb:
--------------------------------------------------------------------------------
1 | class ApplicationJob < ActiveJob::Base
2 | end
3 |
--------------------------------------------------------------------------------
/app/mailers/application_mailer.rb:
--------------------------------------------------------------------------------
1 | class ApplicationMailer < ActionMailer::Base
2 | default from: 'from@example.com'
3 | layout 'mailer'
4 | end
5 |
--------------------------------------------------------------------------------
/app/models/application_record.rb:
--------------------------------------------------------------------------------
1 | class ApplicationRecord < ActiveRecord::Base
2 | self.abstract_class = true
3 | end
4 |
--------------------------------------------------------------------------------
/app/models/channel.rb:
--------------------------------------------------------------------------------
1 | class Channel < ApplicationRecord
2 | validates :name, presence: true
3 | has_many :memberships
4 | has_many :messages
5 | has_many :users, through: :memberships
6 | # has_many :notifications
7 | end
8 |
--------------------------------------------------------------------------------
/app/models/concerns/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/app/models/concerns/.keep
--------------------------------------------------------------------------------
/app/models/membership.rb:
--------------------------------------------------------------------------------
1 | class Membership < ApplicationRecord
2 | validates :user_id, :channel_id, presence: true
3 | belongs_to :user
4 | belongs_to :channel
5 |
6 | # validates uniqueness: { scope: [:user_id, :channel_id] }
7 | # validates :user_id, uniqueness: { scope: [:channel_id] }
8 | end
9 |
--------------------------------------------------------------------------------
/app/models/message.rb:
--------------------------------------------------------------------------------
1 | class Message < ActiveRecord::Base
2 | belongs_to :user
3 | belongs_to :channel
4 | has_many :replies
5 |
6 | # def replies
7 | # Reply.find_by(message_id: == self.id)
8 |
9 | end
10 |
--------------------------------------------------------------------------------
/app/models/reply.rb:
--------------------------------------------------------------------------------
1 | class Reply < ApplicationRecord
2 | validates :user_id, :message_id, presence: true
3 |
4 | belongs_to :user
5 | belongs_to :message
6 | end
7 |
--------------------------------------------------------------------------------
/app/models/user.rb:
--------------------------------------------------------------------------------
1 | class User < ActiveRecord::Base
2 |
3 | attr_reader :password
4 |
5 | validates :username, :password_digest, :session_token, presence: true
6 | validates :username, uniqueness: true
7 | validates :password, length: {minimum: 6}, allow_nil: :true
8 |
9 | after_initialize :ensure_session_token
10 | before_validation :ensure_session_token_uniqueness
11 |
12 | has_many :memberships
13 | has_many :channels, through: :memberships
14 | has_many :messages
15 | has_many :replies
16 |
17 | has_attached_file :avatar
18 | validates_attachment_content_type :avatar, content_type: /\Aimage\/.*\Z/
19 |
20 |
21 | def password= password
22 | self.password_digest = BCrypt::Password.create(password)
23 | @password = password
24 | end
25 |
26 | def self.find_by_credentials username, password
27 | user = User.find_by(username: username)
28 | return nil unless user
29 | user.password_is?(password) ? user : nil
30 | end
31 |
32 | def password_is? password
33 | BCrypt::Password.new(self.password_digest).is_password?(password)
34 | end
35 |
36 | def reset_session_token!
37 | self.session_token = new_session_token
38 | ensure_session_token_uniqueness
39 | self.save
40 | self.session_token
41 | end
42 |
43 | private
44 |
45 | def ensure_session_token
46 | self.session_token ||= new_session_token
47 | end
48 |
49 | def new_session_token
50 | SecureRandom.base64
51 | end
52 |
53 | def ensure_session_token_uniqueness
54 | while User.find_by(session_token: self.session_token)
55 | self.session_token = new_session_token
56 | end
57 | end
58 |
59 | end
60 |
--------------------------------------------------------------------------------
/app/views/api/channels/index.json.jbuilder:
--------------------------------------------------------------------------------
1 | # json.arra! @channels, :name, :private, :id
2 |
3 | @channels.each do |channel|
4 | json.set! channel.id do
5 | json.extract! channel, :name, :private, :id
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/app/views/api/channels/show.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.extract! @channel, :name, :private, :id
2 |
--------------------------------------------------------------------------------
/app/views/api/memberships/show.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.extract! @channel, :name, :private, :id
2 |
--------------------------------------------------------------------------------
/app/views/api/messages/index.json.jbuilder:
--------------------------------------------------------------------------------
1 | @messages.each do |message|
2 | json.set! message.id do
3 | json.extract! message, :content, :user_id, :channel_id
4 | json.count message.replies.length
5 |
6 | json.replies message.replies.each do |reply|
7 | json.avatar reply.user.avatar
8 | json.reply_content reply.content
9 | json.reply_username reply.user.username
10 |
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/app/views/api/messages/show.json.jbuilder:
--------------------------------------------------------------------------------
1 |
2 | json.extract! @message, :id, :content, :channel_id, :user_id
3 | json.count @message.replies.length
4 | json.authorPic @message.user.avatar
5 | json.message_id @message.id
6 | json.replies @message.replies.each do |reply|
7 | json.reply_content reply.content
8 | json.reply_username reply.user.username
9 | json.avatar reply.user.avatar
10 | end
11 |
12 |
13 | # @messages.each do |message|
14 | # json.set! message.id do
15 | # json.extract! message, :content, :user_id, :channel_id
16 | # json.count message.replies.length
17 | #
18 | # json.replies message.replies.each do |reply|
19 | # json.avatar reply.user.avatar
20 | # json.reply_content reply.content
21 | # json.reply_username reply.user.username
22 | #
23 | # end
24 | # end
25 | # end
26 |
27 | # @messages.each do |message|
28 | # json.set! message.id do
29 | # json.extract! message, :content, :user_id, :channel_id
30 | # end
31 | # end
32 |
--------------------------------------------------------------------------------
/app/views/api/replies/index.json.jbuilder:
--------------------------------------------------------------------------------
1 | @replies.each do |reply|
2 | json.set! reply.id do
3 | json.extract! reply, :content, :user_id, :message_id
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/app/views/api/replies/show.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.extract! @reply, :id, :content, :user_id, :message_id
2 |
3 |
--------------------------------------------------------------------------------
/app/views/api/users/_user.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.extract! user, :id, :username
2 |
3 | json.avatar_url asset_path(user.avatar.url)
4 |
--------------------------------------------------------------------------------
/app/views/api/users/index.json.jbuilder:
--------------------------------------------------------------------------------
1 | @users.each do |user|
2 | json.set! user.id do
3 | json.extract! user, :username, :id
4 | #
5 | json.avatar_url asset_path(user.avatar.url)
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/app/views/api/users/show.json.jbuilder:
--------------------------------------------------------------------------------
1 | json.partial! "api/users/user", user: @user
2 |
--------------------------------------------------------------------------------
/app/views/layouts/application.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Slacker
5 | <%= csrf_meta_tags %>
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | <%= stylesheet_link_tag 'application', media: 'all' %>
17 | <%= javascript_include_tag 'application' %>
18 | <%= favicon_link_tag 'favicon.ico' %>
19 |
20 |
21 |
22 |
23 | <%= yield %>
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/views/layouts/mailer.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 | <%= yield %>
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/views/layouts/mailer.text.erb:
--------------------------------------------------------------------------------
1 | <%= yield %>
2 |
--------------------------------------------------------------------------------
/app/views/static_pages/root.html.erb:
--------------------------------------------------------------------------------
1 |
14 |
15 |
--------------------------------------------------------------------------------
/bin/bundle:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3 | load Gem.bin_path('bundler', 'bundle')
4 |
--------------------------------------------------------------------------------
/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path('../spring', __FILE__)
4 | rescue LoadError => e
5 | raise unless e.message.include?('spring')
6 | end
7 | APP_PATH = File.expand_path('../config/application', __dir__)
8 | require_relative '../config/boot'
9 | require 'rails/commands'
10 |
--------------------------------------------------------------------------------
/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path('../spring', __FILE__)
4 | rescue LoadError => e
5 | raise unless e.message.include?('spring')
6 | end
7 | require_relative '../config/boot'
8 | require 'rake'
9 | Rake.application.run
10 |
--------------------------------------------------------------------------------
/bin/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'pathname'
3 | require 'fileutils'
4 | include FileUtils
5 |
6 | # path to your application root.
7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8 |
9 | def system!(*args)
10 | system(*args) || abort("\n== Command #{args} failed ==")
11 | end
12 |
13 | chdir APP_ROOT do
14 | # This script is a starting point to setup your application.
15 | # Add necessary setup steps to this file.
16 |
17 | puts '== Installing dependencies =='
18 | system! 'gem install bundler --conservative'
19 | system('bundle check') || system!('bundle install')
20 |
21 | # puts "\n== Copying sample files =="
22 | # unless File.exist?('config/database.yml')
23 | # cp 'config/database.yml.sample', 'config/database.yml'
24 | # end
25 |
26 | puts "\n== Preparing database =="
27 | system! 'bin/rails db:setup'
28 |
29 | puts "\n== Removing old logs and tempfiles =="
30 | system! 'bin/rails log:clear tmp:clear'
31 |
32 | puts "\n== Restarting application server =="
33 | system! 'bin/rails restart'
34 | end
35 |
--------------------------------------------------------------------------------
/bin/spring:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | # This file loads spring without using Bundler, in order to be fast.
4 | # It gets overwritten when you run the `spring binstub` command.
5 |
6 | unless defined?(Spring)
7 | require 'rubygems'
8 | require 'bundler'
9 |
10 | lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
11 | spring = lockfile.specs.detect { |spec| spec.name == "spring" }
12 | if spring
13 | Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
14 | gem 'spring', spring.version
15 | require 'spring/binstub'
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/bin/update:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'pathname'
3 | require 'fileutils'
4 | include FileUtils
5 |
6 | # path to your application root.
7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8 |
9 | def system!(*args)
10 | system(*args) || abort("\n== Command #{args} failed ==")
11 | end
12 |
13 | chdir APP_ROOT do
14 | # This script is a way to update your development environment automatically.
15 | # Add necessary update steps to this file.
16 |
17 | puts '== Installing dependencies =='
18 | system! 'gem install bundler --conservative'
19 | system('bundle check') || system!('bundle install')
20 |
21 | puts "\n== Updating database =="
22 | system! 'bin/rails db:migrate'
23 |
24 | puts "\n== Removing old logs and tempfiles =="
25 | system! 'bin/rails log:clear tmp:clear'
26 |
27 | puts "\n== Restarting application server =="
28 | system! 'bin/rails restart'
29 | end
30 |
--------------------------------------------------------------------------------
/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require_relative 'config/environment'
4 |
5 | run Rails.application
6 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | require_relative 'boot'
2 |
3 | require 'rails/all'
4 |
5 | # Require the gems listed in Gemfile, including any gems
6 | # you've limited to :test, :development, or :production.
7 | Bundler.require(*Rails.groups)
8 |
9 | module SlackClone
10 | class Application < Rails::Application
11 | # Settings in config/environments/* take precedence over those specified here.
12 | # Application configuration should go into files in config/initializers
13 | # -- all .rb files in that directory are automatically loaded.
14 |
15 |
16 |
17 |
18 | config.paperclip_defaults = {
19 | :storage => :s3,
20 | :s3_credentials => {
21 | :bucket => ENV["s3_bucket"],
22 | :access_key_id => ENV["s3_access_key_id"],
23 | :secret_access_key => ENV["s3_secret_access_key"],
24 | s3_host_name: "s3-#{ENV['s3_region']}.amazonaws.com",
25 | :s3_region => ENV["s3_region"],
26 | :url => ":s3_host_name"
27 | }
28 | }
29 | end
30 | end
31 |
--------------------------------------------------------------------------------
/config/boot.rb:
--------------------------------------------------------------------------------
1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
2 |
3 | require 'bundler/setup' # Set up gems listed in the Gemfile.
4 |
--------------------------------------------------------------------------------
/config/cable.yml:
--------------------------------------------------------------------------------
1 | development:
2 | adapter: async
3 |
4 | test:
5 | adapter: async
6 |
7 | production:
8 | adapter: redis
9 | url: redis://localhost:6379/1
10 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | # PostgreSQL. Versions 9.1 and up are supported.
2 | #
3 | # Install the pg driver:
4 | # gem install pg
5 | # On OS X with Homebrew:
6 | # gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7 | # On OS X with MacPorts:
8 | # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
9 | # On Windows:
10 | # gem install pg
11 | # Choose the win32 build.
12 | # Install PostgreSQL and put its /bin directory on your path.
13 | #
14 | # Configure Using Gemfile
15 | # gem 'pg'
16 | #
17 | default: &default
18 | adapter: postgresql
19 | encoding: unicode
20 | # For details on connection pooling, see rails configuration guide
21 | # http://guides.rubyonrails.org/configuring.html#database-pooling
22 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
23 |
24 | development:
25 | <<: *default
26 | database: SlackClone_development
27 |
28 | # The specified database role being used to connect to postgres.
29 | # To create additional roles in postgres see `$ createuser --help`.
30 | # When left blank, postgres will use the default role. This is
31 | # the same name as the operating system user that initialized the database.
32 | #username: SlackClone
33 |
34 | # The password associated with the postgres role (username).
35 | #password:
36 |
37 | # Connect on a TCP socket. Omitted by default since the client uses a
38 | # domain socket that doesn't need configuration. Windows does not have
39 | # domain sockets, so uncomment these lines.
40 | #host: localhost
41 |
42 | # The TCP port the server listens on. Defaults to 5432.
43 | # If your server runs on a different port number, change accordingly.
44 | #port: 5432
45 |
46 | # Schema search path. The server defaults to $user,public
47 | #schema_search_path: myapp,sharedapp,public
48 |
49 | # Minimum log levels, in increasing order:
50 | # debug5, debug4, debug3, debug2, debug1,
51 | # log, notice, warning, error, fatal, and panic
52 | # Defaults to warning.
53 | #min_messages: notice
54 |
55 | # Warning: The database defined as "test" will be erased and
56 | # re-generated from your development database when you run "rake".
57 | # Do not set this db to the same as development or production.
58 | test:
59 | <<: *default
60 | database: SlackClone_test
61 |
62 | # As with config/secrets.yml, you never want to store sensitive information,
63 | # like your database password, in your source code. If your source code is
64 | # ever seen by anyone, they now have access to your database.
65 | #
66 | # Instead, provide the password as a unix environment variable when you boot
67 | # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
68 | # for a full rundown on how to provide these environment variables in a
69 | # production deployment.
70 | #
71 | # On Heroku and other platform providers, you may have a full connection URL
72 | # available as an environment variable. For example:
73 | #
74 | # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
75 | #
76 | # You can use this database configuration with:
77 | #
78 | # production:
79 | # url: <%= ENV['DATABASE_URL'] %>
80 | #
81 | production:
82 | <<: *default
83 | database: SlackClone_production
84 | username: SlackClone
85 | password: <%= ENV['SLACKCLONE_DATABASE_PASSWORD'] %>
86 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the Rails application.
2 | require_relative 'application'
3 |
4 | # Initialize the Rails application.
5 | Rails.application.initialize!
6 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # In the development environment your application's code is reloaded on
5 | # every request. This slows down response time but is perfect for development
6 | # since you don't have to restart the web server when you make code changes.
7 | config.cache_classes = false
8 |
9 | # Do not eager load code on boot.
10 | config.eager_load = false
11 |
12 | # Show full error reports.
13 | config.consider_all_requests_local = true
14 |
15 | # Enable/disable caching. By default caching is disabled.
16 | if Rails.root.join('tmp/caching-dev.txt').exist?
17 | config.action_controller.perform_caching = true
18 |
19 | config.cache_store = :memory_store
20 | config.public_file_server.headers = {
21 | 'Cache-Control' => 'public, max-age=172800'
22 | }
23 | else
24 | config.action_controller.perform_caching = false
25 |
26 | config.cache_store = :null_store
27 | end
28 |
29 | # Don't care if the mailer can't send.
30 | config.action_mailer.raise_delivery_errors = false
31 |
32 | config.action_mailer.perform_caching = false
33 |
34 | # Print deprecation notices to the Rails logger.
35 | config.active_support.deprecation = :log
36 |
37 | # Raise an error on page load if there are pending migrations.
38 | config.active_record.migration_error = :page_load
39 |
40 | # Debug mode disables concatenation and preprocessing of assets.
41 | # This option may cause significant delays in view rendering with a large
42 | # number of complex assets.
43 | config.assets.debug = true
44 |
45 | # Suppress logger output for asset requests.
46 | config.assets.quiet = true
47 |
48 | # Raises error for missing translations
49 | # config.action_view.raise_on_missing_translations = true
50 |
51 | # Use an evented file watcher to asynchronously detect changes in source code,
52 | # routes, locales, etc. This feature depends on the listen gem.
53 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker
54 | end
55 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # Code is not reloaded between requests.
5 | config.cache_classes = true
6 |
7 | # Eager load code on boot. This eager loads most of Rails and
8 | # your application in memory, allowing both threaded web servers
9 | # and those relying on copy on write to perform better.
10 | # Rake tasks automatically ignore this option for performance.
11 | config.eager_load = true
12 |
13 | # Full error reports are disabled and caching is turned on.
14 | config.consider_all_requests_local = false
15 | config.action_controller.perform_caching = true
16 |
17 | # Disable serving static files from the `/public` folder by default since
18 | # Apache or NGINX already handles this.
19 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
20 |
21 | # Compress JavaScripts and CSS.
22 | config.assets.js_compressor = :uglifier
23 | # config.assets.css_compressor = :sass
24 |
25 | # Do not fallback to assets pipeline if a precompiled asset is missed.
26 | config.assets.compile = false
27 |
28 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
29 |
30 | # Enable serving of images, stylesheets, and JavaScripts from an asset server.
31 | # config.action_controller.asset_host = 'http://assets.example.com'
32 |
33 | # Specifies the header that your server uses for sending files.
34 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
35 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
36 |
37 | # Mount Action Cable outside main process or domain
38 | # config.action_cable.mount_path = nil
39 | # config.action_cable.url = 'wss://example.com/cable'
40 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
41 |
42 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
43 | # config.force_ssl = true
44 |
45 | # Use the lowest log level to ensure availability of diagnostic information
46 | # when problems arise.
47 | config.log_level = :debug
48 |
49 | # Prepend all log lines with the following tags.
50 | config.log_tags = [ :request_id ]
51 |
52 | # Use a different cache store in production.
53 | # config.cache_store = :mem_cache_store
54 |
55 | # Use a real queuing backend for Active Job (and separate queues per environment)
56 | # config.active_job.queue_adapter = :resque
57 | # config.active_job.queue_name_prefix = "SlackClone_#{Rails.env}"
58 | config.action_mailer.perform_caching = false
59 |
60 | # Ignore bad email addresses and do not raise email delivery errors.
61 | # Set this to true and configure the email server for immediate delivery to raise delivery errors.
62 | # config.action_mailer.raise_delivery_errors = false
63 |
64 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
65 | # the I18n.default_locale when a translation cannot be found).
66 | config.i18n.fallbacks = true
67 |
68 | # Send deprecation notices to registered listeners.
69 | config.active_support.deprecation = :notify
70 |
71 | # Use default logging formatter so that PID and timestamp are not suppressed.
72 | config.log_formatter = ::Logger::Formatter.new
73 |
74 | # Use a different logger for distributed setups.
75 | # require 'syslog/logger'
76 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
77 |
78 | if ENV["RAILS_LOG_TO_STDOUT"].present?
79 | logger = ActiveSupport::Logger.new(STDOUT)
80 | logger.formatter = config.log_formatter
81 | config.logger = ActiveSupport::TaggedLogging.new(logger)
82 | end
83 |
84 | # Do not dump schema after migrations.
85 | config.active_record.dump_schema_after_migration = false
86 | end
87 |
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # The test environment is used exclusively to run your application's
5 | # test suite. You never need to work with it otherwise. Remember that
6 | # your test database is "scratch space" for the test suite and is wiped
7 | # and recreated between test runs. Don't rely on the data there!
8 | config.cache_classes = true
9 |
10 | # Do not eager load code on boot. This avoids loading your whole application
11 | # just for the purpose of running a single test. If you are using a tool that
12 | # preloads Rails for running tests, you may have to set it to true.
13 | config.eager_load = false
14 |
15 | # Configure public file server for tests with Cache-Control for performance.
16 | config.public_file_server.enabled = true
17 | config.public_file_server.headers = {
18 | 'Cache-Control' => 'public, max-age=3600'
19 | }
20 |
21 | # Show full error reports and disable caching.
22 | config.consider_all_requests_local = true
23 | config.action_controller.perform_caching = false
24 |
25 | # Raise exceptions instead of rendering exception templates.
26 | config.action_dispatch.show_exceptions = false
27 |
28 | # Disable request forgery protection in test environment.
29 | config.action_controller.allow_forgery_protection = false
30 | config.action_mailer.perform_caching = false
31 |
32 | # Tell Action Mailer not to deliver emails to the real world.
33 | # The :test delivery method accumulates sent emails in the
34 | # ActionMailer::Base.deliveries array.
35 | config.action_mailer.delivery_method = :test
36 |
37 | # Print deprecation notices to the stderr.
38 | config.active_support.deprecation = :stderr
39 |
40 | # Raises error for missing translations
41 | # config.action_view.raise_on_missing_translations = true
42 | end
43 |
--------------------------------------------------------------------------------
/config/initializers/application_controller_renderer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # ApplicationController.renderer.defaults.merge!(
4 | # http_host: 'example.org',
5 | # https: false
6 | # )
7 |
--------------------------------------------------------------------------------
/config/initializers/assets.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Version of your assets, change this if you want to expire all your assets.
4 | Rails.application.config.assets.version = '1.0'
5 |
6 | # Add additional assets to the asset load path
7 | # Rails.application.config.assets.paths << Emoji.images_path
8 |
9 | # Precompile additional assets.
10 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
11 | # Rails.application.config.assets.precompile += %w( search.js )
12 |
--------------------------------------------------------------------------------
/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/config/initializers/cookies_serializer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Specify a serializer for the signed and encrypted cookie jars.
4 | # Valid options are :json, :marshal, and :hybrid.
5 | Rails.application.config.action_dispatch.cookies_serializer = :json
6 |
--------------------------------------------------------------------------------
/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Configure sensitive parameters which will be filtered from the log file.
4 | Rails.application.config.filter_parameters += [:password]
5 |
--------------------------------------------------------------------------------
/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format. Inflections
4 | # are locale specific, and you may define rules for as many different
5 | # locales as you wish. All of these examples are active by default:
6 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
7 | # inflect.plural /^(ox)$/i, '\1en'
8 | # inflect.singular /^(ox)en/i, '\1'
9 | # inflect.irregular 'person', 'people'
10 | # inflect.uncountable %w( fish sheep )
11 | # end
12 |
13 | # These inflection rules are supported but not enabled by default:
14 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
15 | # inflect.acronym 'RESTful'
16 | # end
17 |
--------------------------------------------------------------------------------
/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 |
--------------------------------------------------------------------------------
/config/initializers/new_framework_defaults.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 | #
3 | # This file contains migration options to ease your Rails 5.0 upgrade.
4 | #
5 | # Read the Guide for Upgrading Ruby on Rails for more info on each option.
6 |
7 | Rails.application.config.raise_on_unfiltered_parameters = true
8 |
9 | # Enable per-form CSRF tokens. Previous versions had false.
10 | Rails.application.config.action_controller.per_form_csrf_tokens = true
11 |
12 | # Enable origin-checking CSRF mitigation. Previous versions had false.
13 | Rails.application.config.action_controller.forgery_protection_origin_check = true
14 |
15 | # Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
16 | # Previous versions had false.
17 | ActiveSupport.to_time_preserves_timezone = true
18 |
19 | # Require `belongs_to` associations by default. Previous versions had false.
20 | Rails.application.config.active_record.belongs_to_required_by_default = true
21 |
22 | # Do not halt callback chains when a callback returns false. Previous versions had true.
23 | ActiveSupport.halt_callback_chains_on_return_false = false
24 |
25 | # Configure SSL options to enable HSTS with subdomains. Previous versions had false.
26 | Rails.application.config.ssl_options = { hsts: { subdomains: true } }
27 |
--------------------------------------------------------------------------------
/config/initializers/pusher.rb:
--------------------------------------------------------------------------------
1 | require 'pusher'
2 |
3 | Pusher.app_id = '360472'
4 | Pusher.key = '7ed0f023347152a1d1c7'
5 | Pusher.secret = 'b26e9542281ee8395734'
6 | Pusher.cluster = 'us2'
7 | Pusher.logger = Rails.logger
8 | Pusher.encrypted = true
9 |
--------------------------------------------------------------------------------
/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Rails.application.config.session_store :cookie_store, key: '_SlackClone_session'
4 |
--------------------------------------------------------------------------------
/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # This file contains settings for ActionController::ParamsWrapper which
4 | # is enabled by default.
5 |
6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7 | ActiveSupport.on_load(:action_controller) do
8 | wrap_parameters format: [:json]
9 | end
10 |
11 | # To enable root element in JSON for ActiveRecord objects.
12 | # ActiveSupport.on_load(:active_record) do
13 | # self.include_root_in_json = true
14 | # end
15 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t 'hello'
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t('hello') %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # To learn more, please read the Rails Internationalization guide
20 | # available at http://guides.rubyonrails.org/i18n.html.
21 |
22 | en:
23 | hello: "Hello world"
24 |
--------------------------------------------------------------------------------
/config/puma.rb:
--------------------------------------------------------------------------------
1 | # Puma can serve each request in a thread from an internal thread pool.
2 | # The `threads` method setting takes two numbers a minimum and maximum.
3 | # Any libraries that use thread pools should be configured to match
4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum
5 | # and maximum, this matches the default thread size of Active Record.
6 | #
7 | threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
8 | threads threads_count, threads_count
9 |
10 | # Specifies the `port` that Puma will listen on to receive requests, default is 3000.
11 | #
12 | port ENV.fetch("PORT") { 3000 }
13 |
14 | # Specifies the `environment` that Puma will run in.
15 | #
16 | environment ENV.fetch("RAILS_ENV") { "development" }
17 |
18 | # Specifies the number of `workers` to boot in clustered mode.
19 | # Workers are forked webserver processes. If using threads and workers together
20 | # the concurrency of the application would be max `threads` * `workers`.
21 | # Workers do not work on JRuby or Windows (both of which do not support
22 | # processes).
23 | #
24 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
25 |
26 | # Use the `preload_app!` method when specifying a `workers` number.
27 | # This directive tells Puma to first boot the application and load code
28 | # before forking the application. This takes advantage of Copy On Write
29 | # process behavior so workers use less memory. If you use this option
30 | # you need to make sure to reconnect any threads in the `on_worker_boot`
31 | # block.
32 | #
33 | # preload_app!
34 |
35 | # The code in the `on_worker_boot` will be called if you are using
36 | # clustered mode by specifying a number of `workers`. After each worker
37 | # process is booted this block will be run, if you are using `preload_app!`
38 | # option you will want to use this block to reconnect to any threads
39 | # or connections that may have been created at application boot, Ruby
40 | # cannot share connections between processes.
41 | #
42 | # on_worker_boot do
43 | # ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
44 | # end
45 |
46 | # Allow puma to be restarted by `rails restart` command.
47 | plugin :tmp_restart
48 |
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 | namespace :api, defaults: {format: :json} do
3 | resources :channels, only: [:index, :show, :create, :update, :delete]
4 | resources :messages, only: [:create, :index, :update, :delete, :show]
5 | resources :users, only: [:create, :update, :delete, :index]
6 | resources :memberships, only: [:create]
7 | resource :session, only: [:create, :destroy]
8 | resources :replies, only: [:create, :destroy]
9 | end
10 |
11 | root "static_pages#root"
12 | end
13 |
--------------------------------------------------------------------------------
/config/secrets.yml:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key is used for verifying the integrity of signed cookies.
4 | # If you change this key, all old signed cookies will become invalid!
5 |
6 | # Make sure the secret is at least 30 characters and all random,
7 | # no regular words or you'll be exposed to dictionary attacks.
8 | # You can use `rails secret` to generate a secure secret key.
9 |
10 | # Make sure the secrets in this file are kept private
11 | # if you're sharing your code publicly.
12 |
13 | development:
14 | secret_key_base: 1c1cff33cd7c58649f7ee1644edc2d133d063c600a1cdb0352de5b13ba92b0decbe91820a7c581e3b3835bf4ec3e3bd7c49ceb1d5d2ce2c7c49535d1dfa5cbeb
15 |
16 | test:
17 | secret_key_base: 6b19b41ae9e035f72afd2f9ae126a6a9930f8449c6d40431c073f904c6aa2055bbf8f302d687e3b1dd26f3d0eabaa25506b486a544385605d225a5aa21fd6498
18 |
19 | # Do not keep production secrets in the repository,
20 | # instead read values from the environment.
21 | production:
22 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
23 |
--------------------------------------------------------------------------------
/config/spring.rb:
--------------------------------------------------------------------------------
1 | %w(
2 | .ruby-version
3 | .rbenv-vars
4 | tmp/restart.txt
5 | tmp/caching-dev.txt
6 | ).each { |path| Spring.watch(path) }
7 |
--------------------------------------------------------------------------------
/db/migrate/20170620135604_create_messages.rb:
--------------------------------------------------------------------------------
1 | class CreateMessages < ActiveRecord::Migration[5.0]
2 | def change
3 | create_table :messages do |t|
4 | t.integer :user_id, null: false
5 | t.integer :channel_id, null: false
6 | t.text :content, null: false
7 |
8 | t.timestamps
9 | end
10 | end
11 |
12 | end
13 |
14 |
15 | # t.string :username
16 | # t.string :email
17 | # password_digest :string
18 | # session_token :string
19 |
--------------------------------------------------------------------------------
/db/migrate/20170620140138_create_users.rb:
--------------------------------------------------------------------------------
1 | class CreateUsers < ActiveRecord::Migration[5.0]
2 | def change
3 | create_table :users do |t|
4 | t.string :username, null: false
5 | t.string :email, null: false
6 | t.string :password_digest, null: false
7 | t.string :session_token, null: false
8 |
9 | t.timestamps
10 |
11 | end
12 | add_index :users, :username, unique: true
13 | add_index :users, :email, unique: true
14 | add_index :users, :session_token, unique: true
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/db/migrate/20170620140145_create_channels.rb:
--------------------------------------------------------------------------------
1 | class CreateChannels < ActiveRecord::Migration[5.0]
2 | def change
3 | create_table :channels do |t|
4 | t.string :name, null: false
5 | t.boolean :private, default: false
6 |
7 | t.timestamps
8 | end
9 | end
10 |
11 | end
12 |
--------------------------------------------------------------------------------
/db/migrate/20170620140209_create_memberships.rb:
--------------------------------------------------------------------------------
1 | class CreateMemberships < ActiveRecord::Migration[5.0]
2 | def change
3 | create_table :memberships do |t|
4 | t.integer :user_id, null: false
5 | t.integer :channel_id, null: false
6 |
7 | t.timestamps
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/db/migrate/20170621210151_remove_email_from_users.rb:
--------------------------------------------------------------------------------
1 | class RemoveEmailFromUsers < ActiveRecord::Migration[5.0]
2 | def change
3 | remove_column :users, :email
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/db/migrate/20170627144802_add_attachment_avatar_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddAttachmentAvatarToUsers < ActiveRecord::Migration
2 | def self.up
3 | change_table :users do |t|
4 | t.attachment :avatar
5 | end
6 | end
7 |
8 | def self.down
9 | remove_attachment :users, :avatar
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/db/migrate/20170627203533_add_users_to_channels.rb:
--------------------------------------------------------------------------------
1 | class AddUsersToChannels < ActiveRecord::Migration[5.0]
2 | def change
3 | add_column :channels, :users, :string
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/db/migrate/20171019204157_create_replies.rb:
--------------------------------------------------------------------------------
1 | class CreateReplies < ActiveRecord::Migration[5.0]
2 | def change
3 | create_table :replies do |t|
4 | t.integer :user_id, null: false
5 | t.integer :message_id, null: false
6 | t.string :content, null: false
7 |
8 | t.timestamps
9 | end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/db/schema.rb:
--------------------------------------------------------------------------------
1 | # This file is auto-generated from the current state of the database. Instead
2 | # of editing this file, please use the migrations feature of Active Record to
3 | # incrementally modify your database, and then regenerate this schema definition.
4 | #
5 | # Note that this schema.rb definition is the authoritative source for your
6 | # database schema. If you need to create the application database on another
7 | # system, you should be using db:schema:load, not running all the migrations
8 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9 | # you'll amass, the slower it'll run and the greater likelihood for issues).
10 | #
11 | # It's strongly recommended that you check this file into your version control system.
12 |
13 | ActiveRecord::Schema.define(version: 20171019204157) do
14 |
15 | # These are extensions that must be enabled in order to support this database
16 | enable_extension "plpgsql"
17 |
18 | create_table "channels", force: :cascade do |t|
19 | t.string "name", null: false
20 | t.boolean "private", default: false
21 | t.datetime "created_at", null: false
22 | t.datetime "updated_at", null: false
23 | t.string "users"
24 | end
25 |
26 | create_table "memberships", force: :cascade do |t|
27 | t.integer "user_id", null: false
28 | t.integer "channel_id", null: false
29 | t.datetime "created_at", null: false
30 | t.datetime "updated_at", null: false
31 | end
32 |
33 | create_table "messages", force: :cascade do |t|
34 | t.integer "user_id", null: false
35 | t.integer "channel_id", null: false
36 | t.text "content", null: false
37 | t.datetime "created_at", null: false
38 | t.datetime "updated_at", null: false
39 | end
40 |
41 | create_table "replies", force: :cascade do |t|
42 | t.integer "user_id", null: false
43 | t.integer "message_id", null: false
44 | t.string "content", null: false
45 | t.datetime "created_at", null: false
46 | t.datetime "updated_at", null: false
47 | end
48 |
49 | create_table "users", force: :cascade do |t|
50 | t.string "username", null: false
51 | t.string "password_digest", null: false
52 | t.string "session_token", null: false
53 | t.datetime "created_at", null: false
54 | t.datetime "updated_at", null: false
55 | t.string "avatar_file_name"
56 | t.string "avatar_content_type"
57 | t.integer "avatar_file_size"
58 | t.datetime "avatar_updated_at"
59 | t.index ["session_token"], name: "index_users_on_session_token", unique: true, using: :btree
60 | t.index ["username"], name: "index_users_on_username", unique: true, using: :btree
61 | end
62 |
63 | end
64 |
--------------------------------------------------------------------------------
/docs/api-endpoints.md:
--------------------------------------------------------------------------------
1 | # API Endpoints
2 |
3 | ## HTML API
4 |
5 | #### Root
6 | - `GET /` - load Slacker application
7 |
8 | ## JSON API
9 |
10 | ### Session
11 | - `POST /api/session` -log in
12 | - `DELETE /api/session` - log out
13 |
14 | ### Users
15 | - `GET /api/users` - retrieve all users
16 | - `GET /api/channel/:channel_id/users` - retrieve all users of a channel
17 | - `POST /api/users` - create a user
18 | - `PATCH /api/users/:id` - update a user
19 | - `DELETE /api/users/:id` - delete a user
20 |
21 |
22 | ### Channels
23 | - `GET /api/channels` - retrieve all channels
24 | - `POST /api/channels` - create a channel
25 | - `PATCH /api/channels/:id` - update a channel
26 | - `DELETE /api/channels/:id` - delete a channel
27 | - `GET /api/users/:user_id/channels` - retrieve channels for a user
28 |
29 | ### Messages
30 | - `GET /api/messages` - retrieve all messages
31 | - `GET /api/channels/:channel_id/messages` - retrieve all messages of a channel
32 | - `POST /api/channels/:channel_id/messages/` - create a message
33 | - `PATCH /api/messages/:id` - update a message
34 | - `DELETE /api/messages/:id` - delete a message
35 |
36 |
39 |
--------------------------------------------------------------------------------
/docs/component-hierarchy.md:
--------------------------------------------------------------------------------
1 | # Component Hierarchy:
2 |
3 |
4 | ### Before logging in:
5 | - LandingPageContainer
6 | - NavBarContainer
7 | * NavBar
8 | * SessionForm
9 |
10 |
11 | ## After logging in:
12 | - Home Container
13 | - NavColumn:
14 | - Header Container:
15 | + Header:
16 | * display username
17 | * display 'Slacker'
18 | - ChannelListContainer:
19 | - ChannelList
20 | - NewChannelFormContainer
21 | * NewChannelForm
22 | * ChannelListItem
23 | - DirectMessageListContainer:
24 | - DirectMessageFormContainer
25 | - DirectMessageForm
26 | - DirectMessagesList
27 | * DirectMessageListItem
28 | - MainChannelContainer
29 | - ChannelHeaderContainer
30 | - ChannelHeader
31 | - ChannelMessagesContainer
32 | + ChannelMessages
33 | + ChannelMessageItemContainer
34 | * ChannelMessageItem
35 | - NewMessageContainer
36 | - NewMessageForm
37 |
38 | ## Routes
39 |
40 | |Path | Component |
41 | |-------|-------------|
42 | | "/sign-up" | "SessionFormContainer" |
43 | | "/log-in" | "SessionFormContainer" |
44 | | "/home" | "HomeContainer" |
45 | | "/channels/:channelId" | "MainChannelContainer" |
46 | | "/channels/new" | "NewChannelFormContainer" |
47 | | "/dms/new" | "NewChannelFormContainer" |
48 |
--------------------------------------------------------------------------------
/docs/sample_state.md:
--------------------------------------------------------------------------------
1 | {
2 | modal : {
3 | type: login
4 | }
5 | current_channel : {
6 | name: "MenOfHonor123"
7 | }
8 | session: {
9 | currentUser: {
10 | user: null,
11 | errors: []
12 | }
13 | }
14 | channels: {
15 | 1: {
16 | name: "presidentsofusa"
17 | private: false
18 | }
19 | 2: {
20 | name: "gloryteam"
21 | private: true
22 | }
23 | }
24 | users: {
25 | 1: {
26 | id: 1,
27 | username: "teddy",
28 | }
29 | 2: {
30 | id: 2,
31 | username: "george",
32 | }
33 | }
34 | messages: {
35 | 1: {
36 | id: 32,
37 | user_id: 1,
38 | channel_id: 2,
39 | content: 'america"
40 | }
41 | 2: {
42 | id: 45,
43 | user_id: 1,
44 | channel_id: 1,
45 | content: "canada stinks"
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/docs/schema.md:
--------------------------------------------------------------------------------
1 | # DB Schema
2 |
3 | ## User
4 |
5 | | column | type | details |
6 | |-----------------|----------|---------------------|
7 | | username | `string` | `unique` `presence` `indexed` |
8 | | email | `string` | `unique` `presence` `indexed` |
9 | | avatar_url | `string` | `string` |
10 | | password_digest | `string` | `unique` `presence` |
11 | | session_token | `string` | `unique` `presence` `indexed` |
12 | - User Model Associations
13 | - **Has Many**
14 | - Messages
15 | - Channels through Memberships
16 |
17 |
18 | ## Channel
19 |
20 | | column | type | details |
21 | |-------------|-----------|---------------------|
22 | | name | `string` | `unique` `presence` |
23 | | private | `boolean` | `presence` `default: false`|
24 | - Channel Model Associations
25 | - **Has Many**
26 | - Messages
27 | - Users through Memberships
28 |
29 | ## Message
30 |
31 | | column | type | details |
32 | |------------|-----------|------------|
33 | | user_id | `integer` | `presence` |
34 | | channel_id | `integer` | `presence` |
35 | | content | `string` | |
36 |
37 | - Message Model Associations
38 | - **Belongs To**
39 | - User
40 | - Channel
41 |
42 |
43 | ## Membership
44 |
45 | | column | type | details |
46 | |------------|-----------|------------|
47 | | user_id | `integer` | `presence` |
48 | | channel_id | `integer` | `presence` |
49 | - Membership Model Associations
50 | - **Belongs To**
51 | - User
52 | - Channel
53 |
--------------------------------------------------------------------------------
/docs/wireframes/direct_message_form.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/docs/wireframes/direct_message_form.JPG
--------------------------------------------------------------------------------
/docs/wireframes/homepage.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/docs/wireframes/homepage.JPG
--------------------------------------------------------------------------------
/docs/wireframes/landing_page.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/docs/wireframes/landing_page.JPG
--------------------------------------------------------------------------------
/docs/wireframes/new_channel_form.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/docs/wireframes/new_channel_form.JPG
--------------------------------------------------------------------------------
/docs/wireframes/session_form.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/docs/wireframes/session_form.JPG
--------------------------------------------------------------------------------
/frontend/actions/channel_actions.js:
--------------------------------------------------------------------------------
1 | export const RECEIVE_USER_CHANNELS = "RECEIVE_USER_CHANNELS";
2 | export const RECEIVE_USER_CHANNEL = "RECEIVE_USER_CHANNEL";
3 |
4 | import * as APIUtil from '../util/channel_api_util';
5 | // import { receiveErrors } from './session_actions';
6 |
7 | export const receiveUserChannels = (channels) => {
8 | return({
9 | type: RECEIVE_USER_CHANNELS,
10 | channels
11 | });
12 | };
13 |
14 | export const receiveUserChannel = (channel) => {
15 | return({
16 | type: RECEIVE_USER_CHANNEL,
17 | channel
18 | });
19 | };
20 |
21 |
22 | export const fetchUserChannels = user => dispatch => {
23 | APIUtil.fetchUserChannels(user)
24 | .then(channels => (dispatch(receiveUserChannels(channels))));
25 | // err => (dispatch(receiveErrors(err.responseJSON))));
26 | };
27 |
28 |
29 |
30 | export const fetchCurrentChannel = (channel_id) => dispatch => {
31 | return APIUtil.fetchCurrentChannel(channel_id);
32 | };
33 |
34 |
35 | // channel has channel name and users
36 |
--------------------------------------------------------------------------------
/frontend/actions/current_message_actions.js:
--------------------------------------------------------------------------------
1 | export const RECEIVE_CURRENT_MESSAGE = "RECEIVE_CURRENT_MESSAGE";
2 |
3 | export const receiveCurrentMessage = (message) => {
4 | return({
5 | type: RECEIVE_CURRENT_MESSAGE,
6 | message
7 | })
8 | }
9 |
--------------------------------------------------------------------------------
/frontend/actions/membership_actions.js:
--------------------------------------------------------------------------------
1 | import * as APIUtil from '../util/membership_api_util';
2 | import { receiveUserChannel } from './channel_actions';
3 |
4 | export const createMembership = membership => dispatch => {
5 |
6 | return APIUtil.createMembership(membership)
7 | .then(channel => (dispatch(receiveUserChannel(channel))));
8 | // err => (dispatch(receiveErrors(err.responseJSON))));
9 | };
10 |
--------------------------------------------------------------------------------
/frontend/actions/message_actions.js:
--------------------------------------------------------------------------------
1 | import { receiveCurrentMessage } from './current_message_actions'
2 | export const RECEIVE_SELECTED_MESSAGES = "RECEIVE_SELECTED_MESSAGES";
3 | export const RECEIVE_SELECTED_MESSAGE = "RECEIVE_SELECTED_MESSAGE";
4 |
5 | import * as APIUtil from '../util/message_api_util';
6 | // import { receiveErrors } from './session_actions';
7 |
8 | export const receiveSelectedMessages = (messages) => {
9 | return ({
10 | type: RECEIVE_SELECTED_MESSAGES,
11 | messages
12 | });
13 | };
14 |
15 | export const receiveSelectedMessage = message => {
16 | return ({
17 | type: RECEIVE_SELECTED_MESSAGE,
18 | message
19 | });
20 | };
21 |
22 | export const createMessageReply = reply => dispatch => {
23 | return APIUtil.createMessageReply(reply)
24 | .then( message => {
25 | dispatch(receiveSelectedMessage(message));
26 | dispatch(receiveCurrentMessage(message));
27 | }
28 | );
29 | }
30 |
31 | export const fetchSelectedMessages = channel_id => dispatch => {
32 | return APIUtil.fetchSelectedMessages(channel_id)
33 | .then(messages => dispatch(receiveSelectedMessages(messages)));
34 | };
35 | // err => (dispatch(receiveErrors(err.responseJSON))));
36 |
37 | export const fetchSelectedMessage = message_id => dispatch => {
38 | return APIUtil.fetchSelectedMessage(message_id)
39 | .then(message => dispatch(receiveSelectedMessage(message)))
40 | };
41 |
42 | export const createSelectedMessage = message => dispatch => {
43 | return APIUtil.createSelectedMessage(message)
44 | .then( message => dispatch(receiveSelectedMessage(message)));
45 | };
46 |
--------------------------------------------------------------------------------
/frontend/actions/modal_actions.js:
--------------------------------------------------------------------------------
1 |
2 | export const LOGIN = 'LOGIN';
3 | export const SIGNUP = 'SIGNUP';
4 |
5 | export const signupForm = () => ({
6 | type: SIGNUP
7 | });
8 |
9 | export const loginForm = () => ({
10 | type: LOGIN
11 | });
12 |
--------------------------------------------------------------------------------
/frontend/actions/reply_actions.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mlmid1616/slacker/dad94288aecc72f3ddbc853b30a67c84efdda9cc/frontend/actions/reply_actions.js
--------------------------------------------------------------------------------
/frontend/actions/session_actions.js:
--------------------------------------------------------------------------------
1 | import * as APIUtil from '../util/session_api_util';
2 |
3 |
4 | export const RECEIVE_CURRENT_USER = 'RECEIVE_CURRENT_USER';
5 | export const RECEIVE_SESSION_ERRORS = 'RECEIVE_ERRORS';
6 |
7 | export const receiveCurrentUser = currentUser => ({
8 | type: RECEIVE_CURRENT_USER,
9 | currentUser
10 | });
11 |
12 | export const receiveErrors = errors => ({
13 | type: RECEIVE_SESSION_ERRORS,
14 | errors
15 | });
16 |
17 | export const signup = user => dispatch => (
18 | APIUtil.signup(user).then(user => (
19 | dispatch(receiveCurrentUser(user))
20 | ), err => (
21 | dispatch(receiveErrors(err.responseJSON))
22 | ))
23 | );
24 |
25 | export const login = user => dispatch => (
26 | APIUtil.login(user).then(user => (
27 | dispatch(receiveCurrentUser(user))
28 | ), err => (
29 | dispatch(receiveErrors(err.responseJSON))
30 | ))
31 | );
32 |
33 | export const logout = () => dispatch => (
34 | APIUtil.logout().then(user => (
35 | dispatch(receiveCurrentUser(null))
36 | ))
37 | );
38 |
--------------------------------------------------------------------------------
/frontend/actions/user_actions.js:
--------------------------------------------------------------------------------
1 | export const RECEIVE_ALL_USERS = 'RECEIVE_ALL_USERS';
2 | import * as APIUtil from '../util/user_api_util';
3 |
4 |
5 | export const receiveAllUsers = (users) => {
6 | return({
7 | type: RECEIVE_ALL_USERS,
8 | users
9 | });
10 | };
11 |
12 | export const fetchAllUsers = () => dispatch => {
13 | APIUtil.fetchAllUsers()
14 | .then((users) => (dispatch(receiveAllUsers(users))));
15 | // err => (dispatch(receiveErrors(err.responseJSON))));
16 | };
17 |
--------------------------------------------------------------------------------
/frontend/components/App.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Provider } from 'react-redux';
3 | import {
4 | Route,
5 | Redirect,
6 | Switch,
7 | Link,
8 | HashRouter
9 | } from 'react-router-dom';
10 |
11 | import LandingPage from './landing_page/landing_page';
12 | import HomePage from './homepage/homepage';
13 | import GreetingContainer from './greeting/greeting_container';
14 | import SessionFormContainer from './landing_page/session_form/session_form_container';
15 | import { AuthRoute, ProtectedRoute } from '../util/route_util';
16 | import SelectedChannel from './homepage/selected_channel/selected_channel';
17 |
18 | const App = () => (
19 |