content_flagging 1.0.1 → 1.0.2
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/CHANGELOG.md +43 -0
- data/README.md +21 -2
- data/content_flagging.gemspec +14 -6
- data/lib/content_flagging/version.rb +1 -1
- metadata +15 -77
- data/dummy_app/.dockerignore +0 -37
- data/dummy_app/.ruby-version +0 -1
- data/dummy_app/Dockerfile +0 -62
- data/dummy_app/Gemfile +0 -65
- data/dummy_app/Gemfile.lock +0 -286
- data/dummy_app/README.md +0 -24
- data/dummy_app/Rakefile +0 -6
- data/dummy_app/app/assets/config/manifest.js +0 -2
- data/dummy_app/app/assets/images/.keep +0 -0
- data/dummy_app/app/assets/stylesheets/application.css +0 -15
- data/dummy_app/app/channels/application_cable/channel.rb +0 -4
- data/dummy_app/app/channels/application_cable/connection.rb +0 -4
- data/dummy_app/app/controllers/application_controller.rb +0 -2
- data/dummy_app/app/controllers/concerns/.keep +0 -0
- data/dummy_app/app/helpers/application_helper.rb +0 -2
- data/dummy_app/app/jobs/application_job.rb +0 -7
- data/dummy_app/app/mailers/application_mailer.rb +0 -4
- data/dummy_app/app/models/application_record.rb +0 -3
- data/dummy_app/app/models/concerns/.keep +0 -0
- data/dummy_app/app/models/post.rb +0 -3
- data/dummy_app/app/models/user.rb +0 -2
- data/dummy_app/app/views/layouts/application.html.erb +0 -15
- data/dummy_app/app/views/layouts/mailer.html.erb +0 -13
- data/dummy_app/app/views/layouts/mailer.text.erb +0 -1
- data/dummy_app/bin/docker-entrypoint +0 -8
- data/dummy_app/bin/rails +0 -4
- data/dummy_app/bin/rake +0 -4
- data/dummy_app/bin/setup +0 -33
- data/dummy_app/config/application.rb +0 -42
- data/dummy_app/config/boot.rb +0 -4
- data/dummy_app/config/cable.yml +0 -10
- data/dummy_app/config/credentials.yml.enc +0 -1
- data/dummy_app/config/database.yml +0 -25
- data/dummy_app/config/environment.rb +0 -5
- data/dummy_app/config/environments/development.rb +0 -76
- data/dummy_app/config/environments/production.rb +0 -97
- data/dummy_app/config/environments/test.rb +0 -64
- data/dummy_app/config/initializers/assets.rb +0 -12
- data/dummy_app/config/initializers/content_security_policy.rb +0 -25
- data/dummy_app/config/initializers/filter_parameter_logging.rb +0 -8
- data/dummy_app/config/initializers/inflections.rb +0 -16
- data/dummy_app/config/initializers/permissions_policy.rb +0 -13
- data/dummy_app/config/locales/en.yml +0 -31
- data/dummy_app/config/master.key +0 -1
- data/dummy_app/config/puma.rb +0 -44
- data/dummy_app/config/routes.rb +0 -10
- data/dummy_app/config/storage.yml +0 -34
- data/dummy_app/config.ru +0 -6
- data/dummy_app/db/migrate/20250920174734_create_content_flags.rb +0 -13
- data/dummy_app/db/migrate/20250920174750_create_posts.rb +0 -10
- data/dummy_app/db/migrate/20250920174757_create_users.rb +0 -9
- data/dummy_app/db/schema.rb +0 -40
- data/dummy_app/db/seeds.rb +0 -9
- data/dummy_app/lib/assets/.keep +0 -0
- data/dummy_app/lib/tasks/.keep +0 -0
- data/dummy_app/public/404.html +0 -67
- data/dummy_app/public/422.html +0 -67
- data/dummy_app/public/500.html +0 -66
- data/dummy_app/public/apple-touch-icon-precomposed.png +0 -0
- data/dummy_app/public/apple-touch-icon.png +0 -0
- data/dummy_app/public/favicon.ico +0 -0
- data/dummy_app/public/robots.txt +0 -1
- data/dummy_app/storage/.keep +0 -0
- data/dummy_app/test_console.rb +0 -46
- data/dummy_app/vendor/.keep +0 -0
- data/example_usage.rb +0 -46
- data/test_manual.rb +0 -36
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/dummy_app/public/robots.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
|
data/dummy_app/storage/.keep
DELETED
|
File without changes
|
data/dummy_app/test_console.rb
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# Rails Console Test Script for ContentFlagging
|
|
3
|
-
|
|
4
|
-
puts "=== ContentFlagging Rails Console Test ==="
|
|
5
|
-
puts "Run: rails console"
|
|
6
|
-
puts "Then copy/paste these commands:"
|
|
7
|
-
puts
|
|
8
|
-
|
|
9
|
-
puts <<~RUBY
|
|
10
|
-
# 1. Create test data
|
|
11
|
-
post1 = Post.create(title: "Normal Post")
|
|
12
|
-
post2 = Post.create(title: "Controversial Post")
|
|
13
|
-
user = User.create(name: "Test User")
|
|
14
|
-
|
|
15
|
-
# 2. Check initial state
|
|
16
|
-
puts "Initial posts count: \#{Post.count}"
|
|
17
|
-
puts "Post2 flagged?: \#{post2.flagged?}"
|
|
18
|
-
puts "Post2 flag count: \#{post2.flag_count}"
|
|
19
|
-
|
|
20
|
-
# 3. Flag the post (below threshold)
|
|
21
|
-
post2.flag!(flagged_by: user)
|
|
22
|
-
post2.flag!
|
|
23
|
-
puts "After 2 flags - Post2 flagged?: \#{post2.flagged?}"
|
|
24
|
-
puts "Posts in default scope: \#{Post.count}"
|
|
25
|
-
|
|
26
|
-
# 4. Hit the threshold (3 flags)
|
|
27
|
-
post2.flag!
|
|
28
|
-
puts "After 3 flags - Post2 flagged?: \#{post2.flagged?}"
|
|
29
|
-
puts "Post2 flagged at: \#{post2.flagged_at}"
|
|
30
|
-
puts "Posts in default scope: \#{Post.count}"
|
|
31
|
-
puts "Posts with flagged: \#{Post.with_flagged.count}"
|
|
32
|
-
|
|
33
|
-
# 5. Test scopes
|
|
34
|
-
puts "Flagged posts: \#{Post.with_flagged.flagged.count}"
|
|
35
|
-
puts "Not flagged posts: \#{Post.not_flagged.count}"
|
|
36
|
-
|
|
37
|
-
# 6. Unflag
|
|
38
|
-
post2.unflag!(flagged_by: user)
|
|
39
|
-
puts "After unflagging - Post2 flagged?: \#{post2.flagged?}"
|
|
40
|
-
puts "Posts in default scope: \#{Post.count}"
|
|
41
|
-
RUBY
|
|
42
|
-
|
|
43
|
-
puts
|
|
44
|
-
puts "=== Quick Test Commands ==="
|
|
45
|
-
puts "Post.create(title: 'Test').tap { |p| 3.times { p.flag! } }.flagged?"
|
|
46
|
-
puts "Post.count vs Post.with_flagged.count"
|
data/dummy_app/vendor/.keep
DELETED
|
File without changes
|
data/example_usage.rb
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# Example usage in a Rails application
|
|
2
|
-
|
|
3
|
-
# 1. Model setup
|
|
4
|
-
class Post < ApplicationRecord
|
|
5
|
-
acts_as_flaggable
|
|
6
|
-
# Requires: flagged_count integer column (default: 0)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
class Comment < ApplicationRecord
|
|
10
|
-
acts_as_flaggable threshold: 5
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
class User < ApplicationRecord
|
|
14
|
-
# Can flag content
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# 2. Configuration (config/initializers/content_flagging.rb)
|
|
18
|
-
ContentFlagging.configure do |config|
|
|
19
|
-
config.flag_threshold = 3
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
# 3. Usage examples
|
|
23
|
-
post = Post.create(title: "Controversial Post")
|
|
24
|
-
user1 = User.create(name: "User 1")
|
|
25
|
-
user2 = User.create(name: "User 2")
|
|
26
|
-
|
|
27
|
-
# Flag the post
|
|
28
|
-
post.flag!(flagged_by: user1)
|
|
29
|
-
post.flag!(flagged_by: user2)
|
|
30
|
-
post.flag_count # => 2
|
|
31
|
-
post.flagged? # => false
|
|
32
|
-
|
|
33
|
-
# Third flag triggers threshold
|
|
34
|
-
post.flag!
|
|
35
|
-
post.flagged? # => true
|
|
36
|
-
|
|
37
|
-
# Post is now excluded from default scope
|
|
38
|
-
Post.all # Won't include this post
|
|
39
|
-
Post.with_flagged.all # Will include this post
|
|
40
|
-
Post.with_flagged.flagged # Returns only flagged posts
|
|
41
|
-
Post.not_flagged # Returns only non-flagged posts
|
|
42
|
-
|
|
43
|
-
# Unflagging
|
|
44
|
-
post.unflag!(flagged_by: user1)
|
|
45
|
-
post.flag_count # => 2
|
|
46
|
-
post.flagged? # => false (back in default scope)
|
data/test_manual.rb
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
require_relative 'spec/spec_helper'
|
|
3
|
-
|
|
4
|
-
# Manual testing script
|
|
5
|
-
puts "Testing ContentFlagging gem..."
|
|
6
|
-
|
|
7
|
-
# Create test data
|
|
8
|
-
post = Post.create(title: "Test Post")
|
|
9
|
-
user = User.create(name: "Test User")
|
|
10
|
-
|
|
11
|
-
puts "\n1. Initial state:"
|
|
12
|
-
puts "Post flagged?: #{post.flagged?}"
|
|
13
|
-
puts "Flag count: #{post.flag_count}"
|
|
14
|
-
puts "Posts in default scope: #{Post.count}"
|
|
15
|
-
|
|
16
|
-
puts "\n2. Flag the post twice:"
|
|
17
|
-
post.flag!(flagged_by: user)
|
|
18
|
-
post.flag!
|
|
19
|
-
puts "Post flagged?: #{post.flagged?}"
|
|
20
|
-
puts "Flag count: #{post.flag_count}"
|
|
21
|
-
puts "Posts in default scope: #{Post.count}"
|
|
22
|
-
|
|
23
|
-
puts "\n3. Flag once more (hits threshold):"
|
|
24
|
-
post.flag!
|
|
25
|
-
puts "Post flagged?: #{post.flagged?}"
|
|
26
|
-
puts "Flag count: #{post.flag_count}"
|
|
27
|
-
puts "Posts in default scope: #{Post.count}"
|
|
28
|
-
puts "Posts with flagged: #{Post.with_flagged.count}"
|
|
29
|
-
|
|
30
|
-
puts "\n4. Unflag once:"
|
|
31
|
-
post.unflag!(flagged_by: user)
|
|
32
|
-
puts "Post flagged?: #{post.flagged?}"
|
|
33
|
-
puts "Flag count: #{post.flag_count}"
|
|
34
|
-
puts "Posts in default scope: #{Post.count}"
|
|
35
|
-
|
|
36
|
-
puts "\nTest completed!"
|