Compare commits

...

7 Commits

15 changed files with 253 additions and 59 deletions

View File

@@ -20,15 +20,16 @@ feature
initialize_controls
do
Precursor
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", "", "Grid Demo"))
create datasource.make_news
create search_query.make (create {GOOGLE_AUTOCOMPLETION}.make)
search_query.add_class ("form-control")
create grid.make (<<create {WSF_GRID_COLUMN}.make ("Title", "title"), create {WSF_GRID_COLUMN}.make ("Content", "content")>>, datasource)
Precursor
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", "", "Grid Demo"))
search_query.set_change_event (agent change_query)
control.add_control (search_query)
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h2", "", "Results"))
create grid.make (<<create {WSF_GRID_COLUMN}.make ("Title", "title"), create {WSF_GRID_COLUMN}.make ("Content", "content")>>, datasource)
control.add_control (grid)
navbar.set_active (2)
end

View File

@@ -20,15 +20,17 @@ feature
initialize_controls
do
Precursor
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", "", " Repeater Demo"))
create datasource.make_news
create repeater.make (datasource)
create search_query.make (create {GOOGLE_AUTOCOMPLETION}.make)
search_query.add_class ("form-control")
Precursor
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", "", " Repeater Demo"))
search_query.set_change_event (agent change_query)
control.add_control (search_query)
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h2", "", "Results"))
create repeater.make (datasource)
control.add_control (repeater)
navbar.set_active (3)
end

View File

@@ -28,7 +28,6 @@ feature
cats_container: WSF_FORM_ELEMENT_CONTROL [LIST [STRING_32]]
source: INCREASING_PROGRESSSOURCE
do
Precursor
create form.make
--Number 1
create textbox1.make ({STRING_32} "1")
@@ -64,24 +63,33 @@ feature
form.add_control (cats_container)
--Button 1
create button1.make ("Update")
button1.set_click_event (agent handle_click)
button1.add_class ("col-lg-offset-2")
form.add_control (button1)
--Button 2
create button2.make ("Start Modal Grid")
button2.set_click_event (agent run_modal)
form.add_control (button2)
--Result
create result_html.make ("p", "")
form.add_control (create {WSF_FORM_ELEMENT_CONTROL [STRING_32]}.make ("Result", result_html))
control.add_control (form)
--Progress bar
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h4", "", "Autoincrementing progressbar"))
create source.make
create progress.make_with_source (source)
source.set_control (progress)
progress.set_isolation (true)
Precursor
control.add_control (form)
-- Actions
button1.set_click_event (agent handle_click)
button2.set_click_event (agent run_modal)
--Progress bar
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h4", "", "Autoincrementing progressbar"))
control.add_control (progress)
navbar.set_active (1)
end

View File

@@ -20,7 +20,6 @@ feature -- Implementation
initialize_controls
do
Precursor
create slider.make
--slider.add_control (form, Void)
--slider.add_image ("http://www.placesmustseen.com/wp-content/uploads/2013/01/paris-eiffel-tower.jpg", "Eiffel Tower")
@@ -28,6 +27,8 @@ feature -- Implementation
slider.add_image ("http://31.media.tumblr.com/5b5ae35c4f88d4b80aeb21e36263c6e6/tumblr_mtw7mhZsCe1st5lhmo1_1280.jpg", "landscape")
slider.add_image ("http://25.media.tumblr.com/403969159fb1642e67ed702f28e966e0/tumblr_muuig0890N1st5lhmo1_1280.jpg", "landscape")
slider.add_image ("http://24.media.tumblr.com/d349779e7216167e7c0ca3af66817794/tumblr_mufrlh9WqW1st5lhmo1_1280.jpg", "landscape")
Precursor
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", "", " Image Slider Demo"))
control.add_control (slider)
navbar.set_active (4)

View File

