pressbooks / ideas

Ideas for Pressbooks.
GNU General Public License v3.0
12 stars 4 forks source link

Automated Link Attribution with Copy-Magic-Paste #71

Closed colomet closed 3 years ago

colomet commented 6 years ago

Feature Scope

Feature Description

Each time a user copy and paste a text, automatically they copy the link of the page.

Feature Use Case

We've all seen it: Someone helps themselves to your awesome content and pastes it onto their own website without even mentioning the source.

Wouldn't it be generous of us to do the work for them? Wouldn't it be ideal if their copy and pasted content automatically linked back to your site?

Other Notes

copymagicpaste-a-script-and-easytouseguide-to-customize-the-copyevent-on-your-website

Verdem-crypto commented 4 years ago

where i can download it?

colomet commented 4 years ago

You can copy and paste the code in your theme or plugin maybe.


<!--
-               ADDED: Add a #copyright notice to the clipboard when someone copies a text from the website.
-
-               @SINCE
-               @LINK https://stackoverflow.com/questions/2026335/how-to-add-extra-info-to-copied-web-text
-               @LINK https://developer.mozilla.org/en-US/docs/Web/API/Element/copy_event
-               @LINK https://www.wpbeginner.com/wp-tutorials/how-to-add-a-read-more-link-to-copied-text-in-wordpress/
-     const pagelink = `\n\nSource: © ${document.location.href}`;
-->

<?php
if ( !wp_is_mobile() ) {
    if ( !is_user_logged_in() ) { ?>
    <script type="text/javascript">

    document.addEventListener('copy', (event) => {
      const pagelink = `\n\nSource: <?php the_title(); ?> © <?php echo wp_get_shortlink(get_the_ID()); ?>`;
      event.clipboardData.setData('text', document.getSelection() + pagelink);
      event.preventDefault();
    });

    </script>
<?php }
}
?>
<!-- END CODE -->
colomet commented 4 years ago

If you do not like to show the URL with the id of the page, change the const pagelink =

const pagelink =\n\nSource: © ${document.location.href};

sudarshan-gautam commented 3 years ago

anyone can detail me about the code? I am using WordPress and where to paste it?

colomet commented 3 years ago

Example of tutorial about how to do it: https://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/

SteelWagstaff commented 3 years ago

Closing as we won't be implementing this is Pressbooks core in near future, but open source users are welcome to read this thread for ideas about implementation on their own.

streats commented 3 years ago

Hi - I found out about Copy-Magic-Paste from this 2015 article on Moz.com. Is it the same thing? Is Squarespace supported? I'm helping a friend out who is being copied left right and center (entire pages) by competitors and I wanted to see if this might help provide at least a small deterrent. Thanks!