sws 0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. data/doc/DOC.otl +34 -0
  2. data/doc/Makefile +13 -0
  3. data/doc/architecture.dia +0 -0
  4. data/doc/docbook/architecture.png +0 -0
  5. data/doc/docbook/concepts.docbook +474 -0
  6. data/doc/docbook/installation.docbook +57 -0
  7. data/doc/docbook/introduction.docbook +130 -0
  8. data/doc/docbook/sws_manual.docbook +35 -0
  9. data/doc/docbook/todo.docbook +38 -0
  10. data/doc/docbook/tutorial.docbook +594 -0
  11. data/examples/README +1 -0
  12. data/examples/addressbook/CardBrowse/CardBrowse.html +43 -0
  13. data/examples/addressbook/CardBrowse/CardBrowse.rb +65 -0
  14. data/examples/addressbook/CardBrowse/CardBrowse.sws +92 -0
  15. data/examples/addressbook/Login/LoginPage.html +12 -0
  16. data/examples/addressbook/Login/LoginPage.rb +19 -0
  17. data/examples/addressbook/Login/LoginPage.sws +15 -0
  18. data/examples/addressbook/README +1 -0
  19. data/examples/addressbook/addressbook.rb +70 -0
  20. data/examples/addressbook/application.yaml +8 -0
  21. data/examples/addressbook/db.yaml +7 -0
  22. data/examples/component_demo/CheckBoxDemo/CheckBoxDemo.html +11 -0
  23. data/examples/component_demo/CheckBoxDemo/CheckBoxDemo.rb +21 -0
  24. data/examples/component_demo/CheckBoxDemo/CheckBoxDemo.sws +25 -0
  25. data/examples/component_demo/ComponentDemo.rb +21 -0
  26. data/examples/component_demo/ConditionalDemo/ConditionalDemo.html +18 -0
  27. data/examples/component_demo/ConditionalDemo/ConditionalDemo.rb +2 -0
  28. data/examples/component_demo/ConditionalDemo/ConditionalDemo.sws +22 -0
  29. data/examples/component_demo/FileUploadDemo/FileUploadDemo.html +10 -0
  30. data/examples/component_demo/FileUploadDemo/FileUploadDemo.rb +9 -0
  31. data/examples/component_demo/FileUploadDemo/FileUploadDemo.sws +33 -0
  32. data/examples/component_demo/FormFieldsDemo/FormFieldsDemo.html +12 -0
  33. data/examples/component_demo/FormFieldsDemo/FormFieldsDemo.rb +21 -0
  34. data/examples/component_demo/FormFieldsDemo/FormFieldsDemo.sws +40 -0
  35. data/examples/component_demo/FormListsDemo/FormListsDemo.html +11 -0
  36. data/examples/component_demo/FormListsDemo/FormListsDemo.rb +37 -0
  37. data/examples/component_demo/FormListsDemo/FormListsDemo.sws +47 -0
  38. data/examples/component_demo/GenericDemo/GenericDemo.html +4 -0
  39. data/examples/component_demo/GenericDemo/GenericDemo.rb +2 -0
  40. data/examples/component_demo/GenericDemo/GenericDemo.sws +10 -0
  41. data/examples/component_demo/HyperlinkDemo/HyperlinkDemo.html +8 -0
  42. data/examples/component_demo/HyperlinkDemo/HyperlinkDemo.rb +20 -0
  43. data/examples/component_demo/HyperlinkDemo/HyperlinkDemo.sws +19 -0
  44. data/examples/component_demo/ImageLinkDemo/ImageLinkDemo.html +11 -0
  45. data/examples/component_demo/ImageLinkDemo/ImageLinkDemo.rb +2 -0
  46. data/examples/component_demo/ImageLinkDemo/ImageLinkDemo.sws +14 -0
  47. data/examples/component_demo/PageWrapper/PageWrapper.html +23 -0
  48. data/examples/component_demo/PageWrapper/PageWrapper.rb +2 -0
  49. data/examples/component_demo/PageWrapper/PageWrapper.sws +42 -0
  50. data/examples/component_demo/README +1 -0
  51. data/examples/component_demo/RepetitionDemo/RepetitionDemo.html +13 -0
  52. data/examples/component_demo/RepetitionDemo/RepetitionDemo.rb +19 -0
  53. data/examples/component_demo/RepetitionDemo/RepetitionDemo.sws +20 -0
  54. data/examples/component_demo/StringDemo/StringDemo.html +5 -0
  55. data/examples/component_demo/StringDemo/StringDemo.rb +16 -0
  56. data/examples/component_demo/StringDemo/StringDemo.sws +14 -0
  57. data/examples/component_demo/application.yaml +28 -0
  58. data/examples/component_demo/poweredby.jpg +0 -0
  59. data/examples/component_demo/style.css +1 -0
  60. data/examples/movies/Menu/Menu.html +3 -0
  61. data/examples/movies/Menu/Menu.rb +7 -0
  62. data/examples/movies/Menu/Menu.sws +7 -0
  63. data/examples/movies/MovieBrowse/MovieBrowse.html +68 -0
  64. data/examples/movies/MovieBrowse/MovieBrowse.rb +178 -0
  65. data/examples/movies/MovieBrowse/MovieBrowse.sws +127 -0
  66. data/examples/movies/README +1 -0
  67. data/examples/movies/UserBrowse/UserBrowse.html +50 -0
  68. data/examples/movies/UserBrowse/UserBrowse.rb +69 -0
  69. data/examples/movies/UserBrowse/UserBrowse.sws +49 -0
  70. data/examples/movies/application.yaml +11 -0
  71. data/examples/movies/da.rb +36 -0
  72. data/examples/movies/dbmovies.rb +44 -0
  73. data/examples/movies/frameworks/TestFramework/framework.yaml +4 -0
  74. data/examples/movies/frameworks/TestFramework/resources/im1.jpg +0 -0
  75. data/examples/movies/images/pbr1b.jpg +0 -0
  76. data/examples/movies/movies.rb +28 -0
  77. data/examples/movies/movies.sds +119 -0
  78. data/examples/movies/movies.sqlite +0 -0
  79. data/examples/movies/movies_mysql.sql +28 -0
  80. data/examples/movies/movies_postgres.sql +27 -0
  81. data/examples/movies/movies_sqlite.sql +28 -0
  82. data/lib/sws.rb +89 -0
  83. data/lib/sws/Core/components/CheckBox/CheckBox.api +5 -0
  84. data/lib/sws/Core/components/CheckBox/CheckBox.rb +45 -0
  85. data/lib/sws/Core/components/CheckBoxList/CheckBoxList.api +13 -0
  86. data/lib/sws/Core/components/CheckBoxList/CheckBoxList.rb +54 -0
  87. data/lib/sws/Core/components/Conditional/Conditional.api +3 -0
  88. data/lib/sws/Core/components/Conditional/Conditional.html +1 -0
  89. data/lib/sws/Core/components/Conditional/Conditional.rb +39 -0
  90. data/lib/sws/Core/components/Conditional/Conditional.sws +2 -0
  91. data/lib/sws/Core/components/Content/Content.rb +18 -0
  92. data/lib/sws/Core/components/ExceptionPage/ExceptionPage.html +13 -0
  93. data/lib/sws/Core/components/ExceptionPage/ExceptionPage.rb +18 -0
  94. data/lib/sws/Core/components/ExceptionPage/ExceptionPage.sws +16 -0
  95. data/lib/sws/Core/components/FileUpload/FileUpload.api +16 -0
  96. data/lib/sws/Core/components/FileUpload/FileUpload.rb +62 -0
  97. data/lib/sws/Core/components/Form/Form.api +9 -0
  98. data/lib/sws/Core/components/Form/Form.html +3 -0
  99. data/lib/sws/Core/components/Form/Form.rb +55 -0
  100. data/lib/sws/Core/components/Form/Form.sws +12 -0
  101. data/lib/sws/Core/components/GenericContainer/GenericContainer.api +10 -0
  102. data/lib/sws/Core/components/GenericContainer/GenericContainer.html +1 -0
  103. data/lib/sws/Core/components/GenericContainer/GenericContainer.rb +39 -0
  104. data/lib/sws/Core/components/GenericContainer/GenericContainer.sws +12 -0
  105. data/lib/sws/Core/components/GenericElement/GenericElement.api +10 -0
  106. data/lib/sws/Core/components/GenericElement/GenericElement.rb +34 -0
  107. data/lib/sws/Core/components/HiddenField/HiddenField.api +7 -0
  108. data/lib/sws/Core/components/HiddenField/HiddenField.rb +37 -0
  109. data/lib/sws/Core/components/Hyperlink/Hyperlink.api +13 -0
  110. data/lib/sws/Core/components/Hyperlink/Hyperlink.html +1 -0
  111. data/lib/sws/Core/components/Hyperlink/Hyperlink.rb +102 -0
  112. data/lib/sws/Core/components/Hyperlink/Hyperlink.sws +12 -0
  113. data/lib/sws/Core/components/Image/Image.api +11 -0
  114. data/lib/sws/Core/components/Image/Image.rb +49 -0
  115. data/lib/sws/Core/components/ImageButton/ImageButton.api +16 -0
  116. data/lib/sws/Core/components/ImageButton/ImageButton.rb +76 -0
  117. data/lib/sws/Core/components/Link/Link.api +11 -0
  118. data/lib/sws/Core/components/Link/Link.rb +39 -0
  119. data/lib/sws/Core/components/PasswordField/PasswordField.api +7 -0
  120. data/lib/sws/Core/components/PasswordField/PasswordField.rb +41 -0
  121. data/lib/sws/Core/components/RadioButton/RadioButton.api +7 -0
  122. data/lib/sws/Core/components/RadioButton/RadioButton.rb +44 -0
  123. data/lib/sws/Core/components/RadioButtonList/RadioButtonList.api +20 -0
  124. data/lib/sws/Core/components/RadioButtonList/RadioButtonList.rb +76 -0
  125. data/lib/sws/Core/components/Repetition/Repetition.api +10 -0
  126. data/lib/sws/Core/components/Repetition/Repetition.html +1 -0
  127. data/lib/sws/Core/components/Repetition/Repetition.rb +137 -0
  128. data/lib/sws/Core/components/Repetition/Repetition.sws +2 -0
  129. data/lib/sws/Core/components/ResetButton/ResetButton.api +5 -0
  130. data/lib/sws/Core/components/ResetButton/ResetButton.rb +28 -0
  131. data/lib/sws/Core/components/Select/Select.api +24 -0
  132. data/lib/sws/Core/components/Select/Select.rb +57 -0
  133. data/lib/sws/Core/components/String/String.api +5 -0
  134. data/lib/sws/Core/components/String/String.rb +28 -0
  135. data/lib/sws/Core/components/SubmitButton/SubmitButton.api +6 -0
  136. data/lib/sws/Core/components/SubmitButton/SubmitButton.rb +53 -0
  137. data/lib/sws/Core/components/TextArea/TextArea.api +9 -0
  138. data/lib/sws/Core/components/TextArea/TextArea.rb +28 -0
  139. data/lib/sws/Core/components/TextField/TextField.api +9 -0
  140. data/lib/sws/Core/components/TextField/TextField.rb +46 -0
  141. data/lib/sws/Core/framework.yaml +25 -0
  142. data/lib/sws/JSComponents/components/JSMenu/JSMenu.api +5 -0
  143. data/lib/sws/JSComponents/components/JSMenu/JSMenu.html +58 -0
  144. data/lib/sws/JSComponents/components/JSMenu/JSMenu.rb +34 -0
  145. data/lib/sws/JSComponents/components/JSMenu/JSMenu.sws +37 -0
  146. data/lib/sws/JSComponents/framework.yaml +3 -0
  147. data/lib/sws/adaptor.rb +334 -0
  148. data/lib/sws/application.rb +604 -0
  149. data/lib/sws/component.rb +656 -0
  150. data/lib/sws/cookie.rb +27 -0
  151. data/lib/sws/direct_action.rb +38 -0
  152. data/lib/sws/extensions.rb +49 -0
  153. data/lib/sws/parsers.rb +374 -0
  154. data/lib/sws/request.rb +308 -0
  155. data/lib/sws/response.rb +70 -0
  156. data/lib/sws/session.rb +195 -0
  157. data/lib/sws/slot.rb +198 -0
  158. metadata +263 -0