@@ -21,20 +21,25 @@ feature -- Implementation
initialize_controls
local
do
create form.make
create filebox.make
create n1_container.make ("File Upload", filebox)
create filebox2.make
create n2_container.make ("Auto start Upload", filebox2)
create filebox3.make_with_image_preview
create n3_container.make ("Image Upload", filebox3)
create button1.make ("Update")
Precursor
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", "", "File Upload Demo"))
create form.make
--File
create filebox.make
filebox.set_upload_function (agent upload_file)
filebox.set_upload_done_event (agent submit_form)
create n1_container.make ("File Upload", filebox)
n1_container.add_validator (create {WSF_FILESIZE_VALIDATOR}.make (10000000, "File must be smaller than 10MB"))
form.add_control (n1_container)
--File
create filebox2.make
filebox2.set_upload_function (agent upload_file)
create n2_container.make ("Auto start Upload", filebox2)
filebox2.set_change_event (agent
do
n1_container.validate
@@ -45,15 +50,13 @@ feature -- Implementation
n2_container.add_validator (create {WSF_FILESIZE_VALIDATOR}.make (10000000, "File must be smaller than 10MB"))
form.add_control (n2_container)
--Image
create filebox3.make_with_image_preview
filebox3.set_upload_function (agent upload_file)
filebox3.set_upload_done_event (agent submit_form)
create n3_container.make ("Image Upload", filebox3)
n3_container.add_validator (create {WSF_FILESIZE_VALIDATOR}.make (10000000, "File must be smaller than 10MB"))
form.add_control (n3_container)
--Button 1
create button1.make ("Update")
button1.set_click_event (agent submit_form)
button1.add_class ("col-lg-offset-2")
form.add_control (button1)

View File

@@ -10,7 +10,6 @@
<setting name="concurrency" value="scoop"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="ewsgi" location="..\..\library\server\ewsgi\ewsgi-safe.ecf"/>
<library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf"/>
<library name="vision2" location="$ISE_LIBRARY\library\vision2\vision2-safe.ecf"/>
<library name="web_browser" location="$ISE_LIBRARY\library\web_browser\web_browser-safe.ecf" readonly="false"/>
<library name="wsf" location="..\..\library\server\wsf\wsf-safe.ecf"/>

View File

@@ -50,7 +50,7 @@ feature -- Execution
feature -- Access
on_launched_action: detachable separate PROCEDURE [ANY, TUPLE]
on_launched_action: detachable separate PROCEDURE [TUPLE]
set_on_launched_action (act: like on_launched_action)
do

View File

@@ -207,6 +207,8 @@ feature -- Output
put_character_noexception (c: CHARACTER)
-- Write character `c' to socket.
require
extendible: extendible
do
socket_buffer.put_character (c, 0)
put_managed_pointer_noexception (socket_buffer, 0, character_8_bytes)
@@ -217,13 +219,15 @@ feature -- Output
-- No exception raised!
local
ext: C_STRING
do
do
create ext.make (s)
put_managed_pointer_noexception (ext.managed_data, 0, s.count)
end
put_readable_string_8 (s: READABLE_STRING_8)
-- Write readable string `s' to socket.
require
extendible: extendible
local
ext: C_STRING
do
@@ -243,6 +247,27 @@ feature -- Status report
Result := last_string.count = 1
end
set_bytes_sent (nb: INTEGER)
-- Set `bytes_sent` to `nb`;
do
bytes_sent := nb
end
report_error (m: READABLE_STRING_8)
-- Report error, and set `socket_error` to `m`.
do
socket_error := m
end
feature -- Extension
socket: HTTP_STREAM_SOCKET
-- Associated socket.
do
Result := Current
end
note
copyright: "2011-2016, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"

View File

@@ -8,6 +8,75 @@ note
deferred class
HTTP_STREAM_SOCKET_EXT
feature {NONE} -- No-Exception network operation
feature -- Extension
socket: HTTP_STREAM_SOCKET
-- Associated socket.
-- Used to extend HTTP_STREAM_SOCKET with Current interface.
deferred
end
feature -- No-Exception network operation
put_file_content_with_timeout (a_file: FILE; a_offset: INTEGER; a_byte_count: INTEGER; a_timeout: INTEGER)
-- Send `a_count' bytes from the content of file `a_file' starting at offset `a_offset'.
-- When relevant, use the `a_timeout` to wait on completion (if a_timeout < 0, ignored)
require
a_file_closed_or_openread: a_file.exists and then (a_file.is_access_readable or a_file.is_closed)
byte_count_positive: a_byte_count > 0
extendible: socket.extendible
local
l_close_needed: BOOLEAN
l_bytes_sent: INTEGER
cs: C_STRING
do
if a_file.exists and then a_file.is_access_readable then
if a_file.is_open_read then
l_close_needed := False
else
l_close_needed := True
a_file.open_read
end
create cs.make (a_file.path.name)
l_bytes_sent := c_sendfile (socket.descriptor, a_file.file_pointer, a_offset, a_byte_count, a_timeout)
if l_bytes_sent < 0 then
socket.report_error ("Network error: sendfile")
end
socket.set_bytes_sent (l_bytes_sent)
if l_close_needed then
a_file.close
end
end
ensure
bytes_sent_updated: not socket.was_error implies (0 <= socket.bytes_sent and socket.bytes_sent <= a_byte_count)
end
put_file_content (a_file: FILE; a_offset: INTEGER; a_byte_count: INTEGER)
-- Send `a_count' bytes from the content of file `a_file' starting at offset `a_offset'.
-- When relevant, use the `a_timeout` to wait on completion (if a_timeout < 0, ignored)
do
put_file_content_with_timeout (a_file, a_offset, a_byte_count, -1)
end
feature {NONE} -- External
c_sendfile (a_fd: INTEGER; fp: POINTER; a_offset: INTEGER; len: INTEGER; a_timeout: INTEGER): INTEGER
-- External routine to write file content from `fp` of
-- length `len' to socket `a_fd'
-- note: On Windows, due to asynchronous potential behavior, wait for completion using `timeout` value.
-- EIF_INTEGER c_sendfile_noexception(EIF_INTEGER out_fd, FILE* f, EIF_INTEGER offset, EIF_INTEGER length, EIF_INTEGER timeout).
external
"C blocking"
end
note
copyright: "2011-2016, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -26,28 +26,22 @@ feature -- Initialization
valid_port: a_port >= 0
do
make
set_address (create {like address_type}.make_from_address_and_port (a_address, a_port))
bind
socket.set_address (create {like socket.address_type}.make_from_address_and_port (a_address, a_port))
socket.bind
end
feature -- Basic operation
feature -- Extension
bind
socket: HTTP_STREAM_SOCKET
-- Associated socket.
-- Used to extend HTTP_STREAM_SOCKET with Current interface.
deferred
end
feature -- Access
feature {NONE} -- Externals: socket option levels
set_address (addr: detachable like address_type)
deferred
end
address_type: NETWORK_SOCKET_ADDRESS
deferred
end
descriptor: INTEGER
-- Socket descriptor of current socket
level_sol_socket: INTEGER_32
-- SOL_SOCKET level of options
deferred
end
@@ -59,7 +53,7 @@ feature -- Socket Recv and Send timeout.
require
positive_timeout: a_timeout_seconds >= 0
do
c_set_sock_recv_timeout (descriptor, level_sol_socket, a_timeout_seconds)
c_set_sock_recv_timeout (socket.descriptor, level_sol_socket, a_timeout_seconds)
end
set_send_timeout (a_timeout_seconds: INTEGER)
@@ -68,16 +62,77 @@ feature -- Socket Recv and Send timeout.
require
positive_timeout: a_timeout_seconds >= 0
do
c_set_sock_send_timeout (descriptor, level_sol_socket, a_timeout_seconds)
c_set_sock_send_timeout (socket.descriptor, level_sol_socket, a_timeout_seconds)
end
feature -- Output
put_file_content_with_timeout (a_file: FILE; a_offset: INTEGER; a_byte_count: INTEGER; a_timeout_ms: INTEGER)
-- Send `a_count' bytes from the content of file `a_file' starting at offset `a_offset'.
-- When relevant, use the `a_timeout_ms` to wait on completion (if a_timeout < 0, ignored)
require
a_file_closed_or_openread: a_file.exists and then (a_file.is_access_readable or a_file.is_closed)
byte_count_positive: a_byte_count > 0
extendible: socket.extendible
local
l_close_needed: BOOLEAN
l_remain: INTEGER
l_done: BOOLEAN
s: STRING
l_bytes_sent: INTEGER
do
if a_file.exists and then a_file.is_access_readable then
if a_file.is_open_read then
l_close_needed := False
else
l_close_needed := True
a_file.open_read
end
if a_offset > 0 then
a_file.move (a_offset)
end
from
l_remain := a_byte_count
l_done := False
until
a_file.exhausted or l_done
loop
a_file.read_stream (l_remain.min (4_096))
s := a_file.last_string
if s.is_empty then
-- File error?
l_done := True
else
socket.put_string_8_noexception (s)
l_bytes_sent := l_bytes_sent + socket.bytes_sent
l_remain := l_remain - s.count
check l_remain >= 0 end
l_done := l_remain = 0
end
end
socket.set_bytes_sent (l_bytes_sent)
if l_close_needed then
a_file.close
end
end
ensure
bytes_sent_updated: not socket.was_error implies (0 <= socket.bytes_sent and socket.bytes_sent <= a_byte_count)
end
put_file_content (a_file: FILE; a_offset: INTEGER; a_byte_count: INTEGER)
-- Send `a_count' bytes from the content of file `a_file' starting at offset `a_offset'.
require
a_file_closed_or_openread: a_file.exists and then (a_file.is_access_readable or a_file.is_closed)
byte_count_positive: a_byte_count > 0
extendible: socket.extendible
do
put_file_content_with_timeout (a_file, a_offset, a_byte_count, -1)
ensure
bytes_sent_updated: not socket.was_error implies (0 <= socket.bytes_sent and socket.bytes_sent <= a_byte_count)
end
feature {NONE} -- Externals
level_sol_socket: INTEGER
-- SOL_SOCKET level of options
deferred
end
c_set_sock_recv_timeout (a_fd, a_level: INTEGER; a_timeout_seconds: INTEGER)
-- C routine to set socket option `SO_RCVTIMEO' with `a_timeout_seconds' seconds.
external
@@ -157,4 +212,14 @@ feature {NONE} -- No-Exception network operation
]"
end
note
copyright: "2011-2016, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -12,6 +12,9 @@ class
inherit
WGI_OUTPUT_STREAM
redefine
put_file_content
end
HTTP_STATUS_CODE_MESSAGES
export
@@ -94,6 +97,18 @@ feature -- Output
last_target_call_succeed := not target.was_error
end
put_file_content (a_file: FILE; a_offset: INTEGER; a_byte_count: INTEGER)
-- Send `a_byte_count' bytes from the content of file `a_file' starting at offset `a_offset'.
do
if a_byte_count > 500_000 then
last_target_call_succeed := False
target.put_file_content (a_file, a_offset, a_byte_count)
last_target_call_succeed := not target.was_error
else
Precursor (a_file, a_offset, a_byte_count)
end
end
feature -- Status report
is_available: BOOLEAN

