Commit 2a85506f authored by Pere Cortes's avatar Pere Cortes Committed by Sebastien Robin

erp5_safeimage: Clean-up and view added

parent a0b14c94
from cStringIO import StringIO
from Products.ERP5.Document.Image import Image
from Products.ZoomifyImage.ZoomifyZopeProcessor import ZoomifyZopeProcessor
from Products.ZoomifyImage.ZoomifyBase import ZoomifyBase
from zLOG import LOG,INFO,ERROR,WARNING
class ERP5ZoomifyZopeProcessor(ZoomifyZopeProcessor):
def __init__(self, document):
self.document = document
def createTileContainer(self, tileContainerName=None):
""" create each TileGroup """
self.document.newContent(portal_type="Image Tile Group",title=tileContainerName, id=tileContainerName,filename=tileContainerName)
return
def createDefaultViewer(self):
""" add the default Zoomify viewer to the Zoomify metadata """
pass
return
def createDataContainer(self, imageName="None"):
"""Creates nothing coz we are already in the container"""
pass
return
def saveTile(self, image, scaleNumber, column,row):
"""save the cropped region"""
tileFileName = self.getTileFileName(scaleNumber, column, row)
tileContainerName = self.getAssignedTileContainerName(tileFileName=tileFileName)
namesplit = tileFileName.split('.')
w,h = image.size
if w != 0 and h !=0:
tile_group_id = self.getAssignedTileContainerName()
tile_group=self.document[tile_group_id]
tileImageData= StringIO()
image.save(tileImageData,'JPEG',quality=self.qualitySetting)
tileImageData.seek(0)
if tile_group is None:
raise AttributeError('unable to fine tile group %r' % tile_group_id)
w = tile_group.newContent(portal_type='Image',title=namesplit[0],id=namesplit[0],file=tileImageData,filename=namesplit[0])
return
def saveXMLOutput(self):
"""save the xml file"""
my_string = StringIO()
my_string.write(self.getXMLOutput())
my_string.seek(0)
self.document.newContent(portal_type='Embedded File',id='ImageProperties.xml',file=my_string, filename='ImageProperties.xml')
return
class TileImage(Image):
"""
Tile Images split images in many small parts and then store informations as sub objects
......@@ -62,16 +8,11 @@ class TileImage(Image):
def _setFile(self, *args, **kw):
"""Set the file content and reset image information."""
if "TileGroup0" in self.objectIds():
self.manage_delObjects("TileGroup0")
if "ImageProperties.xml" in self.objectIds():
self.manage_delObjects("ImageProperties.xml")
self._update_image_info()
processor = ERP5ZoomifyZopeProcessor(self)
processor = self.Image_getERP5ZoomifyProcessor(self)
processor.ZoomifyProcess(self.getId(),*args)
import random
import base64
from cStringIO import StringIO
from Products.ERP5.Document.Image import Image
from Products.ZoomifyImage.ZoomifyZopeProcessor import ZoomifyZopeProcessor
from Products.ZoomifyImage.ZoomifyBase import ZoomifyBase
from zLOG import LOG,INFO,ERROR,WARNING
#from Crypto.Cipher import AES
#from Crypto import Random
class ERP5ZoomifyZopeProcessor(ZoomifyZopeProcessor):
def __init__(self, document):
self.document = document
self.count = 0
def createTileContainer(self, tileContainerName=None):
""" create each TileGroup """
self.document.newContent(portal_type="Image Tile Group",title=tileContainerName, id=tileContainerName,filename=tileContainerName)
return
def createDefaultViewer(self):
""" add the default Zoomify viewer to the Zoomify metadata """
pass
return
def createDataContainer(self, imageName="None"):
"""Creates nothing coz we are already in the container"""
pass
return
def saveTile(self, image, scaleNumber, column,row):
"""save the cropped region"""
tileFileName = self.getTileFileName(scaleNumber, column, row)
tileContainerName = self.getAssignedTileContainerName(tileFileName=tileFileName)
namesplit = tileFileName.split('.')
w,h = image.size
if w != 0 and h !=0:
tile_group_id = self.getAssignedTileContainerName()
tile_group=self.document[tile_group_id]
tileImageData= StringIO()
image.save(tileImageData,'JPEG',quality=self.qualitySetting)
tileImageData.seek(0)
#msg = self.encrypto(tileImageData.getvalue())
if tile_group is None:
raise AttributeError('unable to fine tile group %r' % tile_group_id)
w = tile_group.newContent(portal_type='Image',title=namesplit[0],id=namesplit[0],file=tileImageData,filename=namesplit[0])
LOG('SAVE TILE',INFO,'Title: %s' %(namesplit[0],))
self._updateTransformedFile(tile_group_id,namesplit[0])
return
def saveXMLOutput(self):
"""save the xml file"""
my_string = StringIO()
my_string.write(self.getXMLOutput())
my_string.seek(0)
self.document.newContent(portal_type='Embedded File',id='ImageProperties.xml',file=my_string, filename='ImageProperties.xml')
return
def _updateTransformedFile(self,tile_group_id,tile_title):
"""create and save the transform file"""
num = random.choice([0,1])
while num >= 0:
algorithm = random.choice(['sepia','brightness','noise','lighten','posterize','edge','none'])
if algorithm == 'lighten':
param1 = random.choice([-0.6,-0.5,-0.4,-0.3,-0.2,-0.1,0.1,0.2,0.3,0.4,0.5,0.6])
param2 = 0
elif algorithm == 'posterize':
param1 = random.choice([4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21])
param2 = 0
elif algorithm == 'brightness':
param1 = random.choice([-80,-60,-40,-20,20,40,60,80])
param2 = random.choice([-0.3,-0.2,-0.1,0,0.1,0.5,0.9])
else:
param1 = 0
param2 = 0
my_text = '%s %s %s %s %s %s \n' %(tile_group_id,tile_title,algorithm,param1,param2,num)
self.my_file.write(my_text)
num = num - 1
def saveTransformedFile(self):
"""add in Zope the transform file """
self.my_file.seek(0)
self.document.newContent(portal_type='Embedded File', id='TransformFile.txt',file=self.my_file,filename='TransformFile.txt')
return
# def encrypto(self,message='Attack at dawn'):
# """encrypto each thing"""
# key ='abcdefghijklmnop'
# iv = Random.new().read(AES.block_size)
# EncodeIV = lambda : base64.b64encode(iv)
# EncodeAES = lambda c, s: base64.b64encode(c.encrypt(message))
# IVcoded = EncodeIV()
# cipher = AES.new(key,AES.MODE_CFB,iv)
# msg = EncodeAES(cipher,key)
# return msg
class TileImageTransformed(Image):
"""
Tile Images split images in many small parts and then store informations as sub objects
"""
def _setFile(self, *args, **kw):
"""Set the file content and reset image information."""
if "TileGroup0" in self.objectIds():
self.manage_delObjects("TileGroup0")
if "ImageProperties.xml" in self.objectIds():
self.manage_delObjects("ImageProperties.xml")
self._update_image_info()
processor = ERP5ZoomifyZopeProcessor(self)
processor = self.Image_getERP5ZoomifyProcessor(self,True)
processor.ZoomifyProcess(self.getId(),*args)
......@@ -6,6 +6,18 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_roles__</string> </key>
<value>
<tuple>
<string>Manager</string>
<string>Owner</string>
<string>Anonymous</string>
<string>Authenticated</string>
<string>Associate</string>
</tuple>
</value>
</item>
<item>
<key> <string>_local_properties</string> </key>
<value>
......
......@@ -51,12 +51,14 @@
<item>
<key> <string>_body</string> </key>
<value> <string>import json\n
\n
portal = context.getPortalObject()\n
context.REQUEST.response.setHeader(\'Access-Control-Allow-Origin\', \'*\')\n
print portal.portal_catalog(portal_type="Image Title", src__=1)\n
#return printed\n
data = {}\n
data["image_list"] = []\n
image_list = data["image_list"]\n
for tile_image in context.portal_catalog(portal_type="Image Tile"):\n
for tile_image in portal.portal_catalog(portal_type="Image Tile"):\n
title = tile_image.getTitle() \n
id = tile_image.getId()\n
image_list.append({"title":title, "id": id})\n
......@@ -80,6 +82,14 @@ return json.dumps(data)\n
<key> <string>id</string> </key>
<value> <string>ERP5Site_getTileImageMetadataList</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple>
<string>Prints, but never reads \'printed\' variable.</string>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts54117421.77</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>ICanHaz.min.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
(function(){var q=function(){function c(a){return(""+a).replace(/&(?!\\w+;)|[<>"\']/g,function(a){return k[a]||a})}var e=Object.prototype.toString;Array.isArray=Array.isArray||function(a){return"[object Array]"==e.call(a)};var i=String.prototype.trim,g;if(i)g=function(a){return null==a?"":i.call(a)};else{var h,m;/\\S/.test("\\u00a0")?(h=/^[\\s\\xA0]+/,m=/[\\s\\xA0]+$/):(h=/^\\s+/,m=/\\s+$/);g=function(a){return null==a?"":a.toString().replace(h,"").replace(m,"")}}var k={"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;",\n
"\'":"&#39;"},o={},p=function(){};p.prototype={otag:"{{",ctag:"}}",pragmas:{},buffer:[],pragmas_implemented:{"IMPLICIT-ITERATOR":!0},context:{},render:function(a,d,b,f){if(!f)this.context=d,this.buffer=[];if(this.includes("",a)){var a=this.render_pragmas(a),j=this.render_section(a,d,b);!1===j&&(j=this.render_tags(a,d,b,f));if(f)return j;this.sendLines(j)}else{if(f)return a;this.send(a)}},send:function(a){""!==a&&this.buffer.push(a)},sendLines:function(a){if(a)for(var a=a.split("\\n"),d=0;d<a.length;d++)this.send(a[d])},\n
render_pragmas:function(a){if(!this.includes("%",a))return a;var d=this,b=this.getCachedRegex("render_pragmas",function(a,d){return RegExp(a+"%([\\\\w-]+) ?([\\\\w]+=[\\\\w]+)?"+d,"g")});return a.replace(b,function(a,b,e){if(!d.pragmas_implemented[b])throw{message:"This implementation of mustache doesn\'t understand the \'"+b+"\' pragma"};d.pragmas[b]={};e&&(a=e.split("="),d.pragmas[b][a[0]]=a[1]);return""})},render_partial:function(a,d,b){a=g(a);if(!b||void 0===b[a])throw{message:"unknown_partial \'"+a+"\'"};\n
return!d||"object"!=typeof d[a]?this.render(b[a],d,b,!0):this.render(b[a],d[a],b,!0)},render_section:function(a,d,b){if(!this.includes("#",a)&&!this.includes("^",a))return!1;var f=this,j=this.getCachedRegex("render_section",function(a,b){return RegExp("^([\\\\s\\\\S]*?)"+a+"(\\\\^|\\\\#)\\\\s*(.+)\\\\s*"+b+"\\n*([\\\\s\\\\S]*?)"+a+"\\\\/\\\\s*\\\\3\\\\s*"+b+"\\\\s*([\\\\s\\\\S]*)$","g")});return a.replace(j,function(a,j,e,c,g,h){var a=j?f.render_tags(j,d,b,!0):"",h=h?f.render(h,d,b,!0):"",n,c=f.find(c,d);"^"===e?n=!c||Array.isArray(c)&&\n
0===c.length?f.render(g,d,b,!0):"":"#"===e&&(n=Array.isArray(c)?f.map(c,function(a){return f.render(g,f.create_context(a),b,!0)}).join(""):f.is_object(c)?f.render(g,f.create_context(c),b,!0):"function"==typeof c?c.call(d,g,function(a){return f.render(a,d,b,!0)}):c?f.render(g,d,b,!0):"");return a+n+h})},render_tags:function(a,d,b,f){for(var j=this,e=function(){return j.getCachedRegex("render_tags",function(a,b){return RegExp(a+"(=|!|>|&|\\\\{|%)?([^#\\\\^]+?)\\\\1?"+b+"+","g")})},g=e(),h=function(a,f,h){switch(f){case "!":return"";\n
case "=":return j.set_delimiters(h),g=e(),"";case ">":return j.render_partial(h,d,b);case "{":case "&":return j.find(h,d);default:return c(j.find(h,d))}},a=a.split("\\n"),i=0;i<a.length;i++)a[i]=a[i].replace(g,h,this),f||this.send(a[i]);if(f)return a.join("\\n")},set_delimiters:function(a){a=a.split(" ");this.otag=this.escape_regex(a[0]);this.ctag=this.escape_regex(a[1])},escape_regex:function(a){if(!arguments.callee.sRE)arguments.callee.sRE=RegExp("(\\\\/|\\\\.|\\\\*|\\\\+|\\\\?|\\\\||\\\\(|\\\\)|\\\\[|\\\\]|\\\\{|\\\\}|\\\\\\\\)",\n
"g");return a.replace(arguments.callee.sRE,"\\\\$1")},find:function(a,d){function b(a){return!1===a||0===a||a}var a=g(a),f;if(a.match(/([a-z_]+)\\./ig)){var c=this.walk_context(a,d);b(c)&&(f=c)}else b(d[a])?f=d[a]:b(this.context[a])&&(f=this.context[a]);return"function"==typeof f?f.apply(d):void 0!==f?f:""},walk_context:function(a,d){for(var b=a.split("."),f=void 0!=d[b[0]]?d:this.context,c=f[b.shift()];void 0!=c&&0<b.length;)f=c,c=c[b.shift()];return"function"==typeof c?c.apply(f):c},includes:function(a,\n
d){return-1!=d.indexOf(this.otag+a)},create_context:function(a){if(this.is_object(a))return a;var d=".";if(this.pragmas["IMPLICIT-ITERATOR"])d=this.pragmas["IMPLICIT-ITERATOR"].iterator;var b={};b[d]=a;return b},is_object:function(a){return a&&"object"==typeof a},map:function(a,d){if("function"==typeof a.map)return a.map(d);for(var b=[],c=a.length,e=0;e<c;e++)b.push(d(a[e]));return b},getCachedRegex:function(a,d){var b=o[this.otag];b||(b=o[this.otag]={});var c=b[this.ctag];c||(c=b[this.ctag]={});\n
(b=c[a])||(b=c[a]=d(this.otag,this.ctag));return b}};return{name:"mustache.js",version:"0.4.0",to_html:function(a,c,b,f){var e=new p;if(f)e.send=f;e.render(a,c||{},b);if(!f)return e.buffer.join("\\n")}}}();(function(){var c={VERSION:"0.10",templates:{},$:"undefined"!==typeof window?window.jQuery||window.Zepto||null:null,addTemplate:function(e,i){if("object"===typeof e)for(var g in e)this.addTemplate(g,e[g]);else c[e]?console.error("Invalid name: "+e+"."):c.templates[e]?console.error(\'Template "\'+e+\n
\' " exists\'):(c.templates[e]=i,c[e]=function(g,i){var g=g||{},k=q.to_html(c.templates[e],g,c.templates);return c.$&&!i?c.$(k):k})},clearAll:function(){for(var e in c.templates)delete c[e];c.templates={}},refresh:function(){c.clearAll();c.grabTemplates()},grabTemplates:function(){var e,i=document.getElementsByTagName("script"),g,h=[];for(e=0,l=i.length;e<l;e++)if((g=i[e])&&g.innerHTML&&g.id&&("text/html"===g.type||"text/x-icanhaz"===g.type))c.addTemplate(g.id,"".trim?g.innerHTML.trim():g.innerHTML.replace(/^\\s+/,\n
"").replace(/\\s+$/,"")),h.unshift(g);for(e=0,l=h.length;e<l;e++)h[e].parentNode.removeChild(h[e])}};"undefined"!==typeof require?module.exports=c:window.ich=c;"undefined"!==typeof document&&(c.$?c.$(function(){c.grabTemplates()}):document.addEventListener("DOMContentLoaded",function(){c.grabTemplates()},!0))})()})();\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>5445</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>ICanHaz.min.js</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>getERP5ZoomifyProcessor</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>ERP5ZoomifyImage</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Image_getERP5ZoomifyProcessor</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Image_getERP5ZoomifyProcessor</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>css</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>css</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts54117202.45</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>style.css</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/css</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string>/**\n
CSS Reset\n
* From Blueprint reset.css\n
* http://blueprintcss.googlecode.com\n
*/\n
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, code, del, dfn, em, img, q, dl, dt, dd, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {margin:0;padding:0;border:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline;}\n
body {line-height:1.5;}\n
table {border-collapse:separate;border-spacing:0;}\n
caption, th, td {text-align:left;font-weight:normal;}\n
table, td, th {vertical-align:middle;}\n
blockquote:before, blockquote:after, q:before, q:after {content:"";}\n
blockquote, q {quotes:"" "";}\n
a img {border:none;}\n
/**\n
* Basic Typography\n
*/\n
body {\n
font-family: "Lucida Grande", Verdana, Geneva, Lucida, Arial, Helvetica, sans-serif;\n
font-size: 80%;\n
color: #222;\n
background: #fff;\n
margin: 1em 1.5em;\n
}\n
pre, code {\n
margin: 1.5em 0;\n
white-space: pre;\n
}\n
pre, code {\n
font: 1em \'andale mono\', \'lucida console\', monospace;\n
line-height:1.5;\n
}\n
a[href] {\n
color: #436976;\n
background-color: transparent;\n
}\n
h1, h2, h3, h4, h5, h6 {\n
color: #003a6b;\n
background-color: transparent;\n
font: 100% \'Lucida Grande\', Verdana, Geneva, Lucida, Arial, Helvetica, sans-serif;\n
margin: 0;\n
padding-top: 0.5em;\n
}\n
h1 {\n
font-size: 130%;\n
margin-bottom: 0.5em;\n
border-bottom: 1px solid #fcb100;\n
}\n
h2 {\n
font-size: 120%;\n
margin-bottom: 0.5em;\n
border-bottom: 1px solid #aaa;\n
}\n
h3 {\n
font-size: 110%;\n
margin-bottom: 0.5em;\n
text-decoration: underline;\n
}\n
h4 {\n
font-size: 100%;\n
font-weight: bold;\n
}\n
h5 {\n
font-size: 100%;\n
font-weight: bold;\n
}\n
h6 {\n
font-size: 80%;\n
font-weight: bold;\n
}\n
/**\n
* Map Examples Specific\n
*/\n
.smallmap {\n
/*width: 512px;\n
height: 256px;*/\n
width: 800px;\n
height: 500px;\n
border: 1px solid #ccc;\n
}\n
#tags {\n
display: none;\n
}\n
</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>1809</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>style.css</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_text</string> </key>
<value> <unicode encoding="cdata"><![CDATA[
<!DOCTYPE html>\n
<html>\n
<head>\n
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\n
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">\n
<title>SafeImage</title>\n
<link href="css/bootstrap.min.css" rel="stylesheet"/>\n
<link rel="stylesheet" href="css/default_style.css" type="text/css">\n
<link rel="stylesheet" href="css/style.css" type="text/css">\n
</head>\n
<body>\n
<div class="navbar">\n
<div class="navbar-inner">\n
<div class="container-fluid">\n
<div class="row-fluid">\n
<div class="span10">\n
<ul class="nav">\n
<li><a href="#">Dashboard</a></li>\n
<li><a href="#about">About</a></li>\n
<li><a href="#contact">Contact</a></li>\n
</ul>\n
</div>\n
</div>\n
</div>\n
</div>\n
</div>\n
<div class="container-fluid">\n
<div class="row-fluid">\n
<div class="span3">\n
<div class="well">\n
<ul class="nav nav-list">\n
<li class="nav-header">Images</li>\n
</ul>\n
</div>\n
</div>\n
<section class="span9" id="main">\n
<!--Body content-->\n
</section>\n
</div>\n
</div>\n
<script type="text/javascript" src="js/template.js"></script>\n
<script type="text/javascript" src="jquery/core/jquery.js"></script>\n
<script type="text/javascript" src="urlHandler.js"></script>\n
<script type="text/javascript" src="ICanHaz.min.js"></script>\n
<script type="text/javascript" src="openlayers/OpenLayers.js"></script>\n
<script type="text/javascript" src="js/CanvasImage.js"></script>\n
<script type="text/javascript" src="js/ERP5_OpenLayers.js"></script>\n
<script type="text/javascript" src="js/form.js"></script>\n
<script type="text/javascript" src="js/safeimage.js"></script>\n
<script type="text/javascript" src="js/pixastic.js"></script>\n
</body>\n
</html>
]]></unicode> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>index.html</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <unicode>utf-8</unicode> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>js</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>js</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts54117138.4</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>form.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/**\n
* NEXEDI\n
*/\n
(function($) {\n
\n
$.getJSON(\n
\'http://localhost:12001/erp5/portal_skins/erp5_safeimage/ERP5Site_getTileImageTransformMetadataList\', \n
function(data){\n
for (var i = 0; i < data["image_list"].length; i ++ ) {\n
\n
\t\tvar aux1= "<li><a href=#image/";\n
\t\tvar aux2= "><i class=icon-star></i>";\n
\t\tvar aux3= "</a></li>";\n
$(\'.nav-header\').append(aux1+data["image_list"][i]["id"]+aux2+data["image_list"][i]["title"]+aux3) \n
\t \n
};\n
});\n
\n
var routes = {\n
"/image/:id" : "displayData",\n
"image/:id" : "displayData",\n
}\n
\n
var router = function(e, d){\n
var $this = $(this);\n
$.each(routes, function(pattern, callback){\n
pattern = pattern.replace(/:\\w+/g, \'([^\\/]+)\');\n
var regex = new RegExp(\'^\' + pattern + \'$\');\n
var result = regex.exec(d);\n
if (result) {\n
result.shift();\n
methods[callback].apply($this, result);\n
}\n
});\n
}\n
\n
var methods = {\n
init: function() {\n
// Initialize in this context\n
var $this = $(this);\n
// Bind to urlChange event\n
return this.each(function(){\n
$.subscribe("urlChange", function(e, d){\n
router.call($this, e, d);\n
});\n
});\n
},\n
\n
displayData: function(id){\n
var zoomify_url, zoomify_width, zoomify_height = null;\n
zoomify_url = "http://localhost:12001/erp5/image_module/" + id + "/";\n
//XXX look at the xml definition inside image folder\n
var zoomify_data = $.getJSON(\n
\t\t\t\t"http://localhost:12001/erp5/image_module/" + id + "/TileImage_getMetadataAsJSON",\n
\t\t\t\tfunction(data){\n
\t\t\t\t\twidth=data["sizes"][0]["width"];\n
\t\t\t\t\theight=data["sizes"][0]["height"];\n
\t\t\t\t transforms(width,height);\t\t\t\t\t\t\t\n
\t\t\t\t }\n
\n
\t\t\t);\n
\n
\t$(this).form(\'render\', \'image\', {\'image_id\': id});\n
\n
\n
var transforms = function(width,height){\n
$.getJSON(\n
\'http://localhost:12001/erp5/image_module/\'+id+\'/TileImageTransformed_getTransform\',\n
function(data){\n
pass(width,height,data);\n
}\n
);\n
}\n
\n
\tvar pass = function(zoomify_width,zoomify_height,data){\n
\t\t\t\n
\t\t\t\t$(function() {\n
\t\n
\t\t\t SafeImage.loadOpenLayerZoomedImage(zoomify_width,zoomify_height, zoomify_url,data);\n
\t\t\t\t });\n
\t};\n
\n
},\n
\n
render: function(template, data){\n
\t $(this).html(ich[template](data, true));\n
}\n
\n
};\n
\n
$.fn.form = function(method){\n
if ( methods[method] ) {\n
return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));\n
} else if ( typeof method === \'object\' || ! method ) {\n
return methods.init.apply( this, arguments );\n
} else {\n
$.error( \'Method \' + method + \' does not exist on jQuery.form\' );\n
}\n
};\n
})(jQuery);\n
\n
$("#main").form();\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>2900</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>form.js</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts54116947.11</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>safeimage.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string>var SafeImage = (function() {\n
\n
var that = {};\n
\n
that.loadOpenLayerZoomedImage= function(zoomify_width,\n
zoomify_height, zoomify_url,data){\n
if (that.map !== undefined){\n
that.map.destroy();\n
}\n
/* First we initialize the zoomify pyramid (to get number of tiers) */\n
that.zoomify = new OpenLayers.Layer.Zoomify( "Zoomify", zoomify_url,data,\n
new OpenLayers.Size(zoomify_width, zoomify_height ) );\n
\n
/* Map with raster coordinates (pixels) from Zoomify image */\n
var options = {\n
maxExtent: new OpenLayers.Bounds(0, 0, zoomify_width, zoomify_height),\n
maxResolution: Math.pow(2, that.zoomify.numberOfTiers-1 ),\n
numZoomLevels: that.zoomify.numberOfTiers,\n
units: \'pixels\',\n
size: new OpenLayers.Size(3000,2000)\n
};\n
\n
that.map = new OpenLayers.Map("map", options);\n
that.map.addLayer(that.zoomify);\n
\n
that.map.setBaseLayer(that.zoomify);\n
that.map.zoomToMaxExtent();\n
};\n
return that\n
}());\n
</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>1009</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>safeimage.js</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts54117152.04</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>template.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
(function(){\n
document.write("<script id=\'image\' type=\'text/html\'>");\n
document.write("{{! Service page template }}");\n
document.write("<article>");\n
document.write("{{ image_id }}");\n
document.write("<div id=\'map\' class=\'smallmap\'></div>");\n
document.write("</article>");\n
document.write("</script>");\n
document.domain = "localhost";\n
})();\n
\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>350</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>template.js</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>openlayers</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>openlayers</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts54117433.53</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>urlHandler.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/**\n
* NEXEDI\n
* Author: Thomas Lechauve\n
* Date: 4/18/12\n
*/\n
\n
\n
// Hash parser utility\n
$.parseHash = function(hashTag) {\n
\tvar tokenized = $.extractAuth(hashTag);\n
\tif (tokenized) {\n
\t\t$.publish(\'auth\', tokenized);\n
\t}\n
\tvar splitted = hashTag.substr(1).split(\'/\');\n
\treturn {\n
\t\troute : splitted[0],\n
\t\tid : splitted[1],\n
\t\tmethod : splitted[2]\n
\t}\n
};\n
\n
$.extractAuth = function (hashTag) {\n
\tvar del = hashTag.indexOf(\'&\');\n
\tif (del != -1) {\n
\t\tvar splitted = hashTag.substring(del+1).split(\'&\');\n
\t\tvar result = {};\n
\t\tfor (p in splitted) {\n
\t\t\tvar s = splitted[p].split(\'=\');\n
\t\t\tresult[s[0]] = s[1];\n
\t\t}\n
\t\treturn result;\n
\t}\n
\treturn false;\n
};\n
\n
$.genHash = function(url) {\n
\tif (\'id\' in url) {\n
\t\turl[\'id\'] = \'/\' + url[\'id\'];\n
\t}\n
\tif (\'method\' in url) {\n
\t\turl[\'method\'] = \'/\' + url[\'method\'];\n
\t}\n
\treturn \'/\' + url[\'route\'] + (url[\'id\'] || \'\') + (url[\'method\'] || \'\');\n
};\n
\n
/* Pub / Sub Pattern\n
\tWARNING\n
\tWhat\'s happening when we destroy a DOM object subscribed ?\n
*/\n
var o = $({});\n
$.subscribe = function() {\n
\to.on.apply(o, arguments);\n
};\n
$.unsubscribe = function() {\n
\to.off.apply(o, arguments);\n
};\n
$.publish = function() {\n
\to.trigger.apply(o, arguments);\n
};\n
\n
// Event Handlers\n
$.hashHandler = function(){ $.publish("urlChange", window.location.hash.substr(1)); };\n
$.redirectHandler = function(event, url){ window.location.hash = $.genHash(url); };\n
\n
// redirections manager\n
$.redirect = function(url){ $.publish(\'redirect\', url); };\n
$.subscribe(\'redirect\', $.redirectHandler)\n
\n
$(window).bind(\'hashchange\', $.hashHandler);\n
$(window).bind(\'load\', $.hashHandler);\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>1543</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>urlHandler.js</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
2
\ No newline at end of file
3
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment