##// END OF EJS Templates
Migrate to Mergely 3.3.4....
Migrate to Mergely 3.3.4. RhodeCode 2.2.5 distributed Mergely 3.3.4 with some of the changes that Mergely 3.3.3 in RhodeCode 1.7.2 also had. That do however not seem to be changes we want for Kallithea this way and we take the 3.3.4 files as they are. I've also included the Mergely license file, as downloaded from: http://www.mergely.com/license.php That LICENSE file is kept in HTML just as it was downloaded from their website. While it's a bit annoying to keep the license file in HTML, this is the way it came from upstream so we'll leave it that way. Since the Javascript code is used with other GPLv3 Javascript, we are using the GPL option of Mergely's tri-license. Finally, note that previously, this was incorrectly called "mergerly", so the opportunity is taken here to correct the name. That required changes to diff_2way.html. As commands:: $ wget -N --output-document LICENSE-MERGELY.html http://www.mergely.com/license.php $ hg add LICENSE-MERGELY.html $ hg mv rhodecode/public/css/mergerly.css rhodecode/public/css/mergely.css $ hg mv rhodecode/public/js/mergerly.js rhodecode/public/js/mergely.js $ sed -i 's,mergerly\.,mergely,g' rhodecode/templates/files/diff_2way.html $ ( cd /tmp; \ wget -N http://www.mergely.com/releases/mergely-3.3.4.zip; \ unzip mergely-3.3.4.zip ) $ sha256sum /tmp/mergely-3.3.4.zip 87415d30494bbe829c248881aa7cdc0303f7e70b458a5f687615564d4498cc82 mergely-3.3.4.zip $ cp /tmp/mergely-3.3.4/lib/mergely.js rhodecode/public/js/mergely.js $ cp /tmp/mergely-3.3.4/lib/mergely.css rhodecode/public/css/mergely.css $ sed -i -e '/^ \* Version/a\ *\n * NOTE by bkuhn@sfconservancy.org for Kallithea:\n * Mergely license appears at http://www.mergely.com/license.php and in LICENSE-MERGELY.html' rhodecode/public/js/mergely.js rhodecode/public/css/mergely.css

File last commit:

r3029:685ebc84 beta
r4125:aa3b5594 rhodecode-2.2.5-gpl
Show More
ext_json.py
122 lines | 3.7 KiB | text/x-python | PythonLexer
add ext_json module
r2173 import datetime
import functools
import decimal
merge ext_json with upstream
r3013 import imp
add ext_json module
r2173
merge ext_json with upstream
r3013 __all__ = ['json', 'simplejson', 'stdlibjson']
add ext_json module
r2173
def _is_aware(value):
"""
Determines if a given datetime.time is aware.
The logic is described in Python's docs:
http://docs.python.org/library/datetime.html#datetime.tzinfo
"""
return (value.tzinfo is not None
and value.tzinfo.utcoffset(value) is not None)
def _obj_dump(obj):
"""
Custom function for dumping objects to JSON, if obj has __json__ attribute
or method defined it will be used for serialization
:param obj:
"""
if isinstance(obj, complex):
return [obj.real, obj.imag]
# See "Date Time String Format" in the ECMA-262 specification.
# some code borrowed from django 1.4
elif isinstance(obj, datetime.datetime):
r = obj.isoformat()
if obj.microsecond:
r = r[:23] + r[26:]
if r.endswith('+00:00'):
r = r[:-6] + 'Z'
return r
elif isinstance(obj, datetime.date):
return obj.isoformat()
elif isinstance(obj, decimal.Decimal):
return str(obj)
elif isinstance(obj, datetime.time):
if _is_aware(obj):
raise ValueError("JSON can't represent timezone-aware times.")
r = obj.isoformat()
if obj.microsecond:
r = r[:12]
return r
elif isinstance(obj, set):
return list(obj)
elif hasattr(obj, '__json__'):
if callable(obj.__json__):
return obj.__json__()
else:
return obj.__json__
else:
raise NotImplementedError
# Import simplejson
try:
# import simplejson initially
merge ext_json with upstream
r3013 _sj = imp.load_module('_sj', *imp.find_module('simplejson'))
add ext_json module
r2173
def extended_encode(obj):
try:
return _obj_dump(obj)
except NotImplementedError:
pass
raise TypeError("%r is not JSON serializable" % (obj,))
ws cleanup, +changelog
r2174 # we handle decimals our own it makes unified behavior of json vs
add ext_json module
r2173 # simplejson
merge ext_json with upstream
r3013 sj_version = [int(x) for x in _sj.__version__.split('.')]
major, minor = sj_version[0], sj_version[1]
if major < 2 or (major == 2 and minor < 1):
# simplejson < 2.1 doesnt support use_decimal
_sj.dumps = functools.partial(_sj.dumps,
default=extended_encode)
_sj.dump = functools.partial(_sj.dump,
default=extended_encode)
else:
_sj.dumps = functools.partial(_sj.dumps,
default=extended_encode,
use_decimal=False)
_sj.dump = functools.partial(_sj.dump,
default=extended_encode,
use_decimal=False)
simplejson = _sj
add ext_json module
r2173 except ImportError:
# no simplejson set it to None
Simplified ext_json thing, for better scope resolution in pydev
r2528 simplejson = None
add ext_json module
r2173
Fixed simplejson import on python 2.5
r2258 try:
# simplejson not found try out regular json module
merge ext_json with upstream
r3013 _json = imp.load_module('_json', *imp.find_module('json'))
add ext_json module
r2173
Fixed simplejson import on python 2.5
r2258 # extended JSON encoder for json
merge ext_json with upstream
r3013 class ExtendedEncoder(_json.JSONEncoder):
Fixed simplejson import on python 2.5
r2258 def default(self, obj):
try:
return _obj_dump(obj)
except NotImplementedError:
pass
fix ext-json extension issue when exception is raised for non-serializable objects
r2817 raise TypeError("%r is not JSON serializable" % (obj,))
Fixed simplejson import on python 2.5
r2258 # monkey-patch JSON encoder to use extended version
merge ext_json with upstream
r3013 _json.dumps = functools.partial(_json.dumps, cls=ExtendedEncoder)
_json.dump = functools.partial(_json.dump, cls=ExtendedEncoder)
Simplified ext_json thing, for better scope resolution in pydev
r2528
merge ext_json with upstream
r3013 stdlibjson = _json
Fixed simplejson import on python 2.5
r2258 except ImportError:
merge ext_json with upstream
r3013 stdlibjson = None
add ext_json module
r2173
# set all available json modules
Simplified ext_json thing, for better scope resolution in pydev
r2528 if simplejson:
merge ext_json with upstream
r3013 json = _sj
elif stdlibjson:
json = _json
Simplified ext_json thing, for better scope resolution in pydev
r2528 else:
White space cleanup
r3029 raise ImportError('Could not find any json modules')