Coder Social home page Coder Social logo

mick88 / django-clippy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mdornseif/django-clippy

0.0 1.0 0.0 113 KB

flash based template tag for Django to allow copying the Clipboard

License: MIT License

Haxe 25.47% Makefile 3.11% Python 63.56% HTML 7.87%

django-clippy's Introduction

django-clippy - Writing to the Clipboard from within Webpages

django-clippy provides a template tag for the Django Web Framework to allow copying the Clipboard.

{% load clippy %}
<p><input id="clipfield" value="Data in Field"> {% clippy "clipfield" %}

Here is what Clippy looks like on GitHub:

Clippy in action

To install from the Python Package Index with pip:

pip install django-clippy

Add "clippy" to your INSTALLED_APPS in your settings.py. This should be enough to use the {% clippy "id" %} template tag in your templates.

The template tag needs the id of the field you want to copy to the clipboard as a parameter. You can give it an additional parameter describing the background color to use for the widget.

{% clippy "someid" "#FF0000" %}

If you don't give a color, the color given in settings.CLIPPY_BGCOLOR is used. It CLIPPY_BGCOLOR is not set, #ffffff is used as a fall back.

The code comes with a demo application. If you have pip and virtualenv installed, just type make dependencies runserver and go to http://127.0.0.1:8000/ to play with it.

If you see errors like ImportError: No module named django-clippy-1.1 ensure that your current directory name has no dots and spaces in it. E.g. cd ..; mv django-clippy-1.1 django-clippy-11; cd django-clippy-11.

Using the Flash Widget without Django

The "copy to clipboard" functionality is not reliably available in Javascript therefore it is implemented in Flash. If you don't use Django, you obviously can use the Flash widged directly in your HTML code. It can be called like this:

<span id="someid">Somevalue</span>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
        width="110" height="14" id="clippy_someid">
    <param name="movie" value="/mymedia/clippy.swf"/>
    <param name="allowScriptAccess" value="always" />
    <param name="quality" value="high" />
    <param name="scale" value="noscale" />
    <param NAME="FlashVars" value="id=someid">
    <param name="bgcolor" value="#ffffff">
    <embed src="/mymedia/clippy.swf?x=23"
        width="110" height="14" name="clippy" quality="high"
        allowScriptAccess="always"
        type="application/x-shockwave-flash"
        pluginspage="http://www.macromedia.com/go/getflashplayer"
        FlashVars="id=someid" bgcolor="#ffffff" /></object>

The widget understands the following parameters:

  • id - mandantory. Id from which the
  • copied - text to display after copying. Default is "copied!"
  • copyto - text to display before copying. Default is "copy to clipboard"
  • callBack - Javascript function to be called after copying

Compiling the Flash Widget

In order to compile Clippy from source, you need to install the following:

The haXe code is in Clippy.hx, the button images are in assets, and the compiler config is in compile.hxml. Make sure you look at all of these to see where and what you'll need to modify. To compile everything into a final SWF, type make flash.

If that is successful clippy/static//clippy.swf should be the new flash widged which you need to copy to your MEDIA_PATH.

Building the source RPM

  1. Download https://github.com/downloads/Eyepea/django-clippy/django-clippy-1.1.tar.gz in /usr/src/redhat/SOURCES/
  2. rpmbuild -ba python-django-clippy.spec

History

The original clippy code is by Tom Preston-Werner. This version contains Fixes by Zhang Jinzhu and Kyle Neath. Maximillian Dornseif integrated various patches and created the Django template Tag. Check the GitHub Fork Network to better understand the project history.

License

MIT License (see LICENSE file)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.