@@ -0,0 +1,9 @@
1
+ method:
2
+ default: "'POST'"
3
+
4
+ enctype:
5
+ default: "'multipart/form-data'"
6
+
7
+ other_tag_string:
8
+
9
+ action:
@@ -0,0 +1,3 @@
1
+ <span sws="header"></span>
2
+ <span sws="content"></span>
3
+ <span sws="footer"></span>
@@ -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,12 @@
1
+ header:
2
+ _class: SWS::String
3
+ value: generate_head
4
+ escape_html: false
5
+
6
+ footer:
7
+ _class: SWS::String
8
+ value: generate_footer
9
+ escape_html: false
10
+
11
+ content:
12
+ _class: SWS::Content
@@ -0,0 +1,10 @@
1
+ tag_name:
2
+ required: true
3
+
4
+ class:
5
+
6
+ id:
7
+
8
+ name:
9
+
10
+ other_tag_string:
@@ -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,12 @@
1
+ content:
2
+ _class: SWS::Content
3
+
4
+ prefix:
5
+ _class: SWS::String
6
+ value: prefix
7
+ escape_html: false
8
+
9
+ suffix:
10
+ _class: SWS::String
11
+ value: suffix
12
+ escape_html: false
@@ -0,0 +1,10 @@
1
+ tag_name:
2
+ required: true
3
+
4
+ class:
5
+
6
+ id:
7
+
8
+ name:
9
+
10
+ other_tag_string:
@@ -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,7 @@
1
+ value:
2
+ required: true
3
+ settable: true
4
+
5
+ other_tag_string:
6
+
7
+ format:
@@ -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,13 @@
1
+ href:
2
+
3
+ page_name:
4
+
5
+ action:
6
+
7
+ direct_action_class:
8
+
9
+ direct_action_method:
10
+
11
+ direct_action_query_string:
12
+
13
+ other_tag_string:
@@ -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,12 @@
1
+ content:
2
+ _class: SWS::Content
3
+
4
+ prefix:
5
+ _class: SWS::String
6
+ value: prefix
7
+ escape_html: false
8
+
9
+ suffix:
10
+ _class: SWS::String
11
+ value: suffix
12
+ escape_html: false
@@ -0,0 +1,11 @@
1
+ src:
2
+
3
+ framework:
4
+
5
+ resource:
6
+
7
+ alt:
8
+
9
+ title:
10
+
11
+ other_tag_string:
@@ -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