rails-image-post-solution 0.1.2 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2120b2a444d646648b7e9fe57165b4a89f2bffd99b9e6ca2e4aeb19f924dd626
4
- data.tar.gz: fadbb2a26397c2f4172630cbb24ef71f63dc05fd56463097856d0c0516c797bb
3
+ metadata.gz: b625a47080961aad101e70eddcb541dfdb006342fe19cf2b95c9fb7243ecf9b9
4
+ data.tar.gz: 427c9d081155769b7888f130bc34b55da141f530b8d5e748082e60e9c32a4a03
5
5
  SHA512:
6
- metadata.gz: 5472105bd1e6764ff1f977b4f46900f1f7560531a0c30ee05b94b59a645ee8ca103a9d3fcc966328203295796f9cf8fae4a4c41d49034ad9ad65cfe1086bde76
7
- data.tar.gz: 57655c478d8a9a30e4c4f7e3e1158cc62c58eda115725c53810b043ced3599da95c28373c8804e650f1235d99b73deace7a2e16db25ed5cbc942821722117b07
6
+ metadata.gz: 31bfcdcc9416bc822547d27b690c0713a6d717f8a3443e2a758d330c52efd31f9a9b45024662f6e3561c889d8b0eb8834fa6a52f3fcbc4ac701c5447cbfc73f5
7
+ data.tar.gz: 4821a741b4fef32d874c171133d3783c165c67a9a00a364114de0c4ad69e674779b13524a95dbe185bfbb927762a85f7079c0b665bb6176ceadaf71c68cb2373
data/README.md CHANGED
@@ -62,39 +62,9 @@ Mount the engine in your `config/routes.rb`:
62
62
 
63
63
  ```ruby
64
64
  Rails.application.routes.draw do
65
- # Mount the engine (admin routes will be at /moderation/admin/image_reports)
65
+ # Mount the engine - all admin features will be accessible at /moderation/admin/*
66
66
  mount RailsImagePostSolution::Engine => "/moderation"
67
67
 
68
- # Optional: Add direct admin routes (accessible at /admin/*)
69
- namespace :admin do
70
- resources :image_reports, only: %i[index show], controller: 'admin/image_reports' do
71
- member do
72
- patch :confirm
73
- patch :dismiss
74
- end
75
- end
76
-
77
- resources :users, only: %i[index show], controller: 'admin/users' do
78
- member do
79
- post :suspend
80
- post :unsuspend
81
- post :ban
82
- post :unban
83
- end
84
- end
85
-
86
- resources :frozen_posts, only: [:index], controller: 'admin/frozen_posts' do
87
- collection do
88
- post "unfreeze_stage/:id", to: "admin/frozen_posts#unfreeze_stage", as: :unfreeze_stage
89
- post "unfreeze_comment/:id", to: "admin/frozen_posts#unfreeze_comment", as: :unfreeze_comment
90
- post "permanent_freeze_stage/:id", to: "admin/frozen_posts#permanent_freeze_stage", as: :permanent_freeze_stage
91
- post "permanent_freeze_comment/:id", to: "admin/frozen_posts#permanent_freeze_comment", as: :permanent_freeze_comment
92
- delete "destroy_stage/:id", to: "admin/frozen_posts#destroy_stage", as: :destroy_stage
93
- delete "destroy_comment/:id", to: "admin/frozen_posts#destroy_comment", as: :destroy_comment
94
- end
95
- end
96
- end
97
-
98
68
  # ... your other routes
99
69
  end
100
70
  ```
@@ -326,12 +296,17 @@ end
326
296
 
327
297
  ## Routes
328
298
 
329
- ### Engine Routes (via /moderation mount point)
299
+ The engine provides the following routes when mounted at `/moderation`:
330
300
 
331
- When you mount the engine at `/moderation`, these routes are available:
301
+ ### User-Facing Routes
332
302
 
