rails_interact 0.0.1

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.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +20 -0
  3. data/README.md +23 -0
  4. data/Rakefile +32 -0
  5. data/app/controllers/interact/admin/abuses_controller.rb +54 -0
  6. data/app/controllers/interact/admin/attitudes_controller.rb +55 -0
  7. data/app/controllers/interact/admin/base_controller.rb +3 -0
  8. data/app/controllers/interact/admin/comments_controller.rb +42 -0
  9. data/app/controllers/interact/admin/stars_controller.rb +55 -0
  10. data/app/controllers/interact/attitudes_controller.rb +81 -0
  11. data/app/controllers/interact/base_controller.rb +3 -0
  12. data/app/controllers/interact/comments_controller.rb +59 -0
  13. data/app/controllers/interact/my/abuses_controller.rb +46 -0
  14. data/app/controllers/interact/my/attitudes_controller.rb +70 -0
  15. data/app/controllers/interact/my/base_controller.rb +3 -0
  16. data/app/controllers/interact/my/comments_controller.rb +60 -0
  17. data/app/controllers/interact/my/stars_controller.rb +43 -0
  18. data/app/models/interact/abuse.rb +5 -0
  19. data/app/models/interact/attitude.rb +5 -0
  20. data/app/models/interact/comment.rb +6 -0
  21. data/app/models/interact/ext/commentable.rb +16 -0
  22. data/app/models/interact/ext/like.rb +19 -0
  23. data/app/models/interact/ext/user.rb +10 -0
  24. data/app/models/interact/model/abuse.rb +13 -0
  25. data/app/models/interact/model/attitude.rb +69 -0
  26. data/app/models/interact/model/comment.rb +58 -0
  27. data/app/models/interact/model/star.rb +13 -0
  28. data/app/models/interact/star.rb +5 -0
  29. data/app/models/interact.rb +11 -0
  30. data/app/views/application/_interact_nav.html.erb +13 -0
  31. data/app/views/interact/admin/abuses/_form.html.erb +4 -0
  32. data/app/views/interact/admin/abuses/_index/_index_tbody.html.erb +7 -0
  33. data/app/views/interact/admin/abuses/_index/_index_thead.html.erb +7 -0
  34. data/app/views/interact/admin/abuses/_show_table.html.erb +16 -0
  35. data/app/views/interact/admin/attitudes/_form.html.erb +4 -0
  36. data/app/views/interact/admin/attitudes/index.html.erb +50 -0
  37. data/app/views/interact/admin/attitudes/show.html.erb +26 -0
  38. data/app/views/interact/admin/comments/_filter_form.html.erb +8 -0
  39. data/app/views/interact/admin/comments/_filter_table.html.erb +11 -0
  40. data/app/views/interact/admin/comments/_form.html.erb +3 -0
  41. data/app/views/interact/admin/comments/index.html.erb +49 -0
  42. data/app/views/interact/admin/comments/show.html.erb +22 -0
  43. data/app/views/interact/admin/stars/_form.html.erb +3 -0
  44. data/app/views/interact/admin/stars/_search_form.html.erb +7 -0
  45. data/app/views/interact/admin/stars/index.html.erb +48 -0
  46. data/app/views/interact/admin/stars/show.html.erb +22 -0
  47. data/app/views/interact/comments/_comment.json.jbuilder +17 -0
  48. data/app/views/interact/comments/index.json.jbuilder +2 -0
  49. data/app/views/interact/comments/show.json.jbuilder +1 -0
  50. data/app/views/interact/my/attitudes/_form.html.erb +4 -0
  51. data/app/views/interact/my/attitudes/_search_form.html.erb +7 -0
  52. data/app/views/interact/my/attitudes/dislike.js.erb +1 -0
  53. data/app/views/interact/my/attitudes/index.html.erb +41 -0
  54. data/app/views/interact/my/attitudes/like.js.erb +1 -0
  55. data/app/views/interact/my/attitudes/show.html.erb +10 -0
  56. data/app/views/interact/my/comments/_comment.html.erb +27 -0
  57. data/app/views/interact/my/comments/_comment.json.jbuilder +17 -0
  58. data/app/views/interact/my/comments/_form.html.erb +4 -0
  59. data/app/views/interact/my/comments/create.js.erb +5 -0
  60. data/app/views/interact/my/comments/index.html.erb +41 -0
  61. data/app/views/interact/my/comments/index.json.jbuilder +2 -0
  62. data/app/views/interact/my/comments/show.html.erb +10 -0
  63. data/app/views/interact/my/comments/show.json.jbuilder +1 -0
  64. data/app/views/interact/my/stars/_star.json.jbuilder +8 -0
  65. data/app/views/interact/my/stars/index.json.jbuilder +2 -0
  66. data/app/views/interact/my/stars/show.json.jbuilder +1 -0
  67. data/config/locales/en.notify.yml +11 -0
  68. data/config/locales/zh.notify.yml +11 -0
  69. data/config/routes.rb +45 -0
  70. data/lib/rails_interact/config.rb +9 -0
  71. data/lib/rails_interact/engine.rb +20 -0
  72. data/lib/rails_interact.rb +2 -0
  73. metadata +156 -0
