initial packaging (#16407)

This commit is contained in:
Serghei Mihai 2017-05-19 12:20:06 +02:00
commit 6225ed19a8
13 changed files with 240 additions and 0 deletions

2
MANIFEST.in Normal file
View File

@ -0,0 +1,2 @@
include README.txt
recursive-include xstatic/pkg/jquery_colourpicker *

12
README.txt Normal file
View File

@ -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`.

5
debian/changelog vendored Normal file
View File

@ -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 <smihai@entrouvert.com> Fri, 19 May 2017 12:12:26 +0200

1
debian/compat vendored Normal file
View File

@ -0,0 +1 @@
9

26
debian/control vendored Normal file
View File

@ -0,0 +1,26 @@
Source: xstatic-jquery-colourpicker
Maintainer: Serghei Mihai <smihai@entrouvert.com>
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`.
.

8
debian/rules vendored Executable file
View File

@ -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

1
debian/source/format vendored Normal file
View File

@ -0,0 +1 @@
3.0 (quilt)

4
debian/watch vendored Normal file
View File

@ -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)))

26
setup.py Normal file
View File

@ -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=[],
)

1
xstatic/__init__.py Normal file
View File

@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)

1
xstatic/pkg/__init__.py Normal file
View File

@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)

View File

@ -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 = {}

View File

@ -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('<div id="' + config.id + '"></div>').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('<a href="#">...</a>').insertAfter(select);
var input = jQuery('<input type="text" name="' + select.attr('name') + '" value="' + select.val() + '" size="7" />').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 += '<li><a href="#" title="'
+ title
+ '" rel="'
+ hex
+ '" style="background: #'
+ hex
+ '; colour: '
+ hexInvert(hex)
+ ';">'
+ title
+ '</a></li>';
});
// 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('<ul>' + loc + '</ul>').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();
});