333
303
  ```
334
304
  POST /moderation/image_reports # Create report
305
+ ```
306
+
307
+ ### Admin Routes
308
+
309
+ ```
335
310
  GET /moderation/admin/image_reports # List all reports
336
311
  GET /moderation/admin/image_reports/:id # View report details
337
312
  PATCH /moderation/admin/image_reports/:id/confirm # Mark as inappropriate
@@ -343,18 +318,12 @@ POST /moderation/admin/users/:id/unsuspend # Unsuspend user
343
318
  POST /moderation/admin/users/:id/ban # Ban user
344
319
  POST /moderation/admin/users/:id/unban # Unban user
345
320
  GET /moderation/admin/frozen_posts # List frozen posts
346
- ```
347
-
348
- ### Optional: Direct Admin Routes (via host application routes)
349
-
350
- If you want admin routes accessible at `/admin/*` instead of `/moderation/admin/*`, add the routes shown in the Installation section to your host application's `config/routes.rb`. This allows you to access:
351
-
352
- ```
353
- GET /admin/image_reports # List all reports
354
- GET /admin/image_reports/:id # View report details
355
- GET /admin/users # List all users
356
- GET /admin/users/:id # View user details
357
- GET /admin/frozen_posts # List frozen posts
321
+ POST /moderation/admin/frozen_posts/unfreeze_stage/:id # Unfreeze a stage
322
+ POST /moderation/admin/frozen_posts/unfreeze_comment/:id # Unfreeze a comment
323
+ POST /moderation/admin/frozen_posts/permanent_freeze_stage/:id # Permanently freeze a stage
324
+ POST /moderation/admin/frozen_posts/permanent_freeze_comment/:id # Permanently freeze a comment
325
+ DELETE /moderation/admin/frozen_posts/destroy_stage/:id # Delete a frozen stage
326
+ DELETE /moderation/admin/frozen_posts/destroy_comment/:id # Delete a frozen comment
358
327
  ```
359
328
 
360
329
  ## Customization
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Admin
4
- class FrozenPostsController < ApplicationController
3
+ module RailsImagePostSolution
4
+ module Admin
5
+ class FrozenPostsController < ApplicationController
5
6
  before_action :require_login
6
7
  before_action :require_admin
7
8
 
@@ -75,5 +76,6 @@ module Admin
75
76
 
76
77
  redirect_to root_path, alert: I18n.t("admin.flash.access_denied")
77
78
  end
79
+ end
78
80
  end
79
81
  end
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Admin
4
- class UsersController < ApplicationController
3
+ module RailsImagePostSolution
4
+ module Admin
5
+ class UsersController < ApplicationController
5
6
  before_action :require_login
6
7
  before_action :require_admin
7
8
  before_action :set_user, only: %i[show suspend unsuspend ban unban]
@@ -96,5 +97,6 @@ module Admin
96
97
 
97
98
  redirect_to root_path, alert: I18n.t("admin.flash.admin_access_only")
98
99
  end
100
+ end
99
101
  end
100
102
  end
data/config/routes.rb CHANGED
@@ -4,8 +4,9 @@ RailsImagePostSolution::Engine.routes.draw do
4
4
  # User-facing report API
5
5
  resources :image_reports, only: [ :create ]
6
6
 
7
- # Admin dashboard
7
+ # Admin dashboard (engine controllers)
8
8
  namespace :admin do
9
+ # Image reports management
9
10
  resources :image_reports, only: %i[index show] do
10
11
  member do
11
12
  patch :confirm
@@ -24,7 +25,7 @@ RailsImagePostSolution::Engine.routes.draw do
24
25
  end
25
26
 
26
27
  # Frozen posts management
27
- resources :frozen_posts, only: [:index] do
28
+ resources :frozen_posts, only: [ :index ] do
28
29
  collection do
29
30
  post "unfreeze_stage/:id", to: "frozen_posts#unfreeze_stage", as: :unfreeze_stage
30
31
  post "unfreeze_comment/:id", to: "frozen_posts#unfreeze_comment", as: :unfreeze_comment
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsImagePostSolution
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-image-post-solution
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - dhq_boiler
@@ -93,21 +93,19 @@ files:
93
93
  - LICENSE.txt
94
94
  - README.md
95
95
  - Rakefile
96
- - app/controllers/admin/frozen_posts_controller.rb
97
- - app/controllers/admin/image_reports_controller.rb
98
- - app/controllers/admin/users_controller.rb
96
+ - app/controllers/rails_image_post_solution/admin/frozen_posts_controller.rb
99
97
  - app/controllers/rails_image_post_solution/admin/image_reports_controller.rb
98
+ - app/controllers/rails_image_post_solution/admin/image_reports_controller.rb.bak
99
+ - app/controllers/rails_image_post_solution/admin/users_controller.rb
100
100
  - app/controllers/rails_image_post_solution/image_reports_controller.rb
101
101
  - app/jobs/rails_image_post_solution/image_moderation_job.rb
102
102
  - app/models/rails_image_post_solution/image_report.rb