View File

@@ -12,7 +12,7 @@
<setting name="concurrency" value="scoop"/>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="ewsgi" location="..\ewsgi\ewsgi.ecf"/>
<library name="http" location="..\..\network\protocol\http\http.ecf"/>
<library name="http" location="..\..\..\..\network\protocol\http\http.ecf"/>
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
<library name="uuid" location="$ISE_LIBRARY\library\uuid\uuid.ecf"/>
<library name="wsf" location="wsf.ecf"/>

View File

@@ -29,21 +29,29 @@ inherit
feature {NONE} -- Initialize
initialize
do
create_filtered_router
initialize_filtered_router
end
create_filtered_router
-- Create `router` and `filter`.
do
create_router
create_filter
end
initialize_filtered_router
-- Initialize `router` and `filter`.
local
f: like filter
do
Precursor {WSF_ROUTED_EXECUTION}
Precursor {WSF_FILTERED_EXECUTION}
initialize_router
initialize_filter
-- Current is a WSF_FILTER as well in order to call the router
-- let's add Current at the end of the filter chain.
from
f := filter
until
not attached f.next as l_next
loop
f := l_next
end
f.set_next (Current)
append_filter (Current)
end
feature -- Execute Filter

View File

@@ -21,7 +21,6 @@
<library name="default_cgi" location="..\library\server\wsf\default\cgi-safe.ecf" readonly="false"/>
<library name="default_libfcgi" location="..\library\server\wsf\default\libfcgi-safe.ecf" readonly="false"/>
<library name="default_openshift" location="..\library\server\wsf\default\openshift-safe.ecf" readonly="false"/>
<library name="demo-1" location="..\library\security\openid\consumer\demo\demo-safe.ecf" readonly="false"/>
<library name="encoder" location="..\library\text\encoder\encoder-safe.ecf" readonly="false"/>
<library name="error" location="..\library\utility\general\error\error-safe.ecf" readonly="false"/>
<library name="ewsgi" location="..\library\server\ewsgi\ewsgi-safe.ecf" readonly="false"/>

View File

@@ -20,7 +20,6 @@
<library name="default_libfcgi" location="..\library\server\wsf\default\libfcgi-safe.ecf" readonly="false"/>
<library name="default_openshift" location="..\library\server\wsf\default\openshift-safe.ecf" readonly="false"/>
<library name="default_standalone" location="..\library\server\wsf\default\standalone-safe.ecf" readonly="false"/>
<library name="demo-1" location="..\library\security\openid\consumer\demo\demo-safe.ecf" readonly="false"/>
<library name="encoder" location="..\library\text\encoder\encoder-safe.ecf" readonly="false"/>
<library name="error" location="..\library\utility\general\error\error-safe.ecf" readonly="false"/>
<library name="ewsgi" location="..\library\server\ewsgi\ewsgi-safe.ecf" readonly="false"/>