Moved more components from CMS to wsf_html.
This includes WSF_PAGER, and feature in WSF_THEME .. including WSF_API_OPTIONS used to compute url and link.
This commit is contained in:
@@ -8,7 +8,7 @@ class
|
||||
CMS_API_OPTIONS
|
||||
|
||||
inherit
|
||||
TABLE_ITERABLE [detachable ANY, STRING]
|
||||
WSF_API_OPTIONS
|
||||
|
||||
create
|
||||
make,
|
||||
@@ -22,77 +22,5 @@ convert
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (n: INTEGER)
|
||||
do
|
||||
create table.make (n)
|
||||
end
|
||||
|
||||
make_from_manifest (lst: ARRAY [TUPLE [key: STRING; value: detachable ANY]])
|
||||
do
|
||||
make (lst.count)
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
force (c.item.value, c.item.key)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
item (k: STRING): detachable ANY
|
||||
do
|
||||
Result := table.item (k)
|
||||
end
|
||||
|
||||
force (v: detachable ANY; k: STRING)
|
||||
do
|
||||
table.force (v, k)
|
||||
end
|
||||
|
||||
boolean_item (k: STRING; dft: BOOLEAN): BOOLEAN
|
||||
do
|
||||
if attached {BOOLEAN} item (k) as b then
|
||||
Result := b
|
||||
else
|
||||
Result := dft
|
||||
end
|
||||
end
|
||||
|
||||
string_general_item (k: STRING): detachable READABLE_STRING_GENERAL
|
||||
do
|
||||
if attached {READABLE_STRING_GENERAL} item (k) as s then
|
||||
Result := s
|
||||
end
|
||||
end
|
||||
|
||||
string_item, string_8_item (k: STRING): detachable READABLE_STRING_8
|
||||
do
|
||||
if attached {READABLE_STRING_8} item (k) as s then
|
||||
Result := s
|
||||
end
|
||||
end
|
||||
|
||||
table: HASH_TABLE [detachable ANY, STRING]
|
||||
|
||||
feature -- Change
|
||||
|
||||
import (a_opts: CMS_API_OPTIONS)
|
||||
do
|
||||
across
|
||||
a_opts as c
|
||||
loop
|
||||
force (c.item, c.key)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: TABLE_ITERATION_CURSOR [detachable ANY, STRING]
|
||||
-- Fresh cursor associated with current structure
|
||||
do
|
||||
Result := table.new_cursor
|
||||
end
|
||||
|
||||
invariant
|
||||
|
||||
end
|
||||
|
||||
@@ -7,104 +7,28 @@ note
|
||||
deferred class
|
||||
CMS_COMMON_API
|
||||
|
||||
inherit
|
||||
WSF_API_UTILITIES
|
||||
|
||||
feature {NONE} -- Access
|
||||
|
||||
service: CMS_SERVICE
|
||||
deferred
|
||||
end
|
||||
|
||||
site_url: READABLE_STRING_8
|
||||
do
|
||||
Result := service.site_url
|
||||
end
|
||||
|
||||
base_url: detachable READABLE_STRING_8
|
||||
-- Base url if any.
|
||||
do
|
||||
Result := service.script_url
|
||||
end
|
||||
|
||||
based_path (p: STRING): STRING
|
||||
-- Path `p' in the context of the `base_url'
|
||||
do
|
||||
if attached base_url as l_base_url then
|
||||
create Result.make_from_string (l_base_url)
|
||||
if p.is_empty then
|
||||
else
|
||||
if p[1] = '/' then
|
||||
Result.append (p.substring (2, p.count))
|
||||
else
|
||||
Result.append (p)
|
||||
end
|
||||
end
|
||||
else
|
||||
Result := p
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
url_encoded (s: detachable READABLE_STRING_GENERAL): STRING_8
|
||||
local
|
||||
enc: URL_ENCODER
|
||||
do
|
||||
create enc
|
||||
if s /= Void then
|
||||
Result := enc.general_encoded_string (s)
|
||||
else
|
||||
create Result.make_empty
|
||||
end
|
||||
end
|
||||
|
||||
html_encoded (s: detachable READABLE_STRING_GENERAL): STRING_8
|
||||
local
|
||||
enc: HTML_ENCODER
|
||||
do
|
||||
create enc
|
||||
if s /= Void then
|
||||
Result := enc.general_encoded_string (s)
|
||||
else
|
||||
create Result.make_empty
|
||||
end
|
||||
end
|
||||
|
||||
link (a_text: detachable READABLE_STRING_GENERAL; a_path: STRING; opts: detachable CMS_API_OPTIONS): STRING
|
||||
local
|
||||
l_html: BOOLEAN
|
||||
t: READABLE_STRING_GENERAL
|
||||
do
|
||||
l_html := True
|
||||
if opts /= Void then
|
||||
l_html := opts.boolean_item ("html", l_html)
|
||||
end
|
||||
Result := "<a href=%"" + checked_url (url (a_path, opts)) + "%">"
|
||||
if a_text = Void then
|
||||
t := a_path
|
||||
else
|
||||
t := a_text
|
||||
end
|
||||
if l_html then
|
||||
Result.append (html_encoded (t))
|
||||
else
|
||||
Result.append (checked_plain (t))
|
||||
end
|
||||
Result.append ("</a>")
|
||||
end
|
||||
|
||||
link_with_raw_text (a_text: detachable READABLE_STRING_8; a_path: STRING; opts: detachable CMS_API_OPTIONS): STRING
|
||||
local
|
||||
l_html: BOOLEAN
|
||||
t: READABLE_STRING_8
|
||||
do
|
||||
l_html := True
|
||||
if opts /= Void then
|
||||
l_html := opts.boolean_item ("html", l_html)
|
||||
end
|
||||
Result := "<a href=%"" + checked_url (url (a_path, opts)) + "%">"
|
||||
if a_text = Void then
|
||||
t := a_path
|
||||
else
|
||||
t := a_text
|
||||
end
|
||||
Result.append (t)
|
||||
Result.append ("</a>")
|
||||
end
|
||||
|
||||
user_link (u: CMS_USER): like link
|
||||
do
|
||||
Result := link (u.name, "/user/" + u.id.out, Void)
|
||||
@@ -125,91 +49,6 @@ feature -- Access
|
||||
Result := url ("/node/" + n.id.out, Void)
|
||||
end
|
||||
|
||||
absolute_url (a_path: STRING; opts: detachable CMS_API_OPTIONS): STRING
|
||||
local
|
||||
l_opts: detachable CMS_API_OPTIONS
|
||||
do
|
||||
l_opts := opts
|
||||
if l_opts = Void then
|
||||
create l_opts.make (1)
|
||||
end
|
||||
l_opts.force (True, "absolute")
|
||||
Result := url (a_path, l_opts)
|
||||
end
|
||||
|
||||
url (a_path: STRING; opts: detachable CMS_API_OPTIONS): STRING
|
||||
local
|
||||
q,f: detachable STRING_8
|
||||
l_abs: BOOLEAN
|
||||
do
|
||||
l_abs := False
|
||||
|
||||
if opts /= Void then
|
||||
l_abs := opts.boolean_item ("absolute", l_abs)
|
||||
if attached opts.item ("query") as l_query then
|
||||
if attached {READABLE_STRING_8} l_query as s_value then
|
||||
q := s_value
|
||||
elseif attached {ITERABLE [TUPLE [key, value: READABLE_STRING_GENERAL]]} l_query as lst then
|
||||
create q.make_empty
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
if q.is_empty then
|
||||
else
|
||||
q.append_character ('&')
|
||||
end
|
||||
q.append (url_encoded (c.item.key))
|
||||
q.append_character ('=')
|
||||
q.append (url_encoded (c.item.value))
|
||||
end
|
||||
end
|
||||
end
|
||||
if attached opts.string_item ("fragment") as s_frag then
|
||||
f := s_frag
|
||||
end
|
||||
end
|
||||
if l_abs then
|
||||
if a_path.substring_index ("://", 1) = 0 then
|
||||
create Result.make_from_string (service.site_url)
|
||||
if a_path.is_empty then
|
||||
elseif Result.ends_with ("/") then
|
||||
if a_path[1] = '/' then
|
||||
Result.append_string (a_path.substring (2, a_path.count))
|
||||
else
|
||||
Result.append_string (a_path)
|
||||
end
|
||||
else
|
||||
if a_path[1] = '/' then
|
||||
Result.append_string (a_path)
|
||||
else
|
||||
Result.append_character ('/')
|
||||
Result.append_string (a_path)
|
||||
end
|
||||
end
|
||||
else
|
||||
Result := a_path
|
||||
end
|
||||
else
|
||||
Result := based_path (a_path)
|
||||
end
|
||||
if q /= Void then
|
||||
Result.append ("?" + q)
|
||||
end
|
||||
if f /= Void then
|
||||
Result.append ("#" + f)
|
||||
end
|
||||
end
|
||||
|
||||
checked_url (a_url: STRING): STRING
|
||||
do
|
||||
Result := a_url
|
||||
end
|
||||
|
||||
checked_plain (a_text: READABLE_STRING_GENERAL): STRING_8
|
||||
do
|
||||
Result := html_encoder.general_encoded_string (a_text)
|
||||
end
|
||||
|
||||
feature -- Helper
|
||||
|
||||
is_empty (s: detachable READABLE_STRING_GENERAL): BOOLEAN
|
||||
@@ -255,9 +94,9 @@ feature {NONE} -- Implementation
|
||||
end
|
||||
end
|
||||
|
||||
html_encoder: HTML_ENCODER
|
||||
once ("thread")
|
||||
create Result
|
||||
end
|
||||
-- html_encoder: HTML_ENCODER
|
||||
-- once ("thread")
|
||||
-- create Result
|
||||
-- end
|
||||
|
||||
end
|
||||
|
||||
@@ -7,147 +7,11 @@ note
|
||||
class
|
||||
CMS_PAGER
|
||||
|
||||
inherit
|
||||
WSF_WIDGET_PAGER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (tpl: READABLE_STRING_8; a_lower, a_upper: NATURAL_64; a_step: NATURAL_64)
|
||||
do
|
||||
create template.make (tpl)
|
||||
lower := a_lower
|
||||
upper := a_upper
|
||||
step := a_step
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_active_range (a_lower, a_upper: NATURAL_64)
|
||||
do
|
||||
if a_upper = 0 then
|
||||
active_range := [{NATURAL_64} 1, {NATURAL_64} 0]
|
||||
elseif a_lower > 0 and a_lower <= a_upper then
|
||||
active_range := [a_lower, a_upper]
|
||||
else
|
||||
active_range := Void
|
||||
end
|
||||
ensure
|
||||
valid_range: attached active_range as rg implies (rg.upper = 0 or else rg.lower <= rg.upper)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
template: URI_TEMPLATE
|
||||
|
||||
lower: NATURAL_64
|
||||
|
||||
upper: NATURAL_64
|
||||
|
||||
step: NATURAL_64
|
||||
|
||||
active_range: detachable TUPLE [lower_index, upper_index: NATURAL_64]
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
to_html (a_theme: CMS_THEME): STRING_8
|
||||
local
|
||||
l_step: INTEGER
|
||||
nb: INTEGER
|
||||
curr: INTEGER
|
||||
n, i: INTEGER
|
||||
tb: HASH_TABLE [detachable ANY, STRING_8]
|
||||
do
|
||||
create Result.make (32)
|
||||
Result.append ("<div")
|
||||
Result.append_character ('>')
|
||||
nb := ((upper - lower) // step).to_integer_32 + 1
|
||||
if nb > 1 then
|
||||
if attached active_range as rg then
|
||||
if rg.upper_index = 0 then
|
||||
-- all
|
||||
else
|
||||
curr := ((rg.lower_index - lower) // step).to_integer_32
|
||||
if step * curr.to_natural_64 < rg.lower_index then
|
||||
curr := curr + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
l_step := step.to_integer_32
|
||||
create tb.make (2)
|
||||
tb.force (1, "lower")
|
||||
tb.force (step, "upper")
|
||||
if curr > 1 then
|
||||
if curr > 2 then
|
||||
tb.force (1, "lower")
|
||||
tb.force (l_step, "upper")
|
||||
|
||||
Result.append_character (' ')
|
||||
Result.append (a_theme.link ("<<", template.expanded_string (tb), Void))
|
||||
Result.append_character (' ')
|
||||
end
|
||||
|
||||
tb.force ((curr - 1) * l_step + 1, "lower")
|
||||
tb.force ((curr ) * l_step , "upper")
|
||||
|
||||
Result.append_character (' ')
|
||||
Result.append (a_theme.link ("<", template.expanded_string (tb), Void))
|
||||
Result.append_character (' ')
|
||||
end
|
||||
|
||||
from
|
||||
i := (curr - 1).max (1)
|
||||
n := 5
|
||||
until
|
||||
n = 0 or i > nb
|
||||
loop
|
||||
Result.append_character (' ')
|
||||
|
||||
tb.force ((i - 1) * l_step + 1, "lower")
|
||||
tb.force ((i ) * l_step , "upper")
|
||||
|
||||
if i = curr then
|
||||
Result.append ("<strong>")
|
||||
end
|
||||
Result.append (a_theme.link (i.out, template.expanded_string (tb), Void))
|
||||
if i = curr then
|
||||
Result.append ("</strong>")
|
||||
end
|
||||
|
||||
Result.append_character (' ')
|
||||
|
||||
i := i + 1
|
||||
n := n - 1
|
||||
end
|
||||
|
||||
if curr < nb then
|
||||
Result.append_character (' ')
|
||||
tb.force ((curr ) * l_step + 1, "lower")
|
||||
tb.force ((curr + 1) * l_step , "upper")
|
||||
|
||||
Result.append (a_theme.link (">", template.expanded_string (tb), Void))
|
||||
Result.append_character (' ')
|
||||
|
||||
if curr + 1 < nb then
|
||||
tb.force ((nb - 1) * l_step + 1, "lower")
|
||||
tb.force ( upper , "upper")
|
||||
|
||||
Result.append_character (' ')
|
||||
Result.append (a_theme.link (">>", template.expanded_string (tb), Void))
|
||||
Result.append_character (' ')
|
||||
end
|
||||
end
|
||||
Result.append_character (' ')
|
||||
tb.force (1, "lower")
|
||||
tb.force (upper , "upper")
|
||||
Result.append (a_theme.link ("all", template.expanded_string (tb), Void))
|
||||
Result.append_character (' ')
|
||||
end
|
||||
|
||||
Result.append ("</div>")
|
||||
debug
|
||||
Result.append ("curr=" + curr.out +" step=" + step.out + " nb=" + nb.out)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -91,7 +91,7 @@ feature -- Change
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
to_html (a_theme: CMS_THEME): STRING_8
|
||||
to_html (a_theme: WSF_THEME): STRING_8
|
||||
do
|
||||
Result := "<div class=%"log " + category + " " + level_name + "%" id=%"log-" + id.out + "%">"
|
||||
Result.append ("<div class=%"inner%">")
|
||||
|
||||
98
library/server/wsf_html/api/wsf_api_options.e
Normal file
98
library/server/wsf_html/api/wsf_api_options.e
Normal file
@@ -0,0 +1,98 @@
|
||||
note
|
||||
description: "Summary description for {WSF_API_OPTIONS}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_API_OPTIONS
|
||||
|
||||
inherit
|
||||
TABLE_ITERABLE [detachable ANY, STRING]
|
||||
|
||||
create
|
||||
make,
|
||||
make_from_manifest
|
||||
|
||||
convert
|
||||
make_from_manifest ({ ARRAY [TUPLE [key: STRING; value: detachable ANY]],
|
||||
ARRAY [TUPLE [STRING_8, ARRAY [TUPLE [STRING_8, STRING_32]]]],
|
||||
ARRAY [TUPLE [STRING_8, ARRAY [TUPLE [STRING_8, STRING_8]]]]
|
||||
})
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (n: INTEGER)
|
||||
do
|
||||
create table.make (n)
|
||||
end
|
||||
|
||||
make_from_manifest (lst: ARRAY [TUPLE [key: STRING; value: detachable ANY]])
|
||||
do
|
||||
make (lst.count)
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
force (c.item.value, c.item.key)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
item (k: STRING): detachable ANY
|
||||
do
|
||||
Result := table.item (k)
|
||||
end
|
||||
|
||||
force (v: detachable ANY; k: STRING)
|
||||
do
|
||||
table.force (v, k)
|
||||
end
|
||||
|
||||
boolean_item (k: STRING; dft: BOOLEAN): BOOLEAN
|
||||
do
|
||||
if attached {BOOLEAN} item (k) as b then
|
||||
Result := b
|
||||
else
|
||||
Result := dft
|
||||
end
|
||||
end
|
||||
|
||||
string_general_item (k: STRING): detachable READABLE_STRING_GENERAL
|
||||
do
|
||||
if attached {READABLE_STRING_GENERAL} item (k) as s then
|
||||
Result := s
|
||||
end
|
||||
end
|
||||
|
||||
string_item, string_8_item (k: STRING): detachable READABLE_STRING_8
|
||||
do
|
||||
if attached {READABLE_STRING_8} item (k) as s then
|
||||
Result := s
|
||||
end
|
||||
end
|
||||
|
||||
table: HASH_TABLE [detachable ANY, STRING]
|
||||
|
||||
feature -- Change
|
||||
|
||||
import (a_opts: WSF_API_OPTIONS)
|
||||
do
|
||||
across
|
||||
a_opts as c
|
||||
loop
|
||||
force (c.item, c.key)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: TABLE_ITERATION_CURSOR [detachable ANY, STRING]
|
||||
-- Fresh cursor associated with current structure
|
||||
do
|
||||
Result := table.new_cursor
|
||||
end
|
||||
|
||||
invariant
|
||||
|
||||
end
|
||||
208
library/server/wsf_html/api/wsf_api_utilities.e
Normal file
208
library/server/wsf_html/api/wsf_api_utilities.e
Normal file
@@ -0,0 +1,208 @@
|
||||
note
|
||||
description: "Summary description for {WSF_API_UTILITIES}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_API_UTILITIES
|
||||
|
||||
feature -- Core
|
||||
|
||||
site_url: READABLE_STRING_8
|
||||
deferred
|
||||
end
|
||||
|
||||
base_url: detachable READABLE_STRING_8
|
||||
-- Base url if any.
|
||||
deferred
|
||||
end
|
||||
|
||||
based_path (p: STRING): STRING
|
||||
-- Path `p' in the context of the `base_url'
|
||||
do
|
||||
if attached base_url as l_base_url then
|
||||
create Result.make_from_string (l_base_url)
|
||||
if p.is_empty then
|
||||
else
|
||||
if p[1] = '/' then
|
||||
Result.append (p.substring (2, p.count))
|
||||
else
|
||||
Result.append (p)
|
||||
end
|
||||
end
|
||||
else
|
||||
Result := p
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
link (a_text: detachable READABLE_STRING_GENERAL; a_path: READABLE_STRING_8; opts: detachable WSF_API_OPTIONS): STRING
|
||||
do
|
||||
create Result.make (32)
|
||||
append_link_to_html (a_text, a_path, opts, Result)
|
||||
end
|
||||
|
||||
link_with_raw_text (a_raw_text: detachable READABLE_STRING_8; a_path: READABLE_STRING_8; opts: detachable WSF_API_OPTIONS): STRING
|
||||
do
|
||||
create Result.make (32)
|
||||
append_link_with_raw_text_to_html (a_raw_text, a_path, opts, Result)
|
||||
end
|
||||
|
||||
append_link_to_html (a_text: detachable READABLE_STRING_GENERAL; a_path: READABLE_STRING_8; opts: detachable WSF_API_OPTIONS; a_html: STRING_8)
|
||||
local
|
||||
l_html: BOOLEAN
|
||||
t: READABLE_STRING_GENERAL
|
||||
do
|
||||
l_html := True
|
||||
if opts /= Void then
|
||||
l_html := opts.boolean_item ("html", l_html)
|
||||
end
|
||||
a_html.append ("<a href=%"" + checked_url (url (a_path, opts)) + "%">")
|
||||
if a_text = Void then
|
||||
t := a_path
|
||||
else
|
||||
t := a_text
|
||||
end
|
||||
if l_html then
|
||||
a_html.append (html_encoded (t))
|
||||
else
|
||||
a_html.append (checked_plain (t))
|
||||
end
|
||||
a_html.append ("</a>")
|
||||
end
|
||||
|
||||
append_link_with_raw_text_to_html (a_raw_text: detachable READABLE_STRING_8; a_path: READABLE_STRING_8; opts: detachable WSF_API_OPTIONS; a_html: STRING_8)
|
||||
local
|
||||
l_html: BOOLEAN
|
||||
t: READABLE_STRING_8
|
||||
do
|
||||
l_html := True
|
||||
if opts /= Void then
|
||||
l_html := opts.boolean_item ("html", l_html)
|
||||
end
|
||||
a_html.append ("<a href=%"" + checked_url (url (a_path, opts)) + "%">")
|
||||
if a_raw_text = Void then
|
||||
t := a_path
|
||||
else
|
||||
t := a_raw_text
|
||||
end
|
||||
a_html.append (t)
|
||||
a_html.append ("</a>")
|
||||
end
|
||||
|
||||
absolute_url (a_path: STRING; opts: detachable WSF_API_OPTIONS): STRING
|
||||
local
|
||||
l_opts: detachable WSF_API_OPTIONS
|
||||
do
|
||||
l_opts := opts
|
||||
if l_opts = Void then
|
||||
create l_opts.make (1)
|
||||
end
|
||||
l_opts.force (True, "absolute")
|
||||
Result := url (a_path, l_opts)
|
||||
end
|
||||
|
||||
url (a_path: READABLE_STRING_8; opts: detachable WSF_API_OPTIONS): STRING
|
||||
local
|
||||
q,f: detachable STRING_8
|
||||
l_abs: BOOLEAN
|
||||
do
|
||||
l_abs := False
|
||||
|
||||
if opts /= Void then
|
||||
l_abs := opts.boolean_item ("absolute", l_abs)
|
||||
if attached opts.item ("query") as l_query then
|
||||
if attached {READABLE_STRING_8} l_query as s_value then
|
||||
q := s_value
|
||||
elseif attached {ITERABLE [TUPLE [key, value: READABLE_STRING_GENERAL]]} l_query as lst then
|
||||
create q.make_empty
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
if q.is_empty then
|
||||
else
|
||||
q.append_character ('&')
|
||||
end
|
||||
q.append (url_encoded (c.item.key))
|
||||
q.append_character ('=')
|
||||
q.append (url_encoded (c.item.value))
|
||||
end
|
||||
end
|
||||
end
|
||||
if attached opts.string_item ("fragment") as s_frag then
|
||||
f := s_frag
|
||||
end
|
||||
end
|
||||
if l_abs then
|
||||
if a_path.substring_index ("://", 1) = 0 then
|
||||
create Result.make_from_string (site_url)
|
||||
if a_path.is_empty then
|
||||
elseif Result.ends_with ("/") then
|
||||
if a_path[1] = '/' then
|
||||
Result.append_string (a_path.substring (2, a_path.count))
|
||||
else
|
||||
Result.append_string (a_path)
|
||||
end
|
||||
else
|
||||
if a_path[1] = '/' then
|
||||
Result.append_string (a_path)
|
||||
else
|
||||
Result.append_character ('/')
|
||||
Result.append_string (a_path)
|
||||
end
|
||||
end
|
||||
else
|
||||
Result := a_path
|
||||
end
|
||||
else
|
||||
Result := based_path (a_path)
|
||||
end
|
||||
if q /= Void then
|
||||
Result.append ("?" + q)
|
||||
end
|
||||
if f /= Void then
|
||||
Result.append ("#" + f)
|
||||
end
|
||||
end
|
||||
|
||||
checked_url (a_url: READABLE_STRING_8): READABLE_STRING_8
|
||||
do
|
||||
Result := a_url
|
||||
end
|
||||
|
||||
checked_plain (a_text: READABLE_STRING_GENERAL): STRING_8
|
||||
do
|
||||
Result := html_encoded (a_text)
|
||||
end
|
||||
|
||||
feature -- Encoding
|
||||
|
||||
url_encoded (s: detachable READABLE_STRING_GENERAL): STRING_8
|
||||
local
|
||||
enc: URL_ENCODER
|
||||
do
|
||||
create enc
|
||||
if s /= Void then
|
||||
Result := enc.general_encoded_string (s)
|
||||
else
|
||||
create Result.make_empty
|
||||
end
|
||||
end
|
||||
|
||||
html_encoded (s: detachable READABLE_STRING_GENERAL): STRING_8
|
||||
local
|
||||
enc: HTML_ENCODER
|
||||
do
|
||||
create enc
|
||||
if s /= Void then
|
||||
Result := enc.general_encoded_string (s)
|
||||
else
|
||||
create Result.make_empty
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
40
library/server/wsf_html/api/wsf_request_theme.e
Normal file
40
library/server/wsf_html/api/wsf_request_theme.e
Normal file
@@ -0,0 +1,40 @@
|
||||
note
|
||||
description: "[
|
||||
WF_THEME associated with a request
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_REQUEST_THEME
|
||||
|
||||
inherit
|
||||
WSF_THEME
|
||||
|
||||
create
|
||||
make_with_request
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_with_request (req: WSF_REQUEST)
|
||||
do
|
||||
request := req
|
||||
end
|
||||
|
||||
request: WSF_REQUEST
|
||||
-- Associated request
|
||||
|
||||
feature -- Core
|
||||
|
||||
site_url: READABLE_STRING_8
|
||||
do
|
||||
Result := request.absolute_script_url ("")
|
||||
end
|
||||
|
||||
base_url: detachable READABLE_STRING_8
|
||||
-- Base url if any.
|
||||
do
|
||||
Result := request.script_url ("")
|
||||
end
|
||||
|
||||
end
|
||||
14
library/server/wsf_html/api/wsf_theme.e
Normal file
14
library/server/wsf_html/api/wsf_theme.e
Normal file
@@ -0,0 +1,14 @@
|
||||
note
|
||||
description: "Summary description for {WSF_THEME}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_THEME
|
||||
|
||||
inherit
|
||||
WSF_API_UTILITIES
|
||||
|
||||
|
||||
end
|
||||
25
library/server/wsf_html/api/wsf_url_api_options.e
Normal file
25
library/server/wsf_html/api/wsf_url_api_options.e
Normal file
@@ -0,0 +1,25 @@
|
||||
note
|
||||
description: "Summary description for {WSF_URL_API_OPTIONS}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_URL_API_OPTIONS
|
||||
|
||||
inherit
|
||||
WSF_API_OPTIONS
|
||||
|
||||
create
|
||||
make,
|
||||
make_absolute
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_absolute
|
||||
do
|
||||
make (1)
|
||||
force (True, "absolute")
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description : "Objects that ..."
|
||||
author : "$Author$"
|
||||
description : "Objects that represent a form filled with data from request."
|
||||
date : "$Date$"
|
||||
revision : "$Revision$"
|
||||
|
||||
@@ -34,6 +33,9 @@ feature -- Status
|
||||
Result := errors = Void
|
||||
end
|
||||
|
||||
is_applied_to_associated_form: BOOLEAN
|
||||
-- Data already applied to `form'?
|
||||
|
||||
feature -- Access
|
||||
|
||||
item_same_string (a_name: READABLE_STRING_GENERAL; s: READABLE_STRING_GENERAL): BOOLEAN
|
||||
@@ -158,6 +160,7 @@ feature -- Basic operation
|
||||
|
||||
apply_to_associated_form
|
||||
do
|
||||
if not is_applied_to_associated_form then
|
||||
if attached errors as errs then
|
||||
across
|
||||
errs as e
|
||||
@@ -178,6 +181,8 @@ feature -- Basic operation
|
||||
apply_to_associated_form_item (c.key, c.item, i.item)
|
||||
end
|
||||
end
|
||||
is_applied_to_associated_form := True
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation: apply
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {WSF_THEME}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_THEME
|
||||
|
||||
feature -- Access
|
||||
|
||||
url_encoded (s: detachable READABLE_STRING_GENERAL): STRING_8
|
||||
local
|
||||
enc: URL_ENCODER
|
||||
do
|
||||
create enc
|
||||
if s /= Void then
|
||||
Result := enc.general_encoded_string (s)
|
||||
else
|
||||
create Result.make_empty
|
||||
end
|
||||
end
|
||||
|
||||
html_encoded (s: detachable READABLE_STRING_GENERAL): STRING_8
|
||||
local
|
||||
enc: HTML_ENCODER
|
||||
do
|
||||
create enc
|
||||
if s /= Void then
|
||||
Result := enc.general_encoded_string (s)
|
||||
else
|
||||
create Result.make_empty
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
167
library/server/wsf_html/widget/wsf_widget_pager.e
Normal file
167
library/server/wsf_html/widget/wsf_widget_pager.e
Normal file
@@ -0,0 +1,167 @@
|
||||
note
|
||||
description: "Summary description for {WSF_WIDGET_PAGER}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_WIDGET_PAGER
|
||||
|
||||
inherit
|
||||
WSF_WIDGET
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (tpl: READABLE_STRING_8; a_lower, a_upper: NATURAL_64; a_step: NATURAL_64)
|
||||
do
|
||||
create template.make (tpl)
|
||||
lower := a_lower
|
||||
upper := a_upper
|
||||
step := a_step
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_active_range (a_lower, a_upper: NATURAL_64)
|
||||
do
|
||||
if a_upper = 0 then
|
||||
active_range := [{NATURAL_64} 1, {NATURAL_64} 0]
|
||||
elseif a_lower > 0 and a_lower <= a_upper then
|
||||
active_range := [a_lower, a_upper]
|
||||
else
|
||||
active_range := Void
|
||||
end
|
||||
ensure
|
||||
valid_range: attached active_range as rg implies (rg.upper = 0 or else rg.lower <= rg.upper)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
template: URI_TEMPLATE
|
||||
|
||||
lower: NATURAL_64
|
||||
|
||||
upper: NATURAL_64
|
||||
|
||||
step: NATURAL_64
|
||||
|
||||
active_range: detachable TUPLE [lower_index, upper_index: NATURAL_64]
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
to_html (a_theme: WSF_THEME): STRING_8
|
||||
do
|
||||
create Result.make (1024)
|
||||
append_to_html (a_theme, Result)
|
||||
end
|
||||
|
||||
append_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
local
|
||||
l_step: INTEGER
|
||||
nb: INTEGER
|
||||
curr: INTEGER
|
||||
n, i: INTEGER
|
||||
tb: HASH_TABLE [detachable ANY, STRING_8]
|
||||
do
|
||||
a_html.append ("<div")
|
||||
a_html.append_character ('>')
|
||||
nb := ((upper - lower) // step).to_integer_32 + 1
|
||||
if nb > 1 then
|
||||
if attached active_range as rg then
|
||||
if rg.upper_index = 0 then
|
||||
-- all
|
||||
else
|
||||
curr := ((rg.lower_index - lower) // step).to_integer_32
|
||||
if step * curr.to_natural_64 < rg.lower_index then
|
||||
curr := curr + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
l_step := step.to_integer_32
|
||||
create tb.make (2)
|
||||
tb.force (1, "lower")
|
||||
tb.force (step, "upper")
|
||||
if curr > 1 then
|
||||
if curr > 2 then
|
||||
tb.force (1, "lower")
|
||||
tb.force (l_step, "upper")
|
||||
|
||||
a_html.append_character (' ')
|
||||
append_link_to_html (a_theme, "<<", template.expanded_string (tb), a_html)
|
||||
a_html.append_character (' ')
|
||||
end
|
||||
|
||||
tb.force ((curr - 1) * l_step + 1, "lower")
|
||||
tb.force ((curr ) * l_step , "upper")
|
||||
|
||||
a_html.append_character (' ')
|
||||
append_link_to_html (a_theme, "<", template.expanded_string (tb), a_html)
|
||||
a_html.append_character (' ')
|
||||
end
|
||||
|
||||
from
|
||||
i := (curr - 1).max (1)
|
||||
n := 5
|
||||
until
|
||||
n = 0 or i > nb
|
||||
loop
|
||||
a_html.append_character (' ')
|
||||
|
||||
tb.force ((i - 1) * l_step + 1, "lower")
|
||||
tb.force ((i ) * l_step , "upper")
|
||||
|
||||
if i = curr then
|
||||
a_html.append ("<strong>")
|
||||
end
|
||||
append_link_to_html (a_theme, i.out, template.expanded_string (tb), a_html)
|
||||
if i = curr then
|
||||
a_html.append ("</strong>")
|
||||
end
|
||||
|
||||
a_html.append_character (' ')
|
||||
|
||||
i := i + 1
|
||||
n := n - 1
|
||||
end
|
||||
|
||||
if curr < nb then
|
||||
a_html.append_character (' ')
|
||||
tb.force ((curr ) * l_step + 1, "lower")
|
||||
tb.force ((curr + 1) * l_step , "upper")
|
||||
append_link_to_html (a_theme, ">", template.expanded_string (tb), a_html)
|
||||
a_html.append_character (' ')
|
||||
|
||||
if curr + 1 < nb then
|
||||
tb.force ((nb - 1) * l_step + 1, "lower")
|
||||
tb.force ( upper , "upper")
|
||||
|
||||
a_html.append_character (' ')
|
||||
append_link_to_html (a_theme, ">>", template.expanded_string (tb), a_html)
|
||||
a_html.append_character (' ')
|
||||
end
|
||||
end
|
||||
a_html.append_character (' ')
|
||||
tb.force (1, "lower")
|
||||
tb.force (upper , "upper")
|
||||
append_link_to_html (a_theme, "all", template.expanded_string (tb), a_html)
|
||||
a_html.append_character (' ')
|
||||
end
|
||||
|
||||
a_html.append ("</div>")
|
||||
debug
|
||||
a_html.append ("curr=" + curr.out +" step=" + step.out + " nb=" + nb.out)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Factory
|
||||
|
||||
append_link_to_html (a_theme: WSF_THEME; a_text: detachable READABLE_STRING_GENERAL; a_path: STRING; a_html: STRING_8)
|
||||
do
|
||||
a_theme.append_link_to_html (a_text, a_path, Void, a_html)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -11,9 +11,11 @@
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY/library/base/base-safe.ecf"/>
|
||||
<library name="encoder" location="../../text/encoder/encoder-safe.ecf"/>
|
||||
<library name="uri_template" location="../../text/parser/uri_template/uri_template-safe.ecf"/>
|
||||
<library name="wsf" location="../wsf/wsf-safe.ecf"/>
|
||||
<cluster name="form" location="./form" recursive="true"/>
|
||||
<cluster name="widget" location="./widget" recursive="true"/>
|
||||
<cluster name="css" location="./css" recursive="true"/>
|
||||
<cluster name="api" location="./api" recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
|
||||
@@ -11,9 +11,11 @@
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY/library/base/base.ecf"/>
|
||||
<library name="encoder" location="../../text/encoder/encoder.ecf"/>
|
||||
<library name="uri_template" location="../../text/parser/uri_template/uri_template.ecf"/>
|
||||
<library name="wsf" location="../wsf/wsf.ecf"/>
|
||||
<cluster name="form" location="./form" recursive="true"/>
|
||||
<cluster name="widget" location="./widget" recursive="true"/>
|
||||
<cluster name="css" location="./css" recursive="true"/>
|
||||
<cluster name="api" location="./api" recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
|
||||
Reference in New Issue
Block a user