@@ -0,0 +1,27 @@
1
+ <ul>
2
+ <%= image_tag comment.user.avatar, class: 'ui avatar image' %>
3
+ <div class="messageText">
4
+ <div>
5
+ <span class="userName"><%= comment.user.name %></span>
6
+ <div class="ui rating disableRating" data-rating="<%= comment.score %>" data-max-rating="5"></div>
7
+ <span class="date"><%= comment.created_at.to_s(:date) %></span>
8
+ </div>
9
+ <div class="mainText">
10
+ <%= comment.content %>
11
+ </div>
12
+ <div class="zan">
13
+ <div class="zanNum">
14
+ <%= link_to like_my_attitudes_path('Comment', comment), method: :post, remote: true do %>
15
+ <%= image_tag comment.liked?(@current_user&.id) ? 'dapps_yes.png' : 'dapps_no.png', class: 'zanImg'%>
16
+ <span id="comment_<%= comment.id %>_count"><%= comment.liked_count.to_i %></span>
17
+ <% end %>
18
+ </div>
19
+ <!-- <div class="some-wrapping-div">
20
+ <div class="ui custom"><%= t('more')%></div>
21
+ </div> -->
22
+ <!-- <div class="ui custom popup more right">
23
+ <div class="report">举报</div>
24
+ </div> -->
25
+ </div>
26
+ </div>
27
+ </ul>
@@ -0,0 +1,17 @@
1
+ json.extract!(
2
+ comment,
3
+ :id,
4
+ :title,
5
+ :content,
6
+ :state,
7
+ :score,
8
+ :star_count,
9
+ :created_at
10
+ )
11
+ if comment.user
12
+ json.commenter comment.user, :id, :name, :avatar_url
13
+ end
14
+ if current_user
15
+ json.liked comment.liked?(current_user.id)
16
+ end
17
+ json.liked_count comment.liked_count.to_i
@@ -0,0 +1,4 @@
1
+ <%= form_with model: @comment, local: true do |f| %>
2
+ <%= render 'error_messages', target: @comment %>
3
+ <%= f.submit %>
4
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <% if @comment.errors.blank? %>
2
+ $('#comments').prepend('<%= j(render partial: 'comment', locals: { comment: @comment }) %>')
3
+ <% else %>
4
+ $('body').prepend("<%= j(render 'shared/custom_error', target: @comment) %>")
5
+ <% end %>
@@ -0,0 +1,41 @@
1
+ <div class="ui top attached borderless menu">
2
+ <div class="header item">My Comments</div>
3
+ <div class="right menu">
4
+ <div class="item">
5
+ <%= link_to 'New My Comment', new_my_comment_path, class: 'ui teal button' %>
6
+ </div>
7
+ </div>
8
+ </div>
9
+
10
+ <div class="ui attached segment">
11
+ <%= render 'search_form' %>
12
+ </div>
13
+
14
+ <table class="table is-hoverable is-fullwidth">
15
+ <thead>
16
+ <tr>
17
+ <th><%= Comment.human_attribute_name(:id) %></th>
18
+ <th>Actions</th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <% @comments.each do |comment| %>
23
+ <tr>
24
+ <td><%= comment.id %></td>
25
+ <td class="ui labels">
26
+ <%= link_to my_comment_path(comment), aria: { label: t('.show') }, class: 'ui blue mini icon button' do %>
27
+ <i class="location arrow icon"></i>
28
+ <% end %>
29
+ <%= link_to edit_my_comment_path(comment), aria: { label: t('.edit') }, class: 'ui pink mini icon button' do %>
30
+ <i class="pencil alternate icon"></i>
31
+ <% end %>
32
+ <%= link_to my_comment_path(comment), method: :delete, aria: { label: t('.destroy') }, data: { confrim: t('.confirm') }, class: 'ui red mini icon button' do %>
33
+ <i class="times icon"></i>
34
+ <% end %>
35
+ </td>
36
+ </tr>
37
+ <% end %>
38
+ </tbody>
39
+ </table>
40
+
41
+ <%= paginate @comments %>
@@ -0,0 +1,2 @@
1
+ json.comments @comments, partial: 'comment', as: :comment
2
+ json.partial! 'shared/pagination', items: @comments
@@ -0,0 +1,10 @@
1
+ <div class="ui segment breadcrumb">
2
+ <%= link_to 'Back', my_comments_path, class: 'section' %>
3
+ <div class="divider">/</div>
4
+ <div class="active section">Show</div>
5
+ </div>
6
+
7
+ <table class="table is-hoverable is-fullwidth">
8
+ <tbody>
9
+ </tbody>
10
+ </table>
@@ -0,0 +1 @@
1
+ json.comment @comment, partial: 'comment', as: :comment
@@ -0,0 +1,8 @@
1
+ json.extract! star,
2
+ :id,
3
+ :starred_type,
4
+ :starred_id,
5
+ :created_at
6
+ if star.starred
7
+ json.starred star.starred, :id, :title
8
+ end
@@ -0,0 +1,2 @@
1
+ json.stars @stars, partial: 'star', as: :star
2
+ json.partial! 'api/shared/pagination', items: @stars
@@ -0,0 +1 @@
1
+ json.comment @comment, partial: 'comment', as: :comment
@@ -0,0 +1,11 @@
1
+ en:
2
+ activerecord:
3
+ notify:
4
+ attitude:
5
+ default:
6
+ title: '@%{user_name}'
7
+ body: 赞了你的评论
8
+ comment:
9
+ default:
10
+ title: '@%{user_name}评论了你'
11
+ body: '%{content}'
@@ -0,0 +1,11 @@
1
+ zh:
2
+ activerecord:
3
+ notify:
4
+ attitude:
5
+ default:
6
+ title: '@%{user_name}'
7
+ body: 赞了你的评论
8
+ comment:
9
+ default:
10
+ title: '@%{user_name}评论了你'
11
+ body: '%{content}'
data/config/routes.rb ADDED
@@ -0,0 +1,45 @@
1
+ Rails.application.routes.draw do
2
+
3
+ scope module: 'interact' do
4
+ scope ':commentable_type/:commentable_id' do
5
+ resources :comments, only: [:index, :show, :create, :update, :destroy]
6
+ end
7
+ scope ':abusement_type/:abusement_id' do
8
+ resources :abuses, only: [:create, :destroy]
9
+ end
10
+ scope ':attitudinal_type/:attitudinal_id' do
11
+ resources :attitudes, only: [:index, :show, :create, :update, :destroy] do
12
+ post :like, on: :collection
13
+ post :dislike, on: :collection
14
+ post :cancel, on: :collection
15
+ end
16
+ end
17
+ resources :stars, only: [:index]
18
+ scope ':starred_type/:starred_id' do
19
+ resources :stars, only: [:create] do
20
+ post :toggle, on: :collection
21
+ delete '' => :destroy, on: :collection
22
+ end
23
+ end
24
+ end
25
+
26
+ scope :my, module: 'interact/my', as: :my do
27
+ scope ':commentable_type/:commentable_id' do
28
+ resources :comments
29
+ end
30
+ scope ':attitudinal_type/:attitudinal_id' do
31
+ resources :attitudes do
32
+ post :like, on: :collection
33
+ post :dislike, on: :collection
34
+ end
35
+ end
36
+ end
37
+
38
+ scope :admin, module: 'interact/admin', as: :admin do
39
+ resources :comments
40
+ resources :attitudes
41
+ resources :stars
42
+ resources :abuses
43
+ end
44
+
45
+ end
@@ -0,0 +1,9 @@
1
+ require 'active_support/configurable'
2
+
3
+ module RailsInteract
4
+ include ActiveSupport::Configurable
5
+
6
+ configure do |config|
7
+ end
8
+
9
+ end
@@ -0,0 +1,20 @@
1
+ require 'closure_tree'
2
+ require 'rails_com'
3
+ module RailsInteract
4
+ class Engine < ::Rails::Engine
5
+
6
+ config.generators do |g|
7
+ g.rails = {
8
+ assets: false,
9
+ stylesheets: false,
10
+ helper: false
11
+ }
12
+ g.test_unit = {
13
+ fixture: true,
14
+ fixture_replacement: :factory_bot
15
+ }
16
+ g.templates.unshift File.expand_path('lib/templates', RailsCom::Engine.root)
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,2 @@
1
+ require 'rails_interact/engine'
2
+ require 'rails_interact/config'
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_interact
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - qinmingyuan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-12-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails_com
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails_notice
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sqlite3
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Description of RailsInteract.
56
+ email:
57
+ - mingyuan0715@foxmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - LICENSE
63
+ - README.md
64
+ - Rakefile
65
+ - app/controllers/interact/admin/abuses_controller.rb
66
+ - app/controllers/interact/admin/attitudes_controller.rb
67
+ - app/controllers/interact/admin/base_controller.rb
68
+ - app/controllers/interact/admin/comments_controller.rb
69
+ - app/controllers/interact/admin/stars_controller.rb
70
+ - app/controllers/interact/attitudes_controller.rb
71
+ - app/controllers/interact/base_controller.rb
72
+ - app/controllers/interact/comments_controller.rb
73
+ - app/controllers/interact/my/abuses_controller.rb
74
+ - app/controllers/interact/my/attitudes_controller.rb
75
+ - app/controllers/interact/my/base_controller.rb
76
+ - app/controllers/interact/my/comments_controller.rb
77
+ - app/controllers/interact/my/stars_controller.rb
78
+ - app/models/interact.rb
79
+ - app/models/interact/abuse.rb
80
+ - app/models/interact/attitude.rb
81
+ - app/models/interact/comment.rb
82
+ - app/models/interact/ext/commentable.rb
83
+ - app/models/interact/ext/like.rb
84
+ - app/models/interact/ext/user.rb
85
+ - app/models/interact/model/abuse.rb
86
+ - app/models/interact/model/attitude.rb
87
+ - app/models/interact/model/comment.rb
88
+ - app/models/interact/model/star.rb
89
+ - app/models/interact/star.rb
90
+ - app/views/application/_interact_nav.html.erb
91
+ - app/views/interact/admin/abuses/_form.html.erb
92
+ - app/views/interact/admin/abuses/_index/_index_tbody.html.erb
93
+ - app/views/interact/admin/abuses/_index/_index_thead.html.erb
94
+ - app/views/interact/admin/abuses/_show_table.html.erb
95
+ - app/views/interact/admin/attitudes/_form.html.erb
96
+ - app/views/interact/admin/attitudes/index.html.erb
97
+ - app/views/interact/admin/attitudes/show.html.erb
98
+ - app/views/interact/admin/comments/_filter_form.html.erb
99
+ - app/views/interact/admin/comments/_filter_table.html.erb
100
+ - app/views/interact/admin/comments/_form.html.erb
101
+ - app/views/interact/admin/comments/index.html.erb
102
+ - app/views/interact/admin/comments/show.html.erb
103
+ - app/views/interact/admin/stars/_form.html.erb
104
+ - app/views/interact/admin/stars/_search_form.html.erb
105
+ - app/views/interact/admin/stars/index.html.erb
106
+ - app/views/interact/admin/stars/show.html.erb
107
+ - app/views/interact/comments/_comment.json.jbuilder
108
+ - app/views/interact/comments/index.json.jbuilder
109
+ - app/views/interact/comments/show.json.jbuilder
110
+ - app/views/interact/my/attitudes/_form.html.erb
111
+ - app/views/interact/my/attitudes/_search_form.html.erb
112
+ - app/views/interact/my/attitudes/dislike.js.erb
113
+ - app/views/interact/my/attitudes/index.html.erb
114
+ - app/views/interact/my/attitudes/like.js.erb
115
+ - app/views/interact/my/attitudes/show.html.erb
116
+ - app/views/interact/my/comments/_comment.html.erb
117
+ - app/views/interact/my/comments/_comment.json.jbuilder
118
+ - app/views/interact/my/comments/_form.html.erb
119
+ - app/views/interact/my/comments/create.js.erb
120
+ - app/views/interact/my/comments/index.html.erb
121
+ - app/views/interact/my/comments/index.json.jbuilder
122
+ - app/views/interact/my/comments/show.html.erb
123
+ - app/views/interact/my/comments/show.json.jbuilder
124
+ - app/views/interact/my/stars/_star.json.jbuilder
125
+ - app/views/interact/my/stars/index.json.jbuilder
126
+ - app/views/interact/my/stars/show.json.jbuilder
127
+ - config/locales/en.notify.yml
128
+ - config/locales/zh.notify.yml
129
+ - config/routes.rb
130
+ - lib/rails_interact.rb
131
+ - lib/rails_interact/config.rb
132
+ - lib/rails_interact/engine.rb
133
+ homepage: https://github.com/work-design/rails_interact
134
+ licenses:
135
+ - MIT
136
+ metadata: {}
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubygems_version: 3.3.3
153
+ signing_key:
154
+ specification_version: 4
155
+ summary: Summary of RailsInteract.
156
+ test_files: []