rails-image-post-solution 0.1.25 → 0.1.27
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/README.md +158 -25
- data/app/views/rails_image_post_solution/admin/frozen_posts/index.html.erb +83 -83
- data/config/routes.rb +30 -31
- data/lib/rails_image_post_solution/engine.rb +8 -3
- data/lib/rails_image_post_solution/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bc9e3914820aa23b6ad617eed7f8c27e3be5a62957861beeafab4e646bf76717
|
|
4
|
+
data.tar.gz: 7ffe366b6d5c1863c949949d718a73efe76b7a776e8bc8e26db4dcf4b0b58f58
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5fe7e0e0bb33daf2713a5dbd8a15c112afce7e9b03e1bb6935cc3047a1e268ef2c0776c651defd78867e8042d5dd3889fee556fb1aa84cc95a9b98f3cdfcb788
|
|
7
|
+
data.tar.gz: 6694496e85862431e4e18e7ed97da31b3e5b6a0f03d8a1067c5d46c8c41ca4ec7c4989375580c85ce8d9d866afcabdd1be9b089bd781d99930858e20afc1649e
|
data/README.md
CHANGED
|
@@ -20,6 +20,11 @@ A comprehensive Rails engine for image reporting, AI-powered moderation using Op
|
|
|
20
20
|
- **Frozen Posts Management**: Review, unfreeze, or permanently freeze flagged content
|
|
21
21
|
- **Enhanced Reporting**: Extended admin views with detailed statistics
|
|
22
22
|
|
|
23
|
+
### Internationalization
|
|
24
|
+
- **Full i18n Support**: Seamlessly integrates with locale-scoped routes
|
|
25
|
+
- **15+ Languages**: Supports ja, en, ko, zh-CN, zh-TW, es, fr, de, ru, th, vi, id, pt, tr, it
|
|
26
|
+
- **Automatic Locale Handling**: Works with your application's locale configuration
|
|
27
|
+
|
|
23
28
|
## Requirements
|
|
24
29
|
|
|
25
30
|
- Ruby >= 3.4.7
|
|
@@ -60,6 +65,22 @@ rails db:migrate
|
|
|
60
65
|
|
|
61
66
|
Mount the engine in your `config/routes.rb`:
|
|
62
67
|
|
|
68
|
+
**For applications WITH locale-scoped routes:**
|
|
69
|
+
|
|
70
|
+
```ruby
|
|
71
|
+
Rails.application.routes.draw do
|
|
72
|
+
# Wrap all routes including the engine mount in a locale scope
|
|
73
|
+
scope "(:locale)", locale: /[a-z]{2}(-[A-Z]{2})?/ do
|
|
74
|
+
# Mount the engine - all admin features will be accessible at /:locale/moderation/admin/*
|
|
75
|
+
mount RailsImagePostSolution::Engine => "/moderation"
|
|
76
|
+
|
|
77
|
+
# ... your other routes
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**For applications WITHOUT locale-scoped routes:**
|
|
83
|
+
|
|
63
84
|
```ruby
|
|
64
85
|
Rails.application.routes.draw do
|
|
65
86
|
# Mount the engine - all admin features will be accessible at /moderation/admin/*
|
|
@@ -69,6 +90,8 @@ Rails.application.routes.draw do
|
|
|
69
90
|
end
|
|
70
91
|
```
|
|
71
92
|
|
|
93
|
+
**Important**: The engine itself does NOT add locale scoping to its internal routes. Locale handling should be done at the mount level in the host application's routes file.
|
|
94
|
+
|
|
72
95
|
## Configuration
|
|
73
96
|
|
|
74
97
|
Edit `config/initializers/rails_image_post_solution.rb`:
|
|
@@ -140,7 +163,14 @@ The provided partials include:
|
|
|
140
163
|
Admins can access the dashboard at:
|
|
141
164
|
|
|
142
165
|
```
|
|
166
|
+
# Without locale
|
|
143
167
|
/moderation/admin/image_reports
|
|
168
|
+
|
|
169
|
+
# With locale (if using locale-scoped routes)
|
|
170
|
+
/ja/moderation/admin/image_reports
|
|
171
|
+
/en/moderation/admin/image_reports
|
|
172
|
+
/de/moderation/admin/image_reports
|
|
173
|
+
# ... etc
|
|
144
174
|
```
|
|
145
175
|
|
|
146
176
|
Features:
|
|
@@ -149,6 +179,7 @@ Features:
|
|
|
149
179
|
- View detailed information about each report
|
|
150
180
|
- Mark reports as confirmed (inappropriate) or dismissed (safe)
|
|
151
181
|
- View AI moderation results
|
|
182
|
+
- Multi-language support (automatically uses your application's current locale)
|
|
152
183
|
|
|
153
184
|
### AI Moderation
|
|
154
185
|
|
|
@@ -300,46 +331,129 @@ The engine provides the following routes when mounted at `/moderation`:
|
|
|
300
331
|
|
|
301
332
|
### Using Route Helpers
|
|
302
333
|
|
|
303
|
-
The engine automatically makes route helpers available in your application
|
|
334
|
+
The engine automatically makes route helpers available in your application:
|
|
304
335
|
|
|
336
|
+
**In host application views/controllers** (accessing host app routes):
|
|
305
337
|
```ruby
|
|
306
|
-
#
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
338
|
+
# Use main_app prefix to access host application routes
|
|
339
|
+
main_app.root_path(locale: I18n.locale) # => /ja/
|
|
340
|
+
main_app.stages_path(locale: I18n.locale) # => /ja/stages
|
|
341
|
+
main_app.user_path(@user, locale: I18n.locale) # => /ja/users/:id
|
|
342
|
+
```
|
|
310
343
|
|
|
311
|
-
|
|
312
|
-
|
|
344
|
+
**Accessing engine routes from host application:**
|
|
345
|
+
```ruby
|
|
346
|
+
# Use engine namespace
|
|
347
|
+
rails_image_post_solution.admin_image_reports_path # => /moderation/admin/image_reports (or /ja/moderation/admin/image_reports)
|
|
348
|
+
rails_image_post_solution.admin_user_path(@user) # => /moderation/admin/users/:id
|
|
349
|
+
rails_image_post_solution.image_reports_path # => /moderation/image_reports
|
|
350
|
+
|
|
351
|
+
# In locale-scoped applications, locale is automatically included via mount point
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
**In engine views/controllers:**
|
|
355
|
+
```ruby
|
|
356
|
+
# Engine routes (no prefix needed within engine)
|
|
357
|
+
admin_image_reports_path # => /admin/image_reports
|
|
358
|
+
admin_user_path(id: @user.id) # => /admin/users/:id
|
|
359
|
+
|
|
360
|
+
# Host app routes (use main_app prefix)
|
|
361
|
+
main_app.root_path(locale: I18n.locale) # => /ja/
|
|
313
362
|
```
|
|
314
363
|
|
|
315
364
|
### User-Facing Routes
|
|
316
365
|
|
|
317
366
|
```
|
|
318
|
-
POST /moderation/image_reports # Create report
|
|
367
|
+
POST (/:locale)/moderation/image_reports # Create report
|
|
319
368
|
```
|
|
320
369
|
|
|
321
370
|
### Admin Routes
|
|
322
371
|
|
|
372
|
+
**Image Reports:**
|
|
373
|
+
```
|
|
374
|
+
GET (/:locale)/moderation/admin/image_reports # List all reports
|
|
375
|
+
GET (/:locale)/moderation/admin/image_reports/:id # View report details
|
|
376
|
+
PATCH (/:locale)/moderation/admin/image_reports/:id/confirm # Mark as inappropriate
|
|
377
|
+
PATCH (/:locale)/moderation/admin/image_reports/:id/dismiss # Mark as safe
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
**User Management:**
|
|
381
|
+
```
|
|
382
|
+
GET (/:locale)/moderation/admin/users # List all users
|
|
383
|
+
GET (/:locale)/moderation/admin/users/:id # View user details
|
|
384
|
+
POST (/:locale)/moderation/admin/users/:id/suspend # Suspend user
|
|
385
|
+
POST (/:locale)/moderation/admin/users/:id/unsuspend # Unsuspend user
|
|
386
|
+
POST (/:locale)/moderation/admin/users/:id/ban # Ban user
|
|
387
|
+
POST (/:locale)/moderation/admin/users/:id/unban # Unban user
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
**Frozen Posts:**
|
|
323
391
|
```
|
|
324
|
-
GET /moderation/admin/
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
POST /moderation/admin/users/:id/unsuspend # Unsuspend user
|
|
332
|
-
POST /moderation/admin/users/:id/ban # Ban user
|
|
333
|
-
POST /moderation/admin/users/:id/unban # Unban user
|
|
334
|
-
GET /moderation/admin/frozen_posts # List frozen posts
|
|
335
|
-
POST /moderation/admin/frozen_posts/unfreeze_stage/:id # Unfreeze a stage
|
|
336
|
-
POST /moderation/admin/frozen_posts/unfreeze_comment/:id # Unfreeze a comment
|
|
337
|
-
POST /moderation/admin/frozen_posts/permanent_freeze_stage/:id # Permanently freeze a stage
|
|
338
|
-
POST /moderation/admin/frozen_posts/permanent_freeze_comment/:id # Permanently freeze a comment
|
|
339
|
-
DELETE /moderation/admin/frozen_posts/destroy_stage/:id # Delete a frozen stage
|
|
340
|
-
DELETE /moderation/admin/frozen_posts/destroy_comment/:id # Delete a frozen comment
|
|
392
|
+
GET (/:locale)/moderation/admin/frozen_posts # List frozen posts
|
|
393
|
+
POST (/:locale)/moderation/admin/frozen_posts/unfreeze_stage/:id # Unfreeze a stage
|
|
394
|
+
POST (/:locale)/moderation/admin/frozen_posts/unfreeze_comment/:id # Unfreeze a comment
|
|
395
|
+
POST (/:locale)/moderation/admin/frozen_posts/permanent_freeze_stage/:id # Permanently freeze a stage
|
|
396
|
+
POST (/:locale)/moderation/admin/frozen_posts/permanent_freeze_comment/:id # Permanently freeze a comment
|
|
397
|
+
DELETE (/:locale)/moderation/admin/frozen_posts/destroy_stage/:id # Delete a frozen stage
|
|
398
|
+
DELETE (/:locale)/moderation/admin/frozen_posts/destroy_comment/:id # Delete a frozen comment
|
|
341
399
|
```
|
|
342
400
|
|
|
401
|
+
Note: `(/:locale)` means the locale parameter is optional and depends on your application's routing configuration.
|
|
402
|
+
|
|
403
|
+
## Internationalization (i18n)
|
|
404
|
+
|
|
405
|
+
### Supported Languages
|
|
406
|
+
|
|
407
|
+
The engine includes translations for 15 languages:
|
|
408
|
+
- 🇯🇵 Japanese (ja)
|
|
409
|
+
- 🇺🇸 English (en)
|
|
410
|
+
- 🇰🇷 Korean (ko)
|
|
411
|
+
- 🇨🇳 Simplified Chinese (zh-CN)
|
|
412
|
+
- 🇹🇼 Traditional Chinese (zh-TW)
|
|
413
|
+
- 🇪🇸 Spanish (es)
|
|
414
|
+
- 🇫🇷 French (fr)
|
|
415
|
+
- 🇩🇪 German (de)
|
|
416
|
+
- 🇷🇺 Russian (ru)
|
|
417
|
+
- 🇹🇭 Thai (th)
|
|
418
|
+
- 🇻🇳 Vietnamese (vi)
|
|
419
|
+
- 🇮🇩 Indonesian (id)
|
|
420
|
+
- 🇵🇹 Portuguese (pt)
|
|
421
|
+
- 🇹🇷 Turkish (tr)
|
|
422
|
+
- 🇮🇹 Italian (it)
|
|
423
|
+
|
|
424
|
+
### Locale Configuration
|
|
425
|
+
|
|
426
|
+
The engine automatically uses your application's `I18n.locale`. To configure available locales in your host application:
|
|
427
|
+
|
|
428
|
+
```ruby
|
|
429
|
+
# config/application.rb
|
|
430
|
+
config.i18n.available_locales = [:ja, :en, :ko, :zh_CN, :zh_TW, :es, :fr, :de, :ru, :th, :vi, :id, :pt, :tr, :it]
|
|
431
|
+
config.i18n.default_locale = :ja
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### Language Switching in Views
|
|
435
|
+
|
|
436
|
+
When implementing language switching in your application header, use this pattern to preserve the current path with different locales:
|
|
437
|
+
|
|
438
|
+
```erb
|
|
439
|
+
<% I18n.available_locales.each do |locale| %>
|
|
440
|
+
<%
|
|
441
|
+
# Preserve query parameters but replace locale in the path
|
|
442
|
+
new_path = request.path.sub(%r{^/([a-z]{2}(-[A-Z]{2})?)(/|$)}, "/#{locale}\\3")
|
|
443
|
+
|
|
444
|
+
# If path doesn't start with a locale, add one
|
|
445
|
+
unless request.path.match?(%r{^/[a-z]{2}(-[A-Z]{2})?(/|$)})
|
|
446
|
+
new_path = "/#{locale}#{request.path}"
|
|
447
|
+
end
|
|
448
|
+
|
|
449
|
+
new_path += "?#{request.query_string}" if request.query_string.present?
|
|
450
|
+
%>
|
|
451
|
+
<%= link_to t("languages.#{locale}"), new_path, class: "language-menu-item #{'active' if I18n.locale == locale}" %>
|
|
452
|
+
<% end %>
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
This ensures that users can switch languages while staying on the same page, whether they're in the host application or the engine's admin pages.
|
|
456
|
+
|
|
343
457
|
## Customization
|
|
344
458
|
|
|
345
459
|
### Custom Admin Check
|
|
@@ -373,6 +487,25 @@ class CustomImageModerationJob < RailsImagePostSolution::ImageModerationJob
|
|
|
373
487
|
end
|
|
374
488
|
```
|
|
375
489
|
|
|
490
|
+
### Custom Locale Management
|
|
491
|
+
|
|
492
|
+
The engine respects your application's locale configuration. If you need custom locale handling:
|
|
493
|
+
|
|
494
|
+
```ruby
|
|
495
|
+
# app/controllers/application_controller.rb
|
|
496
|
+
class ApplicationController < ActionController::Base
|
|
497
|
+
before_action :set_locale
|
|
498
|
+
|
|
499
|
+
def set_locale
|
|
500
|
+
I18n.locale = params[:locale] || I18n.default_locale
|
|
501
|
+
end
|
|
502
|
+
|
|
503
|
+
def default_url_options
|
|
504
|
+
{ locale: I18n.locale }
|
|
505
|
+
end
|
|
506
|
+
end
|
|
507
|
+
```
|
|
508
|
+
|
|
376
509
|
## Database Schema
|
|
377
510
|
|
|
378
511
|
The gem creates one table: `image_reports`
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
|
|
20
20
|
<!-- Filters -->
|
|
21
21
|
<div class="admin-filters">
|
|
22
|
-
<%= link_to t('admin.frozen_posts.index.filters.all'), admin_frozen_posts_path, class: "filter-btn #{'active' if @filter == 'all'}" %>
|
|
23
|
-
<%= link_to t('admin.frozen_posts.index.filters.temporary'), admin_frozen_posts_path(filter: "temporary"), class: "filter-btn #{'active' if @filter == 'temporary'}" %>
|
|
24
|
-
<%= link_to t('admin.frozen_posts.index.filters.permanent'), admin_frozen_posts_path(filter: "permanent"), class: "filter-btn #{'active' if @filter == 'permanent'}" %>
|
|
22
|
+
<%= link_to t('admin.frozen_posts.index.filters.all'), rails_image_post_solution.admin_frozen_posts_path, class: "filter-btn #{'active' if @filter == 'all'}" %>
|
|
23
|
+
<%= link_to t('admin.frozen_posts.index.filters.temporary'), rails_image_post_solution.admin_frozen_posts_path(filter: "temporary"), class: "filter-btn #{'active' if @filter == 'temporary'}" %>
|
|
24
|
+
<%= link_to t('admin.frozen_posts.index.filters.permanent'), rails_image_post_solution.admin_frozen_posts_path(filter: "permanent"), class: "filter-btn #{'active' if @filter == 'permanent'}" %>
|
|
25
25
|
</div>
|
|
26
26
|
|
|
27
27
|
<!-- Frozen Posts List -->
|
|
@@ -29,90 +29,90 @@
|
|
|
29
29
|
<% if @frozen_posts.any? %>
|
|
30
30
|
<table class="admin-table">
|
|
31
31
|
<thead>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
<tr>
|
|
33
|
+
<th><%= t('admin.frozen_posts.index.table.type') %></th>
|
|
34
|
+
<th><%= t('admin.frozen_posts.index.table.content') %></th>
|
|
35
|
+
<th><%= t('admin.frozen_posts.index.table.poster') %></th>
|
|
36
|
+
<th><%= t('admin.frozen_posts.index.table.freeze_reason') %></th>
|
|
37
|
+
<th><%= t('admin.frozen_posts.index.table.status') %></th>
|
|
38
|
+
<th><%= t('admin.frozen_posts.index.table.frozen_at') %></th>
|
|
39
|
+
<th><%= t('admin.frozen_posts.index.table.actions') %></th>
|
|
40
|
+
</tr>
|
|
41
41
|
</thead>
|
|
42
42
|
<tbody>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
<% @frozen_posts.each do |post| %>
|
|
44
|
+
<tr class="report-row status-<%= post.frozen_type %>">
|
|
45
|
+
<td>
|
|
46
|
+
<% if post.is_a?(Stage) %>
|
|
47
|
+
<span class="post-type-badge stage"><%= t('admin.frozen_posts.index.post_types.stage') %></span>
|
|
48
|
+
<% else %>
|
|
49
|
+
<span class="post-type-badge comment"><%= t('admin.frozen_posts.index.post_types.comment') %></span>
|
|
50
|
+
<% end %>
|
|
51
|
+
</td>
|
|
52
|
+
<td class="content-cell">
|
|
53
|
+
<% if post.is_a?(Stage) %>
|
|
54
|
+
<div class="post-title"><%= link_to post.title, stage_path(post, locale: I18n.locale), target: "_blank", class: "user-link" %></div>
|
|
55
|
+
<div class="post-excerpt"><%= truncate(post.description, length: 80) %></div>
|
|
56
|
+
<% else %>
|
|
57
|
+
<div class="post-title">
|
|
58
|
+
<%= link_to "#{t('admin.frozen_posts.index.comment_prefix')}: #{post.multiplay_recruitment.title}", multiplay_recruitment_path(post.multiplay_recruitment, locale: I18n.locale), target: "_blank", class: "user-link" %>
|
|
59
|
+
</div>
|
|
60
|
+
<div class="post-excerpt"><%= truncate(post.content, length: 80) %></div>
|
|
61
|
+
<% end %>
|
|
62
|
+
</td>
|
|
63
|
+
<td>
|
|
64
|
+
<%= link_to post.user.display_name, rails_image_post_solution.admin_user_path(id: post.user.id), class: "user-link" %>
|
|
65
|
+
</td>
|
|
66
|
+
<td class="reason-cell">
|
|
67
|
+
<%= truncate(post.frozen_reason, length: 100) %>
|
|
68
|
+
</td>
|
|
69
|
+
<td>
|
|
70
|
+
<% if post.temporarily_frozen? %>
|
|
71
|
+
<span class="status-badge status-pending"><%= t('admin.frozen_posts.index.status_badges.temporary') %></span>
|
|
72
|
+
<% elsif post.permanently_frozen? %>
|
|
73
|
+
<span class="status-badge status-confirmed"><%= t('admin.frozen_posts.index.status_badges.permanent') %></span>
|
|
74
|
+
<% end %>
|
|
75
|
+
</td>
|
|
76
|
+
<td>
|
|
77
|
+
<%= l(post.frozen_at, format: :long) %>
|
|
78
|
+
</td>
|
|
79
|
+
<td class="actions-cell">
|
|
80
|
+
<div class="action-buttons">
|
|
53
81
|
<% if post.is_a?(Stage) %>
|
|
54
|
-
|
|
55
|
-
|
|
82
|
+
<% unless post.permanently_frozen? %>
|
|
83
|
+
<%= button_to t('admin.frozen_posts.index.actions.permanent_freeze'), rails_image_post_solution.permanent_freeze_stage_admin_frozen_posts_path(id: post.id),
|
|
84
|
+
method: :post,
|
|
85
|
+
class: "btn-action btn-warning",
|
|
86
|
+
data: { confirm: t('admin.frozen_posts.index.confirm.permanent_freeze') } %>
|
|
87
|
+
<% end %>
|
|
88
|
+
<%= button_to t('admin.frozen_posts.index.actions.unfreeze'), rails_image_post_solution.unfreeze_stage_admin_frozen_posts_path(id: post.id),
|
|
89
|
+
method: :post,
|
|
90
|
+
class: "btn-action btn-success",
|
|
91
|
+
data: { confirm: t('admin.frozen_posts.index.confirm.unfreeze') } %>
|
|
92
|
+
<%= button_to t('admin.frozen_posts.index.actions.delete'), rails_image_post_solution.destroy_stage_admin_frozen_posts_path(id: post.id),
|
|
93
|
+
method: :delete,
|
|
94
|
+
class: "btn-action btn-danger",
|
|
95
|
+
data: { confirm: t('admin.frozen_posts.index.confirm.delete') } %>
|
|
56
96
|
<% else %>
|
|
57
|
-
|
|
58
|
-
<%=
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
</td>
|
|
63
|
-
<td>
|
|
64
|
-
<%= link_to post.user.display_name, admin_user_path(id: post.user.id), class: "user-link" %>
|
|
65
|
-
</td>
|
|
66
|
-
<td class="reason-cell">
|
|
67
|
-
<%= truncate(post.frozen_reason, length: 100) %>
|
|
68
|
-
</td>
|
|
69
|
-
<td>
|
|
70
|
-
<% if post.temporarily_frozen? %>
|
|
71
|
-
<span class="status-badge status-pending"><%= t('admin.frozen_posts.index.status_badges.temporary') %></span>
|
|
72
|
-
<% elsif post.permanently_frozen? %>
|
|
73
|
-
<span class="status-badge status-confirmed"><%= t('admin.frozen_posts.index.status_badges.permanent') %></span>
|
|
74
|
-
<% end %>
|
|
75
|
-
</td>
|
|
76
|
-
<td>
|
|
77
|
-
<%= l(post.frozen_at, format: :long) %>
|
|
78
|
-
</td>
|
|
79
|
-
<td class="actions-cell">
|
|
80
|
-
<div class="action-buttons">
|
|
81
|
-
<% if post.is_a?(Stage) %>
|
|
82
|
-
<% unless post.permanently_frozen? %>
|
|
83
|
-
<%= button_to t('admin.frozen_posts.index.actions.permanent_freeze'), admin_frozen_posts_permanent_freeze_stage_path(id: post.id),
|
|
84
|
-
method: :patch,
|
|
85
|
-
class: "btn-action btn-warning",
|
|
86
|
-
data: { confirm: t('admin.frozen_posts.index.confirm.permanent_freeze') } %>
|
|
87
|
-
<% end %>
|
|
88
|
-
<%= button_to t('admin.frozen_posts.index.actions.unfreeze'), admin_frozen_posts_unfreeze_stage_path(id: post.id),
|
|
89
|
-
method: :patch,
|
|
90
|
-
class: "btn-action btn-success",
|
|
91
|
-
data: { confirm: t('admin.frozen_posts.index.confirm.unfreeze') } %>
|
|
92
|
-
<%= button_to t('admin.frozen_posts.index.actions.delete'), admin_frozen_posts_destroy_stage_path(id: post.id),
|
|
93
|
-
method: :delete,
|
|
94
|
-
class: "btn-action btn-danger",
|
|
95
|
-
data: { confirm: t('admin.frozen_posts.index.confirm.delete') } %>
|
|
96
|
-
<% else %>
|
|
97
|
-
<% unless post.permanently_frozen? %>
|
|
98
|
-
<%= button_to t('admin.frozen_posts.index.actions.permanent_freeze'), admin_frozen_posts_permanent_freeze_comment_path(id: post.id),
|
|
99
|
-
method: :patch,
|
|
100
|
-
class: "btn-action btn-warning",
|
|
101
|
-
data: { confirm: t('admin.frozen_posts.index.confirm.permanent_freeze') } %>
|
|
102
|
-
<% end %>
|
|
103
|
-
<%= button_to t('admin.frozen_posts.index.actions.unfreeze'), admin_frozen_posts_unfreeze_comment_path(id: post.id),
|
|
104
|
-
method: :patch,
|
|
105
|
-
class: "btn-action btn-success",
|
|
106
|
-
data: { confirm: t('admin.frozen_posts.index.confirm.unfreeze') } %>
|
|
107
|
-
<%= button_to t('admin.frozen_posts.index.actions.delete'), admin_frozen_posts_destroy_comment_path(id: post.id),
|
|
108
|
-
method: :delete,
|
|
109
|
-
class: "btn-action btn-danger",
|
|
110
|
-
data: { confirm: t('admin.frozen_posts.index.confirm.delete') } %>
|
|
97
|
+
<% unless post.permanently_frozen? %>
|
|
98
|
+
<%= button_to t('admin.frozen_posts.index.actions.permanent_freeze'), rails_image_post_solution.permanent_freeze_comment_admin_frozen_posts_path(id: post.id),
|
|
99
|
+
method: :post,
|
|
100
|
+
class: "btn-action btn-warning",
|
|
101
|
+
data: { confirm: t('admin.frozen_posts.index.confirm.permanent_freeze') } %>
|
|
111
102
|
<% end %>
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
103
|
+
<%= button_to t('admin.frozen_posts.index.actions.unfreeze'), rails_image_post_solution.unfreeze_comment_admin_frozen_posts_path(id: post.id),
|
|
104
|
+
method: :post,
|
|
105
|
+
class: "btn-action btn-success",
|
|
106
|
+
data: { confirm: t('admin.frozen_posts.index.confirm.unfreeze') } %>
|
|
107
|
+
<%= button_to t('admin.frozen_posts.index.actions.delete'), rails_image_post_solution.destroy_comment_admin_frozen_posts_path(id: post.id),
|
|
108
|
+
method: :delete,
|
|
109
|
+
class: "btn-action btn-danger",
|
|
110
|
+
data: { confirm: t('admin.frozen_posts.index.confirm.delete') } %>
|
|
111
|
+
<% end %>
|
|
112
|
+
</div>
|
|
113
|
+
</td>
|
|
114
|
+
</tr>
|
|
115
|
+
<% end %>
|
|
116
116
|
</tbody>
|
|
117
117
|
</table>
|
|
118
118
|
<% else %>
|
|
@@ -123,6 +123,6 @@
|
|
|
123
123
|
</div>
|
|
124
124
|
|
|
125
125
|
<div class="admin-actions">
|
|
126
|
-
<%= link_to t('admin.frozen_posts.index.back'), root_path, class: "btn btn-secondary" %>
|
|
126
|
+
<%= link_to t('admin.frozen_posts.index.back'), main_app.root_path(locale: I18n.locale), class: "btn btn-secondary" %>
|
|
127
127
|
</div>
|
|
128
128
|
</div>
|
data/config/routes.rb
CHANGED
|
@@ -1,42 +1,41 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
RailsImagePostSolution::Engine.routes.draw do
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
scope "(:locale)", locale: /[a-z]{2}/ do
|
|
7
|
-
# User-facing report API
|
|
8
|
-
resources :image_reports, only: [ :create ]
|
|
4
|
+
# Locale parameter is handled by the host application at mount level
|
|
5
|
+
# No need for locale scope within the engine itself
|
|
9
6
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
# User-facing report API
|
|
8
|
+
resources :image_reports, only: [ :create ]
|
|
9
|
+
|
|
10
|
+
# Admin dashboard (engine controllers)
|
|
11
|
+
namespace :admin do
|
|
12
|
+
# Image reports management
|
|
13
|
+
resources :image_reports, only: %i[index show] do
|
|
14
|
+
member do
|
|
15
|
+
patch :confirm
|
|
16
|
+
patch :dismiss
|
|
18
17
|
end
|
|
18
|
+
end
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
end
|
|
20
|
+
# User management
|
|
21
|
+
resources :users, only: %i[index show] do
|
|
22
|
+
member do
|
|
23
|
+
post :suspend
|
|
24
|
+
post :unsuspend
|
|
25
|
+
post :ban
|
|
26
|
+
post :unban
|
|
28
27
|
end
|
|
28
|
+
end
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
end
|
|
30
|
+
# Frozen posts management
|
|
31
|
+
resources :frozen_posts, only: [ :index ] do
|
|
32
|
+
collection do
|
|
33
|
+
post "unfreeze_stage/:id", to: "frozen_posts#unfreeze_stage", as: :unfreeze_stage
|
|
34
|
+
post "unfreeze_comment/:id", to: "frozen_posts#unfreeze_comment", as: :unfreeze_comment
|
|
35
|
+
post "permanent_freeze_stage/:id", to: "frozen_posts#permanent_freeze_stage", as: :permanent_freeze_stage
|
|
36
|
+
post "permanent_freeze_comment/:id", to: "frozen_posts#permanent_freeze_comment", as: :permanent_freeze_comment
|
|
37
|
+
delete "destroy_stage/:id", to: "frozen_posts#destroy_stage", as: :destroy_stage
|
|
38
|
+
delete "destroy_comment/:id", to: "frozen_posts#destroy_comment", as: :destroy_comment
|
|
40
39
|
end
|
|
41
40
|
end
|
|
42
41
|
end
|
|
@@ -14,10 +14,15 @@ module RailsImagePostSolution
|
|
|
14
14
|
#{root}/app/controllers
|
|
15
15
|
]
|
|
16
16
|
|
|
17
|
-
# Prepend view paths so engine views are found
|
|
18
|
-
initializer "rails_image_post_solution.view_paths" do
|
|
17
|
+
# Prepend view paths so engine views are found from host app
|
|
18
|
+
initializer "rails_image_post_solution.view_paths", before: :load_config_initializers do |app|
|
|
19
|
+
# Add engine views to all view paths
|
|
19
20
|
ActiveSupport.on_load(:action_controller) do
|
|
20
|
-
|
|
21
|
+
append_view_path RailsImagePostSolution::Engine.root.join("app", "views")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
ActiveSupport.on_load(:action_view) do
|
|
25
|
+
ActionView::Base.prepend_view_path RailsImagePostSolution::Engine.root.join("app", "views")
|
|
21
26
|
end
|
|
22
27
|
end
|
|
23
28
|
|