Xwitter 0.3.0.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +17 -0
- data/Installation.md +25 -0
- data/Procfile +1 -0
- data/Schemafile +9 -0
- data/app/assets/stylesheets/application.scss +7 -0
- data/app/assets/stylesheets/themes/dark.scss +6 -0
- data/app/controllers/subscriptions_controller.rb +36 -0
- data/app/controllers/topics_controller.rb +31 -3
- data/app/models/user.rb +5 -0
- data/app/models/user_subscribe_topic.rb +4 -0
- data/app/views/layouts/application.html.slim +12 -1
- data/app/views/profiles/_form.html.slim +2 -1
- data/app/views/subscriptions/index.html.slim +16 -0
- data/app/views/topics/show.html.slim +8 -1
- data/config/environments/production.rb +1 -1
- data/config/routes.rb +7 -1
- data/config/storage.yml +6 -7
- data/lib/Xwitter/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abdbb05a5cd81884154473636023b5040e1bb2a9803f451da0267b011178e82f
|
4
|
+
data.tar.gz: 8d6fb1088756eae4ca6a3b3e7fdfa59a90ee18a0212db47365466f325def55a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45cf24ac6a2985ff2701fc823f64dda317547f1e6e093623785aefdf55c3541160845a1a399c8c1de924728ce4cbbd73632c958880363bb87695ce13ac977a8d
|
7
|
+
data.tar.gz: 0d92263a775c8151a6d4ea39fc4a2e3e170a35cf34992aa3f1a534b9c8c33b061d82e21ebe7a124cce3255b8d050c5264dd8cf0c9da5b05f9b83046d392b051f
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -43,6 +43,21 @@ GEM
|
|
43
43
|
minitest (~> 5.1)
|
44
44
|
tzinfo (~> 1.1)
|
45
45
|
arel (9.0.0)
|
46
|
+
aws-eventstream (1.0.1)
|
47
|
+
aws-partitions (1.96.0)
|
48
|
+
aws-sdk-core (3.22.1)
|
49
|
+
aws-eventstream (~> 1.0)
|
50
|
+
aws-partitions (~> 1.0)
|
51
|
+
aws-sigv4 (~> 1.0)
|
52
|
+
jmespath (~> 1.0)
|
53
|
+
aws-sdk-kms (1.6.0)
|
54
|
+
aws-sdk-core (~> 3)
|
55
|
+
aws-sigv4 (~> 1.0)
|
56
|
+
aws-sdk-s3 (1.17.0)
|
57
|
+
aws-sdk-core (~> 3, >= 3.21.2)
|
58
|
+
aws-sdk-kms (~> 1)
|
59
|
+
aws-sigv4 (~> 1.0)
|
60
|
+
aws-sigv4 (1.0.3)
|
46
61
|
babel-source (5.8.35)
|
47
62
|
babel-transpiler (0.7.0)
|
48
63
|
babel-source (>= 4.0, < 6)
|
@@ -82,6 +97,7 @@ GEM
|
|
82
97
|
jbuilder (2.8.0)
|
83
98
|
activesupport (>= 4.2.0)
|
84
99
|
multi_json (>= 1.2)
|
100
|
+
jmespath (1.4.0)
|
85
101
|
libv8 (6.7.288.46.1)
|
86
102
|
listen (3.1.5)
|
87
103
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
@@ -217,6 +233,7 @@ PLATFORMS
|
|
217
233
|
ruby
|
218
234
|
|
219
235
|
DEPENDENCIES
|
236
|
+
aws-sdk-s3
|
220
237
|
bcrypt (~> 3.1.7)
|
221
238
|
bootsnap (>= 1.1.0)
|
222
239
|
byebug
|
data/Installation.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# yarn
|
2
|
+
|
3
|
+
Need node, npm, and yarn.
|
4
|
+
|
5
|
+
# Postgresql (production)
|
6
|
+
|
7
|
+
# Ridgepole
|
8
|
+
|
9
|
+
```
|
10
|
+
$ ridgepole -c config/database.yml --apply
|
11
|
+
```
|
12
|
+
|
13
|
+
## Heroku
|
14
|
+
|
15
|
+
```
|
16
|
+
$ heroku run 'bundle exec ridgepole -c config/database.yml -E production -f Schemafile --apply'
|
17
|
+
```
|
18
|
+
|
19
|
+
# ImageMagick
|
20
|
+
|
21
|
+
## Heroku (stack heroku-16)
|
22
|
+
|
23
|
+
```
|
24
|
+
$ heroku buildpacks:add https://github.com/ello/heroku-buildpack-imagemagick
|
25
|
+
```
|
data/Procfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
web: bin/rails server -p $PORT -e $RAILS_ENV
|
data/Schemafile
CHANGED
@@ -32,6 +32,15 @@ create_table "messages", force: :cascade do |t|
|
|
32
32
|
end
|
33
33
|
add_foreign_key "messages", "users"
|
34
34
|
|
35
|
+
create_table "user_subscribe_topics", force: :cascade do |t|
|
36
|
+
t.bigint "user_id", null: false
|
37
|
+
t.string "topic", null: false
|
38
|
+
t.index ["user_id", "topic"], unique: true
|
39
|
+
t.index ["topic"]
|
40
|
+
t.datetime "created_at", null: false
|
41
|
+
end
|
42
|
+
add_foreign_key "user_subscribe_topics", "users"
|
43
|
+
|
35
44
|
create_table "message_topics", force: :cascade, id: false do |t|
|
36
45
|
t.string "topic", null: false
|
37
46
|
t.bigint "message_id", null: false
|
@@ -15,6 +15,12 @@ body.theme-dark {
|
|
15
15
|
body.theme-leaf {
|
16
16
|
color: #162727;
|
17
17
|
a { color: #20c728; }
|
18
|
+
.btn.btn-primary,
|
19
|
+
.btn.btn-success,
|
20
|
+
.btn.btn-warning,
|
21
|
+
.btn.btn-danger,
|
22
|
+
.btn.btn-dark,
|
23
|
+
.btn.btn-secondary, { color: #fff; }
|
18
24
|
h1 {
|
19
25
|
color: #384b54;
|
20
26
|
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class SubscriptionsController < ApplicationController
|
2
|
+
# GET /subscriptions
|
3
|
+
# GET /subscriptions.json
|
4
|
+
def index
|
5
|
+
@subscriptions = UserSubscribeTopic.where(user: current_user)
|
6
|
+
@subscription = UserSubscribeTopic.new(topic: topic)
|
7
|
+
end
|
8
|
+
|
9
|
+
# POST /subscriptions
|
10
|
+
# POST /subscriptions.json
|
11
|
+
def create
|
12
|
+
respond_to do |format|
|
13
|
+
if UserSubscribeTopic.create(topic: topic, user: current_user)
|
14
|
+
format.html { redirect_to '/subscriptions', notice: "You are subscribe #{topic}." }
|
15
|
+
else
|
16
|
+
format.html { render :index }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# DELETE /subscriptions/:topic
|
22
|
+
# DELETE /subscriptions/:topic.json
|
23
|
+
def destroy
|
24
|
+
UserSubscribeTopic.find_by(topic: params[:id], user: current_user).destroy
|
25
|
+
respond_to do |format|
|
26
|
+
format.html { redirect_to '/subscriptions', notice: "You are unsbscribe #{topic}" }
|
27
|
+
format.json { head :no_content }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def topic
|
34
|
+
params[:user_subscribe_topic][:topic] if params[:user_subscribe_topic]
|
35
|
+
end
|
36
|
+
end
|
@@ -1,7 +1,35 @@
|
|
1
1
|
class TopicsController < ApplicationController
|
2
|
-
# GET /
|
3
|
-
# GET /
|
2
|
+
# GET /topic/:name
|
3
|
+
# GET /topic/:name.json
|
4
4
|
def show
|
5
|
-
@messages = Message.topic_of(
|
5
|
+
@messages = Message.topic_of(topic)
|
6
|
+
end
|
7
|
+
|
8
|
+
# POST /topic/:name/subscribe
|
9
|
+
# POST /topic/:name/subscribe.json
|
10
|
+
def subscribe
|
11
|
+
respond_to do |format|
|
12
|
+
if UserSubscribeTopic.create(topic: topic, user: current_user)
|
13
|
+
format.html { redirect_to topic_path(topic), notice: "You are subscribe it." }
|
14
|
+
else
|
15
|
+
format.html { render :index }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# DELETE /topic/:name/subscribe
|
21
|
+
# DELETE /topic/:name/subscribe.json
|
22
|
+
def unsubscribe
|
23
|
+
UserSubscribeTopic.find_by(topic: params[:id], user: current_user).destroy
|
24
|
+
respond_to do |format|
|
25
|
+
format.html { redirect_to topic_path(topic), notice: "You are unsubscribe it." }
|
26
|
+
format.json { head :no_content }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def topic
|
33
|
+
params[:id]
|
6
34
|
end
|
7
35
|
end
|
data/app/models/user.rb
CHANGED
@@ -8,6 +8,7 @@ class User < ApplicationRecord
|
|
8
8
|
has_many :observe_users, through: :observes, source: "to_user"
|
9
9
|
has_many :observed, foreign_key: "to_user_id", class_name: "Observe"
|
10
10
|
has_many :observed_users, through: :observed, source: "from_user"
|
11
|
+
has_many :subscribe_topics, class_name: 'UserSubscribeTopic'
|
11
12
|
|
12
13
|
has_one_attached :profile_image
|
13
14
|
|
@@ -16,4 +17,8 @@ class User < ApplicationRecord
|
|
16
17
|
def follow?(user)
|
17
18
|
observe_users.include?(user)
|
18
19
|
end
|
20
|
+
|
21
|
+
def subscribe_topic?(topic)
|
22
|
+
subscribe_topics.where(topic: topic).exists?
|
23
|
+
end
|
19
24
|
end
|
@@ -18,9 +18,20 @@ html
|
|
18
18
|
body(class="theme-#{current_user.try(:theme)}")
|
19
19
|
.navbar
|
20
20
|
div
|
21
|
-
= link_to '
|
21
|
+
= link_to '', root_path, class: 'btn oi oi-home'
|
22
22
|
- if @user.try(:persisted?)
|
23
23
|
= link_to '@' + @user.name, '/' + @user.name, class: 'btn'
|
24
|
+
- if user_signed_in?
|
25
|
+
nav.left-nav
|
26
|
+
.navbar
|
27
|
+
= link_to '', '/' + current_user.name, class: 'btn oi oi-person'
|
28
|
+
.navbar
|
29
|
+
= link_to '', '/subscriptions', class: 'btn oi oi-folder'
|
30
|
+
.navbar
|
31
|
+
= link_to '', destroy_user_session_path, class: 'btn oi oi-power-standby',
|
32
|
+
method: :delete, data: { confirm: "Are you sure logout from 'Xwitter' ?" }
|
33
|
+
.navbar
|
34
|
+
= link_to '', root_path, class: 'btn oi oi-wrench'
|
24
35
|
|
25
36
|
.container
|
26
37
|
= yield
|
@@ -0,0 +1,16 @@
|
|
1
|
+
h1 Your subscriptions
|
2
|
+
ul
|
3
|
+
- @subscriptions.each do |subscription|
|
4
|
+
li
|
5
|
+
= link_to subscription.topic, topic_path(subscription.topic)
|
6
|
+
|
|
7
|
+
= link_to 'Remove', subscription_path(subscription.topic), class: 'btn btn-sm btn-dark',
|
8
|
+
data: { confirm: "Are you sure remove '#{subscription.topic}' subscription?" }, method: :delete
|
9
|
+
|
10
|
+
h3 New subscribe
|
11
|
+
= form_for @subscription, url: '/subscriptions' do |f|
|
12
|
+
= f.label :topic, 'Name'
|
13
|
+
br
|
14
|
+
= f.text_field :topic
|
15
|
+
|
|
16
|
+
= f.submit 'Follow topic', class: 'btn btn-success'
|
@@ -1,2 +1,9 @@
|
|
1
|
-
|
1
|
+
- topic = params[:id]
|
2
|
+
h1
|
3
|
+
| Topic #{topic}
|
4
|
+
- if current_user.subscribe_topic?(topic)
|
5
|
+
= link_to 'Remove subscription', subscribe_topic_path(topic), method: :delete, class: 'btn btn-warning'
|
6
|
+
- else
|
7
|
+
= link_to 'Follow it', subscribe_topic_path(topic), method: :post, class: 'btn btn-success'
|
8
|
+
|
2
9
|
= render 'messages/index', messages: @messages
|
@@ -41,7 +41,7 @@ Rails.application.configure do
|
|
41
41
|
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
42
42
|
|
43
43
|
# Store uploaded files on the local file system (see config/storage.yml for options)
|
44
|
-
config.active_storage.service = :
|
44
|
+
config.active_storage.service = :amazon
|
45
45
|
|
46
46
|
# Mount Action Cable outside main process or domain
|
47
47
|
# config.action_cable.mount_path = nil
|
data/config/routes.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
2
|
resource :profile
|
3
3
|
resources :messages
|
4
|
-
resources :
|
4
|
+
resources :subscriptions
|
5
|
+
resources :topics, path: 'topic' do
|
6
|
+
member do
|
7
|
+
post :subscribe
|
8
|
+
delete :subscribe, to: 'topics#unsubscribe'
|
9
|
+
end
|
10
|
+
end
|
5
11
|
devise_for :users
|
6
12
|
root 'messages#index'
|
7
13
|
get ':username', to: 'profiles#show'
|
data/config/storage.yml
CHANGED
@@ -6,13 +6,12 @@ local:
|
|
6
6
|
service: Disk
|
7
7
|
root: <%= Rails.root.join("storage") %>
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
# bucket: your_own_bucket
|
9
|
+
amazon:
|
10
|
+
service: S3
|
11
|
+
access_key_id: <%= ENV['BUCKETEER_AWS_ACCESS_KEY_ID'] %>
|
12
|
+
secret_access_key: <%= ENV['BUCKETEER_AWS_SECRET_ACCESS_KEY'] %>
|
13
|
+
region: <%= ENV['BUCKETEER_AWS_REGION'] %>
|
14
|
+
bucket: <%= ENV['BUCKETEER_BUCKET_NAME'] %>
|
16
15
|
|
17
16
|
# Remember not to checkin your GCS keyfile to a repository
|
18
17
|
# google:
|
data/lib/Xwitter/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Xwitter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- myun2
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -51,7 +51,9 @@ files:
|
|
51
51
|
- ".ruby-version"
|
52
52
|
- Gemfile
|
53
53
|
- Gemfile.lock
|
54
|
+
- Installation.md
|
54
55
|
- LICENSE.txt
|
56
|
+
- Procfile
|
55
57
|
- README.md
|
56
58
|
- Rakefile
|
57
59
|
- Schemafile
|
@@ -74,6 +76,7 @@ files:
|
|
74
76
|
- app/controllers/follows_controller.rb
|
75
77
|
- app/controllers/messages_controller.rb
|
76
78
|
- app/controllers/profiles_controller.rb
|
79
|
+
- app/controllers/subscriptions_controller.rb
|
77
80
|
- app/controllers/topics_controller.rb
|
78
81
|
- app/helpers/application_helper.rb
|
79
82
|
- app/helpers/messages_helper.rb
|
@@ -92,6 +95,7 @@ files:
|
|
92
95
|
- app/models/message_topic.rb
|
93
96
|
- app/models/observe.rb
|
94
97
|
- app/models/user.rb
|
98
|
+
- app/models/user_subscribe_topic.rb
|
95
99
|
- app/views/follows/followed.html.slim
|
96
100
|
- app/views/follows/index.html.slim
|
97
101
|
- app/views/layouts/application.html.slim
|
@@ -113,6 +117,7 @@ files:
|
|
113
117
|
- app/views/profiles/edit.html.slim
|
114
118
|
- app/views/profiles/show.html.slim
|
115
119
|
- app/views/profiles/show.json.jbuilder
|
120
|
+
- app/views/subscriptions/index.html.slim
|
116
121
|
- app/views/topics/show.html.slim
|
117
122
|
- app/views/users/confirmations/new.html.erb
|
118
123
|
- app/views/users/mailer/confirmation_instructions.html.erb
|