diff options
-rw-r--r-- | demo/grappelli/static/grappelli/css/forms.css | 6 | ||||
-rw-r--r-- | demo/grappelli/static/grappelli/css/grappelli-skin-default.css | 13 | ||||
-rw-r--r-- | gstudio/models.py | 38 | ||||
-rw-r--r-- | gstudio/static/gstudio/css/screen.css | 27 | ||||
-rw-r--r-- | gstudio/templates/gstudio/base.html | 4 | ||||
-rw-r--r-- | gstudio/templates/gstudio/skeleton.html | 75 | ||||
-rw-r--r-- | gstudio/xmlrpc/__init__.py | 34 | ||||
-rw-r--r-- | gstudio/xmlrpc/metaweblog.py | 193 | ||||
-rw-r--r-- | gstudio/xmlrpc/rpc/views.py | 186 | ||||
-rw-r--r-- | objectapp/models.py | 26 | ||||
-rw-r--r-- | objectapp/settings.py | 2 | ||||
-rw-r--r-- | objectapp/static/objectapp/css/screen.css | 24 | ||||
-rw-r--r-- | objectapp/templates/objectapp/_gbobject_detail.html | 4 | ||||
-rw-r--r-- | objectapp/templates/objectapp/skeleton.html | 83 |
14 files changed, 599 insertions, 116 deletions
diff --git a/demo/grappelli/static/grappelli/css/forms.css b/demo/grappelli/static/grappelli/css/forms.css index 84e21f6..277334e 100644 --- a/demo/grappelli/static/grappelli/css/forms.css +++ b/demo/grappelli/static/grappelli/css/forms.css @@ -2,7 +2,7 @@ /* Basic Settings, Fieldsets, Form-Rows ------------------------------------------------------------------------------------------------------- */ +----------------------------------------------------------------------------------------------------- */ form { margin: 0; @@ -657,7 +657,7 @@ select.span-16, textarea.span-16, div.autocomplete-wrapper-m2m.span-16, .span-20 label + input[type=text], .span-20 label + input[type=password], .span-20 label + select, .span-20 label + textarea { - width: 598px; + width: 230px; } .span-16 div.autocomplete-wrapper-m2m ul.repr, .span-16 div.autocomplete-wrapper-m2m ul.repr li, @@ -1240,4 +1240,4 @@ div.autocomplete-wrapper-m2m input.vManyToManyRawIdAdminField, div.autocomplete- background: transparent !important; box-shadow: none !important; -moz-box-shadow: none !important; -webkit-box-shadow: none !important; cursor: default !important; -}
\ No newline at end of file +} diff --git a/demo/grappelli/static/grappelli/css/grappelli-skin-default.css b/demo/grappelli/static/grappelli/css/grappelli-skin-default.css index 6f5e721..fe718a3 100644 --- a/demo/grappelli/static/grappelli/css/grappelli-skin-default.css +++ b/demo/grappelli/static/grappelli/css/grappelli-skin-default.css @@ -7,7 +7,7 @@ /* Paragraphs ------------------------------------------------------------------------------------------------------- */ +----------------------------------------------------------------------------------------------------- */ .module p.help, p.help { @@ -166,6 +166,7 @@ body { background: -moz-linear-gradient(top, white, white); background: -webkit-gradient(linear, left top, left bottom, from(white), to(white)); background: -o-linear-gradient(top, white, white); + background: #2B3959; } #header a:hover, #header a:active { color: red; @@ -1907,7 +1908,7 @@ a:hover, a:active, a.selected { } #header a:link, #header a:visited { - color: #0872B4; + color: white; } #header a:hover, #header a:active { color: red; @@ -2016,11 +2017,11 @@ hr { /* User Tools ................................................... */ #user-tools { - border-left: 1px solid #303030; + border-left: 0px solid #303030; } #user-tools>li { - border-left: 1px solid #404040; - border-right: 1px solid #303030; + border-left: 0px solid #404040; + border-right: 0px solid #303030; } li.user-options-container.open a.user-options-handler { color: #eee !important; @@ -2946,7 +2947,7 @@ ul.pagination li.separator span { /* Tooltips ------------------------------------------------------------------------------------------------------- */ +----------------------------------------------------------------------------------------------------- */ .module.search .tooltip .tooltip-content { border: 1px solid #ccc; diff --git a/gstudio/models.py b/gstudio/models.py index 4e047fc..c28b81c 100644 --- a/gstudio/models.py +++ b/gstudio/models.py @@ -746,14 +746,15 @@ class Nodetype(Node): g_json = {} g_json["node_metadata"]= [] g_json["relations"]=[] - + g_json["relset"]=[] + global counter global attr_counter nbh = self.get_nbh predicate_id = {} for key in nbh.keys(): - val = str(counter)+"a" + val = str(counter) + "a" predicate_id[key] = val counter = counter + 1 #print predicate_id @@ -761,7 +762,8 @@ class Nodetype(Node): this_node = {"_id":str(self.id),"title":self.title,"screen_name":self.title, "url":self.get_absolute_url(),"expanded":"true"} - g_json["node_metadata"].append(this_node) + g_json["node_metadata"].append(this_node) + g_json["relset"].append(self.id) for key in predicate_id.keys(): if nbh[key]: @@ -774,14 +776,32 @@ class Nodetype(Node): #g_json[str(key)].append({"from":self.id , "to":predicate_id[key],"value":1, "level":1 }) g_json["relations"].append({"from":self.id ,"type":str(key),"value":1,"to":predicate_id[key] }) + if not isinstance(nbh[key],basestring): for item in nbh[key]: - #create nodes - g_json["node_metadata"].append({"_id":str(item.id),"screen_name":item.title,"title":self.title, "url":item.get_absolute_url(),"expanded":"false"}) + if item.reftype!="Relation": + # create nodes + + g_json["node_metadata"].append({"_id":str(item.id),"screen_name":item.title,"title":self.title, "url":item.get_absolute_url(),"expanded":"false"}) + g_json["relset"].append(item.id) + + + # g_json[str(key)].append({"from":predicate_id[key] , "to":item.id ,"value":1 }) + #create links + g_json["relations"].append({"from":predicate_id[key] ,"type":str(key), "value":1,"to":item.id }) + + else: + + if item.left_subject.id==self.id: + item1=item.right_subject + elif item.right_subject.id==self.id: + item1=item.left_subject + + g_json["node_metadata"].append({"_id":str(item1.id),"screen_name":item1.title,"title":self.title, "url":item1.get_absolute_url(),"expanded":"false"}) - # g_json[str(key)].append({"from":predicate_id[key] , "to":item.id ,"value":1 }) - #create links - g_json["relations"].append({"from":predicate_id[key] ,"type":str(key), "value":1,"to":item.id }) + # g_json[str(key)].append({"from":predicate_id[key] , "to":item.id ,"value":1 }) + #create links + g_json["relations"].append({"from":predicate_id[key] ,"type":str(key), "value":1,"to":item1.id }) else: #value={nbh["plural"]:"a4",nbh["altnames"]:"a5"} @@ -789,7 +809,7 @@ class Nodetype(Node): #for item in value.keys(): g_json["node_metadata"].append({"_id":(str(attr_counter)+"a"),"screen_name":nbh[key]}) #g_json[str(key)].append({"from":predicate_id[key] , "to":attr_counter ,"value":1, "level":2 }) - g_json["relations"].append({"from":predicate_id[key] ,"type":str(key) ,"value":1,"to":(str(attr_counter)+"a") }) + g_json["relations"].append({"from":predicate_id[key] ,"type":str(key) ,"value":1,"to":(str(attr_counter)+"a")}) attr_counter-=1 except: diff --git a/gstudio/static/gstudio/css/screen.css b/gstudio/static/gstudio/css/screen.css index f786de6..c107776 100644 --- a/gstudio/static/gstudio/css/screen.css +++ b/gstudio/static/gstudio/css/screen.css @@ -1,4 +1,4 @@ -body { line-height: 1.5; font-family: Arial, Helvetica, sans-serif; color: #333333; font-size: 75%; height:1500px;width:1500px} +body { line-height: 1.5; font-family: Arial, Helvetica, sans-serif; color: #333333; font-size: 75%; height:1500px; width: 90%; } h1, h2, h3, h4, h5, h6 { font-weight: normal; color: #176691; border-radius:15px; } h1 img, h2 img, h3 img, h4 img, h5 img, h6 img { margin: 0; } @@ -130,7 +130,7 @@ caption { background: #eeeeee; } .span-15 { width: 590px; } -.span-16 { width: 150px; } +.span-16 { width: 500px; } .span-17 { width: 670px; } @@ -406,7 +406,7 @@ textarea { margin: 0.5em 0; padding: 5px; } select { margin: 0.5em 0; } -fieldset { border: 1px solid #cccccc; } +fieldset { border: 1px solid #cccccc; width:150px;} input.text, input.title, input[type=email], input[type=text], input[type=password], textarea { background-color: #fff; border: 1px solid #bbbbbb; } input.text:focus, input.title:focus, input[type=email]:focus, input[type=text]:focus, input[type=password]:focus, textarea:focus { border: 1px solid #666666; } @@ -424,7 +424,7 @@ ul, ol { margin: 0 1.5em 1.5em 0; padding-left: 3.333em; } a { text-decoration: none; } a:hover { text-decoration: underline; } -#header { margin-bottom: 1em; border-bottom: 1px solid #e9e9f3; } +#header { margin-bottom: 1em; border-bottom: 1px solid #e9e9f3; background: #2b3959; color: white;} #header h1 { font-size: 2em; font-weight: bold; margin-bottom: 0; } #header .top-navigation { float: right; } #header .top-navigation img { border: 0; } @@ -436,7 +436,7 @@ a:hover { text-decoration: underline; } #b1 {position:relative; center:5%; background-color:#43AEE7; color: white; border: 1px solid #000000; font-size:1em;} #b2 {position:relative; center:6%; background-color:#43AEE7; color: white; border: 1px solid #000000; font-size:1em;} -#body { margin-bottom: 1em; border-bottom: 1px solid #e9e9f3; } +#body { margin-bottom: 1em; border-bottom: 1px solid #e9e9f3; width: 100%; } #content h1, #content h2, #content h3 { margin-top: 10px; } @@ -446,13 +446,12 @@ a:hover { text-decoration: underline; } float: left; clear: both; margin-bottom: 10px; - margin-left: 0; - margin-right: 60px; + margin-left: 0%; + margin-right: 0%; margin-top: 10px; - padding-right: 30px; + padding-right: 0px; width:250px; } - #graph { position: absolute; float: left; @@ -475,14 +474,14 @@ a:hover { text-decoration: underline; } font-weight: bold; } #graphcss { - margin-left: 224px; - margin-right: 150px; + margin-left: 231px; + margin-right: 0%; margin-top: 1px; position: absolute; - width: 300px; + width: 54%; height: 900px } -#sidebar{position:absolute; margin-left:1000px; margin-right:150px; margin-top:10px; width:300px;} +#sidebar{position:relative; margin-left:85%; margin-right:0%; margin-top:10px; width:24%;} #sidebar div:first-child h3 { margin-top:0px; } #sidebar h3 { background-color: #C4EBF4; padding: 0.5em; } #sidebar p { padding-left: 1em; } @@ -504,7 +503,7 @@ a:hover { text-decoration: underline; } #sidebar .tags div ul .tag_4 { font-size: 2em; color: #0070a8; } #sidebar .tags div ul .tag_5 { font-size: 2.25em; color: #0099e5; } #sidebar .tags div ul .tag_6 { font-size: 3em; color: #00adff; } - +#footer{position: static; top: 4px; left: -1px; margin-top: 18px;} th.month{padding:0cm 2.5cm;} table.month { margin-bottom: 0; } table.month th.month { text-transform: uppercase; color: #006699; background: none; } diff --git a/gstudio/templates/gstudio/base.html b/gstudio/templates/gstudio/base.html index 94a72eb..0b70311 100644 --- a/gstudio/templates/gstudio/base.html +++ b/gstudio/templates/gstudio/base.html @@ -20,8 +20,8 @@ {% endblock %} {% block sidebar %} - <img src="{{ STATIC_URL }}objectapp/img/rss.png" alt="?" width="20" height="" /> - <a href="{% url objectapp_gbobject_latest_feed %}" class="feeds"><h4>Rssfeed</h4></a> + <img src="{{ STATIC_URL }}gstudio/img/rss.png" alt="?" width="20" height="" /> + <a href="{% url gstudio_nodetype_latest_feed %}" class="feeds"><h4>Rssfeed</h4></a> <div class="search"> <h3>{% trans "Search" %}</h3> diff --git a/gstudio/templates/gstudio/skeleton.html b/gstudio/templates/gstudio/skeleton.html index 41df756..3b945f4 100644 --- a/gstudio/templates/gstudio/skeleton.html +++ b/gstudio/templates/gstudio/skeleton.html @@ -46,8 +46,8 @@ display: block; } svg { - margin-left: 50%; - margin-right: 50%; + margin-left: 0%; + margin-right: 10%; display: block; position: absolute; } @@ -192,10 +192,10 @@ function init(a,b) all_edges =_(b).chain().map(function(e) { e.source = nodes_by_id[e.from]; e.target = nodes_by_id[e.to]; - + //`e.type = nodes_by_id[e.type] return e; }).filter(function(e){ - return nodes_by_id[e.from] && nodes_by_id[e.to]&& e.type!="title" && e.type!="content" + return nodes_by_id[e.from] && nodes_by_id[e.to]&& e.type!="title" && e.type!="content" }).value(); @@ -207,6 +207,7 @@ $(function fgraph() { $.getJSON('/nodetypes/graphs/graph_json/' + {{object.id}}, function (json1) { metadata=json1.node_metadata; relations=json1.relations; + relnset=json1.relset init(metadata,relations); load({{object.id}}) }); @@ -214,26 +215,25 @@ $.getJSON('/nodetypes/graphs/graph_json/' + {{object.id}}, function (json1) { function load(key) { - -var a = 25 * s; - - if ( a > 700 ) - { - var w = 700; - } - else - { - var w = a; - } - - var h = 24 * s, + if (s > 0 ){ + var a = 50 * s; + var w = 700; + var p = 100 + "%"; + var h = 600; + var q = 3 * s + 35 + "%"; + }else{ + var w = 700; + var p = 100 + "%"; + var h = 600; + var q = 110 + "%"; + } fill = d3.scale.category20(); var vis = d3.select("#chart") .append("svg:svg") .attr("id", "amazingViz") - .attr("width", w) - .attr("height", h); + .attr("width", p) + .attr("height", q); vis.append("svg:g").attr("class", "edges"); vis.append("svg:g").attr("class", "nodes"); @@ -253,7 +253,7 @@ var a = 25 * s; .charge(-5000) .friction(0.7) .gravity(0.7) - .linkDistance(75) + .linkDistance(50) .nodes([]) .links([]) .size([w, h]) @@ -282,7 +282,7 @@ var a = 25 * s; - link = d3.select("#chart g.edges").selectAll("line.link") + link = d3.select("#chart g.edges").selectAll("line.link").select(this.arrowhead) .data(edges, function(e){return e.from + "-" + e.to + "-" + e.type}); link.enter().append("svg:line") @@ -305,11 +305,11 @@ var a = 25 * s; .attr("text", function(d) { return d.type; }) + .attr("marker-end", "url(#arrowhead)"); + + - .append("a") - .text(function(d) { return d.type; }); - var node = d3.select("#chart g.nodes").selectAll("g.node").data(nodes); @@ -324,6 +324,21 @@ var a = 25 * s; + new_g.append("svg:marker") + .attr("id", "arrowhead") + .attr("viewBox","0 0 10 10") + .attr("refX","20") + .attr("refY","5") + .attr("markerUnits","strokeWidth") + .attr("markerWidth","9") + .attr("markerHeight","5") + .attr("orient","auto") + .append("svg:path") + .attr("d","M 0 0 L 10 5 L 0 10 z") + .attr("fill", "#6D6666"); + + + $(window).bind('keydown',function(event){ if(17==event.keyCode){ new_g.on("click",function(d){ @@ -333,7 +348,8 @@ $(window).bind('keydown',function(event){ d.expanded="true"; $.getJSON('/nodetypes/graphs/graph_json/' + d._id , function (json2) { new_metadata=json2.node_metadata; - new_relations=json2.relations; + new_relations=json2.relations; + new_relnset=json2.relset metadata=_.union(new_metadata,metadata); relations=_.union(new_relations,relations); init(metadata,relations); @@ -383,7 +399,8 @@ $(window).bind('keydown',function(event){ new_g.filter(function(d) { return (d._id).charAt(0)=="-"; }).append("svg:rect") - .attr("x",bbox.x-22) + .attr("x",bbox.x-22 + ) .attr("y", bbox.y) .attr("width", function(d) {var ttx=d.screen_name ; return (ttx.length+bbox.width+40)}) .attr("height", bbox.height) @@ -411,6 +428,7 @@ $(window).bind('keydown',function(event){ + node.exit().remove(); @@ -450,7 +468,6 @@ $(window).bind('keydown',function(event){ </script> - </div> <div id="sidebar"> {% block sidebar %} @@ -458,7 +475,7 @@ $(window).bind('keydown',function(event){ </div> - <div id="footer" class="span-24 last"> + <div id="footer"> <p> <a rel="license" @@ -471,6 +488,6 @@ $(window).bind('keydown',function(event){ </p> </div> - + </div> </body> </html> diff --git a/gstudio/xmlrpc/__init__.py b/gstudio/xmlrpc/__init__.py index 9bec595..afb41e6 100644 --- a/gstudio/xmlrpc/__init__.py +++ b/gstudio/xmlrpc/__init__.py @@ -80,6 +80,38 @@ GSTUDIO_XMLRPC_METAWEBLOG = [ ('gstudio.xmlrpc.metaweblog.get_nbh', 'metaWeblog.get_nbh'), ('gstudio.xmlrpc.metaweblog.new_media_object', - 'metaWeblog.newMediaObject')] + 'metaWeblog.newMediaObject'), + ('gstudio.xmlrpc.metaweblog.getNodetype', + 'metaweblog.getNodetype'), + ('gstudio.xmlrpc.metaweblog.nidExists', + 'metaweblog.nidExists'), + ('gstudio.xmlrpc.metaweblog.getinfoFromSSID', + 'metaweblog.getinfoFromSSID'), + #('gstudio.xmlrpc.metaweblog.getNeighbourhood', + #'metaweblog.getNeighbourhood'), + # ('gstudio.xmlrpc.metaweblog.getallNodes', + # 'metaweblog.getallNodes'), + ('gstudio.xmlrpc.metaweblog.getDatatype', + 'metaweblog.getDatatype'), + ('gstudio.xmlrpc.metaweblog.getAttributevalues', + 'metaweblog.getAttributevalues'), + ('gstudio.xmlrpc.metaweblog.getSubjecttypes', + 'metaweblog.getSubjecttypes'), + #('gstudio.xmlrpc.metaweblog.getAttributeType', + #'metaweblog.getAttributeType'), + ('gstudio.xmlrpc.metaweblog.getRoles', + 'metaweblog.getRoles'), + ('gstudio.xmlrpc.metaweblog.getSubtypes', + 'metaweblog.getSubtypes'), + #('gstudio.xmlrpc.metaweblog.Suballtypes', + #'metaweblog.Suballtypes'), + ('gstudio.xmlrpc.metaweblog.getRestrictions', + 'metaweblog.getRestrictions'), + ('gstudio.xmlrpc.metaweblog.getlatestSSID', + 'metaweblog.getlatestSSID'), + ('gstudio.xmlrpc.metaweblog.getAllSnapshots', + 'metaweblog.getAllSnapshots') +] + GSTUDIO_XMLRPC_METHODS = GSTUDIO_XMLRPC_PINGBACK + GSTUDIO_XMLRPC_METAWEBLOG diff --git a/gstudio/xmlrpc/metaweblog.py b/gstudio/xmlrpc/metaweblog.py index 6c89c21..5b273ea 100644 --- a/gstudio/xmlrpc/metaweblog.py +++ b/gstudio/xmlrpc/metaweblog.py @@ -1,4 +1,4 @@ -# Copyright (c) 2011, 2012 Free Software Foundation + # Copyright (c) 2011, 2012 Free Software Foundation # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -70,6 +70,8 @@ from gstudio.settings import PROTOCOL from gstudio.settings import UPLOAD_TO from gstudio.managers import DRAFT, PUBLISHED from django_xmlrpc.decorators import xmlrpc_func +from django.utils.datastructures import SortedDict +from gstudio.models import * # http://docs.nucleuscms.org/blog/12#errorcodes LOGIN_ERROR = 801 @@ -373,4 +375,191 @@ def new_media_object(blog_id, username, password, media): authenticate(username, password) path = default_storage.save(os.path.join(UPLOAD_TO, media['name']), ContentFile(media['bits'].data)) - return {'url': default_storage.url(path)} + return {'url': default_storage.url(path)} + + +@xmlrpc_func(returns='string', args='int') +def getNodetype(ssid): + """Returns the nodetype of given ssid """ + try : + g = Nodetype.objects.get(id=ssid) + return (g.ref._meta.module_name) + except Nodetype.DoesNotExist : + return "Node with the given ssid does not exist" + +@xmlrpc_func(returns='int', args='string') +def nidExists(nid): + """Returns 1 if a node with given id exists, else returns a 0 """ + try: + p = Nodetype.objects.get(title = nid) + return 1 + except Nodetype.DoesNotExist: + return 0 + + +@xmlrpc_func(returns=['struct'],args=['string']) +def getinfoFromSSID(ssid_list) : + """Given a list of ssids, it returns entire information of each ssid inside a dictionary with all the dictionaries contained within a list """ + lst = [] + for ssid in ssid_list : + try : + p = Objecttype.objects.get(id = ssid) + nbh = p.ref.get_nbh + lst.append(str(nbh)) + except Objecttype.DoesNotExist : + return "ssid",ssid,"Does not exist" + + + return lst + + + +@xmlrpc_func(returns=['struct'], args=['string']) + +def getDatatype(attrtype_ssid_list) : + """Given a list of attributessids, it returns its datatypes """ + + d = {} + g = {} + for l in attrtype_ssid_list : + p = NID.objects.get(id = l) + n = p.ref._meta.module_name + if n == 'attributetype' : + ft = FIELD_TYPE_CHOICES[int(p.ref.dataType) - 1] + d[str(p.id)] = ft[1] + else : + return " Node does not exist " + + return d + + +@xmlrpc_func(returns=['struct'], args=['string']) + +def getAttributevalues(Attrssidlist) : + """Given a list of attributessid, it returns their values """ + + d = {} + for l in Attrssidlist : + try : + p = Attribute.objects.get(id = l) + d[str(p.id)] = p.svalue + except Attribute.DoesNotExist : + return " Node does not exist" + + return d + + +@xmlrpc_func(returns=['struct'], args=['string']) + + +def getSubjecttypes( AttributeTypeNid ) : + """Given an attributetypenid, it returns the subjecttype participating in the attributetype """ + d ={} + for l in AttributeTypeNid : + try : + p = Attributetype.objects.get(id = l) + n = p.ref.subjecttype_id + s = NID.objects.get(id = n) + d[str(s.title)]= n + d['applicable_nodetypes'] = p.applicable_nodetypes + except Attribute.DoesNotExist: + return " Node does not exist " + return d + + + + + + +@xmlrpc_func(returns=['struct'], args=['string']) + +def getRoles(relationtypenid) : + """given a relationtype nid this method returns the roles participating in the relationtype """ + + d = {} + p = Relationtype.objects.get(nodetype_ptr_id = relationtypenid) + + d['cardinality1 '] = p.left_cardinality + d['cardinality2'] = p.right_cardinality + d['rtid'] = p.nodetype_ptr_id + d['applicablenodetype1'] = p.left_applicable_nodetypes + d['applicablenodetype2'] = p.right_applicable_nodetypes + d['subjecttype1'] = p.left_subjecttype_id + d['subjecttype2'] = p.right_subjecttype_id + return d + + +@xmlrpc_func(returns=['struct'], args=['string']) + + +def getSubtypes(nodeid) : + """Returns only the immediate subtype of the node specified""" + i = 0 + l = [] + p = Objecttype.objects.get(id = nodeid) + n = p.get_children() + u = len(n) + while u>0 : + t = n[i].id + l.append(str(t)) + i = i+1 + u = u-1 + return l + + + + +@xmlrpc_func(returns=['struct'], args=['string']) + +def getRestrictions(ATlist) : + """Given a list of attributetype ssids, this method returns all the restrictions that the attributetypes have """ + u = {} + d = {} + ft = [] + for a in ATlist : + p = Attributetype.objects.get(id = a) + ft = FIELD_TYPE_CHOICES[int(p.dataType)-1] + u['datatype'] = ft[1] + u['length'] = p.max_digits + u['precision'] = p.decimal_places + d[str(p.id)] = u + + return d + +@xmlrpc_func(returns='int', args='int') + +def getlatestSSID(nid) : + """Given the id, this method will return the latest ssid of the given id """ + + p = NID.objects.get(id = nid) + n = p.get_ssid + u = len(n) + r = n[u-1] + return r + + +@xmlrpc_func(returns=['struct'], args='int') + +def getAllSnapshots(nid) : + """Given the id, this method will return all the ssids of the given id """ + + p = NID.objects.get(id = nid) + n = p.get_ssid + return n + + + + + + + + + + + + + + + + + diff --git a/gstudio/xmlrpc/rpc/views.py b/gstudio/xmlrpc/rpc/views.py new file mode 100644 index 0000000..8c66b38 --- /dev/null +++ b/gstudio/xmlrpc/rpc/views.py @@ -0,0 +1,186 @@ +"""Uses SimpleXMLRPCServer's SimpleXMLRPCDispatcher to serve XML-RPC requests + +Authors:: + Graham Binns + Reza Mohammadi + Julien Fache + +Credit must go to Brendan W. McAdams <brendan.mcadams@thewintergrp.com>, who +posted the original SimpleXMLRPCDispatcher to the Django wiki: +http://code.djangoproject.com/wiki/XML-RPC + +New BSD License +=============== +Copyright (c) 2007, Graham Binns http://launchpad.net/~codedragon + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the <ORGANIZATION> nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +""" +import sys + +import django +from django.conf import settings +from django.template import RequestContext +from django.shortcuts import render_to_response +from django.core.exceptions import ImproperlyConfigured +from django.http import HttpResponse, HttpResponseServerError +from gstudio.xmlrpc.metaweblog import * +from django.utils.datastructures import SortedDict +try: + from django.views.decorators.csrf import csrf_exempt +except ImportError: + from django.contrib.csrf.middleware import csrf_exempt + +from dispatcher import DjangoXMLRPCDispatcher +from decorators import xmlrpc_func + + +# We create a local DEBUG variable from the data in settings. +DEBUG = hasattr(settings, 'XMLRPC_DEBUG') and settings.XMLRPC_DEBUG + +# Declare xmlrpcdispatcher correctly depending on our python version +if sys.version_info[:3] >= (2, 5,): + xmlrpcdispatcher = DjangoXMLRPCDispatcher(allow_none=True, encoding=None) +else: + xmlrpcdispatcher = DjangoXMLRPCDispatcher() + + +def request_datas(request): + if django.VERSION[1] > 3: + return request.body + return request.raw_post_data + + +@xmlrpc_func(returns='string', args=['string']) +def test_xmlrpc(text): + """Simply returns the args passed to it as a string""" + return "Here's a response! %s" % str(text) + + +@csrf_exempt +def handle_xmlrpc(request): + """Handles XML-RPC requests. All XML-RPC calls should be forwarded here + + request + The HttpRequest object that carries the XML-RPC call. If this is a + GET request, nothing will happen (we only accept POST requests) + """ + if request.method == "POST": + if DEBUG: + print request_datas(request) + try: + response = HttpResponse(content_type='text/xml') + response.write( + xmlrpcdispatcher._marshaled_dispatch(request_datas(request))) + if DEBUG: + print response + return response + except: + return HttpResponseServerError() + else: + methods = xmlrpcdispatcher.system_listMethods() + method_list = [] + + for method in methods: + sig_ = xmlrpcdispatcher.system_methodSignature(method) + sig = { + 'returns': sig_[0], + 'args': ", ".join(sig_[1:]), + } + + # this just reads your docblock, so fill it in! + method_help = xmlrpcdispatcher.system_methodHelp(method) + + method_list.append((method, sig, method_help)) + + if hasattr(settings, 'XMLRPC_GET_TEMPLATE'): + # This behaviour is deprecated + if settings.DEBUG: + print "Use of settings.XMLRPC_GET_TEMPLATE is deprecated " \ + + "Please update your code to use django_xmlrpc/templates" + template = settings.XMLRPC_GET_TEMPLATE + else: + template = 'xmlrpc_get.html' + return render_to_response(template, {'methods': method_list}, + context_instance=RequestContext(request)) + + +# Load up any methods that have been registered with the server in settings +if hasattr(settings, 'XMLRPC_METHODS'): + for path, name in settings.XMLRPC_METHODS: + # if "path" is actually a function, just add it without fuss + if callable(path): + xmlrpcdispatcher.register_function(path, name) + continue + + # Otherwise we try and find something that we can call + i = path.rfind('.') + module, attr = path[:i], path[i + 1:] + + try: + mod = __import__(module, globals(), locals(), [attr]) + except ImportError, ex: + raise ImproperlyConfigured("Error registering XML-RPC method: " \ + + "module %s can't be imported" % module) + + try: + func = getattr(mod, attr) + except AttributeError: + raise ImproperlyConfigured('Error registering XML-RPC method: ' \ + + 'module %s doesn\'t define a method "%s"' % (module, attr)) + + if not callable(func): + raise ImproperlyConfigured('Error registering XML-RPC method: ' \ + + '"%s" is not callable in module %s' % (attr, module)) + + xmlrpcdispatcher.register_function(func, name) + xmlrpcdispatcher.register_function(getNodetype,'getNodetype') + xmlrpcdispatcher.register_function(nidExists,'nidExists') + xmlrpcdispatcher.register_function(getinfoFromSSID,'getinfoFromSSID') + #xmlrpcdispatcher.register_function(getNeighbourhood,'getNeighbourhood') + xmlrpcdispatcher.register_function(get_nbh,'get_nbh') + #xmlrpcdispatcher.register_function(getallNodes,'getallNodes') + xmlrpcdispatcher.register_function(getDatatype,'getDatatype') + xmlrpcdispatcher.register_function(getAttributevalues,'getAttributevalues') + xmlrpcdispatcher.register_function(getSubjecttypes,'getSubjecttypes') + #xmlrpcdispatcher.register_function(getAttributeType,'getAttributeType') + xmlrpcdispatcher.register_function(getRoles,'getRoles') + xmlrpcdispatcher.register_function(getSubtypes,'getSubtypes') + #xmlrpcdispatcher.register_function(Suballtypes,'Suballtypes') + xmlrpcdispatcher.register_function(getRestrictions,'getRestrictions') + xmlrpcdispatcher.register_function(getlatestSSID,'getlatestSSID') + xmlrpcdispatcher.register_function(getAllSnapshots,'getAllSnapshots') + + + + + + + +# Finally, register the introspection and multicall methods with the XML-RPC +# namespace +xmlrpcdispatcher.register_introspection_functions() +xmlrpcdispatcher.register_multicall_functions() diff --git a/objectapp/models.py b/objectapp/models.py index 182b0f2..4ed7279 100644 --- a/objectapp/models.py +++ b/objectapp/models.py @@ -367,6 +367,7 @@ class Gbobject(Node): g_json = {} g_json["node_metadata"]= [] g_json["relations"]=[] + g_json["relset"]=[] global counter global attr_counter @@ -383,6 +384,7 @@ class Gbobject(Node): this_node = {"_id":str(self.id),"title":self.title,"screen_name":self.title, "url":self.get_absolute_url(),"expanded":"true"} g_json["node_metadata"].append(this_node) + g_json["relset"].append(self.id) for key in predicate_id.keys(): if nbh[key]: @@ -394,13 +396,27 @@ class Gbobject(Node): g_json["relations"].append({"from":self.id ,"type":str(key),"value":1,"to":predicate_id[key] }) if not isinstance(nbh[key],basestring): for item in nbh[key]: + if item.reftype!="Relation": # create nodes - g_json["node_metadata"].append({"_id":str(item.id),"screen_name":item.title,"title":self.title, "url":item.get_absolute_url(),"expanded":"false"}) - # g_json[str(key)].append({"from":predicate_id[key] , "to":item.id ,"value":1 }) - #create links - g_json["relations"].append({"from":predicate_id[key] ,"type":str(key), "value":1,"to":item.id }) - + g_json["node_metadata"].append({"_id":str(item.id),"screen_name":item.title,"title":self.title, "url":item.get_absolute_url(),"expanded":"false"}) + g_json["relset"].append(item.id) + # g_json[str(key)].append({"from":predicate_id[key] , "to":item.id ,"value":1 }) + #create links + g_json["relations"].append({"from":predicate_id[key] ,"type":str(key), "value":1,"to":item.id }) + + else: + + if item.left_subject.id==self.id: + item1=item.right_subject + elif item.right_subject.id==self.id: + item1=item.left_subject + + g_json["node_metadata"].append({"_id":str(item1.id),"screen_name":item1.title,"title":self.title, "url":item1.get_absolute_url(),"expanded":"false"}) + + # g_json[str(key)].append({"from":predicate_id[key] , "to":item.id ,"value":1 }) + #create links + g_json["relations"].append({"from":predicate_id[key] ,"type":str(key), "value":1,"to":item1.id }) else: #value={nbh["plural"]:"a4",nbh["altnames"]:"a5"} #this_node[str(key)]=nbh[key] key, nbh[key] diff --git a/objectapp/settings.py b/objectapp/settings.py index 727b716..ba6004d 100644 --- a/objectapp/settings.py +++ b/objectapp/settings.py @@ -56,7 +56,7 @@ SAVE_PING_EXTERNAL_URLS = getattr(settings, 'OBJECTAPP_PING_EXTERNAL_URLS', True COPYRIGHT = getattr(settings, 'OBJECTAPP_COPYRIGHT', 'Objectapp') -PAGINATION = getattr(settings, 'OBJECTAPP_PAGINATION', 10) +PAGINATION = getattr(settings, 'OBJECTAPP_PAGINATION', 4) ALLOW_EMPTY = getattr(settings, 'OBJECTAPP_ALLOW_EMPTY', True) ALLOW_FUTURE = getattr(settings, 'OBJECTAPP_ALLOW_FUTURE', True) diff --git a/objectapp/static/objectapp/css/screen.css b/objectapp/static/objectapp/css/screen.css index c69ca99..408dd84 100644 --- a/objectapp/static/objectapp/css/screen.css +++ b/objectapp/static/objectapp/css/screen.css @@ -1,4 +1,4 @@ -body { line-height: 1.5; font-family: Arial, Helvetica, sans-serif; color: #333333; font-size: 75%; height:1500px;width:1500px} +body { line-height: 1.5; font-family: Arial, Helvetica, sans-serif; color: #333333; font-size: 75%; height:1500px; width: 85%; } h1, h2, h3, h4, h5, h6 { font-weight: normal; color: #000000; border-radius:15px; } h1 img, h2 img, h3 img, h4 img, h5 img, h6 img { margin: 0; } @@ -424,7 +424,7 @@ ul, ol { margin: 0 1.5em 1.5em 0; padding-left: 3.333em; } a { text-decoration: none; } a:hover { text-decoration: underline; } -#header { margin-bottom: 1em; border-bottom: 1px solid #e9e9f3; } +#header { margin-bottom: 1em; border-bottom: 1px solid #e9e9f3; background: #2b3959; color: white;} #header h1 { font-size: 2em; font-weight: bold; margin-bottom: 0; } #header .top-navigation { float: right; } #header .top-navigation img { border: 0; } @@ -440,7 +440,7 @@ a:hover { text-decoration: underline; } #b1 {position:relative; center:5%; background-color:#43AEE7; color: white; border: 1px solid #000000; font-size:1em;} #b2 {position:relative; center:6%; background-color:#43AEE7; color: white; border: 1px solid #000000; font-size:1em;} -#body { margin-bottom: 1em; border-bottom: 1px solid #e9e9f3; } +#body { margin-bottom: 1em; border-bottom: 0px solid #e9e9f3; width: 100%;} #content h1, #content h2, #content h3 { margin-top: 10px; } @@ -450,10 +450,10 @@ a:hover { text-decoration: underline; } float: left; clear: both; margin-bottom: 10px; - margin-left: 0; - margin-right: 60px; + margin-left: 0%; + margin-right: 0%; margin-top: 10px; - padding-right: 30px; + padding-right: 0%; width:250px; } @@ -479,14 +479,14 @@ a:hover { text-decoration: underline; } font-weight: bold; } #graphcss{ - margin-left: 230px; - margin-right: 150px; + margin-left: 237px; + margin-right: 0px; margin-top: 1px; position: absolute; - width: 300px; + width: 46%; height: 900px } -#sidebar{position:absolute; margin-left:600px; margin-right:150px; margin-top:10px; width:300px;} +#sidebar{position:relative; margin-left:92%; margin-right:0px; margin-top:10px; width:23%;} #sidebar div:first-child h3 { margin-top:0px; } #sidebar h3 { background-color: #FFE9E8; padding: 0.5em; } #sidebar p { padding-left: 1em; } @@ -508,7 +508,7 @@ a:hover { text-decoration: underline; } #sidebar .tags div ul .tag_4 { font-size: 2em; color: #0070a8; } #sidebar .tags div ul .tag_5 { font-size: 2.25em; color: #0099e5; } #sidebar .tags div ul .tag_6 { font-size: 3em; color: #00adff; } - +#footer{ position:static; border-bottom: 1px solid #E9E9F3; margin-top: 85px; } th.month{padding:0cm 2.5cm;} table.month { margin-bottom: 0; } table.month th.month { text-transform: uppercase; color: #555555; background: none; } @@ -516,7 +516,7 @@ table.month th { text-transform: capitalize; color: #555555; background-color: # table.month td { text-align: center; font-weight: bold; } table.month td.objecttype { background-color: #C4EBF4; } -div.paginator { margin-bottom: 1em; } +div.paginator { margin-bottom: 2em; } div.paginator span { font-size: 1.2em; margin-left: 0.3em; padding: 0 0.5em 0 0.5em; float: left; border: 1px solid #e9e9f3; } div.paginator span.index { margin-left: 0; } div.paginator span.page:hover, div.paginator span.next:hover, div.paginator span.previous:hover { background-color: #006699; } diff --git a/objectapp/templates/objectapp/_gbobject_detail.html b/objectapp/templates/objectapp/_gbobject_detail.html index 6b21356..ee43aba 100644 --- a/objectapp/templates/objectapp/_gbobject_detail.html +++ b/objectapp/templates/objectapp/_gbobject_detail.html @@ -28,7 +28,7 @@ </div> -</div> + <p> <b>Name: </b> {{ object.title }} <br/> @@ -76,7 +76,7 @@ </p> - +</div> <div class="gbobject-body span-16 last"> diff --git a/objectapp/templates/objectapp/skeleton.html b/objectapp/templates/objectapp/skeleton.html index 2990d9a..928c0e6 100644 --- a/objectapp/templates/objectapp/skeleton.html +++ b/objectapp/templates/objectapp/skeleton.html @@ -47,8 +47,8 @@ display: block; } svg { - margin-left: 10%; - margin-right: 10%; + margin-left: 0%; + margin-right: 0%; display: block; position: absolute; } @@ -224,27 +224,26 @@ $.getJSON('/nodetypes/graphs/graph_json/' + {{object.id}}, function (json1) { function load(key) { - -var a = 800 * s; - - if ( a > 700 ) - { - var w = 700; - } - else - { - var w = a; - } - - var h = 232 * s, + +if ( s > 0) { +var w = 700; +var p = 122 + "%"; +var h = 800; +var q = 3 * s + 60 + "%"; +}else{ +var w = 700; +var p = 122 + "%"; +var h = 800; +var q = 110 + "%"; +} fill = d3.scale.category20(); var vis = d3.select("#chart") .append("svg:svg") .attr("id", "amazingViz") - .attr("width", w) - .attr("height", h); + .attr("width", p) + .attr("height", q); vis.append("svg:g").attr("class", "edges"); vis.append("svg:g").attr("class", "nodes"); @@ -264,7 +263,7 @@ var a = 800 * s; .charge(-5000) .friction(0.7) .gravity(0.7) - .linkDistance(75) + .linkDistance(50) .nodes([]) .links([]) .size([w, h]) @@ -290,12 +289,12 @@ var a = 800 * s; force.links(edges); force.start(); - link = d3.select("#chart g.edges").selectAll("line.link") + link = d3.select("#chart g.edges").selectAll("line.link").select(this.arrowhead) .data(edges, function(e){return e.from + "-" + e.to + "-" + e.type}); link.enter().append("svg:line") .attr("class", "link") - .style("stroke-width", 2 /* function(d) { + .style("stroke-width", 2/* function(d) { return Math.sqrt(d.value); } */ ) .attr("x1", function(d) { @@ -313,9 +312,8 @@ var a = 800 * s; .attr("text", function(d) { return d.type; }) - - .append("a") - .text(function(d) { return d.type; }); + + .attr("marker-end", "url(#arrowhead)"); @@ -332,6 +330,23 @@ var a = 800 * s; .call(force.drag); + new_g.append("svg:marker") + .attr("id", "arrowhead") + .attr("viewBox","0 0 10 10") + .attr("refX","20") + .attr("refY","5") + .attr("markerUnits","strokeWidth") + .attr("markerWidth","9") + .attr("markerHeight","5") + .attr("orient","auto") + .append("svg:path") + .attr("d","M 0 0 L 10 5 L 0 10 z") + .attr("fill", "#6D6666"); + + + + + $(window).bind('keydown',function(event){ @@ -408,8 +423,8 @@ $(window).bind('keydown',function(event){ .attr("cx", bbox.x+25) .attr("cy", bbox.y+13) .call(force.drag) - .attr("rx",function(d) {var ttx=d.screen_name ; return (ttx.length + 40)}) - .attr("ry",13) + .attr("rx",function(d) {var ttx=d.screen_name ; return (ttx.length + 55)}) + .attr("ry",14) .style("fill-opacity", ".2") .style("stroke", "#666") .style("stroke-width", "1.5px") @@ -458,16 +473,24 @@ $(window).bind('keydown',function(event){ </script> {% block graph %} {% endblock %} </div> - <div id="sidebar" class="span-8 last"> + <div id="sidebar"> {% block sidebar %} {% endblock %} </div> - </div> - <div id="footer" class="span-24 last"> - <p>Powered by <a href="http://www.djangoproject.com" title="http://www.djangoproject.com">Django</a> and <a href="http://github.com/gnowgi/django-gstudio" title="http://github.com/gnowgi/django-gstudio">Gstudio {{ GSTUDIO_VERSION }}</a>.</p> + + <div id="footer"> + <p> + + <a rel="license" + href="http://creativecommons.org/licenses/by-sa/3.0/" title="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative + Commons License" style="border-width:0"src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png"/></a> All material is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/" title = "http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a> unless mentioned otherwise. + <br/> + Poweredby <a href="http://www.djangoproject.com" title="https://www.djangoproject.com/">Django</a> + and <a href="https://github.com/gnowgi/gnowsys-studio" title="https://github.com/gnowgi/gnowsys-studio">Gstudio + {{ GSTUDIO_VERSION }}</a>. + </p> </div> </div> </body> </html> - |