forked from lucyparsons/OpenOversight
-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add content warnings for videos/links #457
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function createOverlay(container) { | ||
const warningText = $( | ||
"<span><h3>Content Warning</h3><p>This video may be disturbing for some viewers</p></span>" | ||
) | ||
const hide = $('<button type="button" class="btn btn-lg">Show video</button>') | ||
hide.click(() => overlay.css("display", "none")) | ||
|
||
const wrapper = $("<div>") | ||
wrapper.append(warningText) | ||
wrapper.append(hide) | ||
|
||
const overlay = $('<div class="overlay">') | ||
overlay.append(wrapper) | ||
container.append(overlay) | ||
} | ||
|
||
$(document).ready(() => { | ||
$(".video-container").each((index, element) => { | ||
const container = $(element) | ||
if (container.data("has-content-warning")) { | ||
createOverlay(container) | ||
} | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
OpenOversight/migrations/versions/2024-06-05-0203_939ea0f2b26d_.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""Add has_content_warning column to link model | ||
Revision ID: 939ea0f2b26d | ||
Revises: 52d3f6a21dd9 | ||
Create Date: 2024-06-05 02:03:29.168771 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
|
||
revision = "939ea0f2b26d" | ||
down_revision = "52d3f6a21dd9" | ||
|
||
|
||
def upgrade(): | ||
# This is not expected to impact performance: https://dba.stackexchange.com/a/216153 | ||
with op.batch_alter_table("links", schema=None) as batch_op: | ||
batch_op.add_column( | ||
sa.Column( | ||
"has_content_warning", | ||
sa.Boolean(), | ||
nullable=False, | ||
server_default="false", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This migration does not add content warnings to existing links and videos, so users will need to mark those manually |
||
) | ||
) | ||
|
||
|
||
def downgrade(): | ||
with op.batch_alter_table("links", schema=None) as batch_op: | ||
batch_op.drop_column("has_content_warning") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to add a
</div>
to this or does jquery handle it for us?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edit: This is the case based on the Jquery documentation!