Jacob Levernier 84a5d61ccc Updated documentation. | vor 9 Jahren | |
---|---|---|
.. | ||
Readme.md | vor 9 Jahren | |
__init__.py | vor 10 Jahren | |
video_privacy_enhancer.py | vor 9 Jahren | |
video_privacy_enhancer_jquery.js | vor 9 Jahren | |
video_service_thumbnail_url_generating_functions.py | vor 9 Jahren |
This plugin is a conceptual port of the Electronic Frontier Foundation's (EFF's) MyTube Drupal plugin to Pelican. It increases user privacy by stopping video services (e.g., for YouTube, Google) from placing cookies on a user's system through an embedded video without that user explicitly opting-in to viewing the video (by clicking on it).
This plugin is copyright 2014 Jacob Levernier
It is released under the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 (as is the default for Pelican Plugins in the getpelican/pelican-plugins repository).
Although not required by the license, I would very much appreciate it if you placed a note in the "About" page of your website that you use this plugin, in order to raise user awareness of web tracking issues.
This is the first plugin that I've written for Pelican, and it was intended as a training project for learning Pelican as well as Python better. I would be very happy to hear constructive feedback on the plugin and for suggestions for making it more efficient and/or expandable. Also, I've heavily annotated all of the Python and jQuery code in order to make it easier to understand for others looking to learn more, like I was when I wrote the plugin.
I'm grateful to Jordi Burgos and Duncan Lock for writing helpful introductory blog posts on writing Pelican plugins. Both of these posts helped to decrease the intimidation factor associated with learning a new system like Pelican.
I'm also grateful to the authors of the plugins in the pelican-plugins repo; being able to look over other plugins' authors' code helped me immensely in learning more about how Pelican's signals system works.
Many videos (e.g., from YouTube) that are embedded in a website are capable of placing a cookie (or using other tracking methods) on a visitor's computer even if that visitor does not play the movie. For certain sites that deal with political or other potentially sensitive topics, this automatic tracking could raise privacy concerns among users. Thus, this plugin fetches and stores, on your server, a copy of the thumbnail image of each embedded YouTube video on your website. It then displays that image instead of the video until the user "opts-in" to watching the video by clicking on the thumbnail (at which point the image is replaced by the youtube embed iframe).
This plugin allows video shortcodes to be used in any Pelican page or article.
The currently-allowed shortcodes are as follows:
!youtube(video_id)
!vimeo(video_id)
For example, !youtube(2XID_W4neJo)
can be used to embed and privacy-protect the video available at https://www.youtube.com/watch?v=2XID_W4neJo. During the make html
process, the plugin will find every instance of each supported shortcode, and for each instance, will automatically download the video's thumbnail if it hasn't been downloaded previously, and will save the thumbnail to the Pelican output folder (by default, to /output/images/video-thumbnails). It will then replace the shortcode with the thumbnail image. A jQuery script then watches for thumbnail image clicks; when a user clicks a thumbnail image, the jQuery script will fade the image out, and replace it with the actual video iframe.
YouTube does have a "privacy-enhanced mode" that purports not to place cookies on a user's page until the user clicks on a video. However, if you are a website author who wants to ensure that no cookies are initially placed, this plugin puts that power in your hands.
!youtube(2XID_W4neJo)
written anywhere in the content of a page or post will become <img class="video-embed-dummy-image" id="2XID_W4neJo" src="YOUR_SITEURL/images/video-thumbnails/2XID_W4neJo.jpg" alt="Embedded Video - Click to view" title="Embedded Video - Click to view"></img>
during the make html
process ('YOUR_SITEURL' is replaced by your actual SITEURL
from pelicanconf.py). The plugin will take care of downloading 2XID_W4neJo.jpg
.
The plugin comes with an example jQuery file to copy into your theme's static folder. With this jQuery script, anytime a thumbnail image is clicked by a user, the thumbnail will fade out and then be replaced by the actual video embed. Thus, the <img>...</img>
code above will become <iframe width="853" height="480" src="https://www.youtube-nocookie.com/embed/2XID_W4neJo" frameborder="0" allowfullscreen></iframe>
when clicked.
To set the plugin up, just read the instructions at the top of youtube_privacy_enhancer.py. That file also includes some example CSS to copy into your theme's CSS file, as well as a setting or two for you to look over.
If you would like to add support for a new video service, there are just a few steps:
video_privacy_enhancer_jQuery.js
when you first set up the plugin by following the instructions at the top of video_privacy_enhancer.py.As noted in an EFF blog post, the Drupal MyTube plugin from which this plugin takes its idea is capable of handling videos not only from YouTube and Vimeo but also Comedy Central and other sites. It would be nice to expand this Pelican plugin in the future to do the same.