2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
1 |
import os |
2 |
||
2939.2.9
by Xavier Morel
[FIX] handling of static resources in addons (maybe) |
3 |
import openobject |
2816
by ame (Tiny)
[REF] refactoring (merged common api with base addons to eliminate confusing namespace) |
4 |
from _base import Widget |
5 |
from _utils import Enum |
|
2863
by ame (Tiny)
[REF] openerp-web => openobject-web (project name changed) |
6 |
from openobject import tools |
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
7 |
|
2939.2.9
by Xavier Morel
[FIX] handling of static resources in addons (maybe) |
8 |
|
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
9 |
locations = Enum(["head", "bodytop", "bodybottom"]) |
10 |
||
11 |
class Resource(Widget): |
|
2327.1.30
by ame (Tiny/Axelor)
* removed trailing whitespace from py files. |
12 |
|
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
13 |
location = locations.head |
2327.1.30
by ame (Tiny/Axelor)
* removed trailing whitespace from py files. |
14 |
|
2327.1.24
by ame (Tiny/Axelor)
* Tree now works... |
15 |
@property
|
16 |
def name(self): |
|
17 |
return None |
|
2327.1.30
by ame (Tiny/Axelor)
* removed trailing whitespace from py files. |
18 |
|
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
19 |
|
20 |
class Link(Resource): |
|
2327.1.30
by ame (Tiny/Axelor)
* removed trailing whitespace from py files. |
21 |
|
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
22 |
params = { |
23 |
'link': None, |
|
24 |
}
|
|
2327.1.30
by ame (Tiny/Axelor)
* removed trailing whitespace from py files. |
25 |
|
2817
by ame (Tiny)
[REF] static contentes moved to base/static |
26 |
_filename = None |
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
27 |
modname = None |
2327.1.30
by ame (Tiny/Axelor)
* removed trailing whitespace from py files. |
28 |
|
2327.1.21
by ame (Tiny/Axelor)
* converted search widgets |
29 |
def __init__(self, modname, filename, location=locations.head, **kw): |
2817
by ame (Tiny)
[REF] static contentes moved to base/static |
30 |
super(Link, self).__init__(modname=modname, location=location, **kw) |
31 |
self._filename = filename |
|
2938.1.2
by Xavier Morel
[imp] Cleanup stray whitespace (lines of whitespace, extra whitespace after end of lines, ...) |
32 |
|
2817
by ame (Tiny)
[REF] static contentes moved to base/static |
33 |
def get_link(self): |
3043
by Amit Mendapara
[UPD] Removed timestamp from static resource links. |
34 |
return tools.url('/%s/static/%s' % (self.modname, self.filename)) |
2938.1.2
by Xavier Morel
[imp] Cleanup stray whitespace (lines of whitespace, extra whitespace after end of lines, ...) |
35 |
|
2817
by ame (Tiny)
[REF] static contentes moved to base/static |
36 |
def get_file(self): |
37 |
return self._filename |
|
2938.1.2
by Xavier Morel
[imp] Cleanup stray whitespace (lines of whitespace, extra whitespace after end of lines, ...) |
38 |
|
2817
by ame (Tiny)
[REF] static contentes moved to base/static |
39 |
link = property(lambda self: self.get_link()) |
40 |
filename = property(lambda self: self.get_file()) |
|
2701
by ame (Tiny)
[FIX] Resource widget (consider server.webpath for href/src). |
41 |
|
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
42 |
def __eq__(self, other): |
43 |
return getattr(other, 'link', None) == self.link |
|
2327.1.30
by ame (Tiny/Axelor)
* removed trailing whitespace from py files. |
44 |
|
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
45 |
def __hash__(self): |
46 |
return hash(self.link) |
|
47 |
||
48 |
||
49 |
class JSLink(Link): |
|
2327.1.30
by ame (Tiny/Axelor)
* removed trailing whitespace from py files. |
50 |
|
4014
by Xavier Morel
[IMP] move all remaining inline templates to standalone file for mako caching reasons |
51 |
template = "/openobject/widgets/templates/jslink.mako" |
2327.1.30
by ame (Tiny/Axelor)
* removed trailing whitespace from py files. |
52 |
|
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
53 |
params = { |
54 |
'charset': 'The character encoding of the linked script', |
|
55 |
'defer': 'If true, browser may defer execution of the script' |
|
56 |
}
|
|
2327.1.30
by ame (Tiny/Axelor)
* removed trailing whitespace from py files. |
57 |
|
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
58 |
charset = None |
2327.1.39
by ame (Tiny/Axelor)
* refactoring/cleanup. |
59 |
defer = None |
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
60 |
|
61 |
||
62 |
class CSSLink(Link): |
|
2327.1.30
by ame (Tiny/Axelor)
* removed trailing whitespace from py files. |
63 |
|
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
64 |
params = { |
65 |
'media': 'Specify the media attribute for the css link tag' |
|
66 |
}
|
|
2327.1.30
by ame (Tiny/Axelor)
* removed trailing whitespace from py files. |
67 |
|
4014
by Xavier Morel
[IMP] move all remaining inline templates to standalone file for mako caching reasons |
68 |
template = "/openobject/widgets/templates/csslink.mako" |
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
69 |
|
70 |
class Source(Resource): |
|
2327.1.30
by ame (Tiny/Axelor)
* removed trailing whitespace from py files. |
71 |
|
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
72 |
params = { |
73 |
'src': 'The source text', |
|
74 |
}
|
|
2327.1.30
by ame (Tiny/Axelor)
* removed trailing whitespace from py files. |
75 |
|
2327.1.21
by ame (Tiny/Axelor)
* converted search widgets |
76 |
def __init__(self, src, location=locations.head, **kw): |
77 |
super(Source, self).__init__(src=src, location=location, **kw) |
|
2327.1.30
by ame (Tiny/Axelor)
* removed trailing whitespace from py files. |
78 |
|
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
79 |
def __hash__(self): |
80 |
return hash(self.src) |
|
2327.1.30
by ame (Tiny/Axelor)
* removed trailing whitespace from py files. |
81 |
|
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
82 |
def __eq__(self, other): |
83 |
return self.src == getattr(other, 'src', None) |
|
84 |
||
85 |
||
86 |
class JSSource(Source): |
|
87 |
"""A JavaScript source snippet."""
|
|
88 |
||
4014
by Xavier Morel
[IMP] move all remaining inline templates to standalone file for mako caching reasons |
89 |
template = "/openobject/widgets/templates/jssource.mako" |
2327.1.30
by ame (Tiny/Axelor)
* removed trailing whitespace from py files. |
90 |
|
2327.1.39
by ame (Tiny/Axelor)
* refactoring/cleanup. |
91 |
params = { |
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
92 |
'defer': 'If true, browser may defer execution of the script' |
93 |
}
|
|
2327.1.30
by ame (Tiny/Axelor)
* removed trailing whitespace from py files. |
94 |
|
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
95 |
|
96 |
class CSSSource(Source): |
|
97 |
"""A CSS source snippet."""
|
|
98 |
||
4014
by Xavier Morel
[IMP] move all remaining inline templates to standalone file for mako caching reasons |
99 |
template = "/openobject/widgets/templates/csssource.mako" |
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
100 |
|
101 |
params = { |
|
102 |
'src': 'The CSS source for the link', |
|
103 |
'media' : 'Specify the media the css source link is for' |
|
104 |
}
|
|
2327.1.30
by ame (Tiny/Axelor)
* removed trailing whitespace from py files. |
105 |
|
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
106 |
media = "all" |
107 |
||
2817
by ame (Tiny)
[REF] static contentes moved to base/static |
108 |
def register_resource_directory(config, modulename, directory): |
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
109 |
"""Set up an application wide static resource directory...
|
110 |
"""
|
|
2939.2.9
by Xavier Morel
[FIX] handling of static resources in addons (maybe) |
111 |
if not openobject.WSGI_STATIC_PATHS: |
112 |
return False |
|
2327.1.30
by ame (Tiny/Axelor)
* removed trailing whitespace from py files. |
113 |
|
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
114 |
directory = os.path.abspath(directory) |
2876
by ame (Tiny)
[REF] static contents now accessible via (/package_name/static/...) |
115 |
config.update({'/%s/static' % modulename: { |
2327.1.5
by ame (Tiny/Axelor)
* Integrated new widgets |
116 |
'tools.staticdir.on': True, |
117 |
'tools.staticdir.dir': directory |
|
118 |
}})
|
|
2939.2.9
by Xavier Morel
[FIX] handling of static resources in addons (maybe) |
119 |
return True |