Вы находитесь на странице: 1из 10

Ring Documentation, Release 1.5.3

}

textbox([

:name

=

"Value"

])

newline()

newline()

 

divend()

formend()

submit([

:value

=

"Send"

])

Screen Shot:

submit( [ :value = "Send" ] ) Screen Shot: The Response #!c:\ring\bin\ring.exe -cgi Load

The Response

#!c:\ring\bin\ring.exe -cgi Load "weblib.ring" Import System.Web New Page { boxstart() text( "Hash
#!c:\ring\bin\ring.exe
-cgi
Load
"weblib.ring"
Import
System.Web
New
Page
{
boxstart()
text(
"Hash
Result"
)
newline()
boxend()
divstart([
:style
=
styleFloatLeft()
+
styleWidth("100%")
])
newline()
text(
"Value
:
"
+
aPageVars["Value"]
)
newline()
text(
"MD5
:
"
+
MD5(aPageVars["Value"])
)
newline()
text(
"SHA1
:
"
+
SHA1(aPageVars["Value"])
)
newline()
text(
"SHA256
:
"
+
SHA256(aPageVars["Value"])
)
newline()
text(
"SHA224
:
"
+
SHA224(aPageVars["Value"])
)
newline()
text(
"SHA384
:
"
+
SHA384(aPageVars["Value"])
)
newline()
text(
"SHA512
:
"
+
SHA512(aPageVars["Value"])
)
newline()
divend()
}

Screen Shot:

Ring Documentation, Release 1.5.3

Ring Documentation, Release 1.5.3 47.13 Random Image #!c:\ring\bin\ring.exe -cgi Load "weblib.ring" Import

47.13 Random Image

#!c:\ring\bin\ring.exe

-cgi

