From 6225ed19a8e00dcf1c733c831ce090e804bbe93f Mon Sep 17 00:00:00 2001 From: Serghei Mihai Date: Fri, 19 May 2017 12:20:06 +0200 Subject: [PATCH] initial packaging (#16407) --- MANIFEST.in | 2 + README.txt | 12 ++ debian/changelog | 5 + debian/compat | 1 + debian/control | 26 ++++ debian/rules | 8 ++ debian/source/format | 1 + debian/watch | 4 + setup.py | 26 ++++ xstatic/__init__.py | 1 + xstatic/pkg/__init__.py | 1 + xstatic/pkg/jquery_colourpicker/__init__.py | 41 +++++++ .../data/jquery.colourpicker.js | 112 ++++++++++++++++++ 13 files changed, 240 insertions(+) create mode 100644 MANIFEST.in create mode 100644 README.txt create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100755 debian/rules create mode 100644 debian/source/format create mode 100644 debian/watch create mode 100644 setup.py create mode 100644 xstatic/__init__.py create mode 100644 xstatic/pkg/__init__.py create mode 100644 xstatic/pkg/jquery_colourpicker/__init__.py create mode 100644 xstatic/pkg/jquery_colourpicker/data/jquery.colourpicker.js diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..12af2c0 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +include README.txt +recursive-include xstatic/pkg/jquery_colourpicker * diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..ddb7928 --- /dev/null +++ b/README.txt @@ -0,0 +1,12 @@ +XStatic-Jquery-Colourpicker +-------------- + +Jquery Colour-Picker packaged for setuptools (easy_install) / pip. + +This package is intended to be used by **any** project that needs these files. + +It intentionally does **not** provide any extra code except some metadata +**nor** has any extra requirements. You MAY use some minimal support code from +the XStatic base package, if you like. + +You can find more info about the xstatic packaging way in the package `XStatic`. diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..70da494 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +xstatic-jquery-colourpicker (1.0.0.1-1) unstable; urgency=low + + * source package automatically created by stdeb 0.8.5 + + -- Serghei Mihai Fri, 19 May 2017 12:12:26 +0200 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..6115d73 --- /dev/null +++ b/debian/control @@ -0,0 +1,26 @@ +Source: xstatic-jquery-colourpicker +Maintainer: Serghei Mihai +Section: python +Priority: optional +Build-Depends: dh-python, python-setuptools (>= 0.6b3), python-all (>= 2.6.6-3), debhelper (>= 9) +Standards-Version: 3.9.6 +Homepage: http://andreaslagerkvist.com/jquery/colour-picker/ + +Package: python-xstatic-jquery-colourpicker +Architecture: all +Depends: ${misc:Depends}, ${python:Depends} +Description: jquery-colourpicker 1.0.0 (XStatic packaging standard) + XStatic-Jquery-Colourpicker + -------------- + . + Jquery Colour-Picker packaged for setuptools (easy_install) / pip. + . + This package is intended to be used by **any** project that needs these files. + . + It intentionally does **not** provide any extra code except some metadata + **nor** has any extra requirements. You MAY use some minimal support code from + the XStatic base package, if you like. + . + You can find more info about the xstatic packaging way in the package `XStatic`. + . + diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..c565f00 --- /dev/null +++ b/debian/rules @@ -0,0 +1,8 @@ +#!/usr/bin/make -f + +# This file was automatically generated by stdeb 0.8.5 at +# Fri, 19 May 2017 12:12:26 +0200 +export PYBUILD_NAME=xstatic-jquery-colourpicker +%: + dh $@ --with python2 --buildsystem=pybuild + diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/watch b/debian/watch new file mode 100644 index 0000000..6fbe468 --- /dev/null +++ b/debian/watch @@ -0,0 +1,4 @@ +# please also check http://pypi.debian.net/XStatic-jquery-colourpicker/watch +version=3 +opts=uversionmangle=s/(rc|a|b|c)/~$1/ \ +http://pypi.debian.net/XStatic-jquery-colourpicker/XStatic-jquery-colourpicker-(.+)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz))) \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..8be7511 --- /dev/null +++ b/setup.py @@ -0,0 +1,26 @@ +from xstatic.pkg import jquery_colourpicker as xs + +# The README.txt file should be written in reST so that PyPI can use +# it to generate your project's PyPI page. +long_description = open('README.txt').read() + +from setuptools import setup, find_packages + +setup( + name=xs.PACKAGE_NAME, + version=xs.PACKAGE_VERSION, + description=xs.DESCRIPTION, + long_description=long_description, + classifiers=xs.CLASSIFIERS, + keywords=xs.KEYWORDS, + maintainer=xs.MAINTAINER, + maintainer_email=xs.MAINTAINER_EMAIL, + license=xs.LICENSE, + url=xs.HOMEPAGE, + platforms=xs.PLATFORMS, + packages=find_packages(), + namespace_packages=['xstatic', 'xstatic.pkg', ], + include_package_data=True, + zip_safe=False, + install_requires=[], +) diff --git a/xstatic/__init__.py b/xstatic/__init__.py new file mode 100644 index 0000000..de40ea7 --- /dev/null +++ b/xstatic/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/xstatic/pkg/__init__.py b/xstatic/pkg/__init__.py new file mode 100644 index 0000000..de40ea7 --- /dev/null +++ b/xstatic/pkg/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/xstatic/pkg/jquery_colourpicker/__init__.py b/xstatic/pkg/jquery_colourpicker/__init__.py new file mode 100644 index 0000000..541d7f0 --- /dev/null +++ b/xstatic/pkg/jquery_colourpicker/__init__.py @@ -0,0 +1,41 @@ +""" +XStatic resource package + +See package 'XStatic' for documentation and basic tools. +""" + +DISPLAY_NAME = 'jquery-colourpicker' # official name, upper/lowercase allowed, no spaces +PACKAGE_NAME = 'XStatic-%s' % DISPLAY_NAME # name used for PyPi + +NAME = __name__.split('.')[-1] # package name (e.g. 'foo' or 'foo_bar') + # please use a all-lowercase valid python + # package name + +VERSION = '1.0.0' # version of the packaged files, please use the upstream + # version number +BUILD = '1' # our package build number, so we can release new builds + # with fixes for xstatic stuff. +PACKAGE_VERSION = VERSION + '.' + BUILD # version used for PyPi + +DESCRIPTION = "%s %s (XStatic packaging standard)" % (DISPLAY_NAME, VERSION) + +PLATFORMS = 'any' +CLASSIFIERS = [] +KEYWORDS = '%s xstatic' % NAME + +# XStatic-* package maintainer: +MAINTAINER = 'Serghei Mihai' +MAINTAINER_EMAIL = 'smihai@entrouvert.com' + +# this refers to the project homepage of the stuff we packaged: +HOMEPAGE = 'http://andreaslagerkvist.com/jquery/colour-picker/' + +# this refers to all files: +LICENSE = '(same as %s)' % DISPLAY_NAME + +from os.path import join, dirname +BASE_DIR = join(dirname(__file__), 'data') +# linux package maintainers just can point to their file locations like this: +#BASE_DIR = '/usr/share/javascript/jquery_ui' + +LOCATIONS = {} diff --git a/xstatic/pkg/jquery_colourpicker/data/jquery.colourpicker.js b/xstatic/pkg/jquery_colourpicker/data/jquery.colourpicker.js new file mode 100644 index 0000000..8012c43 --- /dev/null +++ b/xstatic/pkg/jquery_colourpicker/data/jquery.colourpicker.js @@ -0,0 +1,112 @@ +/* adapted from http://andreaslagerkvist.com/jquery/colour-picker/ */ + +jQuery.fn.colourPicker = function (conf) { + // Config for plug + var config = jQuery.extend({ + id: 'jquery-colour-picker', // id of colour-picker container + inputBG: true, // Whether to change the input's background to the selected colour's + speed: 500 // Speed of dialogue-animation + }, conf); + + // Inverts a hex-colour + var hexInvert = function (hex) { + var r = parseInt(hex.substr(0, 2), 16); + var g = parseInt(hex.substr(2, 2), 16); + var b = parseInt(hex.substr(4, 2), 16); + + return 0.212671 * r + 0.715160 * g + 0.072169 * b < 128 ? 'ffffff' : '000000' + }; + + // Add the colour-picker dialogue if not added + var colourPicker = jQuery('#' + config.id); + + if (!colourPicker.length) { + colourPicker = jQuery('
').appendTo(document.body).hide(); + + // Remove the colour-picker if you click outside it (on body) + jQuery(document.body).click(function(event) { + if (!(jQuery(event.target).is('#' + config.id) || jQuery(event.target).parents('#' + config.id).length)) { + colourPicker.hide(config.speed); + } + }); + } + + // For every select passed to the plug-in + return this.each(function () { + // Insert icon and input + var select = jQuery(this); + var icon = jQuery('...').insertAfter(select); + var input = jQuery('').insertAfter(select); + var loc = ''; + + // Build a list of colours based on the colours in the select + jQuery('option', select).each(function () { + var option = jQuery(this); + var hex = option.val(); + var title = option.text(); + + loc += '
  • ' + + title + + '
  • '; + }); + + // Remove select + select.remove(); + + // If user wants to, change the input's BG to reflect the newly selected colour + if (config.inputBG) { + input.change(function () { + input.css({background: '#' + input.val(), color: '#' + hexInvert(input.val())}); + }); + + input.change(); + } + + // When you click the icon + icon.click(function () { + // Show the colour-picker next to the icon and fill it with the colours in the select that used to be there + var iconPos = icon.offset(); + + colourPicker.html('
      ' + loc + '
    ').css({ + position: 'absolute', + left: iconPos.left + 'px', + top: iconPos.top + 'px' + }).show(config.speed); + + // When you click a colour in the colour-picker + jQuery('a', colourPicker).click(function () { + // The hex is stored in the link's rel-attribute + var hex = jQuery(this).attr('rel'); + + input.val(hex); + + // If user wants to, change the input's BG to reflect the newly selected colour + if (config.inputBG) { + input.css({background: '#' + hex, color: '#' + hexInvert(hex)}); + } + + // Trigger change-event on input + input.change(); + + // Hide the colour-picker and return false + colourPicker.hide(config.speed); + + return false; + }); + + return false; + }); + }); +}; + +$(function() { + jQuery('select.colour-picker').colourPicker(); +});