sws 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/DOC.otl +34 -0
- data/doc/Makefile +13 -0
- data/doc/architecture.dia +0 -0
- data/doc/docbook/architecture.png +0 -0
- data/doc/docbook/concepts.docbook +474 -0
- data/doc/docbook/installation.docbook +57 -0
- data/doc/docbook/introduction.docbook +130 -0
- data/doc/docbook/sws_manual.docbook +35 -0
- data/doc/docbook/todo.docbook +38 -0
- data/doc/docbook/tutorial.docbook +594 -0
- data/examples/README +1 -0
- data/examples/addressbook/CardBrowse/CardBrowse.html +43 -0
- data/examples/addressbook/CardBrowse/CardBrowse.rb +65 -0
- data/examples/addressbook/CardBrowse/CardBrowse.sws +92 -0
- data/examples/addressbook/Login/LoginPage.html +12 -0
- data/examples/addressbook/Login/LoginPage.rb +19 -0
- data/examples/addressbook/Login/LoginPage.sws +15 -0
- data/examples/addressbook/README +1 -0
- data/examples/addressbook/addressbook.rb +70 -0
- data/examples/addressbook/application.yaml +8 -0
- data/examples/addressbook/db.yaml +7 -0
- data/examples/component_demo/CheckBoxDemo/CheckBoxDemo.html +11 -0
- data/examples/component_demo/CheckBoxDemo/CheckBoxDemo.rb +21 -0
- data/examples/component_demo/CheckBoxDemo/CheckBoxDemo.sws +25 -0
- data/examples/component_demo/ComponentDemo.rb +21 -0
- data/examples/component_demo/ConditionalDemo/ConditionalDemo.html +18 -0
- data/examples/component_demo/ConditionalDemo/ConditionalDemo.rb +2 -0
- data/examples/component_demo/ConditionalDemo/ConditionalDemo.sws +22 -0
- data/examples/component_demo/FileUploadDemo/FileUploadDemo.html +10 -0
- data/examples/component_demo/FileUploadDemo/FileUploadDemo.rb +9 -0
- data/examples/component_demo/FileUploadDemo/FileUploadDemo.sws +33 -0
- data/examples/component_demo/FormFieldsDemo/FormFieldsDemo.html +12 -0
- data/examples/component_demo/FormFieldsDemo/FormFieldsDemo.rb +21 -0
- data/examples/component_demo/FormFieldsDemo/FormFieldsDemo.sws +40 -0
- data/examples/component_demo/FormListsDemo/FormListsDemo.html +11 -0
- data/examples/component_demo/FormListsDemo/FormListsDemo.rb +37 -0
- data/examples/component_demo/FormListsDemo/FormListsDemo.sws +47 -0
- data/examples/component_demo/GenericDemo/GenericDemo.html +4 -0
- data/examples/component_demo/GenericDemo/GenericDemo.rb +2 -0
- data/examples/component_demo/GenericDemo/GenericDemo.sws +10 -0
- data/examples/component_demo/HyperlinkDemo/HyperlinkDemo.html +8 -0
- data/examples/component_demo/HyperlinkDemo/HyperlinkDemo.rb +20 -0
- data/examples/component_demo/HyperlinkDemo/HyperlinkDemo.sws +19 -0
- data/examples/component_demo/ImageLinkDemo/ImageLinkDemo.html +11 -0
- data/examples/component_demo/ImageLinkDemo/ImageLinkDemo.rb +2 -0
- data/examples/component_demo/ImageLinkDemo/ImageLinkDemo.sws +14 -0
- data/examples/component_demo/PageWrapper/PageWrapper.html +23 -0
- data/examples/component_demo/PageWrapper/PageWrapper.rb +2 -0
- data/examples/component_demo/PageWrapper/PageWrapper.sws +42 -0
- data/examples/component_demo/README +1 -0
- data/examples/component_demo/RepetitionDemo/RepetitionDemo.html +13 -0
- data/examples/component_demo/RepetitionDemo/RepetitionDemo.rb +19 -0
- data/examples/component_demo/RepetitionDemo/RepetitionDemo.sws +20 -0
- data/examples/component_demo/StringDemo/StringDemo.html +5 -0
- data/examples/component_demo/StringDemo/StringDemo.rb +16 -0
- data/examples/component_demo/StringDemo/StringDemo.sws +14 -0
- data/examples/component_demo/application.yaml +28 -0
- data/examples/component_demo/poweredby.jpg +0 -0
- data/examples/component_demo/style.css +1 -0
- data/examples/movies/Menu/Menu.html +3 -0
- data/examples/movies/Menu/Menu.rb +7 -0
- data/examples/movies/Menu/Menu.sws +7 -0
- data/examples/movies/MovieBrowse/MovieBrowse.html +68 -0
- data/examples/movies/MovieBrowse/MovieBrowse.rb +178 -0
- data/examples/movies/MovieBrowse/MovieBrowse.sws +127 -0
- data/examples/movies/README +1 -0
- data/examples/movies/UserBrowse/UserBrowse.html +50 -0
- data/examples/movies/UserBrowse/UserBrowse.rb +69 -0
- data/examples/movies/UserBrowse/UserBrowse.sws +49 -0
- data/examples/movies/application.yaml +11 -0
- data/examples/movies/da.rb +36 -0
- data/examples/movies/dbmovies.rb +44 -0
- data/examples/movies/frameworks/TestFramework/framework.yaml +4 -0
- data/examples/movies/frameworks/TestFramework/resources/im1.jpg +0 -0
- data/examples/movies/images/pbr1b.jpg +0 -0
- data/examples/movies/movies.rb +28 -0
- data/examples/movies/movies.sds +119 -0
- data/examples/movies/movies.sqlite +0 -0
- data/examples/movies/movies_mysql.sql +28 -0
- data/examples/movies/movies_postgres.sql +27 -0
- data/examples/movies/movies_sqlite.sql +28 -0
- data/lib/sws.rb +89 -0
- data/lib/sws/Core/components/CheckBox/CheckBox.api +5 -0
- data/lib/sws/Core/components/CheckBox/CheckBox.rb +45 -0
- data/lib/sws/Core/components/CheckBoxList/CheckBoxList.api +13 -0
- data/lib/sws/Core/components/CheckBoxList/CheckBoxList.rb +54 -0
- data/lib/sws/Core/components/Conditional/Conditional.api +3 -0
- data/lib/sws/Core/components/Conditional/Conditional.html +1 -0
- data/lib/sws/Core/components/Conditional/Conditional.rb +39 -0
- data/lib/sws/Core/components/Conditional/Conditional.sws +2 -0
- data/lib/sws/Core/components/Content/Content.rb +18 -0
- data/lib/sws/Core/components/ExceptionPage/ExceptionPage.html +13 -0
- data/lib/sws/Core/components/ExceptionPage/ExceptionPage.rb +18 -0
- data/lib/sws/Core/components/ExceptionPage/ExceptionPage.sws +16 -0
- data/lib/sws/Core/components/FileUpload/FileUpload.api +16 -0
- data/lib/sws/Core/components/FileUpload/FileUpload.rb +62 -0
- data/lib/sws/Core/components/Form/Form.api +9 -0
- data/lib/sws/Core/components/Form/Form.html +3 -0
- data/lib/sws/Core/components/Form/Form.rb +55 -0
- data/lib/sws/Core/components/Form/Form.sws +12 -0
- data/lib/sws/Core/components/GenericContainer/GenericContainer.api +10 -0
- data/lib/sws/Core/components/GenericContainer/GenericContainer.html +1 -0
- data/lib/sws/Core/components/GenericContainer/GenericContainer.rb +39 -0
- data/lib/sws/Core/components/GenericContainer/GenericContainer.sws +12 -0
- data/lib/sws/Core/components/GenericElement/GenericElement.api +10 -0
- data/lib/sws/Core/components/GenericElement/GenericElement.rb +34 -0
- data/lib/sws/Core/components/HiddenField/HiddenField.api +7 -0
- data/lib/sws/Core/components/HiddenField/HiddenField.rb +37 -0
- data/lib/sws/Core/components/Hyperlink/Hyperlink.api +13 -0
- data/lib/sws/Core/components/Hyperlink/Hyperlink.html +1 -0
- data/lib/sws/Core/components/Hyperlink/Hyperlink.rb +102 -0
- data/lib/sws/Core/components/Hyperlink/Hyperlink.sws +12 -0
- data/lib/sws/Core/components/Image/Image.api +11 -0
- data/lib/sws/Core/components/Image/Image.rb +49 -0
- data/lib/sws/Core/components/ImageButton/ImageButton.api +16 -0
- data/lib/sws/Core/components/ImageButton/ImageButton.rb +76 -0
- data/lib/sws/Core/components/Link/Link.api +11 -0
- data/lib/sws/Core/components/Link/Link.rb +39 -0
- data/lib/sws/Core/components/PasswordField/PasswordField.api +7 -0
- data/lib/sws/Core/components/PasswordField/PasswordField.rb +41 -0
- data/lib/sws/Core/components/RadioButton/RadioButton.api +7 -0
- data/lib/sws/Core/components/RadioButton/RadioButton.rb +44 -0
- data/lib/sws/Core/components/RadioButtonList/RadioButtonList.api +20 -0
- data/lib/sws/Core/components/RadioButtonList/RadioButtonList.rb +76 -0
- data/lib/sws/Core/components/Repetition/Repetition.api +10 -0
- data/lib/sws/Core/components/Repetition/Repetition.html +1 -0
- data/lib/sws/Core/components/Repetition/Repetition.rb +137 -0
- data/lib/sws/Core/components/Repetition/Repetition.sws +2 -0
- data/lib/sws/Core/components/ResetButton/ResetButton.api +5 -0
- data/lib/sws/Core/components/ResetButton/ResetButton.rb +28 -0
- data/lib/sws/Core/components/Select/Select.api +24 -0
- data/lib/sws/Core/components/Select/Select.rb +57 -0
- data/lib/sws/Core/components/String/String.api +5 -0
- data/lib/sws/Core/components/String/String.rb +28 -0
- data/lib/sws/Core/components/SubmitButton/SubmitButton.api +6 -0
- data/lib/sws/Core/components/SubmitButton/SubmitButton.rb +53 -0
- data/lib/sws/Core/components/TextArea/TextArea.api +9 -0
- data/lib/sws/Core/components/TextArea/TextArea.rb +28 -0
- data/lib/sws/Core/components/TextField/TextField.api +9 -0
- data/lib/sws/Core/components/TextField/TextField.rb +46 -0
- data/lib/sws/Core/framework.yaml +25 -0
- data/lib/sws/JSComponents/components/JSMenu/JSMenu.api +5 -0
- data/lib/sws/JSComponents/components/JSMenu/JSMenu.html +58 -0
- data/lib/sws/JSComponents/components/JSMenu/JSMenu.rb +34 -0
- data/lib/sws/JSComponents/components/JSMenu/JSMenu.sws +37 -0
- data/lib/sws/JSComponents/framework.yaml +3 -0
- data/lib/sws/adaptor.rb +334 -0
- data/lib/sws/application.rb +604 -0
- data/lib/sws/component.rb +656 -0
- data/lib/sws/cookie.rb +27 -0
- data/lib/sws/direct_action.rb +38 -0
- data/lib/sws/extensions.rb +49 -0
- data/lib/sws/parsers.rb +374 -0
- data/lib/sws/request.rb +308 -0
- data/lib/sws/response.rb +70 -0
- data/lib/sws/session.rb +195 -0
- data/lib/sws/slot.rb +198 -0
- metadata +263 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
module SWS
|
2
|
+
|
3
|
+
# Represents <FORM> tag.
|
4
|
+
# Bindings:
|
5
|
+
# - method (default: "POST") - HTTP methods to send form data
|
6
|
+
# - enctype - as "enctype" parameter of HTML form
|
7
|
+
# - other_tag_string - generic string to add to the FORM tag
|
8
|
+
# - action - method to call on form submission (you shouldn't use both Form's
|
9
|
+
# and SubmitButton's action at the same time)
|
10
|
+
class Form < Component
|
11
|
+
|
12
|
+
def initialize (*args)
|
13
|
+
super
|
14
|
+
@action = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
# Generates opening <FORM> tag with proper attributes. Do NOT use other
|
18
|
+
# methods than default POST
|
19
|
+
def generate_head ()
|
20
|
+
|
21
|
+
string = "<FORM"
|
22
|
+
string << " #{@slots["method"].to_tag_attribute()}"
|
23
|
+
string << " action=\"#{app.adaptor.base_path}#{app.component_request_handler_key}/#{page.url_string}"
|
24
|
+
if (slot_bound?( "action" ))
|
25
|
+
page.action_components[ self.object_id ] = self
|
26
|
+
string << "/#{self.object_id}"
|
27
|
+
end
|
28
|
+
string << "\" #{@slots["enctype"].to_tag_attribute()}"
|
29
|
+
string << generic_attr_string()
|
30
|
+
string << ">"
|
31
|
+
return string
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
# Generates closing </FORM> tag
|
37
|
+
def generate_footer ()
|
38
|
+
return "</FORM>"
|
39
|
+
end
|
40
|
+
|
41
|
+
# Enables the action of the receiver, so that the action will be performed.
|
42
|
+
# Called by request handler, when it finds this form id in url
|
43
|
+
def enable_action ()
|
44
|
+
@action = @slots["action"].bound_object()
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
# Performs the action if it has been set up
|
49
|
+
def perform_action ()
|
50
|
+
return @action ? @action.call() : super;
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<span sws="prefix"></span><span sws="content"></span><span sws="suffix"></span>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module SWS
|
2
|
+
|
3
|
+
|
4
|
+
# Represents a custom container component. Used to display HTML tags that do
|
5
|
+
# not (yet) have dedicated components.
|
6
|
+
# Bindings:
|
7
|
+
# - tag_name (required) - name of the tag to use
|
8
|
+
# - class - CSS class of the tag
|
9
|
+
# - name - name attribute of the tag
|
10
|
+
# - other_tag_string - generic string to add to the tag
|
11
|
+
class GenericContainer < Component
|
12
|
+
|
13
|
+
def container? ()
|
14
|
+
return true
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
def prefix ()
|
19
|
+
|
20
|
+
tag_name = @slots["tag_name"].value()
|
21
|
+
string = "<#{tag_name}"
|
22
|
+
string << bound_slot_string( "class","name","id" )
|
23
|
+
string << generic_attr_string() << ">"
|
24
|
+
return string
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
def suffix ()
|
30
|
+
|
31
|
+
tag_name = @slots["tag_name"].value()
|
32
|
+
return "</#{tag_name}>"
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module SWS
|
2
|
+
|
3
|
+
# Represents a custom non-container component. Used to display HTML tags that do
|
4
|
+
# not (yet) have dedicated components.
|
5
|
+
# Bindings:
|
6
|
+
# - tag_name (required) - name of the tag to use
|
7
|
+
# - class - CSS class of the tag
|
8
|
+
# - name - name attribute of the tag
|
9
|
+
# - other_tag_string - generic string to add to the tag
|
10
|
+
class GenericElement < Component
|
11
|
+
|
12
|
+
def container? ()
|
13
|
+
return false
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
def append_to_response ( response )
|
18
|
+
response << generate_html()
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def generate_html ()
|
23
|
+
|
24
|
+
tag_name = @slots["tag_name"].value()
|
25
|
+
string = "<#{tag_name}"
|
26
|
+
string << bound_slot_string( "class","name","id" )
|
27
|
+
string << generic_attr_string() << ">"
|
28
|
+
return string
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module SWS
|
2
|
+
|
3
|
+
# Represents <INPUT type=hidden HTML tag.
|
4
|
+
# Bindings:
|
5
|
+
# - value (required) - the value of the field
|
6
|
+
# - other_tag_string - generic string to add to the tag
|
7
|
+
class HiddenField < FormElement
|
8
|
+
|
9
|
+
|
10
|
+
def update_binding ( key,value )
|
11
|
+
|
12
|
+
if ( key == "value" )
|
13
|
+
if ( slot_bound?("format") )
|
14
|
+
@slots["value"].value = value.method( @slots["format"].value ).call()
|
15
|
+
else
|
16
|
+
@slots["value"].value = value
|
17
|
+
end
|
18
|
+
else
|
19
|
+
#TODO: not sure if necessary - there are no more settable slots beside "value"
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def append_to_response ( response )
|
27
|
+
response << generate_html()
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
def generate_html ()
|
32
|
+
return "<INPUT TYPE=\"hidden\" NAME=\"#{element_name()}.value\" VALUE=\"#{@slots["value"].value}\"#{generic_attr_string()}>"
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<span sws="prefix"/><span sws="content"/><span sws="suffix"/>
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module SWS
|
2
|
+
|
3
|
+
# Represents <A> tag
|
4
|
+
# Bindings:
|
5
|
+
# - href - href attribute of the tag
|
6
|
+
# - page_name - name of the page to display after clicking the link (new
|
7
|
+
# instance of the page will be created)
|
8
|
+
# - action - methods to call of link click
|
9
|
+
# - other_tag_string - generic string to add to the tag
|
10
|
+
# - direct_action_class - name of DirectAction subclass to call. Defaults to
|
11
|
+
# "default_direct_action_class" from application.yaml file
|
12
|
+
# - direct_action_method - method of object of class specified in
|
13
|
+
# "direct_action_class" binding to call on hyperlink click.
|
14
|
+
# - direct_action_query_string - query_string to attach to DirectAction
|
15
|
+
# requests. May be used freely.
|
16
|
+
class Hyperlink < Component
|
17
|
+
|
18
|
+
def initialize (*args)
|
19
|
+
super
|
20
|
+
@action = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
# Returns opening <A> tag
|
24
|
+
def prefix ()
|
25
|
+
|
26
|
+
if ( slot_bound?( "href" ) ) #normal, href hyperlink
|
27
|
+
return generate_href_link( @slots["href"].value() )
|
28
|
+
elsif ( slot_bound?( "page_name" ) ) #page for name
|
29
|
+
return generate_page_link( @slots["page_name"].value() )
|
30
|
+
elsif ( slot_bound?( "action" ) ) #call method on the same component
|
31
|
+
return generate_action_link()
|
32
|
+
elsif ( slot_bound?( "direct_action_class" ) )
|
33
|
+
return generate_direct_action_link()
|
34
|
+
end #TODO: throw exception if none found?
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
# Enables the action of the receiver, so that the action will be
|
40
|
+
# performed. Called by request handler, when it finds this hyperlink id
|
41
|
+
# in url
|
42
|
+
def enable_action ()
|
43
|
+
@action = @slots["action"].bound_object()
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
# Performs the action if it has been set up
|
48
|
+
def perform_action ()
|
49
|
+
return @action ? @action.call() : nil;
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
# Generates closing </A> tag
|
54
|
+
def suffix ()
|
55
|
+
return "</A>"
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
protected
|
60
|
+
def generate_href_link ( href )
|
61
|
+
|
62
|
+
link = "<A href=\"#{href}\"#{generic_attr_string()}>"
|
63
|
+
return link
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
def generate_page_link ( page_name )
|
69
|
+
|
70
|
+
href = "#{app.adaptor.base_path}#{app.page_name_request_handler_key}/#{page.object_id}/#{page_name}"
|
71
|
+
return generate_href_link( href )
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
def generate_action_link ( )
|
77
|
+
|
78
|
+
page.action_components[self.object_id] = self
|
79
|
+
href = "#{app.adaptor.base_path}#{app.component_request_handler_key}/#{page.url_string}/#{self.object_id}"
|
80
|
+
return generate_href_link( href )
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
def generate_direct_action_link()
|
86
|
+
|
87
|
+
href = "#{app.adaptor.base_path}#{app.direct_action_request_handler_key}/"
|
88
|
+
href << @slots["direct_action_class"].value()
|
89
|
+
if ( slot_bound?( "direct_action_method" ) )
|
90
|
+
href << "/#{@slots["direct_action_method"].value()}"
|
91
|
+
end
|
92
|
+
if ( slot_bound?( "direct_action_query_string" ) )
|
93
|
+
href << "?#{@slots["direct_action_query_string"].value()}"
|
94
|
+
end
|
95
|
+
|
96
|
+
return generate_href_link( href )
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module SWS
|
2
|
+
|
3
|
+
# Represents <IMG HTML tag
|
4
|
+
# Bindings:
|
5
|
+
# - src - src attribute of the tag
|
6
|
+
# - alt - alt attribute of the tag
|
7
|
+
# - resource - resource name to use as data for the image
|
8
|
+
# - framework - framework name to find the resource in
|
9
|
+
# - other_tag_string - generic string to add to the tag
|
10
|
+
class Image < Component
|
11
|
+
|
12
|
+
def container? ()
|
13
|
+
return false
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
def append_to_response ( response )
|
18
|
+
response << generate_html()
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def generate_html ()
|
23
|
+
|
24
|
+
string = "<IMG"
|
25
|
+
|
26
|
+
if ( slot_bound?( "resource" ) )
|
27
|
+
framework = slot_bound?("framework") ? @slots["framework"].value : "app"
|
28
|
+
src = app().adaptor.base_path() + app().resource_request_handler_key + "/" + framework + "/" + @slots["resource"].value
|
29
|
+
elsif ( slot_bound?("src") )
|
30
|
+
src = @slots["src"].value()
|
31
|
+
end
|
32
|
+
|
33
|
+
string << " src=\"#{src}\""
|
34
|
+
|
35
|
+
["alt", "title"].each do |attr|
|
36
|
+
if ( slot_bound?(attr) )
|
37
|
+
string << " #{@slots[attr].to_tag_attribute}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
string << generic_attr_string() << ">"
|
42
|
+
|
43
|
+
return string
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|