Load "weblib.ring" Import System.Web cUploadPath = "C:/Apache2.2/htdocs/ringapp/upload/" New Page
Load
"weblib.ring"
Import
System.Web
cUploadPath
=
"C:/Apache2.2/htdocs/ringapp/upload/"
New
Page
{
boxstart()
text(
"Random
Test")
newline()
boxend()
divstart([
:style
=
styleFloatLeft()
+
styleWidth("400px")
])
newline()
aList
=
dir(cUploadPath)
if
len(aList)
>
0
nIndex
=
random(len(aList))
if
nindex
=
0
nIndex
=
1
ok
cItem
=
"upload/"
+
aList[nIndex][1]
newline()
image(
[
:url
=
cItem
,
:alt
=
:image
]
)
else
text("No
images!")
newline()
ok
divend()
}

Screen Shot:

Ring Documentation, Release 1.5.3

Ring Documentation, Release 1.5.3 47.14 HTML Lists The next example print a list contains numbers from

47.14 HTML Lists

The next example print a list contains numbers from 1 to 10 Then print a list from Ring List. Finally we have a list of buttons and when we press on a button we get a message contains the clicked button number. To start the list we uses the ulstart() function. To end the list we uses the ulend() function. We uses listart() and liend() to determine the list item.

#!c:\ring\bin\ring.exe -cgi Load "weblib.ring" Import System.Web Func Main New Page { ulstart([]) for
#!c:\ring\bin\ring.exe
-cgi
Load
"weblib.ring"
Import
System.Web
Func
Main
New
Page
{
ulstart([])
for
x
=
1
to
10
listart([])
text(x)
liend()
next
ulend()
list2ul(["one","two","three","four","five"])
ulstart([])
for
x
=
1
to
10
listart([])

Ring Documentation, Release 1.5.3

cFuncName

=

"btn"+x+"()"

 

button([

:onclick

=

cFuncName

,

:value

=

x])

script(scriptfuncalert(cFuncName,string(x)))

}

ulend()

next

liend()

Screen Shot:

script(scriptfuncalert(cFuncName, string (x))) } ulend() next liend() Screen Shot: 47.14. HTML Lists 388

Ring Documentation, Release 1.5.3

47.15 HTML Tables

In this example we will learn how to generate HTML tables using the tablestart(), tableend(), rowstart(), rowend() ,headerstart(), headerend(), cellstart() and cellend() functions.

#!c:\ring\bin\ring.exe

-cgi

Load "weblib.ring" Import System.Web Func Main New Page { divstart([ :style =
Load
"weblib.ring"
Import
System.Web
Func
Main
New
Page
{
divstart([
:style
=
styledivcenter("400px","500px")
]
)
style(styletable()
+
styletablerows("t01"))
tablestart([
:id
=
:t01
,
:style
=
stylewidth("100%")
])
rowstart([])
headerstart([])
text("Number")
headerend()
headerstart([])
text("square")
headerend()
rowend()
for
x
=
1
to
10
rowstart([])
cellstart([])
cellstart([])
text(x)
text(x * x)
cellend()
cellend()
rowend()
next
tableend()
divend()
}

Screen Shot:

text(x * x) cellend() cellend() rowend() next tableend() divend() } Screen Shot: 47.15. HTML Tables 389

Ring Documentation, Release 1.5.3

47.16 Gradient

In this example we will learn how to use the StyleGradient() function. The function takes the style number as input (range from 1 to 60).

#!c:\ring\bin\ring.exe

-cgi

Load "weblib.ring" Import System.Web Func Main New Page { boxstart() text("StyleGradient()
Load
"weblib.ring"
Import
System.Web
Func
Main
New
Page
{
boxstart()
text("StyleGradient()
Function")
boxend()
for
x
=
1
to
60
divstart([
:id
=
x
,
:align
=
"center"
,
:style
=
stylefloatleft()
+
stylesize(string(100/60 * 6)+"%","50px")
+
stylegradient(x)
])
h3(x)
divend()
next
}

Screen Shot:

* 6)+"%","50px") + stylegradient(x) ]) h3(x) divend() next } Screen Shot: 47.16. Gradient 390

Ring Documentation, Release 1.5.3

47.17 Generating Pages using Objects

Instead of using functions/methods to generate HTML pages, we can use an object for each element in the page.

This choice means more beautiful code but slower.

The fastest method is to print HTML code directly, then using functions then using templates then using objects (slower).

#!c:\ring\bin\ring.exe -cgi Load "weblib.ring" Import System.Web Func Main WebPage() { Title =
#!c:\ring\bin\ring.exe
-cgi
Load
"weblib.ring"
Import
System.Web
Func
Main
WebPage()
{
Title
=
"Using
objects
to
create
the
Web
Page
content"
h1
{
text("welcome")
}
link
{
Title
=
"Google"
Link
=
"http://www.google.com"
}
div
{
id
=
"div1"
style
=
stylegradient(30)
+
stylesize("50%","50%")
text("Outer
Div")
div
{
id
=
"div2"
color
=
"white"
backgroundcolor
=
"green"
width
=
"50%"
height
=
"50%"
marginleft
=
"5%"
margintop
=
"5%"
text("Inner
Div")
}
}
div
{
id
=
"div3"
color
=
"black"
backgroundcolor
=
"silver"
width
=
"100%"
height
=
"100%"
text("Form")
form
{
method
=
"POST"
Action
=
"helloworld.ring"
Table
{
style
=
stylewidth("100%")
+
stylegradient(24)
TR
{
TD
{
WIDTH="10%"
text("Name
:
"
)
}

Ring Documentation, Release 1.5.3

TD { Input { type = "text" } } } TR { TD { WIDTH="10%"
TD
{
Input
{
type
=
"text"
}
}
}
TR
{
TD
{
WIDTH="10%"
text("Email
:
"
)
}
TD
{
Input
{
type
=
"text"
}
}
}
TR
{
TD
{
WIDTH="10%"
text("Password
:
"
)
}
TD
{
Input
{
type
=
"password"
}
}
}
TR
{
TD
{
WIDTH="10%"
text("Notes")
}
TD
{
TextArea
{
width="100%"
rows
=
10
cols
=
10
text("type
text
here
")
}
}
}
TR
{
TD
{
WIDTH="10%"
text("Gender")
}
TD
{
select
{
width
=
"100%"
option
{
text("Male")
}
option
{
text("Female")
}
}
}
}
TR
{
TD
{
WIDTH="10%"
text("Role")
}
TD
{
select
{
multiple
=
"multiple"
width
=
"100%"
option
{
text("student")
}
option
{
text("admin")
}
}
}
}

}

Input

{

type

=

"submit"

value

=

"send"

}

Image

{

src="upload/profile1.jpg"

alt="profile"}

 

Input

{

type

=

"checkbox"

value

=

"Old

Member"}

text("old

member")

Input

{

type

=

"range"

min=1

max=100}

 

Input

{

type

=

"number"

min=1

max=100}

Input

{

type

=

"radio"

color="black"

name="one"

 
 

value

=

"one"}

text("one")

 

}

}

div

{

color

=

"white"

Ring Documentation, Release 1.5.3

Ring Documentation, Release 1.5.3 backgroundcolor = "blue" width = "100%" UL { LI {
backgroundcolor = "blue" width = "100%" UL { LI { TEXT("ONE") } LI {
backgroundcolor
=
"blue"
width
=
"100%"
UL
{
LI
{
TEXT("ONE")
}
LI
{
TEXT("TWO")
}
LI
{
TEXT("THREE")
}
}
}
div
{
audio
{
src
=
"horse.ogg"
type
=
"audio/ogg"
}
video
{
width
=
320
height
=
240
src
=
"movie.mp4"
type
=
"video/mp4"
}
Input
{
type
=
"color"
value
=
"#ff0000"
onchange
=
"clickColor(0,
-1,
-1,
5)"
}
}
}
Screen Shot:

Ring Documentation, Release 1.5.3

Ring Documentation, Release 1.5.3 47.17. Generating Pages using Objects 394