103
103
  - app/services/rails_image_post_solution/openai_vision_service.rb
104
- - app/views/admin/frozen_posts/index.html.erb
105
- - app/views/admin/image_reports/index.html.erb
106
- - app/views/admin/image_reports/show.html.erb
107
- - app/views/admin/users/index.html.erb
108
- - app/views/admin/users/show.html.erb
104
+ - app/views/rails_image_post_solution/admin/frozen_posts/index.html.erb
109
105
  - app/views/rails_image_post_solution/admin/image_reports/index.html.erb
110
106
  - app/views/rails_image_post_solution/admin/image_reports/show.html.erb
107
+ - app/views/rails_image_post_solution/admin/users/index.html.erb
108
+ - app/views/rails_image_post_solution/admin/users/show.html.erb
111
109
  - app/views/shared/_image_report_button.html.erb
112
110
  - app/views/shared/_image_report_modal.html.erb
113
111
  - config/locales/en.yml
@@ -1,94 +0,0 @@
1
- <div class="admin-container">
2
- <h1 class="admin-header"><%= t('rails_image_post_solution.admin.index.title') %></h1>
3
-
4
- <!-- Statistics -->
5
- <div class="admin-stats">
6
- <div class="stat-card">
7
- <div class="stat-label"><%= t('rails_image_post_solution.admin.index.stats.total') %></div>
8
- <div class="stat-value"><%= @stats[:total] %></div>
9
- </div>
10
- <div class="stat-card pending">
11
- <div class="stat-label"><%= t('rails_image_post_solution.admin.index.stats.pending') %></div>
12
- <div class="stat-value"><%= @stats[:pending] %></div>
13
- </div>
14
- <div class="stat-card confirmed">
15
- <div class="stat-label"><%= t('rails_image_post_solution.admin.index.stats.confirmed') %></div>
16
- <div class="stat-value"><%= @stats[:confirmed] %></div>
17
- </div>
18
- <div class="stat-card dismissed">
19
- <div class="stat-label"><%= t('rails_image_post_solution.admin.index.stats.dismissed') %></div>
20
- <div class="stat-value"><%= @stats[:dismissed] %></div>
21
- </div>
22
- <div class="stat-card reviewed">
23
- <div class="stat-label"><%= t('rails_image_post_solution.admin.index.stats.reviewed') %></div>
24
- <div class="stat-value"><%= @stats[:reviewed] %></div>
25
- </div>
26
- </div>
27
-
28
- <!-- Filters -->
29
- <div class="admin-filters">
30
- <%= link_to t('rails_image_post_solution.admin.index.filters.all'), admin_image_reports_path, class: "filter-btn #{'active' if @status_filter == 'all'}" %>
31
- <%= link_to t('rails_image_post_solution.admin.index.filters.pending'), admin_image_reports_path(status: 'pending'), class: "filter-btn #{'active' if @status_filter == 'pending'}" %>
32
- <%= link_to t('rails_image_post_solution.admin.index.filters.confirmed'), admin_image_reports_path(status: 'confirmed'), class: "filter-btn #{'active' if @status_filter == 'confirmed'}" %>
33
- <%= link_to t('rails_image_post_solution.admin.index.filters.dismissed'), admin_image_reports_path(status: 'dismissed'), class: "filter-btn #{'active' if @status_filter == 'dismissed'}" %>
34
- <%= link_to t('rails_image_post_solution.admin.index.filters.reviewed'), admin_image_reports_path(status: 'reviewed'), class: "filter-btn #{'active' if @status_filter == 'reviewed'}" %>
35
- </div>
36
-
37
- <!-- Reports List -->
38
- <div class="admin-reports-list">
39
- <% if @reports.any? %>
40
- <table class="admin-table">
41
- <thead>
42
- <tr>
43
- <th><%= t('rails_image_post_solution.admin.index.table.image') %></th>
44
- <th><%= t('rails_image_post_solution.admin.index.table.reporter') %></th>
45
- <th><%= t('rails_image_post_solution.admin.index.table.reason') %></th>
46
- <th><%= t('rails_image_post_solution.admin.index.table.status') %></th>
47
- <th><%= t('rails_image_post_solution.admin.index.table.reported_at') %></th>
48
- <th><%= t('rails_image_post_solution.admin.index.table.reviewer') %></th>
49
- <th><%= t('rails_image_post_solution.admin.index.table.actions') %></th>
50
- </tr>
51
- </thead>
52
- <tbody>
53
- <% @reports.each do |report| %>
54
- <tr class="report-row status-<%= report.status %>">
55
- <td class="image-cell">
56
- <% if report.active_storage_attachment.present? %>
57
- <%= image_tag report.active_storage_attachment.blob, class: "admin-thumbnail", style: "max-width: 100px; max-height: 100px;" %>
58
- <% else %>
59
- <span class="text-muted"><%= t('rails_image_post_solution.admin.index.deleted') %></span>
60
- <% end %>
61
- </td>
62
- <td><%= link_to report.user.display_name, user_path(report.user), class: "user-link" %></td>
63
- <td class="reason-cell"><%= truncate(report.reason, length: 50) || t('rails_image_post_solution.admin.index.no_reason') %></td>
64
- <td>
65
- <span class="status-badge status-<%= report.status %>">
66
- <%= t("rails_image_post_solution.image_report.statuses.#{report.status}") %>
67
- </span>
68
- </td>
69
- <td><%= l(report.created_at, format: :long) %></td>
70
- <td>
71
- <% if report.reviewed_by %>
72
- <%= report.reviewed_by.display_name %>
73
- <% else %>
74
- <span class="text-muted">-</span>
75
- <% end %>
76
- </td>
77
- <td class="actions-cell">
78
- <%= link_to t('rails_image_post_solution.admin.index.detail'), admin_image_report_path(report), class: "btn-action btn-detail" %>
79
- </td>
80
- </tr>
81
- <% end %>
82
- </tbody>
83
- </table>
84
- <% else %>
85
- <div class="empty-state">
86
- <p><%= t('rails_image_post_solution.admin.index.no_reports') %></p>
87
- </div>
88
- <% end %>
89
- </div>
90
-
91
- <div class="admin-actions">
92
- <%= link_to t('rails_image_post_solution.admin.index.back'), root_path, class: "btn btn-secondary" %>
93
- </div>
94
- </div>
@@ -1,138 +0,0 @@
1
- <div class="admin-container">
2
- <h1 class="admin-header"><%= t('rails_image_post_solution.admin.show.title') %></h1>
3
-
4
- <div class="report-detail">
5
- <!-- Image Display -->
6
- <div class="detail-section">
7
- <h3><%= t('rails_image_post_solution.admin.show.reported_image') %></h3>
8
- <% if @attachment.present? %>
9
- <div class="reported-image-container">
10
- <%= image_tag @attachment.blob, class: "reported-image-large", style: "max-width: 800px; max-height: 600px;" %>
11
- </div>
12
- <% else %>
13
- <p class="text-muted"><%= t('rails_image_post_solution.admin.show.image_deleted') %></p>
14
- <% end %>
15
- </div>
16
-
17
- <!-- Report Information -->
18
- <div class="detail-section">
19
- <h3><%= t('rails_image_post_solution.admin.show.report_info') %></h3>
20
- <table class="detail-table">
21
- <tr>
22
- <th><%= t('rails_image_post_solution.admin.show.status') %></th>
23
- <td>
24
- <span class="status-badge status-<%= @report.status %>">
25
- <%= t("rails_image_post_solution.image_report.statuses.#{@report.status}") %>
26
- </span>
27
- </td>
28
- </tr>
29
- <tr>
30
- <th><%= t('rails_image_post_solution.admin.show.reporter') %></th>
31
- <td><%= link_to @report.user.display_name, user_path(@report.user), class: "user-link" %></td>
32
- </tr>
33
- <tr>
34
- <th><%= t('rails_image_post_solution.admin.show.reason') %></th>
35
- <td><%= simple_format(@report.reason) || t('rails_image_post_solution.admin.show.no_reason') %></td>
36
- </tr>
37
- <tr>
38
- <th><%= t('rails_image_post_solution.admin.show.reported_at') %></th>
39
- <td><%= l(@report.created_at, format: :long) %></td>
40
- </tr>
41
- <% if @report.reviewed_by %>
42
- <tr>
43
- <th><%= t('rails_image_post_solution.admin.show.reviewer') %></th>
44
- <td><%= @report.reviewed_by.display_name %></td>
45
- </tr>
46
- <tr>
47
- <th><%= t('rails_image_post_solution.admin.show.reviewed_at') %></th>
48
- <td><%= l(@report.reviewed_at, format: :long) %></td>
49
- </tr>
50
- <% end %>
51
- </table>
52
- </div>
53
-
54
- <!-- Image Poster Information -->
55
- <% if @reported_user %>
56
- <div class="detail-section">
57
- <h3><%= t('rails_image_post_solution.admin.show.image_poster') %></h3>
58
- <table class="detail-table">
59
- <tr>
60
- <th><%= t('rails_image_post_solution.admin.show.username') %></th>
61
- <td><%= link_to @reported_user.display_name, user_path(@reported_user), class: "user-link" %></td>
62
- </tr>
63
- <tr>
64
- <th><%= t('rails_image_post_solution.admin.show.user_status') %></th>
65
- <td>
66
- <% if @reported_user.banned? %>
67
- <span class="user-status-badge banned"><%= t('rails_image_post_solution.admin.show.banned') %></span>
68
- <% elsif @reported_user.suspended? %>
69
- <span class="user-status-badge suspended"><%= t('rails_image_post_solution.admin.show.suspended') %></span>
70
- <% else %>
71
- <span class="user-status-badge active"><%= t('rails_image_post_solution.admin.show.active') %></span>
72
- <% end %>
73
- </td>
74
- </tr>
75
- </table>
76
- </div>
77
- <% end %>
78
-
79
- <!-- Other Reports for Same Image -->
80
- <div class="detail-section">
81
- <h3><%= t('rails_image_post_solution.admin.show.all_reports_title', count: @all_reports.count) %></h3>
82
- <% if @all_reports.count > 1 %>
83
- <table class="admin-table">
84
- <thead>
85
- <tr>
86
- <th><%= t('rails_image_post_solution.admin.index.table.reporter') %></th>
87
- <th><%= t('rails_image_post_solution.admin.index.table.reason') %></th>
88
- <th><%= t('rails_image_post_solution.admin.index.table.status') %></th>
89
- <th><%= t('rails_image_post_solution.admin.index.table.reported_at') %></th>
90
- </tr>
91
- </thead>
92
- <tbody>
93
- <% @all_reports.each do |r| %>
94
- <tr class="<%= 'current-report' if r.id == @report.id %>">
95
- <td>
96
- <%= link_to r.user.display_name, user_path(r.user), class: "user-link" %>
97
- <% if r.id == @report.id %>
98
- <span class="badge-current"><%= t('rails_image_post_solution.admin.show.current') %></span>
99
- <% end %>
100
- </td>
101
- <td><%= truncate(r.reason, length: 50) || t('rails_image_post_solution.admin.index.no_reason') %></td>
102
- <td>
103
- <span class="status-badge status-<%= r.status %>">
104
- <%= t("rails_image_post_solution.image_report.statuses.#{r.status}") %>
105
- </span>
106
- </td>
107
- <td><%= l(r.created_at, format: :long) %></td>
108
- </tr>
109
- <% end %>
110
- </tbody>
111
- </table>
112
- <% else %>
113
- <p class="text-muted"><%= t('rails_image_post_solution.admin.show.single_report') %></p>
114
- <% end %>
115
- </div>
116
-
117
- <!-- Actions -->
118
- <div class="detail-actions">
119
- <% if @report.status == ImageReport::STATUSES[:pending] %>
120
- <%= button_to t('rails_image_post_solution.admin.show.confirm_button'), confirm_admin_image_report_path(@report), method: :patch, class: "btn btn-danger", data: { turbo_confirm: t('rails_image_post_solution.admin.show.confirm_action') } %>
121
- <%= button_to t('rails_image_post_solution.admin.show.dismiss_button'), dismiss_admin_image_report_path(@report), method: :patch, class: "btn btn-success", data: { turbo_confirm: t('rails_image_post_solution.admin.show.dismiss_action') } %>
122
- <% else %>
123
- <p class="text-muted"><%= t('rails_image_post_solution.admin.show.already_reviewed') %></p>
124
- <% end %>
125
-
126
- <% if @reported_user && @reported_user.active? %>
127
- <div class="user-actions">
128
- <h4><%= t('rails_image_post_solution.admin.show.user_actions') %></h4>
129
- <%= link_to t('rails_image_post_solution.admin.show.view_user_admin'), admin_user_path(@reported_user), class: "btn btn-secondary" %>
130
- </div>
131
- <% end %>
132
- </div>
133
- </div>
134
-
135
- <div class="admin-actions">
136
- <%= link_to t('rails_image_post_solution.admin.show.back_to_list'), admin_image_reports_path, class: "btn btn-default" %>
137
- </div>
138
- </div>